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).
This commit is contained in:
Samuel Holland 2017-08-22 16:24:29 -05:00
parent 12ceed013c
commit 054f310868

View file

@ -902,7 +902,7 @@ fn link_args(cmd: &mut Linker,
let mut args = args.iter().chain(more_args.iter()).chain(used_link_args.iter());
if get_reloc_model(sess) == llvm::RelocMode::PIC
&& !args.any(|x| *x == "-static") {
&& !sess.crt_static() && !args.any(|x| *x == "-static") {
cmd.position_independent_executable();
}
}