verify passed -no-pie arg before retrying failed link

This commit is contained in:
Jimmy Brush 2018-02-11 10:50:18 -05:00
parent 8a72f589e5
commit f0e9af1c55
No known key found for this signature in database
GPG key ID: 8C0A2907991F5664
2 changed files with 7 additions and 1 deletions

View file

@ -109,6 +109,10 @@ impl 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())
}

View 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() {