Skip to content

Commit ca3daa0

Browse files
committed
Fix x check --stage 1 when download-ci-llvm=false
1 parent fb92796 commit ca3daa0

File tree

4 files changed

+24
-22
lines changed

4 files changed

+24
-22
lines changed

src/bootstrap/check.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl Step for Rustc {
237237
target,
238238
cargo_subcommand(builder.kind),
239239
);
240-
rustc_cargo(builder, &mut cargo, target);
240+
rustc_cargo(builder, &mut cargo, target, compiler.stage);
241241

242242
// For ./x.py clippy, don't run with --all-targets because
243243
// linting tests and benchmarks can produce very noisy results
@@ -315,7 +315,7 @@ impl Step for CodegenBackend {
315315
cargo
316316
.arg("--manifest-path")
317317
.arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend)));
318-
rustc_cargo_env(builder, &mut cargo, target);
318+
rustc_cargo_env(builder, &mut cargo, target, compiler.stage);
319319

320320
let msg = if compiler.host == target {
321321
format!("Checking stage{} {} artifacts ({target})", builder.top_stage, backend)

src/bootstrap/compile.rs

+20-18
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl Step for Rustc {
696696
));
697697

698698
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build");
699-
rustc_cargo(builder, &mut cargo, target);
699+
rustc_cargo(builder, &mut cargo, target, compiler.stage);
700700

701701
if builder.config.rust_profile_use.is_some()
702702
&& builder.config.rust_profile_generate.is_some()
@@ -813,16 +813,21 @@ impl Step for Rustc {
813813
}
814814
}
815815

816-
pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection) {
816+
pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection, stage: u32) {
817817
cargo
818818
.arg("--features")
819819
.arg(builder.rustc_features(builder.kind))
820820
.arg("--manifest-path")
821821
.arg(builder.src.join("compiler/rustc/Cargo.toml"));
822-
rustc_cargo_env(builder, cargo, target);
822+
rustc_cargo_env(builder, cargo, target, stage);
823823
}
824824

825-
pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection) {
825+
pub fn rustc_cargo_env(
826+
builder: &Builder<'_>,
827+
cargo: &mut Cargo,
828+
target: TargetSelection,
829+
stage: u32,
830+
) {
826831
// Set some configuration variables picked up by build scripts and
827832
// the compiler alike
828833
cargo
@@ -867,16 +872,18 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
867872
cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
868873
}
869874

870-
//
871875
// Note that this is disabled if LLVM itself is disabled or we're in a check
872876
// build. If we are in a check build we still go ahead here presuming we've
873877
// detected that LLVM is already built and good to go which helps prevent
874878
// busting caches (e.g. like #71152).
875-
if builder.config.llvm_enabled()
876-
&& (builder.kind != Kind::Check
877-
|| crate::llvm::prebuilt_llvm_config(builder, target).is_ok())
878-
{
879-
rustc_llvm_env(builder, cargo, target)
879+
if builder.config.llvm_enabled() {
880+
let building_is_expensive = crate::llvm::prebuilt_llvm_config(builder, target).is_err();
881+
// `top_stage == stage` might be false for `check --stage 1`, if we are building the stage 1 compiler
882+
let can_skip_build = builder.kind == Kind::Check && builder.top_stage == stage;
883+
let should_skip_build = building_is_expensive && can_skip_build;
884+
if !should_skip_build {
885+
rustc_llvm_env(builder, cargo, target)
886+
}
880887
}
881888
}
882889

@@ -933,13 +940,8 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
933940
&& !target.contains("apple")
934941
&& !target.contains("solaris")
935942
{
936-
let file = compiler_file(
937-
builder,
938-
builder.cxx(target).unwrap(),
939-
target,
940-
CLang::Cxx,
941-
"libstdc++.a",
942-
);
943+
let file =
944+
compiler_file(builder, builder.cxx(target).unwrap(), target, CLang::Cxx, "libstdc++.a");
943945
cargo.env("LLVM_STATIC_STDCPP", file);
944946
}
945947
if builder.llvm_link_shared() {
@@ -1054,7 +1056,7 @@ impl Step for CodegenBackend {
10541056
cargo
10551057
.arg("--manifest-path")
10561058
.arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend)));
1057-
rustc_cargo_env(builder, &mut cargo, target);
1059+
rustc_cargo_env(builder, &mut cargo, target, compiler.stage);
10581060

10591061
let tmp_stamp = out_dir.join(".tmp.stamp");
10601062

src/bootstrap/doc.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -696,7 +696,7 @@ impl Step for Rustc {
696696
cargo.rustdocflag("-Znormalize-docs");
697697
cargo.rustdocflag("--show-type-layout");
698698
cargo.rustdocflag("--generate-link-to-definition");
699-
compile::rustc_cargo(builder, &mut cargo, target);
699+
compile::rustc_cargo(builder, &mut cargo, target, compiler.stage);
700700
cargo.arg("-Zunstable-options");
701701
cargo.arg("-Zskip-rustdoc-fingerprint");
702702

src/bootstrap/test.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2143,7 +2143,7 @@ impl Step for Crate {
21432143
compile::std_cargo(builder, target, compiler.stage, &mut cargo);
21442144
}
21452145
Mode::Rustc => {
2146-
compile::rustc_cargo(builder, &mut cargo, target);
2146+
compile::rustc_cargo(builder, &mut cargo, target, compiler.stage);
21472147
}
21482148
_ => panic!("can only test libraries"),
21492149
};

0 commit comments

Comments
 (0)