It has been observed in practice on powerpc64(le)-linux that zig.o (in various stages and build modes) is large enough that the +/- 32MB branch range of PowerPC is insufficient to reach from one end of the code section to the other. With LLVM 21, this leads to silent miscompiles that then crash at runtime. With LLVM 22, it will at least lead to branch range errors that fail the compilation, but that gets us no closer to a working compiler. By using these options, we give the linker much greater flexibility to move code and data around to satisfy these range constraints; without them, the linker is not allowed to split up the huge code and data sections of zig.o to do so. Similar issues have also been observed on powerpc-linux (32-bit), hexagon-linux, and some variations of mips(64)(el)-linux. But let's be conservative for now; those other targets can be added to the condition later. As a data point to support this change, it's worth noting that LLD started enabling these options for LTO precisely because the resulting large compilation units ran into these range issues. In some abstract sense, Zig can be seen as doing a limited form of "LTO" in the frontend, so it's not surprising that we would hit the same issues.
Alex Rønne Petersen committed on 1/6/2026, 8:15:02 PMparenta996a75
2 files changedLine totals unavailable