commit c6208369458208f097b8ce1ad1bb6c2bf40f211d (tree)
parent 0ccd2b0c5cdf4bee706b4a9341b97f786b19a978
Author: Alex Rønne Petersen <alex@alexrp.com>
Date: Wed, 4 Jun 2025 10:29:13 +0200
zig cc: Pass -f(no-)PIE to clang.
Otherwise we rely on Clang's default which is known to not always match ours.
Diffstat:
1 file changed, 3 insertions(+), 0 deletions(-)
diff --git a/src/Compilation.zig b/src/Compilation.zig
@@ -6169,6 +6169,9 @@ pub fn addCCArgs(
}
if (target_util.supports_fpic(target)) {
+ // PIE needs to go before PIC because Clang interprets `-fno-PIE` to imply `-fno-PIC`, which
+ // we don't necessarily want.
+ try argv.append(if (comp.config.pie) "-fPIE" else "-fno-PIE");
try argv.append(if (mod.pic) "-fPIC" else "-fno-PIC");
}