Skip to content

Commit 054f310

Browse files
committed
Disable PIE when linking statically
Static PIE support, while supported on musl, requires a patch to GCC. Until/unless it is merged, adding '-pie' to the linker command line will override '-static' and create a binary that requires a dynamic interpreter (ld.so).
1 parent 12ceed0 commit 054f310

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/librustc_trans/back/link.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -902,7 +902,7 @@ fn link_args(cmd: &mut Linker,
902902
let mut args = args.iter().chain(more_args.iter()).chain(used_link_args.iter());
903903

904904
if get_reloc_model(sess) == llvm::RelocMode::PIC
905-
&& !args.any(|x| *x == "-static") {
905+
&& !sess.crt_static() && !args.any(|x| *x == "-static") {
906906
cmd.position_independent_executable();
907907
}
908908
}

0 commit comments

Comments
 (0)