Skip to content

Commit

Permalink
only pass -no-pie if linker_is_gnu
Browse files Browse the repository at this point in the history
  • Loading branch information
canarysnort01 committed Feb 14, 2018
1 parent c8def92 commit ab9cae1
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/librustc_trans/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -669,7 +669,8 @@ fn link_natively(sess: &Session,
// 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") ||
if sess.target.target.options.linker_is_gnu &&
(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") {
Expand Down Expand Up @@ -936,7 +937,12 @@ fn link_args(cmd: &mut Linker,
if position_independent_executable {
cmd.position_independent_executable();
} else {
cmd.no_position_independent_executable();
// recent versions of gcc can be configured to generate position
// independent executables by default. We have to pass -no-pie to
// explicitly turn that off.
if sess.target.target.options.linker_is_gnu {
cmd.no_position_independent_executable();
}
}
}

Expand Down

0 comments on commit ab9cae1

Please sign in to comment.