Skip to content

Commit

Permalink
Rollup merge of rust-lang#87191 - adamgemmell:dev/llvm-lib-package, r…
Browse files Browse the repository at this point in the history
…=Mark-Simulacrum

Package LLVM libs for the target rather than the build host

Fixes rust-lang#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.
  • Loading branch information
JohnTitor authored Jul 23, 2021
2 parents ba869da + 24254d6 commit aca83f1
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion config.toml.example
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ changelog-seen = 2
# This is false by default so that distributions don't unexpectedly download
# LLVM from the internet.
#
# All tier 1 targets are currently supported; set this to `"if-supported"` if
# All tier 1 targets are currently supported; set this to `"if-available"` if
# you are not sure whether you're on a tier 1 target.
#
# We also currently only support this when building LLVM for the build triple.
Expand Down
10 changes: 9 additions & 1 deletion src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1955,8 +1955,16 @@ fn maybe_install_llvm(builder: &Builder<'_>, target: TargetSelection, dst_libdir
cmd.arg("--libfiles");
builder.verbose(&format!("running {:?}", cmd));
let files = output(&mut cmd);
let build_llvm_out = &builder.llvm_out(builder.config.build);
let target_llvm_out = &builder.llvm_out(target);
for file in files.trim_end().split(' ') {
builder.install(Path::new(file), dst_libdir, 0o644);
// If we're not using a custom LLVM, make sure we package for the target.
let file = if let Ok(relative_path) = Path::new(file).strip_prefix(build_llvm_out) {
target_llvm_out.join(relative_path)
} else {
PathBuf::from(file)
};
builder.install(&file, dst_libdir, 0o644);
}
!builder.config.dry_run
} else {
Expand Down

0 comments on commit aca83f1

Please sign in to comment.