about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2018-02-10 12:09:25 -0800
committerAlex Crichton <alex@alexcrichton.com>2018-03-03 20:21:35 -0800
commit0129b01a41a062f82909cecdfd0cc7f0093c71f8 (patch)
tree7213eec523af5741bc99ac39388d8a2f83a16c97 /src/bootstrap
parentd69b24805b5071e5ec9e62d2777a761723644144 (diff)
downloadrust-0129b01a41a062f82909cecdfd0cc7f0093c71f8.tar.gz
rust-0129b01a41a062f82909cecdfd0cc7f0093c71f8.zip
rustc: Tweak default linker selection
This commit refactors how the path to the linker that we're going to invoke is
selected. Previously all targets listed *both* a `LinkerFlavor` and a `linker`
(path) option, but this meant that whenever you changed one you had to change
the other. The purpose of this commit is to avoid coupling these where possible.

Target specifications now only unconditionally define the *flavor* of the linker
that they're using by default. If not otherwise specified each flavor now
implies a particular default linker to run. As a result, this means that if
you'd like to test out `ld` for example you should be able to do:

    rustc -Z linker-flavor=ld foo.rs

whereas previously you had to do

    rustc -Z linker-flavor=ld -C linker=ld foo.rs

This will hopefully make it a bit easier to tinker around with variants that
should otherwise be well known to work, for example with LLD, `ld` on OSX, etc.
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/dist.rs6
-rw-r--r--src/bootstrap/native.rs13
2 files changed, 12 insertions, 7 deletions
diff --git a/src/bootstrap/dist.rs b/src/bootstrap/dist.rs
index 02ef7c0e1ff..576e5078247 100644
--- a/src/bootstrap/dist.rs
+++ b/src/bootstrap/dist.rs
@@ -606,8 +606,10 @@ impl Step for Std {
         let mut src = builder.sysroot_libdir(compiler, target).to_path_buf();
         src.pop(); // Remove the trailing /lib folder from the sysroot_libdir
         cp_filtered(&src, &dst, &|path| {
-            path.file_name().and_then(|s| s.to_str()) !=
-                Some(build.config.rust_codegen_backends_dir.as_str())
+            let name = path.file_name().and_then(|s| s.to_str());
+            name != Some(build.config.rust_codegen_backends_dir.as_str()) &&
+                name != Some("bin")
+
         });
 
         let mut cmd = rust_installer(builder);
diff --git a/src/bootstrap/native.rs b/src/bootstrap/native.rs
index 987d70fd047..7888f0b938d 100644
--- a/src/bootstrap/native.rs
+++ b/src/bootstrap/native.rs
@@ -208,7 +208,7 @@ impl Step for Llvm {
             cfg.define("LLVM_NATIVE_BUILD", build.llvm_out(build.build).join("build"));
         }
 
-        configure_cmake(build, target, &mut cfg);
+        configure_cmake(build, target, &mut cfg, false);
 
         // FIXME: we don't actually need to build all LLVM tools and all LLVM
         //        libraries here, e.g. we just want a few components and a few
@@ -241,7 +241,8 @@ fn check_llvm_version(build: &Build, llvm_config: &Path) {
 
 fn configure_cmake(build: &Build,
                    target: Interned<String>,
-                   cfg: &mut cmake::Config) {
+                   cfg: &mut cmake::Config,
+                   building_dist_binaries: bool) {
     if build.config.ninja {
         cfg.generator("Ninja");
     }
@@ -294,8 +295,10 @@ fn configure_cmake(build: &Build,
     cfg.build_arg("-j").build_arg(build.jobs().to_string());
     cfg.define("CMAKE_C_FLAGS", build.cflags(target).join(" "));
     let mut cxxflags = build.cflags(target).join(" ");
-    if build.config.llvm_static_stdcpp && !target.contains("windows") {
-        cxxflags.push_str(" -static-libstdc++");
+    if building_dist_binaries {
+        if build.config.llvm_static_stdcpp && !target.contains("windows") {
+            cxxflags.push_str(" -static-libstdc++");
+        }
     }
     cfg.define("CMAKE_CXX_FLAGS", cxxflags);
     if let Some(ar) = build.ar(target) {
@@ -350,7 +353,7 @@ impl Step for Lld {
         t!(fs::create_dir_all(&out_dir));
 
         let mut cfg = cmake::Config::new(build.src.join("src/tools/lld"));
-        configure_cmake(build, target, &mut cfg);
+        configure_cmake(build, target, &mut cfg, true);
 
         cfg.out_dir(&out_dir)
            .profile("Release")