1
Fork 0

Fix x check --stage 1 when download-ci-llvm=false

This commit is contained in:
Joshua Nelson 2023-04-09 15:19:03 -05:00
parent fb927968cc
commit ca3daa0fb6
4 changed files with 24 additions and 22 deletions

View file

@ -237,7 +237,7 @@ impl Step for Rustc {
target, target,
cargo_subcommand(builder.kind), cargo_subcommand(builder.kind),
); );
rustc_cargo(builder, &mut cargo, target); rustc_cargo(builder, &mut cargo, target, compiler.stage);
// For ./x.py clippy, don't run with --all-targets because // For ./x.py clippy, don't run with --all-targets because
// linting tests and benchmarks can produce very noisy results // linting tests and benchmarks can produce very noisy results
@ -315,7 +315,7 @@ impl Step for CodegenBackend {
cargo cargo
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend))); .arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend)));
rustc_cargo_env(builder, &mut cargo, target); rustc_cargo_env(builder, &mut cargo, target, compiler.stage);
let msg = if compiler.host == target { let msg = if compiler.host == target {
format!("Checking stage{} {} artifacts ({target})", builder.top_stage, backend) format!("Checking stage{} {} artifacts ({target})", builder.top_stage, backend)

View file

@ -696,7 +696,7 @@ impl Step for Rustc {
)); ));
let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build"); let mut cargo = builder.cargo(compiler, Mode::Rustc, SourceType::InTree, target, "build");
rustc_cargo(builder, &mut cargo, target); rustc_cargo(builder, &mut cargo, target, compiler.stage);
if builder.config.rust_profile_use.is_some() if builder.config.rust_profile_use.is_some()
&& builder.config.rust_profile_generate.is_some() && builder.config.rust_profile_generate.is_some()
@ -813,16 +813,21 @@ impl Step for Rustc {
} }
} }
pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection) { pub fn rustc_cargo(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection, stage: u32) {
cargo cargo
.arg("--features") .arg("--features")
.arg(builder.rustc_features(builder.kind)) .arg(builder.rustc_features(builder.kind))
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join("compiler/rustc/Cargo.toml")); .arg(builder.src.join("compiler/rustc/Cargo.toml"));
rustc_cargo_env(builder, cargo, target); rustc_cargo_env(builder, cargo, target, stage);
} }
pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelection) { pub fn rustc_cargo_env(
builder: &Builder<'_>,
cargo: &mut Cargo,
target: TargetSelection,
stage: u32,
) {
// Set some configuration variables picked up by build scripts and // Set some configuration variables picked up by build scripts and
// the compiler alike // the compiler alike
cargo cargo
@ -867,16 +872,18 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
cargo.env("RUSTC_VERIFY_LLVM_IR", "1"); cargo.env("RUSTC_VERIFY_LLVM_IR", "1");
} }
//
// Note that this is disabled if LLVM itself is disabled or we're in a check // Note that this is disabled if LLVM itself is disabled or we're in a check
// build. If we are in a check build we still go ahead here presuming we've // build. If we are in a check build we still go ahead here presuming we've
// detected that LLVM is already built and good to go which helps prevent // detected that LLVM is already built and good to go which helps prevent
// busting caches (e.g. like #71152). // busting caches (e.g. like #71152).
if builder.config.llvm_enabled() if builder.config.llvm_enabled() {
&& (builder.kind != Kind::Check let building_is_expensive = crate::llvm::prebuilt_llvm_config(builder, target).is_err();
|| crate::llvm::prebuilt_llvm_config(builder, target).is_ok()) // `top_stage == stage` might be false for `check --stage 1`, if we are building the stage 1 compiler
{ let can_skip_build = builder.kind == Kind::Check && builder.top_stage == stage;
rustc_llvm_env(builder, cargo, target) let should_skip_build = building_is_expensive && can_skip_build;
if !should_skip_build {
rustc_llvm_env(builder, cargo, target)
}
} }
} }
@ -933,13 +940,8 @@ fn rustc_llvm_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetSelect
&& !target.contains("apple") && !target.contains("apple")
&& !target.contains("solaris") && !target.contains("solaris")
{ {
let file = compiler_file( let file =
builder, compiler_file(builder, builder.cxx(target).unwrap(), target, CLang::Cxx, "libstdc++.a");
builder.cxx(target).unwrap(),
target,
CLang::Cxx,
"libstdc++.a",
);
cargo.env("LLVM_STATIC_STDCPP", file); cargo.env("LLVM_STATIC_STDCPP", file);
} }
if builder.llvm_link_shared() { if builder.llvm_link_shared() {
@ -1054,7 +1056,7 @@ impl Step for CodegenBackend {
cargo cargo
.arg("--manifest-path") .arg("--manifest-path")
.arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend))); .arg(builder.src.join(format!("compiler/rustc_codegen_{}/Cargo.toml", backend)));
rustc_cargo_env(builder, &mut cargo, target); rustc_cargo_env(builder, &mut cargo, target, compiler.stage);
let tmp_stamp = out_dir.join(".tmp.stamp"); let tmp_stamp = out_dir.join(".tmp.stamp");

View file

@ -696,7 +696,7 @@ impl Step for Rustc {
cargo.rustdocflag("-Znormalize-docs"); cargo.rustdocflag("-Znormalize-docs");
cargo.rustdocflag("--show-type-layout"); cargo.rustdocflag("--show-type-layout");
cargo.rustdocflag("--generate-link-to-definition"); cargo.rustdocflag("--generate-link-to-definition");
compile::rustc_cargo(builder, &mut cargo, target); compile::rustc_cargo(builder, &mut cargo, target, compiler.stage);
cargo.arg("-Zunstable-options"); cargo.arg("-Zunstable-options");
cargo.arg("-Zskip-rustdoc-fingerprint"); cargo.arg("-Zskip-rustdoc-fingerprint");

View file

@ -2143,7 +2143,7 @@ impl Step for Crate {
compile::std_cargo(builder, target, compiler.stage, &mut cargo); compile::std_cargo(builder, target, compiler.stage, &mut cargo);
} }
Mode::Rustc => { Mode::Rustc => {
compile::rustc_cargo(builder, &mut cargo, target); compile::rustc_cargo(builder, &mut cargo, target, compiler.stage);
} }
_ => panic!("can only test libraries"), _ => panic!("can only test libraries"),
}; };