Skip to content

Commit 7cae6fe

Browse files
committed
don't pass -no-pie to gnu ld
fixes #48884
1 parent a0b0f5f commit 7cae6fe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/librustc_trans/back/link.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -712,6 +712,7 @@ fn link_natively(sess: &Session,
712712
// linking executables as pie. Different versions of gcc seem to use
713713
// different quotes in the error message so don't check for them.
714714
if sess.target.target.options.linker_is_gnu &&
715+
sess.linker_flavor() != LinkerFlavor::Ld &&
715716
(out.contains("unrecognized command line option") ||
716717
out.contains("unknown argument")) &&
717718
out.contains("-no-pie") &&
@@ -1007,8 +1008,9 @@ fn link_args(cmd: &mut Linker,
10071008
} else {
10081009
// recent versions of gcc can be configured to generate position
10091010
// independent executables by default. We have to pass -no-pie to
1010-
// explicitly turn that off.
1011-
if sess.target.target.options.linker_is_gnu {
1011+
// explicitly turn that off. Not applicable to ld.
1012+
if sess.target.target.options.linker_is_gnu
1013+
&& sess.linker_flavor() != LinkerFlavor::Ld {
10121014
cmd.no_position_independent_executable();
10131015
}
10141016
}

0 commit comments

Comments
 (0)