From c8def9222be5079585e15b2902039d371b7527ce Mon Sep 17 00:00:00 2001 From: Jimmy Brush Date: Mon, 12 Feb 2018 13:32:55 -0500 Subject: [PATCH] handle -no-pie error from clang --- src/librustc_trans/back/link.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/librustc_trans/back/link.rs b/src/librustc_trans/back/link.rs index 6f8b425ad56d..0a3e6265c1b7 100644 --- a/src/librustc_trans/back/link.rs +++ b/src/librustc_trans/back/link.rs @@ -664,11 +664,13 @@ fn link_natively(sess: &Session, let out = String::from_utf8_lossy(&out); // Check to see if the link failed with "unrecognized command line option: - // '-no-pie'". If so, reperform the link step without the -no-pie option. This - // 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") && + // '-no-pie'" for gcc or "unknown argument: '-no-pie'" for clang. If so, + // reperform the link step without the -no-pie option. This 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("unknown argument")) && out.contains("-no-pie") && cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") { info!("linker output: {:?}", out);