-
Notifications
You must be signed in to change notification settings - Fork 13.5k
Enforce in bootstrap that check must have stage at least 1 #143048
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
base: master
Are you sure you want to change the base?
Conversation
f06e41e
to
aed5f23
Compare
CC @jieyouxu (one of many heaps of bootstrap fixup commits I have in store 😆) |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #141899) made this pull request unmergeable. Please resolve the merge conflicts. |
aed5f23
to
a36ee24
Compare
Cross-compilation checks are now doing too much work, I need to take a look at how we can reduce that, because |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #143254) made this pull request unmergeable. Please resolve the merge conflicts. |
…fault check stage for it
a36ee24
to
22fb548
Compare
This PR modifies If appropriate, please update This PR modifies If appropriate, please update |
r? @jieyouxu |
|
The job Click to see the possible cause of the failure (guessed by this bot)
|
☔ The latest upstream changes (presumably #143287) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this a lot in general, it does feel much more self-consistent and coherent.
I left some questions/discussions for things that I wanted to double-check, but overall looks good!
// We skip populating the sysroot in non-zero stage because that'll lead | ||
// to rlib/rmeta conflicts if std gets built during this session. | ||
if compiler.stage == 0 { | ||
let libdir = builder.sysroot_target_libdir(compiler, target); | ||
let hostdir = builder.sysroot_target_libdir(compiler, compiler.host); | ||
add_to_sysroot(builder, &libdir, &hostdir, &stamp); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: we really do have a lot of hacks for stage 0 std...
self.stage.or(self | ||
.built_by | ||
.map(|compiler| if self.name == "std" { compiler.stage } else { compiler.stage + 1 })) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussion: this makes me feel a bit uneasy, but I guess the logic here is: anything that's not the standard library should be considered a non-library artifact, and should be considered a product of the stage n
(compiler, standard library) pair (and so gets numbered as the next stage)? I.e. reading back https://hackmd.io/QXj6LqntQTKPgm3uBuE-aA again, the core model is
stage corresponds to what gets built, not what is used to build it
(The following is me trying to make sure I understand this)
Let's call the (compiler, library) pair12
where the separation between stages is delineated by which
With the stage 0 redesign, we now have a nice straightforward "derivation chain" (
actually holds even for
However, for:
-
bootstrap tools
Tools that are unconditionally built by the stage 0$\mathbf{CLP}$ , i.e. always depends on$\mathbf{CLP}_{0}$ . Their stage numbering will be called$\mathrm{BootstrapTool}_{1}$ , at least in the short-term. -
host rustc tools
Tools that depend onrustc_private
and so on$\mathrm{compiler}_{\mathrm{stage}}$ . This means that they will be numbered as$\mathrm{HostRustcTool}_{\mathrm{stage} + 1}$ . -
std tools
Tools that depend on the whole$\mathbf{CLP}_{\mathrm{stage}}$ , i.e. both$\mathrm{compiler}_{\mathrm{stage}}$ , and$\mathrm{library}_{\mathrm{stage}}$ . Similiarly, this means that they will be numbered as$\mathrm{StdTool}_{\mathrm{stage} + 1}$ .
They then follow the general "what gets built" model (?).
Footnotes
ctx.config("check") | ||
.path("library") | ||
.render_steps(), @r" | ||
[build] llvm <host> | ||
[build] rustc 0 <host> -> rustc 1 <host> | ||
[check] rustc 1 <host> -> std 1 <host> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussion (not for this PR): I do wonder how we would encode / fix the download-rustc
logic here. I can see why the previous pretend-to-be-
[build] llvm <host> | ||
[build] rustc 0 <host> -> rustc 1 <host> | ||
[build] rustc 1 <host> -> std 1 <host> | ||
[check] compiletest <host> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remark: yes, this looks right 👍
&compiler.host, | ||
&target, | ||
); | ||
run_cargo(builder, cargo, builder.config.free_args.clone(), &stamp, vec![], true, false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: I don't remember, does the check macro support free args? I don't think this is actually equivalent, specifically the free_args
part. Looking at src/tools/coverage-dump
, it supports a --demangle
flag:
rust/src/tools/coverage-dump/src/main.rs
Lines 15 to 17 in f51c987
if &args[1..] == &["--demangle"] { | |
return demangle(); | |
} |
Although, as the check step, this does not matter, right?
// A small number of tools rely on in-tree standard | ||
// library crates (e.g. compiletest needs libtest). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: compiletest needs internal library feature from in-tree std (which could be different from stage 0 std), but no longer libtest.
builder.std(build_compiler, host); | ||
builder.std(build_compiler, target); | ||
builder.ensure(Std::new(build_compiler, target)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: wait, why is this different? For
rust/src/bootstrap/src/core/builder/mod.rs
Lines 1393 to 1409 in f51c987
if compiler.stage == 0 { | |
if target != compiler.host { | |
panic!( | |
r"It is not possible to build the standard library for `{target}` using the stage0 compiler. | |
You have to build a stage1 compiler for `{}` first, and then use it to build a standard library for `{target}`. | |
", | |
compiler.host | |
) | |
} | |
// We still need to link the prebuilt standard library into the ephemeral stage0 sysroot | |
self.ensure(StdLink::from_std(Std::new(compiler, target), compiler)); | |
} else { | |
// This step both compiles the std and links it into the compiler's sysroot. | |
// Yes, it's quite magical and side-effecty.. would be nice to refactor later. | |
self.ensure(Std::new(compiler, target)); | |
} |
At this point, wouldn't we have already rejected invoking ./x check
flow with
.targets(&[TEST_TRIPLE_1]) | ||
.hosts(&[TEST_TRIPLE_1]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit (tiny, just for consistency): can you swap targets()
and hosts()
around? Usually the ordering is hosts then targets right :D
@@ -48,7 +48,7 @@ ENV SCRIPT \ | |||
python3 ../x.py build src/tools/build-manifest && \ | |||
python3 ../x.py test --stage 0 src/tools/compiletest && \ | |||
python3 ../x.py check compiletest --set build.compiletest-use-stage0-libtest=true && \ | |||
python3 ../x.py check --stage 1 --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \ | |||
python3 ../x.py check --stage 2 --target=i686-pc-windows-gnu --host=i686-pc-windows-gnu && \ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggestion: actually, can you add a comment for this specifically that we're exercising cross-compile here, so --stage 1
isn't sufficient?
This PR is another step towards https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Proposal.20to.20cleanup.20stages.20and.20steps.20after.20the.20redesign/with/523586917, this time dealing with
x check
.It enforces the invariant that:
It creates a single function that prepares a proper build compiler for checking something, and also adds snapshot tests for various common check steps. Some obsolete code was also removed.
The default check stage also becomes 1, for all profiles. I tested manually that
x check std
withdownload-ci-rustc
still works and doesn't build rustc locally.Subsumes #139170.
r? @ghost