Skip to content

Commit f0e9af1

Browse files
committed
verify passed -no-pie arg before retrying failed link
1 parent 8a72f58 commit f0e9af1

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/librustc_trans/back/command.rs

+4
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ impl Command {
109109

110110
// extensions
111111

112+
pub fn get_args(&self) -> &[OsString] {
113+
&self.args
114+
}
115+
112116
pub fn take_args(&mut self) -> Vec<OsString> {
113117
mem::replace(&mut self.args, Vec::new())
114118
}

src/librustc_trans/back/link.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -668,7 +668,9 @@ fn link_natively(sess: &Session,
668668
// is safe because if the linker doesn't support -no-pie then it should not
669669
// default to linking executables as pie. Different versions of gcc seem to
670670
// use different quotes in the error message so don't check for them.
671-
if out.contains("unrecognized command line option") && out.contains("-no-pie") {
671+
if out.contains("unrecognized command line option") &&
672+
out.contains("-no-pie") &&
673+
cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") {
672674
info!("linker output: {:?}", out);
673675
warn!("Linker does not support -no-pie command line option. Retrying without.");
674676
for arg in cmd.take_args() {

0 commit comments

Comments
 (0)