Skip to content

Commit aca83f1

Browse files
authored
Rollup merge of #87191 - adamgemmell:dev/llvm-lib-package, r=Mark-Simulacrum
Package LLVM libs for the target rather than the build host Fixes #85250 `dist.rs` uses, in the `rust-dev` stage, `llvm-config --libfiles` to get a list of the LLVM library files built but of course only for the build host. If the target differs we want to package lib files from the target's build tree instead. This is done by splitting/rejoining the paths on their build directories. At the moment `tree` on the LLVM build directories seems to give almost identical output, but of course this might not be the case in the future. If a file is missing in the target's build tree then this stage will error in the `builder.install()` call. If the target build tree has an extra file then it silently won't be copied and we'll get a linker error when building using this artifact (via `download-ci-llvm = "if-available"`), though we would have received a linker error anyway without this change. There was also a typo in the example config around this option.
2 parents ba869da + 24254d6 commit aca83f1

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

config.toml.example

+1-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ changelog-seen = 2
3838
# This is false by default so that distributions don't unexpectedly download
3939
# LLVM from the internet.
4040
#
41-
# All tier 1 targets are currently supported; set this to `"if-supported"` if
41+
# All tier 1 targets are currently supported; set this to `"if-available"` if
4242
# you are not sure whether you're on a tier 1 target.
4343
#
4444
# We also currently only support this when building LLVM for the build triple.

src/bootstrap/dist.rs

+9-1
Original file line numberDiff line numberDiff line change
@@ -1955,8 +1955,16 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
19551955
cmd.arg("--libfiles");
19561956
builder.verbose(&format!("running {:?}", cmd));
19571957
let files = output(&mut cmd);
1958+
let build_llvm_out = &builder.llvm_out(builder.config.build);
1959+
let target_llvm_out = &builder.llvm_out(target);
19581960
for file in files.trim_end().split(' ') {
1959-
builder.install(Path::new(file), dst_libdir, 0o644);
1961+
// If we're not using a custom LLVM, make sure we package for the target.
1962+
let file = if let Ok(relative_path) = Path::new(file).strip_prefix(build_llvm_out) {
1963+
target_llvm_out.join(relative_path)
1964+
} else {
1965+
PathBuf::from(file)
1966+
};
1967+
builder.install(&file, dst_libdir, 0o644);
19601968
}
19611969
!builder.config.dry_run
19621970
} else {

0 commit comments

Comments
 (0)