Skip to content

Commit e9c3e64

Browse files
committed
Remove compiler_for from test::CodegenCranelift
1 parent 7a20ab0 commit e9c3e64

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
@@ -3419,7 +3419,7 @@ impl Step for TestHelpers {
34193419

34203420
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
34213421
pub struct CodegenCranelift {
3422-
compiler: Compiler,
3422+
compilers: RustcPrivateCompilers,
34233423
target: TargetSelection,
34243424
}
34253425

@@ -3435,7 +3435,7 @@ impl Step for CodegenCranelift {
34353435
fn make_run(run: RunConfig<'_>) {
34363436
let builder = run.builder;
34373437
let host = run.build_triple();
3438-
let compiler = run.builder.compiler_for(run.builder.top_stage, host, host);
3438+
let compilers = RustcPrivateCompilers::new(run.builder, run.builder.top_stage, host);
34393439

34403440
if builder.doc_tests == DocTests::Only {
34413441
return;
@@ -3465,71 +3465,50 @@ impl Step for CodegenCranelift {
34653465
return;
34663466
}
34673467

3468-
builder.ensure(CodegenCranelift { compiler, target: run.target });
3468+
builder.ensure(CodegenCranelift { compilers, target: run.target });
34693469
}
34703470

34713471
fn run(self, builder: &Builder<'_>) {
3472-
let compiler = self.compiler;
3473-
let target = self.target;
3474-
3475-
builder.std(compiler, target);
3472+
let compilers = self.compilers;
3473+
let build_compiler = compilers.build_compiler();
34763474

3477-
// If we're not doing a full bootstrap but we're testing a stage2
3478-
// version of libstd, then what we're actually testing is the libstd
3479-
// produced in stage1. Reflect that here by updating the compiler that
3480-
// we're working with automatically.
3481-
let compiler = builder.compiler_for(compiler.stage, compiler.host, target);
3475+
// We need to run the cranelift tests with the compiler against cranelift links to, not with
3476+
// the build compiler.
3477+
let target_compiler = compilers.target_compiler();
3478+
let target = self.target;
34823479

3483-
let build_cargo = || {
3484-
let mut cargo = builder::Cargo::new(
3485-
builder,
3486-
compiler,
3487-
Mode::Codegen, // Must be codegen to ensure dlopen on compiled dylibs works
3488-
SourceType::InTree,
3489-
target,
3490-
Kind::Run,
3491-
);
3480+
builder.std(target_compiler, target);
34923481

3493-
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_cranelift"));
3494-
cargo
3495-
.arg("--manifest-path")
3496-
.arg(builder.src.join("compiler/rustc_codegen_cranelift/build_system/Cargo.toml"));
3497-
compile::rustc_cargo_env(builder, &mut cargo, target);
3482+
let mut cargo = builder::Cargo::new(
3483+
builder,
3484+
target_compiler,
3485+
Mode::Codegen, // Must be codegen to ensure dlopen on compiled dylibs works
3486+
SourceType::InTree,
3487+
target,
3488+
Kind::Run,
3489+
);
34983490

3499-
// Avoid incremental cache issues when changing rustc
3500-
cargo.env("CARGO_BUILD_INCREMENTAL", "false");
3491+
cargo.current_dir(&builder.src.join("compiler/rustc_codegen_cranelift"));
3492+
cargo
3493+
.arg("--manifest-path")
3494+
.arg(builder.src.join("compiler/rustc_codegen_cranelift/build_system/Cargo.toml"));
3495+
compile::rustc_cargo_env(builder, &mut cargo, target);
35013496

3502-
cargo
3503-
};
3497+
// Avoid incremental cache issues when changing rustc
3498+
cargo.env("CARGO_BUILD_INCREMENTAL", "false");
35043499

3505-
builder.info(&format!(
3506-
"{} cranelift stage{} ({} -> {})",
3507-
Kind::Test.description(),
3508-
compiler.stage,
3509-
&compiler.host,
3510-
target
3511-
));
3512-
let _time = helpers::timeit(builder);
3500+
let _guard = builder.msg_test("rustc_codegen_cranelift", target_compiler);
35133501

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

3517-
// FIXME: Uncomment the `prepare` command below once vendoring is implemented.
3518-
/*
3519-
let mut prepare_cargo = build_cargo();
3520-
prepare_cargo.arg("--").arg("prepare").arg("--download-dir").arg(&download_dir);
3521-
#[expect(deprecated)]
3522-
builder.config.try_run(&mut prepare_cargo.into()).unwrap();
3523-
*/
3524-
3525-
let mut cargo = build_cargo();
35263505
cargo
35273506
.arg("--")
35283507
.arg("test")
35293508
.arg("--download-dir")
35303509
.arg(&download_dir)
35313510
.arg("--out-dir")
3532-
.arg(builder.stage_out(compiler, Mode::ToolRustc).join("cg_clif"))
3511+
.arg(builder.stage_out(build_compiler, Mode::Codegen).join("cg_clif"))
35333512
.arg("--no-unstable-features")
35343513
.arg("--use-backend")
35353514
.arg("cranelift")
@@ -3543,6 +3522,13 @@ impl Step for CodegenCranelift {
35433522

35443523
cargo.into_cmd().run(builder);
35453524
}
3525+
3526+
fn metadata(&self) -> Option<StepMetadata> {
3527+
Some(
3528+
StepMetadata::test("rustc_codegen_cranelift", self.target)
3529+
.built_by(self.compilers.build_compiler()),
3530+
)
3531+
}
35463532
}
35473533

35483534
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
@@ -3606,7 +3592,7 @@ impl Step for CodegenGCC {
36063592
.extra_rust_args(&["-Csymbol-mangling-version=v0", "-Cpanic=abort"]),
36073593
);
36083594

3609-
let _msg = builder.msg_test("rustc_codegen_gcc", compilers.build_compiler());
3595+
let _guard = builder.msg_test("rustc_codegen_gcc", compilers.build_compiler());
36103596

36113597
let mut cargo = builder::Cargo::new(
36123598
builder,

0 commit comments

Comments
 (0)