Skip to content

Commit

Permalink
bootstrap: Link LLVM tools dynamically in order to save time in ThinL…
Browse files Browse the repository at this point in the history
…TO builds.
  • Loading branch information
michaelwoerister committed Aug 14, 2018
1 parent 8ad40ed commit e896d4f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 12 deletions.
21 changes: 16 additions & 5 deletions src/bootstrap/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1924,16 +1924,27 @@ impl Step for LlvmTools {
drop(fs::remove_dir_all(&image));

// Prepare the image directory
let bindir = builder
let src_bindir = builder
.llvm_out(target)
.join("bin");
let dst = image.join("lib/rustlib")
let dst_bindir = image.join("lib/rustlib")
.join(target)
.join("bin");
t!(fs::create_dir_all(&dst));
t!(fs::create_dir_all(&dst_bindir));
for tool in LLVM_TOOLS {
let exe = bindir.join(exe(tool, &target));
builder.install(&exe, &dst, 0o755);
let exe = src_bindir.join(exe(tool, &target));
builder.install(&exe, &dst_bindir, 0o755);
}

if builder.llvm_link_tools_dynamically(target) {
let src_libdir = builder
.llvm_out(target)
.join("lib");
let dst_libdir = image.join("lib/rustlib")
.join(target)
.join("lib");
t!(fs::create_dir_all(&dst_libdir));
builder.install(&src_libdir.join("libLLVM.so"), &dst_libdir, 0o644);
}

// Prepare the overlay
Expand Down
4 changes: 4 additions & 0 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,10 @@ impl Build {
self.rust_version()
}

fn llvm_link_tools_dynamically(&self, target: Interned<String>) -> bool {
target.contains("linux-gnu") || target.contains("apple-darwin")
}

/// Returns the `version` string associated with this compiler for Rust
/// itself.
///
Expand Down
11 changes: 4 additions & 7 deletions src/bootstrap/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,13 +170,10 @@ impl Step for Llvm {

// This setting makes the LLVM tools link to the dynamic LLVM library,
// which saves both memory during parallel links and overall disk space
// for the tools. We don't distribute any of those tools, so this is
// just a local concern. However, it doesn't work well everywhere.
//
// If we are shipping llvm tools then we statically link them LLVM
if (target.contains("linux-gnu") || target.contains("apple-darwin")) &&
!builder.config.llvm_tools_enabled {
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
// for the tools. We don't do this on every platform as it doesn't work
// equally well everywhere.
if builder.llvm_link_tools_dynamically(target) {
cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
}

// For distribution we want the LLVM tools to be *statically* linked to libstdc++
Expand Down

0 comments on commit e896d4f

Please sign in to comment.