Skip to content

Commit 557c669

Browse files
authored
Unrolled build for rust-lang#128437
Rollup merge of rust-lang#128437 - onur-ozkan:handle-llvm-tools-properly, r=albertlarsan68,Kobzol improve bootstrap to allow selecting llvm tools individually Everything works as before, + now bootstrap allows for individually selecting LLVM tools (e.g., `x dist opt llvm-dis`) to include in the dist artifact.
2 parents 70591dc + f6c4110 commit 557c669

File tree

1 file changed

+34
-3
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+34
-3
lines changed

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

+34-3
Original file line numberDiff line numberDiff line change
@@ -2122,15 +2122,46 @@ impl Step for LlvmTools {
21222122

21232123
fn should_run(run: ShouldRun<'_>) -> ShouldRun<'_> {
21242124
let default = should_build_extended_tool(run.builder, "llvm-tools");
2125-
// FIXME: allow using the names of the tools themselves?
2126-
run.alias("llvm-tools").default_condition(default)
2125+
2126+
let mut run = run.alias("llvm-tools");
2127+
for tool in LLVM_TOOLS {
2128+
run = run.alias(tool);
2129+
}
2130+
2131+
run.default_condition(default)
21272132
}
21282133

21292134
fn make_run(run: RunConfig<'_>) {
21302135
run.builder.ensure(LlvmTools { target: run.target });
21312136
}
21322137

21332138
fn run(self, builder: &Builder<'_>) -> Option<GeneratedTarball> {
2139+
fn tools_to_install(paths: &[PathBuf]) -> Vec<&'static str> {
2140+
let mut tools = vec![];
2141+
2142+
for path in paths {
2143+
let path = path.to_str().unwrap();
2144+
2145+
// Include all tools if path is 'llvm-tools'.
2146+
if path == "llvm-tools" {
2147+
return LLVM_TOOLS.to_owned();
2148+
}
2149+
2150+
for tool in LLVM_TOOLS {
2151+
if path == *tool {
2152+
tools.push(*tool);
2153+
}
2154+
}
2155+
}
2156+
2157+
// If no specific tool is requested, include all tools.
2158+
if tools.is_empty() {
2159+
tools = LLVM_TOOLS.to_owned();
2160+
}
2161+
2162+
tools
2163+
}
2164+
21342165
let target = self.target;
21352166

21362167
/* run only if llvm-config isn't used */
@@ -2151,7 +2182,7 @@ impl Step for LlvmTools {
21512182
// Prepare the image directory
21522183
let src_bindir = builder.llvm_out(target).join("bin");
21532184
let dst_bindir = format!("lib/rustlib/{}/bin", target.triple);
2154-
for tool in LLVM_TOOLS {
2185+
for tool in tools_to_install(&builder.paths) {
21552186
let exe = src_bindir.join(exe(tool, target));
21562187
tarball.add_file(&exe, &dst_bindir, 0o755);
21572188
}

0 commit comments

Comments
 (0)