Skip to content

Commit 4285e1c

Browse files
authored
Rollup merge of rust-lang#49329 - canarysnort01:fix-no-pie, r=pnkfelix
don't pass -no-pie to gnu ld fixes rust-lang#48884
2 parents 43f56ce + 7cae6fe commit 4285e1c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/librustc_trans/back/link.rs

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

0 commit comments

Comments
 (0)