Skip to content

Commit b7c6e8f

Browse files
committed
Auto merge of #51728 - bradjc:llvm-tools2, r=kennytm
build: add llvm-tools to manifest This commit expands on a previous commit to build llvm-tools as a rustup component. It causes the llvm-tools component to be built if the extended step is active. It also adds llvm-tools to the build manifest so rustup can find it. I tested this as far as I could, but had to hack `build-manifest/src/main.rs` a bit as it is not supported on MacOS. The main change I am not sure about is this line: ```rust self.package("llvm-tools", &mut manifest.pkg, TARGETS); ``` There are numerous calls to `self.package()`, and I'm not sure if `TARGETS`, `HOSTS`, or `["*"]` is appropriate for llvm-tools. Otherwise I mostly copied the example set by `rustfmt-preview`.
2 parents 8acec1f + f10da5f commit b7c6e8f

File tree

3 files changed

+39
-30
lines changed

3 files changed

+39
-30
lines changed

src/bootstrap/dist.rs

+11-12
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ pub fn pkgname(builder: &Builder, component: &str) -> String {
4444
} else if component == "rustfmt" {
4545
format!("{}-{}", component, builder.rustfmt_package_vers())
4646
} else if component == "llvm-tools" {
47-
format!("{}-{}", component, builder.llvm_tools_vers())
47+
format!("{}-{}", component, builder.llvm_tools_package_vers())
4848
} else {
4949
assert!(component.starts_with("rust"));
5050
format!("{}-{}", component, builder.rust_package_vers())
@@ -1303,6 +1303,7 @@ impl Step for Extended {
13031303
let cargo_installer = builder.ensure(Cargo { stage, target });
13041304
let rustfmt_installer = builder.ensure(Rustfmt { stage, target });
13051305
let rls_installer = builder.ensure(Rls { stage, target });
1306+
let llvm_tools_installer = builder.ensure(LlvmTools { stage, target });
13061307
let mingw_installer = builder.ensure(Mingw { host: target });
13071308
let analysis_installer = builder.ensure(Analysis {
13081309
compiler: builder.compiler(stage, self.host),
@@ -1340,6 +1341,7 @@ impl Step for Extended {
13401341
tarballs.push(cargo_installer);
13411342
tarballs.extend(rls_installer.clone());
13421343
tarballs.extend(rustfmt_installer.clone());
1344+
tarballs.extend(llvm_tools_installer.clone());
13431345
tarballs.push(analysis_installer);
13441346
tarballs.push(std_installer);
13451347
if builder.config.docs {
@@ -1740,7 +1742,7 @@ impl Step for HashSign {
17401742
cmd.arg(builder.package_vers(&builder.release_num("cargo")));
17411743
cmd.arg(builder.package_vers(&builder.release_num("rls")));
17421744
cmd.arg(builder.package_vers(&builder.release_num("rustfmt")));
1743-
cmd.arg(builder.llvm_tools_vers());
1745+
cmd.arg(builder.llvm_tools_package_vers());
17441746
cmd.arg(addr);
17451747

17461748
builder.create_dir(&distdir(builder));
@@ -1755,7 +1757,6 @@ impl Step for HashSign {
17551757
#[derive(Clone, Debug, Eq, Hash, PartialEq)]
17561758
pub struct LlvmTools {
17571759
pub stage: u32,
1758-
pub compiler: Compiler,
17591760
pub target: Interned<String>,
17601761
}
17611762

@@ -1770,19 +1771,16 @@ impl Step for LlvmTools {
17701771
fn make_run(run: RunConfig) {
17711772
run.builder.ensure(LlvmTools {
17721773
stage: run.builder.top_stage,
1773-
compiler: run.builder.compiler(run.builder.top_stage, run.target),
17741774
target: run.target,
17751775
});
17761776
}
17771777

17781778
fn run(self, builder: &Builder) -> Option<PathBuf> {
1779-
let compiler = self.compiler;
1780-
let host = compiler.host;
1781-
17821779
let stage = self.stage;
1780+
let target = self.target;
17831781
assert!(builder.config.extended);
17841782

1785-
builder.info(&format!("Dist LlvmTools stage{} ({})", stage, host));
1783+
builder.info(&format!("Dist LlvmTools stage{} ({})", stage, target));
17861784
let src = builder.src.join("src/llvm");
17871785
let name = pkgname(builder, "llvm-tools");
17881786

@@ -1794,9 +1792,9 @@ impl Step for LlvmTools {
17941792
// Prepare the image directory
17951793
for tool in LLVM_TOOLS {
17961794
let exe = builder
1797-
.llvm_out(host)
1795+
.llvm_out(target)
17981796
.join("bin")
1799-
.join(exe(tool, &compiler.host));
1797+
.join(exe(tool, &target));
18001798
builder.install(&exe, &image.join("bin"), 0o755);
18011799
}
18021800

@@ -1806,6 +1804,7 @@ impl Step for LlvmTools {
18061804
builder.create_dir(&overlay);
18071805
builder.install(&src.join("README.txt"), &overlay, 0o644);
18081806
builder.install(&src.join("LICENSE.TXT"), &overlay, 0o644);
1807+
builder.create(&overlay.join("version"), &builder.llvm_tools_vers());
18091808

18101809
// Generate the installer tarball
18111810
let mut cmd = rust_installer(builder);
@@ -1817,12 +1816,12 @@ impl Step for LlvmTools {
18171816
.arg("--work-dir").arg(&tmpdir(builder))
18181817
.arg("--output-dir").arg(&distdir(builder))
18191818
.arg("--non-installed-overlay").arg(&overlay)
1820-
.arg(format!("--package-name={}-{}", name, host))
1819+
.arg(format!("--package-name={}-{}", name, target))
18211820
.arg("--legacy-manifest-dirs=rustlib,cargo")
18221821
.arg("--component-name=llvm-tools");
18231822

18241823

18251824
builder.run(&mut cmd);
1826-
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, host)))
1825+
Some(distdir(builder).join(format!("{}-{}.tar.gz", name, target)))
18271826
}
18281827
}

src/bootstrap/lib.rs

+4-17
Original file line numberDiff line numberDiff line change
@@ -973,24 +973,11 @@ impl Build {
973973
self.package_vers(&self.release_num("rustfmt"))
974974
}
975975

976-
fn llvm_tools_vers(&self) -> String {
977-
// japaric: should we use LLVM version here?
978-
// let stdout = build_helper::output(
979-
// Command::new(self.llvm_out(self.config.build).join("build/bin/llvm-size"))
980-
// .arg("--version"),
981-
// );
982-
983-
// for line in stdout.lines() {
984-
// if line.contains("LLVM version") {
985-
// if let Some(vers) = line.split_whitespace().nth(2) {
986-
// return vers.to_string();
987-
// }
988-
// }
989-
// }
990-
991-
// panic!("The output of $LLVM_TOOL has changed; \
992-
// please fix `bootstrap::Build.llvm_tools_vers`");
976+
fn llvm_tools_package_vers(&self) -> String {
977+
self.package_vers(&self.rust_version())
978+
}
993979

980+
fn llvm_tools_vers(&self) -> String {
994981
self.rust_version()
995982
}
996983

src/tools/build-manifest/src/main.rs

+24-1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ struct Builder {
184184
cargo_release: String,
185185
rls_release: String,
186186
rustfmt_release: String,
187+
llvm_tools_release: String,
187188

188189
input: PathBuf,
189190
output: PathBuf,
@@ -196,11 +197,13 @@ struct Builder {
196197
cargo_version: Option<String>,
197198
rls_version: Option<String>,
198199
rustfmt_version: Option<String>,
200+
llvm_tools_version: Option<String>,
199201

200202
rust_git_commit_hash: Option<String>,
201203
cargo_git_commit_hash: Option<String>,
202204
rls_git_commit_hash: Option<String>,
203205
rustfmt_git_commit_hash: Option<String>,
206+
llvm_tools_git_commit_hash: Option<String>,
204207
}
205208

206209
fn main() {
@@ -212,7 +215,7 @@ fn main() {
212215
let cargo_release = args.next().unwrap();
213216
let rls_release = args.next().unwrap();
214217
let rustfmt_release = args.next().unwrap();
215-
let _llvm_tools_vers = args.next().unwrap(); // FIXME do something with it?
218+
let llvm_tools_release = args.next().unwrap();
216219
let s3_address = args.next().unwrap();
217220
let mut passphrase = String::new();
218221
t!(io::stdin().read_to_string(&mut passphrase));
@@ -222,6 +225,7 @@ fn main() {
222225
cargo_release,
223226
rls_release,
224227
rustfmt_release,
228+
llvm_tools_release,
225229

226230
input,
227231
output,
@@ -234,11 +238,13 @@ fn main() {
234238
cargo_version: None,
235239
rls_version: None,
236240
rustfmt_version: None,
241+
llvm_tools_version: None,
237242

238243
rust_git_commit_hash: None,
239244
cargo_git_commit_hash: None,
240245
rls_git_commit_hash: None,
241246
rustfmt_git_commit_hash: None,
247+
llvm_tools_git_commit_hash: None,
242248
}.build();
243249
}
244250

@@ -248,11 +254,14 @@ impl Builder {
248254
self.cargo_version = self.version("cargo", "x86_64-unknown-linux-gnu");
249255
self.rls_version = self.version("rls", "x86_64-unknown-linux-gnu");
250256
self.rustfmt_version = self.version("rustfmt", "x86_64-unknown-linux-gnu");
257+
self.llvm_tools_version = self.version("llvm-tools", "x86_64-unknown-linux-gnu");
251258

252259
self.rust_git_commit_hash = self.git_commit_hash("rust", "x86_64-unknown-linux-gnu");
253260
self.cargo_git_commit_hash = self.git_commit_hash("cargo", "x86_64-unknown-linux-gnu");
254261
self.rls_git_commit_hash = self.git_commit_hash("rls", "x86_64-unknown-linux-gnu");
255262
self.rustfmt_git_commit_hash = self.git_commit_hash("rustfmt", "x86_64-unknown-linux-gnu");
263+
self.llvm_tools_git_commit_hash = self.git_commit_hash("llvm-tools",
264+
"x86_64-unknown-linux-gnu");
256265

257266
self.digest_and_sign();
258267
let manifest = self.build_manifest();
@@ -289,9 +298,11 @@ impl Builder {
289298
self.package("rls-preview", &mut manifest.pkg, HOSTS);
290299
self.package("rustfmt-preview", &mut manifest.pkg, HOSTS);
291300
self.package("rust-analysis", &mut manifest.pkg, TARGETS);
301+
self.package("llvm-tools", &mut manifest.pkg, TARGETS);
292302

293303
let rls_present = manifest.pkg.contains_key("rls-preview");
294304
let rustfmt_present = manifest.pkg.contains_key("rustfmt-preview");
305+
let llvm_tools_present = manifest.pkg.contains_key("llvm-tools");
295306

296307
if rls_present {
297308
manifest.renames.insert("rls".to_owned(), Rename { to: "rls-preview".to_owned() });
@@ -346,6 +357,12 @@ impl Builder {
346357
target: host.to_string(),
347358
});
348359
}
360+
if llvm_tools_present {
361+
extensions.push(Component {
362+
pkg: "llvm-tools".to_string(),
363+
target: host.to_string(),
364+
});
365+
}
349366
extensions.push(Component {
350367
pkg: "rust-analysis".to_string(),
351368
target: host.to_string(),
@@ -455,6 +472,8 @@ impl Builder {
455472
format!("rls-{}-{}.tar.gz", self.rls_release, target)
456473
} else if component == "rustfmt" || component == "rustfmt-preview" {
457474
format!("rustfmt-{}-{}.tar.gz", self.rustfmt_release, target)
475+
} else if component == "llvm_tools" {
476+
format!("llvm-tools-{}-{}.tar.gz", self.llvm_tools_release, target)
458477
} else {
459478
format!("{}-{}-{}.tar.gz", component, self.rust_release, target)
460479
}
@@ -467,6 +486,8 @@ impl Builder {
467486
&self.rls_version
468487
} else if component == "rustfmt" || component == "rustfmt-preview" {
469488
&self.rustfmt_version
489+
} else if component == "llvm-tools" {
490+
&self.llvm_tools_version
470491
} else {
471492
&self.rust_version
472493
}
@@ -479,6 +500,8 @@ impl Builder {
479500
&self.rls_git_commit_hash
480501
} else if component == "rustfmt" || component == "rustfmt-preview" {
481502
&self.rustfmt_git_commit_hash
503+
} else if component == "llvm-tools" {
504+
&self.llvm_tools_git_commit_hash
482505
} else {
483506
&self.rust_git_commit_hash
484507
}

0 commit comments

Comments
 (0)