-
Notifications
You must be signed in to change notification settings - Fork 546
Extract Bootstrap into its own section #1939
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Common `x` commands | ||
|
||
| Command | Explanation | Remarks | | ||
|------------------------------------------------|---------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ||
| `x build --keep-stage 0` | Assume stage0 std can be reused | | | ||
| `x build --stage 1` | Build up to stage1 std and create a sysroot | | | ||
| `x clean` | Invalidate build config cache | Does not clean LLVM cache | | ||
| `x dist rustc-dev` | Build rustc-dev | | | ||
| `x test --stage 0 library/std` | Test standard library | | | ||
| `x check library/std` | Only check standard library | | | ||
| `x check` | Check compiler/rustc | | | ||
| `x check --all-targets` | Cross-compile for a lot of targets | Can be made less failure-prone by putting the imports inside the function where they're used rather than using separate configs; creates a problem of missing functions | | ||
| `x build library/std --stage 0` | If only working on standard library | Builds library/std then compiler/rustc then library/std again | | ||
| `x test --stage 1` | Test the compiler | | | ||
| `x test --stage 1 --keep-stage-std 1 tests/ui` | Run UI tests with cached stage1 std | | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# How Bootstrap does it | ||
|
||
The core concept in Bootstrap is a build [`Step`], which are chained together | ||
by [`Builder::ensure`]. [`Builder::ensure`] takes a [`Step`] as input, and runs | ||
the [`Step`] if and only if it has not already been run. Let's take a closer | ||
look at [`Step`]. | ||
|
||
## Synopsis of [`Step`] | ||
|
||
A [`Step`] represents a granular collection of actions involved in the process | ||
of producing some artifact. It can be thought of like a rule in Makefiles. | ||
The [`Step`] trait is defined as: | ||
|
||
```rs,no_run | ||
pub trait Step: 'static + Clone + Debug + PartialEq + Eq + Hash { | ||
type Output: Clone; | ||
|
||
const DEFAULT: bool = false; | ||
const ONLY_HOSTS: bool = false; | ||
|
||
// Required methods | ||
fn run(self, builder: &Builder<'_>) -> Self::Output; | ||
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_>; | ||
|
||
// Provided method | ||
fn make_run(_run: RunConfig<'_>) { ... } | ||
} | ||
``` | ||
|
||
- `run` is the function that is responsible for doing the work. | ||
[`Builder::ensure`] invokes `run`. | ||
- `should_run` is the command-line interface, which determines if an invocation | ||
such as `x build foo` should run a given [`Step`]. In a "default" context | ||
where no paths are provided, then `make_run` is called directly. | ||
- `make_run` is invoked only for things directly asked via the CLI and not | ||
for steps which are dependencies of other steps. | ||
|
||
## The entry points | ||
|
||
There's a couple of preliminary steps before core Bootstrap code is reached: | ||
|
||
1. Shell script: [`./x`](https://github.com/rust-lang/rust/blob/master/x) or [`./x.ps1`](https://github.com/rust-lang/rust/blob/master/x.ps1) | ||
2. Convenience wrapper script: [`x.py`](https://github.com/rust-lang/rust/blob/master/x.py) | ||
3. [`src/bootstrap/bootstrap.py`](https://github.com/rust-lang/rust/blob/master/src/bootstrap/bootstrap.py) | ||
4. [`src/bootstrap/src/bin/main.rs`](https://github.com/rust-lang/rust/blob/master/src/bootstrap/src/bin/main.rs) | ||
jieyouxu marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
[`Step`]: https://doc.rust-lang.org/nightly/nightly-rustc/bootstrap/core/builder/trait.Step.html | ||
[`Builder::ensure`]: https://doc.rust-lang.org/nightly/nightly-rustc/bootstrap/core/builder/struct.Builder.html#method.ensure |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Bootstrapping the compiler | ||
|
||
[*Bootstrapping*][boot] is the process of using a compiler to compile itself. | ||
More accurately, it means using an older compiler to compile a newer version | ||
of the same compiler. | ||
|
||
This raises a chicken-and-egg paradox: where did the first compiler come from? | ||
It must have been written in a different language. In Rust's case it was | ||
[written in OCaml][ocaml-compiler]. However it was abandoned long ago and the | ||
only way to build a modern version of rustc is a slightly less modern | ||
version. | ||
|
||
This is exactly how `x.py` works: it downloads the current beta release of | ||
rustc, then uses it to compile the new compiler. | ||
|
||
In this section, we give a high-level overview of | ||
[what Bootstrap does](./what-bootstrapping-does.md), followed by a high-level | ||
introduction to [how Bootstrap does it](./how-bootstrap-does-it.md). A | ||
[listing of common bootstrap commands](./common-commands.md) is also provided | ||
for convenience. | ||
|
||
[boot]: https://en.wikipedia.org/wiki/Bootstrapping_(compilers) | ||
[ocaml-compiler]: https://github.com/rust-lang/rust/tree/ef75860a0a72f79f97216f8aaa5b388d98da6480/src/boot |
15 changes: 1 addition & 14 deletions
15
src/building/bootstrapping.md → .../bootstrapping/what-bootstrapping-does.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.