about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorJimmy Brush <code@jimmah.com>2018-02-13 22:09:02 -0500
committerJimmy Brush <code@jimmah.com>2018-02-13 22:10:27 -0500
commitab9cae1ba192afcc35e8bd6a5fddcd1445d05da7 (patch)
treed96eb368884a57944ffa3dd319e312785473c6f1 /src
parentc8def9222be5079585e15b2902039d371b7527ce (diff)
downloadrust-ab9cae1ba192afcc35e8bd6a5fddcd1445d05da7.tar.gz
rust-ab9cae1ba192afcc35e8bd6a5fddcd1445d05da7.zip
only pass -no-pie if linker_is_gnu
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/back/link.rs10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs
index 0a3e6265c1b..8be4dc48d51 100644
--- a/src/librustc_trans/back/link.rs
+++ b/src/librustc_trans/back/link.rs
@@ -669,7 +669,8 @@ fn link_natively(sess: &Session,
         // if the linker doesn't support -no-pie then it should not default to
         // linking executables as pie. Different versions of gcc seem to use
         // different quotes in the error message so don't check for them.
-        if (out.contains("unrecognized command line option") ||
+        if sess.target.target.options.linker_is_gnu &&
+           (out.contains("unrecognized command line option") ||
             out.contains("unknown argument")) &&
            out.contains("-no-pie") &&
            cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") {
@@ -936,7 +937,12 @@ fn link_args(cmd: &mut Linker,
         if position_independent_executable {
             cmd.position_independent_executable();
         } else {
-            cmd.no_position_independent_executable();
+            // recent versions of gcc can be configured to generate position
+            // independent executables by default. We have to pass -no-pie to
+            // explicitly turn that off.
+            if sess.target.target.options.linker_is_gnu {
+                cmd.no_position_independent_executable();
+            }
         }
     }