Skip to content

Commit 2ca5cb8

Browse files
committed
Remove compiler_for from test::CodegenCranelift
1 parent 42fb65b commit 2ca5cb8

File tree

1 file changed

+35
-49
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+35
-49
lines changed

src/bootstrap/src/core/build_steps/test.rs

Lines changed: 35 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,7 +3450,7 @@ impl Step for TestHelpers {
34503450

34513451
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
34523452
pub struct CodegenCranelift {
3453-
compiler: Compiler,
3453+
compilers: RustcPrivateCompilers,
34543454
target: TargetSelection,
34553455
}
34563456

@@ -3466,7 +3466,7 @@ impl Step for CodegenCranelift {
34663466
fn make_run(run: RunConfig<'_>) {
34673467
let builder = run.builder;
34683468
let host = run.build_triple();
3469-
let compiler = run.builder.compiler_for(run.builder.top_stage, host, host);
3469+
let compilers = RustcPrivateCompilers::new(run.builder, run.builder.top_stage, host);
34703470

34713471
if builder.doc_tests == DocTests::Only {
34723472
return;
@@ -3496,71 +3496,50 @@ impl Step for CodegenCranelift {
34963496
return;
34973497
}
34983498

3499-
builder.ensure(CodegenCranelift { compiler, target: run.target });
3499+
builder.ensure(CodegenCranelift { compilers, target: run.target });
35003500
}
35013501

35023502
fn run(self, builder: &Builder<'_>) {
3503-
let compiler = self.compiler;
3504-
let target = self.target;
3505-
3506-
builder.std(compiler, target);
3503+
let compilers = self.compilers;
3504+
let build_compiler = compilers.build_compiler();
35073505

3508-
// If we're not doing a full bootstrap but we're testing a stage2
3509-
// version of libstd, then what we're actually testing is the libstd
3510-
// produced in stage1. Reflect that here by updating the compiler that
3511-
// we're working with automatically.
3512-
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
3506+
// We need to run the cranelift tests with the compiler against cranelift links to, not with
3507+
// the build compiler.
3508+
let target_compiler = compilers.target_compiler();
3509+
let target = self.target;
35133510

3514-
let build_cargo = || {
3515-
let mut cargo = builder::Cargo::new(
3516-
builder,
3517-
compiler,
3518-
Mode::Codegen, // Must be codegen to ensure dlopen on compiled dylibs works
3519-
SourceType::InTree,
3520-
target,
3521-
Kind::Run,
3522-
);
3511+
builder.std(target_compiler, target);
35233512

3524-
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_cranelift"));
3525-
cargo
3526-
.arg("--manifest-path")
3527-
.arg(builder.src.join("compiler/rustc_codegen_cranelift/build_system/Cargo.toml"));
3528-
compile::rustc_cargo_env(builder, &mut cargo, target);
3513+
let mut cargo = builder::Cargo::new(
3514+
builder,
3515+
target_compiler,
3516+
Mode::Codegen, // Must be codegen to ensure dlopen on compiled dylibs works
3517+
SourceType::InTree,
3518+
target,
3519+
Kind::Run,
3520+
);
35293521

3530-
// Avoid incremental cache issues when changing rustc
3531-
cargo.env("CARGO_BUILD_INCREMENTAL", "false");
3522+
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_cranelift"));
3523+
cargo
3524+
.arg("--manifest-path")
3525+
.arg(builder.src.join("compiler/rustc_codegen_cranelift/build_system/Cargo.toml"));
3526+
compile::rustc_cargo_env(builder, &mut cargo, target);
35323527

3533-
cargo
3534-
};
3528+
// Avoid incremental cache issues when changing rustc
3529+
cargo.env("CARGO_BUILD_INCREMENTAL", "false");
35353530

3536-
builder.info(&format!(
3537-
"{} cranelift stage{} ({} -> {})",
3538-
Kind::Test.description(),
3539-
compiler.stage,
3540-
&compiler.host,
3541-
target
3542-
));
3543-
let _time = helpers::timeit(builder);
3531+
let _guard = builder.msg_test("rustc_codegen_cranelift", target_compiler);
35443532

35453533
// FIXME handle vendoring for source tarballs before removing the --skip-test below
35463534
let download_dir = builder.out.join("cg_clif_download");
35473535

3548-
// FIXME: Uncomment the `prepare` command below once vendoring is implemented.
3549-
/*
3550-
let mut prepare_cargo = build_cargo();
3551-
prepare_cargo.arg("--").arg("prepare").arg("--download-dir").arg(&download_dir);
3552-
#[expect(deprecated)]
3553-
builder.config.try_run(&mut prepare_cargo.into()).unwrap();
3554-
*/
3555-
3556-
let mut cargo = build_cargo();
35573536
cargo
35583537
.arg("--")
35593538
.arg("test")
35603539
.arg("--download-dir")
35613540
.arg(&download_dir)
35623541
.arg("--out-dir")
3563-
.arg(builder.stage_out(compiler, Mode::ToolRustc).join("cg_clif"))
3542+
.arg(builder.stage_out(build_compiler, Mode::Codegen).join("cg_clif"))
35643543
.arg("--no-unstable-features")
35653544
.arg("--use-backend")
35663545
.arg("cranelift")
@@ -3574,6 +3553,13 @@ impl Step for CodegenCranelift {
35743553

35753554
cargo.into_cmd().run(builder);
35763555
}
3556+
3557+
fn metadata(&self) -> Option<StepMetadata> {
3558+
Some(
3559+
StepMetadata::test("rustc_codegen_cranelift", self.target)
3560+
.built_by(self.compilers.build_compiler()),
3561+
)
3562+
}
35773563
}
35783564

35793565
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3637,7 +3623,7 @@ impl Step for CodegenGCC {
36373623
.extra_rust_args(&["-Csymbol-mangling-version=v0", "-Cpanic=abort"]),
36383624
);
36393625

3640-
let _msg = builder.msg_test("rustc_codegen_gcc", compilers.build_compiler());
3626+
let _guard = builder.msg_test("rustc_codegen_gcc", compilers.build_compiler());
36413627

36423628
let mut cargo = builder::Cargo::new(
36433629
builder,

0 commit comments

Comments
 (0)