]> git.lizzy.rs Git - rust.git/commitdiff
verify passed -no-pie arg before retrying failed link
authorJimmy Brush <code@jimmah.com>
Sun, 11 Feb 2018 15:50:18 +0000 (10:50 -0500)
committerJimmy Brush <code@jimmah.com>
Wed, 14 Feb 2018 03:10:27 +0000 (22:10 -0500)
src/librustc_trans/back/command.rs
src/librustc_trans/back/link.rs

index 3b765a493e0e79a15d98982f4fbb986d7fa0b0be..0bccef1e62a8e186126bd6cc4593d806e3d6064f 100644 (file)
@@ -109,6 +109,10 @@ pub fn command(&self) -> process::Command {
 
     // extensions
 
+    pub fn get_args(&self) -> &[OsString] {
+        &self.args
+    }
+
     pub fn take_args(&mut self) -> Vec<OsString> {
         mem::replace(&mut self.args, Vec::new())
     }
index d15450212ae376d32e581dea2b1bd7eff9e59246..6f8b425ad56dc010118812753b4eff88a1c6e1a2 100644 (file)
@@ -668,7 +668,9 @@ fn link_natively(sess: &Session,
         // is safe because 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") && out.contains("-no-pie") {
+        if out.contains("unrecognized command line option") &&
+           out.contains("-no-pie") &&
+           cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") {
             info!("linker output: {:?}", out);
             warn!("Linker does not support -no-pie command line option. Retrying without.");
             for arg in cmd.take_args() {