Commit c620836945

Alex Rønne Petersen <alex@alexrp.com>
2025-06-04 10:29:13
zig cc: Pass -f(no-)PIE to clang.
Otherwise we rely on Clang's default which is known to not always match ours.
1 parent 0ccd2b0
Changed files (1)
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");
     }