Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2059,7 +2059,7 @@ impl Step for Assemble {
trace!("llvm-bitcode-linker enabled, installing");
let llvm_bitcode_linker =
builder.ensure(crate::core::build_steps::tool::LlvmBitcodeLinker {
compiler,
build_compiler: compiler,
target: target_compiler.host,
});

Expand Down
3 changes: 2 additions & 1 deletion src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2374,7 +2374,8 @@ impl Step for LlvmBitcodeLinker {

builder.ensure(compile::Rustc::new(compiler, target));

let llbc_linker = builder.ensure(tool::LlvmBitcodeLinker { compiler, target });
let llbc_linker =
builder.ensure(tool::LlvmBitcodeLinker { build_compiler: compiler, target });

let self_contained_bin_dir = format!("lib/rustlib/{}/bin/self-contained", target.triple);

Expand Down
12 changes: 9 additions & 3 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ impl Step for RustAnalyzerProcMacroSrv {

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
pub struct LlvmBitcodeLinker {
pub compiler: Compiler,
pub build_compiler: Compiler,
pub target: TargetSelection,
}

Expand All @@ -1031,7 +1031,9 @@ impl Step for LlvmBitcodeLinker {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(LlvmBitcodeLinker {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.host_target),
build_compiler: run
.builder
.compiler(run.builder.top_stage, run.builder.config.host_target),
target: run.target,
});
}
Expand All @@ -1042,7 +1044,7 @@ impl Step for LlvmBitcodeLinker {
)]
fn run(self, builder: &Builder<'_>) -> ToolBuildResult {
builder.ensure(ToolBuild {
compiler: self.compiler,
compiler: self.build_compiler,
target: self.target,
tool: "llvm-bitcode-linker",
mode: Mode::ToolRustc,
Expand All @@ -1054,6 +1056,10 @@ impl Step for LlvmBitcodeLinker {
artifact_kind: ToolArtifactKind::Binary,
})
}

fn metadata(&self) -> Option<StepMetadata> {
Some(StepMetadata::build("LlvmBitcodeLinker", self.target).built_by(self.build_compiler))
}
}

#[derive(Debug, Clone, Hash, PartialEq, Eq)]
Expand Down
23 changes: 23 additions & 0 deletions src/bootstrap/src/core/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -757,6 +757,27 @@ mod snapshot {
");
}

#[test]
fn build_compiler_tools() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx
.config("build")
.stage(2)
.args(&["--set", "rust.llvm-bitcode-linker=true"])
.render_steps(), @r"
[build] llvm <host>
[build] rustc 0 <host> -> rustc 1 <host>
[build] rustc 1 <host> -> LlvmBitcodeLinker 2 <host>
[build] rustc 1 <host> -> std 1 <host>
[build] rustc 1 <host> -> rustc 2 <host>
[build] rustc 2 <host> -> LlvmBitcodeLinker 3 <host>
[build] rustc 2 <host> -> std 2 <host>
[build] rustdoc 1 <host>
"
);
}

#[test]
fn build_library_no_explicit_stage() {
let ctx = TestCtx::new();
Expand Down Expand Up @@ -1040,6 +1061,7 @@ mod snapshot {
[build] rustc 0 <host> -> cargo-clippy 1 <host>
[build] rustc 0 <host> -> miri 1 <host>
[build] rustc 0 <host> -> cargo-miri 1 <host>
[build] rustc 1 <host> -> LlvmBitcodeLinker 2 <host>
");
}

Expand Down Expand Up @@ -1230,6 +1252,7 @@ mod snapshot {
[build] rustc 0 <host> -> cargo-clippy 1 <target1>
[build] rustc 0 <host> -> miri 1 <target1>
[build] rustc 0 <host> -> cargo-miri 1 <target1>
[build] rustc 1 <host> -> LlvmBitcodeLinker 2 <target1>
");
}

Expand Down