Skip to content

Commit 503d8f0

Browse files
author
Kjetil Kjeka
committed
Bootstrap: Add llvm-bitcode-linker as preview component
1 parent f841b26 commit 503d8f0

File tree

4 files changed

+63
-0
lines changed

4 files changed

+63
-0
lines changed

src/bootstrap/src/core/build_steps/dist.rs

+48
Original file line numberDiff line numberDiff line change
@@ -1546,6 +1546,7 @@ impl Step for Extended {
15461546
compiler: builder.compiler(stage, target),
15471547
backend: "cranelift".to_string(),
15481548
});
1549+
add_component!("llvm-bitcode-linker" => LlvmBitcodeLinker {compiler, target});
15491550

15501551
let etc = builder.src.join("src/etc/installer");
15511552

@@ -2222,6 +2223,53 @@ impl Step for LlvmTools {
22222223
}
22232224
}
22242225

2226+
#[derive(Debug, PartialOrd, Ord, Clone, Hash, PartialEq, Eq)]
2227+
pub struct LlvmBitcodeLinker {
2228+
pub compiler: Compiler,
2229+
pub target: TargetSelection,
2230+
}
2231+
2232+
impl Step for LlvmBitcodeLinker {
2233+
type Output = Option<GeneratedTarball>;
2234+
const DEFAULT: bool = true;
2235+
const ONLY_HOSTS: bool = true;
2236+
2237+
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
2238+
let default = should_build_extended_tool(run.builder, "llvm-bitcode-linker");
2239+
run.alias("llvm-bitcode-linker").default_condition(default)
2240+
}
2241+
2242+
fn make_run(run: RunConfig<'_>) {
2243+
run.builder.ensure(LlvmBitcodeLinker {
2244+
compiler: run.builder.compiler_for(
2245+
run.builder.top_stage,
2246+
run.builder.config.build,
2247+
run.target,
2248+
),
2249+
target: run.target,
2250+
});
2251+
}
2252+
2253+
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
2254+
let compiler = self.compiler;
2255+
let target = self.target;
2256+
2257+
let llbc_linker =
2258+
builder.ensure(tool::LlvmBitcodeLinker { compiler, target, extra_features: vec![] });
2259+
2260+
let self_contained_bin_dir = format!("lib/rustlib/{}/bin/self-contained", target.triple);
2261+
2262+
// Prepare the image directory
2263+
let mut tarball = Tarball::new(builder, "llvm-bitcode-linker", &target.triple);
2264+
tarball.set_overlay(OverlayKind::LlvmBitcodeLinker);
2265+
tarball.is_preview(true);
2266+
2267+
tarball.add_file(llbc_linker, self_contained_bin_dir, 0o755);
2268+
2269+
Some(tarball.generate())
2270+
}
2271+
}
2272+
22252273
// Tarball intended for internal consumption to ease rustc/std development.
22262274
//
22272275
// Should not be considered stable by end users.

src/bootstrap/src/core/build_steps/install.rs

+9
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,15 @@ install!((self, builder, _config),
300300
);
301301
}
302302
};
303+
LlvmBitcodeLinker, alias = "llvm-bitcode-linker", Self::should_build(_config), only_hosts: true, {
304+
if let Some(tarball) = builder.ensure(dist::LlvmBitcodeLinker { compiler: self.compiler, target: self.target }) {
305+
install_sh(builder, "llvm-bitcode-linker", self.compiler.stage, Some(self.target), &tarball);
306+
} else {
307+
builder.info(
308+
&format!("skipping llvm-too stage{} ({})", self.compiler.stage, self.target),
309+
);
310+
}
311+
};
303312
);
304313

305314
#[derive(Debug, Clone, Hash, PartialEq, Eq)]

src/bootstrap/src/core/builder.rs

+1
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ impl<'a> Builder<'a> {
869869
dist::Clippy,
870870
dist::Miri,
871871
dist::LlvmTools,
872+
dist::LlvmBitcodeLinker,
872873
dist::RustDev,
873874
dist::Bootstrap,
874875
dist::Extended,

src/bootstrap/src/utils/tarball.rs

+5
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ pub(crate) enum OverlayKind {
2020
RLS,
2121
RustAnalyzer,
2222
RustcCodegenCranelift,
23+
LlvmBitcodeLinker,
2324
}
2425

2526
impl OverlayKind {
@@ -64,6 +65,9 @@ impl OverlayKind {
6465
"compiler/rustc_codegen_cranelift/LICENSE-APACHE",
6566
"compiler/rustc_codegen_cranelift/LICENSE-MIT",
6667
],
68+
OverlayKind::LlvmBitcodeLinker => {
69+
&["COPYRIGHT", "LICENSE-APACHE", "LICENSE-MIT", "README.md"]
70+
}
6771
}
6872
}
6973

@@ -87,6 +91,7 @@ impl OverlayKind {
8791
.rust_analyzer_info
8892
.version(builder, &builder.release_num("rust-analyzer/crates/rust-analyzer")),
8993
OverlayKind::RustcCodegenCranelift => builder.rust_version(),
94+
OverlayKind::LlvmBitcodeLinker => builder.rust_version(),
9095
}
9196
}
9297
}

0 commit comments

Comments
 (0)