]> git.lizzy.rs Git - rust.git/commitdiff
Bootstrap: change logic for choosing linker and rpath
authorJethro Beekman <jethro@fortanix.com>
Mon, 9 Dec 2019 08:46:55 +0000 (09:46 +0100)
committerJethro Beekman <jethro@fortanix.com>
Mon, 9 Dec 2019 08:46:55 +0000 (09:46 +0100)
src/bootstrap/builder.rs
src/bootstrap/lib.rs
src/bootstrap/util.rs

index 99b8ddf7db1f0c704785a9fef9502150ac2e343d..025d5e7140139c29b5442fd22889612b10e2bd52 100644 (file)
@@ -980,7 +980,7 @@ pub fn cargo(
         // argument manually via `-C link-args=-Wl,-rpath,...`. Plus isn't it
         // fun to pass a flag to a tool to pass a flag to pass a flag to a tool
         // to change a flag in a binary?
-        if self.config.rust_rpath {
+        if self.config.rust_rpath && util::use_host_linker(&target) {
             let rpath = if target.contains("apple") {
 
                 // Note that we need to take one extra step on macOS to also pass
@@ -990,10 +990,7 @@ pub fn cargo(
                 // flesh out rpath support more fully in the future.
                 rustflags.arg("-Zosx-rpath-install-name");
                 Some("-Wl,-rpath,@loader_path/../lib")
-            } else if !target.contains("windows") &&
-                      !target.contains("wasm32") &&
-                      !target.contains("emscripten") &&
-                      !target.contains("fuchsia") {
+            } else if !target.contains("windows") {
                 Some("-Wl,-rpath,$ORIGIN/../lib")
             } else {
                 None
index 7ea2bb126a641ca8fa9ceb38b327ccdd3327bcbb..09e3bb5e231eecc8a001cf6496fc15891dc2dab2 100644 (file)
@@ -806,12 +806,8 @@ fn linker(&self, target: Interned<String>) -> Option<&Path> {
                                                        .and_then(|c| c.linker.as_ref()) {
             Some(linker)
         } else if target != self.config.build &&
-                  !target.contains("msvc") &&
-                  !target.contains("emscripten") &&
-                  !target.contains("wasm32") &&
-                  !target.contains("nvptx") &&
-                  !target.contains("fortanix") &&
-                  !target.contains("fuchsia") {
+                  util::use_host_linker(&target) &&
+                  !target.contains("msvc") {
             Some(self.cc(target))
         } else {
             None
index 6f8a630874570324e26b750ec700d05122fca01b..6824b7a58c480cdf44ec5192311b311d9ca19221 100644 (file)
@@ -15,6 +15,7 @@
 
 use crate::config::Config;
 use crate::builder::Builder;
+use crate::cache::Interned;
 
 /// Returns the `name` as the filename of a static library for `target`.
 pub fn staticlib(name: &str, target: &str) -> String {
@@ -306,3 +307,15 @@ pub fn forcing_clang_based_tests() -> bool {
         false
     }
 }
+
+pub fn use_host_linker(target: &Interned<String>) -> bool {
+    // FIXME: this information should be gotten by checking the linker flavor
+    // of the rustc target
+    !(
+        target.contains("emscripten") ||
+        target.contains("wasm32") ||
+        target.contains("nvptx") ||
+        target.contains("fortanix") ||
+        target.contains("fuchsia")
+    )
+}