From e8cf5721b1b3ebdc8ee69d15a375afd2eab0dd8f Mon Sep 17 00:00:00 2001 From: Vadim Petrochenkov Date: Mon, 15 Jun 2020 23:05:05 +0300 Subject: [PATCH] linker: Never pass `-no-pie` to non-gnu linkers --- src/librustc_codegen_ssa/back/linker.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/librustc_codegen_ssa/back/linker.rs b/src/librustc_codegen_ssa/back/linker.rs index b17c367820748..efcabc57e6f70 100644 --- a/src/librustc_codegen_ssa/back/linker.rs +++ b/src/librustc_codegen_ssa/back/linker.rs @@ -280,7 +280,7 @@ impl<'a> Linker for GccLinker<'a> { fn set_output_kind(&mut self, output_kind: LinkOutputKind, out_filename: &Path) { match output_kind { LinkOutputKind::DynamicNoPicExe => { - if !self.is_ld { + if !self.is_ld && self.sess.target.target.options.linker_is_gnu { self.cmd.arg("-no-pie"); } } @@ -291,7 +291,7 @@ impl<'a> Linker for GccLinker<'a> { LinkOutputKind::StaticNoPicExe => { // `-static` works for both gcc wrapper and ld. self.cmd.arg("-static"); - if !self.is_ld { + if !self.is_ld && self.sess.target.target.options.linker_is_gnu { self.cmd.arg("-no-pie"); } }