Skip to content

Commit 152b6c1

Browse files
Rollup merge of rust-lang#160620 - mati865:no-no-pie-windows, r=bjorn3
Do not pass `-no-pie` on Windows The warning can be seen with a simple example: ``` ❯ cargo new /tmp/hello -q ❯ cargo rustc --target x86_64-pc-windows-gnullvm -q -- -C target-feature=+crt-static warning: linker stderr: clang: argument unused during compilation: '-no-pie' [-Wunused-command-line-argument] | = note: `#[warn(linker_messages)]` on by default ```
2 parents e64c8a6 + 2697924 commit 152b6c1

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

compiler/rustc_codegen_ssa/src/back/linker.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,8 @@ impl<'a> Linker for GccLinker<'a> {
532532
LinkOutputKind::StaticNoPicExe => {
533533
// `-static` works for both gcc wrapper and ld.
534534
self.link_or_cc_arg("-static");
535-
if !self.is_ld && self.is_gnu {
535+
// noop on windows w/ gcc, warning w/ clang
536+
if !self.is_ld && self.is_gnu && !self.sess.target.is_like_windows {
536537
self.cc_arg("-no-pie");
537538
}
538539
}

0 commit comments

Comments
 (0)