Skip to content

Commit c8def92

Browse files
committed
handle -no-pie error from clang
1 parent f0e9af1 commit c8def92

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/librustc_trans/back/link.rs

+7-5
Original file line numberDiff line numberDiff line change
@@ -664,11 +664,13 @@ fn link_natively(sess: &Session,
664664
let out = String::from_utf8_lossy(&out);
665665

666666
// Check to see if the link failed with "unrecognized command line option:
667-
// '-no-pie'". If so, reperform the link step without the -no-pie option. This
668-
// is safe because if the linker doesn't support -no-pie then it should not
669-
// default to linking executables as pie. Different versions of gcc seem to
670-
// use different quotes in the error message so don't check for them.
671-
if out.contains("unrecognized command line option") &&
667+
// '-no-pie'" for gcc or "unknown argument: '-no-pie'" for clang. If so,
668+
// reperform the link step without the -no-pie option. This is safe because
669+
// if the linker doesn't support -no-pie then it should not default to
670+
// linking executables as pie. Different versions of gcc seem to use
671+
// different quotes in the error message so don't check for them.
672+
if (out.contains("unrecognized command line option") ||
673+
out.contains("unknown argument")) &&
672674
out.contains("-no-pie") &&
673675
cmd.get_args().iter().any(|e| e.to_string_lossy() == "-no-pie") {
674676
info!("linker output: {:?}", out);

0 commit comments

Comments
 (0)