diff options
| author | Jakub Beránek <berykubik@gmail.com> | 2025-08-08 16:30:43 +0200 |
|---|---|---|
| committer | Jakub Beránek <berykubik@gmail.com> | 2025-08-13 08:07:55 +0200 |
| commit | 6e7e243ef2790169cfd0e228d22fb6fdd9093317 (patch) | |
| tree | bca8fdfe72bf44e8a9229179b99acda6e3670e13 | |
| parent | 1553adfe6884a8f6c28f5a673d3e605535ee0113 (diff) | |
| download | rust-6e7e243ef2790169cfd0e228d22fb6fdd9093317.tar.gz rust-6e7e243ef2790169cfd0e228d22fb6fdd9093317.zip | |
Prepare standard library for checking rustc in `prepare_compiler_for_check`
| -rw-r--r-- | src/bootstrap/src/core/build_steps/check.rs | 48 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/clippy.rs | 2 |
2 files changed, 23 insertions, 27 deletions
diff --git a/src/bootstrap/src/core/build_steps/check.rs b/src/bootstrap/src/core/build_steps/check.rs index 0cbf8f55e99..2d27ad4cdf3 100644 --- a/src/bootstrap/src/core/build_steps/check.rs +++ b/src/bootstrap/src/core/build_steps/check.rs @@ -168,12 +168,8 @@ pub struct Rustc { } impl Rustc { - pub fn new(builder: &Builder<'_>, build_compiler: Compiler, target: TargetSelection) -> Self { - let crates = builder - .in_tree_crates("rustc-main", Some(target)) - .into_iter() - .map(|krate| krate.name.to_string()) - .collect(); + pub fn new(builder: &Builder<'_>, target: TargetSelection, crates: Vec<String>) -> Self { + let build_compiler = prepare_compiler_for_check(builder, target, Mode::Rustc); Self { build_compiler, target, crates } } } @@ -189,11 +185,7 @@ impl Step for Rustc { fn make_run(run: RunConfig<'_>) { let crates = run.make_run_crates(Alias::Compiler); - run.builder.ensure(Rustc { - target: run.target, - build_compiler: prepare_compiler_for_check(run.builder, run.target, Mode::Rustc), - crates, - }); + run.builder.ensure(Rustc::new(run.builder, run.target, crates)); } /// Check the compiler. @@ -207,15 +199,6 @@ impl Step for Rustc { let build_compiler = self.build_compiler; let target = self.target; - // Build host std for compiling build scripts - builder.std(build_compiler, build_compiler.host); - - // Build target std so that the checked rustc can link to it during the check - // FIXME: maybe we can a way to only do a check of std here? - // But for that we would have to copy the stdlib rmetas to the sysroot of the build - // compiler, which conflicts with std rlibs, if we also build std. - builder.std(build_compiler, target); - let mut cargo = builder::Cargo::new( builder, build_compiler, @@ -289,11 +272,13 @@ fn prepare_compiler_for_check( build_compiler } Mode::ToolRustc | Mode::Codegen => { - // FIXME: this is a hack, see description of Mode::Rustc below - let stage = if host == target { builder.top_stage - 1 } else { builder.top_stage }; - // When checking tool stage N, we check it with compiler stage N-1 - let build_compiler = builder.compiler(stage, host); - builder.ensure(Rustc::new(builder, build_compiler, target)); + // Check Rustc to produce the required rmeta artifacts for rustc_private, and then + // return the build compiler that was used to check rustc. + // We do not need to check examples/tests/etc. of Rustc for rustc_private, so we pass + // an empty set of crates, which will avoid using `cargo -p`. + let check = Rustc::new(builder, target, vec![]); + let build_compiler = check.build_compiler; + builder.ensure(check); build_compiler } Mode::Rustc => { @@ -305,7 +290,18 @@ fn prepare_compiler_for_check( // FIXME: remove this and either fix cross-compilation check on stage 2 (which has a // myriad of other problems) or disable cross-checking on stage 1. let stage = if host == target { builder.top_stage - 1 } else { builder.top_stage }; - builder.compiler(stage, host) + let build_compiler = builder.compiler(stage, host); + + // Build host std for compiling build scripts + builder.std(build_compiler, build_compiler.host); + + // Build target std so that the checked rustc can link to it during the check + // FIXME: maybe we can a way to only do a check of std here? + // But for that we would have to copy the stdlib rmetas to the sysroot of the build + // compiler, which conflicts with std rlibs, if we also build std. + builder.std(build_compiler, target); + + build_compiler } Mode::Std => { // When checking std stage N, we want to do it with the stage N compiler diff --git a/src/bootstrap/src/core/build_steps/clippy.rs b/src/bootstrap/src/core/build_steps/clippy.rs index 4d734fe5c66..2cba9aa8e8b 100644 --- a/src/bootstrap/src/core/build_steps/clippy.rs +++ b/src/bootstrap/src/core/build_steps/clippy.rs @@ -298,7 +298,7 @@ macro_rules! lint_any { let target = self.target; if !builder.download_rustc() { - builder.ensure(check::Rustc::new(builder, build_compiler, target)); + builder.ensure(check::Rustc::new(builder, target, vec![])); }; let cargo = prepare_tool_cargo( |
