Skip to content

Commit 13abc0a

Browse files
committed
Auto merge of #122558 - kjetilkjeka:llvm_bitcode_linker_no_trigger_rebuild, r=onur-ozkan
LLVM bitcode linker: use --cfg=parallel_compiler to avoid invalidating the build cache of rustdoc fixes #122491 `@rustbot` ready
2 parents a42873e + 7bdd63d commit 13abc0a

File tree

1 file changed

+73
-1
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+73
-1
lines changed

src/bootstrap/src/core/build_steps/tool.rs

+73-1
Original file line numberDiff line numberDiff line change
@@ -692,6 +692,79 @@ impl Step for RustAnalyzerProcMacroSrv {
692692
}
693693
}
694694

695+
#[derive(Debug, Clone, Hash, PartialEq, Eq)]
696+
pub struct LlvmBitcodeLinker {
697+
pub compiler: Compiler,
698+
pub target: TargetSelection,
699+
pub extra_features: Vec<String>,
700+
}
701+
702+
impl Step for LlvmBitcodeLinker {
703+
type Output = PathBuf;
704+
const DEFAULT: bool = true;
705+
const ONLY_HOSTS: bool = true;
706+
707+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
708+
let builder = run.builder;
709+
run.path("src/tools/llvm-bitcode-linker").default_condition(
710+
builder.config.extended
711+
&& builder
712+
.config
713+
.tools
714+
.as_ref()
715+
.map_or(builder.build.unstable_features(), |tools| {
716+
tools.iter().any(|tool| tool == "llvm-bitcode-linker")
717+
}),
718+
)
719+
}
720+
721+
fn make_run(run: RunConfig<'_>) {
722+
run.builder.ensure(LlvmBitcodeLinker {
723+
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
724+
extra_features: Vec::new(),
725+
target: run.target,
726+
});
727+
}
728+
729+
fn run(self, builder: &Builder<'_>) -> PathBuf {
730+
let bin_name = "llvm-bitcode-linker";
731+
732+
builder.ensure(compile::Std::new(self.compiler, self.compiler.host));
733+
builder.ensure(compile::Rustc::new(self.compiler, self.target));
734+
735+
let mut cargo = prepare_tool_cargo(
736+
builder,
737+
self.compiler,
738+
Mode::ToolRustc,
739+
self.target,
740+
"build",
741+
"src/tools/llvm-bitcode-linker",
742+
SourceType::InTree,
743+
&self.extra_features,
744+
);
745+
746+
if builder.config.rustc_parallel {
747+
cargo.rustflag("--cfg=parallel_compiler");
748+
}
749+
750+
builder.run(&mut cargo.into());
751+
752+
let tool_out = builder
753+
.cargo_out(self.compiler, Mode::ToolRustc, self.target)
754+
.join(exe(bin_name, self.compiler.host));
755+
756+
if self.compiler.stage > 0 {
757+
let bindir = builder.sysroot(self.compiler).join("bin");
758+
t!(fs::create_dir_all(&bindir));
759+
let bin_destination = bindir.join(exe(bin_name, self.compiler.host));
760+
builder.copy_link(&tool_out, &bin_destination);
761+
bin_destination
762+
} else {
763+
tool_out
764+
}
765+
}
766+
}
767+
695768
macro_rules! tool_extended {
696769
(($sel:ident, $builder:ident),
697770
$($name:ident,
@@ -795,7 +868,6 @@ tool_extended!((self, builder),
795868
Rls, "src/tools/rls", "rls", stable=true, tool_std=true;
796869
RustDemangler, "src/tools/rust-demangler", "rust-demangler", stable=false, tool_std=true;
797870
Rustfmt, "src/tools/rustfmt", "rustfmt", stable=true, add_bins_to_sysroot = ["rustfmt", "cargo-fmt"];
798-
LlvmBitcodeLinker, "src/tools/llvm-bitcode-linker", "llvm-bitcode-linker", stable=false, add_bins_to_sysroot = ["llvm-bitcode-linker"];
799871
);
800872

801873
impl<'a> Builder<'a> {

0 commit comments

Comments
 (0)