bootstrap: work around GCC bug

GCC bug 119085, which affects versions 13.0--15.1, is being triggered by
the C backend, resulting in a (small but critical) miscompilation in
zig2. Unfortunately, we can't really work around that bug without a
command-line flag, because the bug is sensitive to things like the order
in which `struct` types are defined.

Therefore, I have added an option to `bootstrap.c` which causes it to
pass the appropriate flag to `gcc` to disable the optimization pass in
question. This flag can likely be removed in future, once the affected
GCC versions become less common.

At least one of our x86_64-linux CI machines is using an affected GCC
version, so I also updated the relevant CI script to pass this flag when
testing no-LLVM bootstrap.

CMakeLists also has a workaround, but no user intervention is required
there: the GCC version range is automatically detected by CMakeLists.
This commit is contained in:
Matthew Lugg
2026-03-04 10:52:54 +00:00
parent c73db56b45
commit a5219cd288
3 changed files with 33 additions and 3 deletions
+2 -1
View File
@@ -21,7 +21,8 @@ export ZIG_LOCAL_CACHE_DIR="$PWD/zig-local-cache"
# Test building from source without LLVM.
cc -o bootstrap bootstrap.c
./bootstrap
# See comments in bootstrap.c for an explanation of the flag given here.
./bootstrap --workaround-gcc-sra-miscomp
./zig2 build -Dno-lib
./zig-out/bin/zig test test/behavior.zig