about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorJorge Aparicio <jorge@japaric.io>2018-04-30 10:15:48 +0200
committerJorge Aparicio <jorge@japaric.io>2018-06-03 18:23:01 +0200
commit5e577b8aee60b7ee2394a50d8eec8a3b26541d11 (patch)
tree0a55efe8512a2fd5c987f727bbe852ff8815224b /src/bootstrap
parent7d576f25fcb0b0ea1e4d442329a4949765fa02f0 (diff)
downloadrust-5e577b8aee60b7ee2394a50d8eec8a3b26541d11.tar.gz
rust-5e577b8aee60b7ee2394a50d8eec8a3b26541d11.zip
ship LLVM tools with the toolchain
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/compile.rs22
-rw-r--r--src/bootstrap/config.rs3
-rwxr-xr-xsrc/bootstrap/configure.py1
-rw-r--r--src/bootstrap/dist.rs20
-rw-r--r--src/bootstrap/lib.rs2
-rw-r--r--src/bootstrap/native.rs7
6 files changed, 51 insertions, 4 deletions
diff --git a/src/bootstrap/compile.rs b/src/bootstrap/compile.rs
index 231ed9d40d2..ea234c0016c 100644
--- a/src/bootstrap/compile.rs
+++ b/src/bootstrap/compile.rs
@@ -31,7 +31,7 @@ use filetime::FileTime;
 use serde_json;
 
 use util::{exe, libdir, is_dylib, CiEnv};
-use {Compiler, Mode};
+use {Compiler, Mode, LLVM_TOOLS};
 use native;
 use tool;
 
@@ -775,6 +775,23 @@ fn copy_codegen_backends_to_sysroot(builder: &Builder,
     }
 }
 
+fn copy_llvm_tools_to_sysroot(builder: &Builder,
+                              target_compiler: Compiler) {
+    let target = target_compiler.host;
+
+    let dst = builder.sysroot_libdir(target_compiler, target)
+        .parent()
+        .unwrap()
+        .join("bin");
+    t!(fs::create_dir_all(&dst));
+
+    let src = builder.llvm_out(target).join("bin");
+    for tool in LLVM_TOOLS {
+        let exe = exe(tool, &target);
+        builder.copy(&src.join(&exe), &dst.join(&exe));
+    }
+}
+
 fn copy_lld_to_sysroot(builder: &Builder,
                        target_compiler: Compiler,
                        lld_install_root: &Path) {
@@ -966,6 +983,9 @@ impl Step for Assemble {
         copy_codegen_backends_to_sysroot(builder,
                                          build_compiler,
                                          target_compiler);
+        if builder.config.ship_llvm_tools {
+            copy_llvm_tools_to_sysroot(builder, target_compiler);
+        }
         if let Some(lld_install) = lld_install {
             copy_lld_to_sysroot(builder, target_compiler, &lld_install);
         }
diff --git a/src/bootstrap/config.rs b/src/bootstrap/config.rs
index 9840682d137..b676ba22172 100644
--- a/src/bootstrap/config.rs
+++ b/src/bootstrap/config.rs
@@ -88,6 +88,7 @@ pub struct Config {
     pub llvm_link_jobs: Option<u32>,
 
     pub lld_enabled: bool,
+    pub ship_llvm_tools: bool,
 
     // rust codegen options
     pub rust_optimize: bool,
@@ -308,6 +309,7 @@ struct Rust {
     codegen_backends_dir: Option<String>,
     wasm_syscall: Option<bool>,
     lld: Option<bool>,
+    llvm_tools: Option<bool>,
     deny_warnings: Option<bool>,
     backtrace_on_ice: Option<bool>,
 }
@@ -531,6 +533,7 @@ impl Config {
             set(&mut config.test_miri, rust.test_miri);
             set(&mut config.wasm_syscall, rust.wasm_syscall);
             set(&mut config.lld_enabled, rust.lld);
+            set(&mut config.ship_llvm_tools, rust.llvm_tools);
             config.rustc_parallel_queries = rust.experimental_parallel_queries.unwrap_or(false);
             config.rustc_default_linker = rust.default_linker.clone();
             config.musl_root = rust.musl_root.clone().map(PathBuf::from);
diff --git a/src/bootstrap/configure.py b/src/bootstrap/configure.py
index 3574b7d210a..36d936bab3b 100755
--- a/src/bootstrap/configure.py
+++ b/src/bootstrap/configure.py
@@ -335,6 +335,7 @@ for key in known_args:
     elif option.name == 'full-tools':
         set('rust.codegen-backends', ['llvm', 'emscripten'])
         set('rust.lld', True)
+        set('rust.llvm-tools', True)
         set('build.extended', True)
     elif option.name == 'option-checking':
         # this was handled above
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 82ba03ec777..9092deeac46 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -26,7 +26,7 @@ use std::process::{Command, Stdio};
 
 use build_helper::output;
 
-use {Compiler, Mode};
+use {Compiler, Mode, LLVM_TOOLS};
 use channel;
 use util::{libdir, is_dylib, exe};
 use builder::{Builder, RunConfig, ShouldRun, Step};
@@ -503,6 +503,24 @@ impl Step for Rustc {
                 builder.copy(&src, &dst);
             }
 
+            if builder.config.ship_llvm_tools {
+                let src = builder.sysroot_libdir(compiler, host)
+                    .parent()
+                    .unwrap()
+                    .join("bin");
+
+                let dst = image.join("lib/rustlib")
+                    .join(&*host)
+                    .join("bin");
+
+                t!(fs::create_dir_all(&dst.parent().unwrap()));
+
+                for tool in LLVM_TOOLS {
+                    let exe = exe(tool, &compiler.host);
+                    builder.copy(&src.join(&exe), &dst.join(&exe));
+                }
+            }
+
             // Man pages
             t!(fs::create_dir_all(image.join("share/man/man1")));
             let man_src = builder.src.join("src/doc/man");
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index f64161fb027..4d1bc6ad6ba 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -199,6 +199,8 @@ use flags::Subcommand;
 use cache::{Interned, INTERNER};
 use toolstate::ToolState;
 
+const LLVM_TOOLS: &[&str] = &["llvm-nm", "llvm-objcopy", "llvm-objdump", "llvm-size"];
+
 /// A structure representing a Rust compiler.
 ///
 /// Each compiler has a `stage` that it is associated with and a `host` that
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 93292c658ba..2f6af1e0640 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -167,8 +167,11 @@ impl Step for Llvm {
         // 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 target.contains("linux-gnu") || target.contains("apple-darwin") {
-           cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
+        //
+        // If we are shipping llvm tools then we statically link them LLVM
+        if (target.contains("linux-gnu") || target.contains("apple-darwin")) &&
+            !builder.config.ship_llvm_tools  {
+                cfg.define("LLVM_LINK_LLVM_DYLIB", "ON");
         }
 
         if target.contains("msvc") {