From 2566b8f5fcb92b9a9dbf9f406c65a1e920ce22dd Mon Sep 17 00:00:00 2001 From: Amanieu d'Antras Date: Sun, 28 Jun 2026 06:02:52 +0100 Subject: [PATCH] Enable static PIE on all GNU targets --- compiler/rustc_target/src/spec/base/linux_gnu.rs | 6 +++++- .../src/spec/targets/x86_64_unknown_linux_gnu.rs | 1 - 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/compiler/rustc_target/src/spec/base/linux_gnu.rs b/compiler/rustc_target/src/spec/base/linux_gnu.rs index 7a907c802df2e..02e243fe0a129 100644 --- a/compiler/rustc_target/src/spec/base/linux_gnu.rs +++ b/compiler/rustc_target/src/spec/base/linux_gnu.rs @@ -1,7 +1,11 @@ use crate::spec::{Cc, Env, LinkerFlavor, Lld, TargetOptions, base}; pub(crate) fn opts() -> TargetOptions { - let mut base = TargetOptions { env: Env::Gnu, ..base::linux::opts() }; + let mut base = TargetOptions { + env: Env::Gnu, + static_position_independent_executables: true, + ..base::linux::opts() + }; // When we're asked to use the `rust-lld` linker by default, set the appropriate lld-using // linker flavor, and self-contained linker component. diff --git a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs index 0d87a7b760c61..f8556b3415d94 100644 --- a/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs +++ b/compiler/rustc_target/src/spec/targets/x86_64_unknown_linux_gnu.rs @@ -9,7 +9,6 @@ pub(crate) fn target() -> Target { base.max_atomic_width = Some(64); base.add_pre_link_args(LinkerFlavor::Gnu(Cc::Yes, Lld::No), &["-m64"]); base.stack_probes = StackProbeType::Inline; - base.static_position_independent_executables = true; base.supported_sanitizers = SanitizerSet::ADDRESS | SanitizerSet::CFI | SanitizerSet::KCFI