| author | |
| committer | |
| log | 79e7b719a362959fd172bbe7f7d9abe3e2f6f0cc |
| tree | 80da616bafae5253858f6c0c4af44d2e5bd44f98 |
| parent | 57114044db85717bea7204f2693d6c8a62111635 |
| signature |
The C backend has always gleefully violated C's strict aliasing rules,
and I just got bitten by it for the first time when bootstrapping on
macOS. This probably hasn't been helping with some of the weird
bootstrap-related CI failures we've seen. So, update `bootstrap.c` and
`CMakeLists.txt` to tell GCC/Clang to disable type-based alias analysis.
No change is needed to the MSVC flags because MSVC does not, and never
has, implemented TBAA.2 files changed, 4 insertions(+), 3 deletions(-)
CMakeLists.txt+2-2| ... | ... | @@ -608,8 +608,8 @@ if(MSVC) |
| 608 | 608 | set(ZIG2_LINK_FLAGS "/STACK:16777216 /FORCE:MULTIPLE") |
| 609 | 609 | else() |
| 610 | 610 | set(ZIG_WASM2C_COMPILE_FLAGS "-std=c99 -O2") |
| 611 | set(ZIG1_COMPILE_FLAGS "-std=c99 -Os") | |
| 612 | set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector") | |
| 611 | set(ZIG1_COMPILE_FLAGS "-std=c99 -Os -fno-strict-aliasing") | |
| 612 | set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector -fno-strict-aliasing") | |
| 613 | 613 | # Must match the condition in build.zig. |
| 614 | 614 | if(ZIG_HOST_TARGET_ARCH MATCHES "^(arm|thumb)(eb)?$" OR ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(64)?(le)?$") |
| 615 | 615 | set(ZIG1_COMPILE_FLAGS "${ZIG1_COMPILE_FLAGS} -ffunction-sections -fdata-sections") |
bootstrap.c+2-1| ... | ... | @@ -136,7 +136,7 @@ int main(int argc, char **argv) { |
| 136 | 136 | } |
| 137 | 137 | { |
| 138 | 138 | const char *child_argv[] = { |
| 139 | cc, "-o", "zig1", "zig1.c", "stage1/wasi.c", "-std=c99", "-Os", "-lm", NULL, | |
| 139 | cc, "-o", "zig1", "zig1.c", "stage1/wasi.c", "-std=c99", "-Os", "-fno-strict-aliasing", "-lm", NULL, | |
| 140 | 140 | }; |
| 141 | 141 | print_and_run(child_argv); |
| 142 | 142 | } |
| ... | ... | @@ -213,6 +213,7 @@ int main(int argc, char **argv) { |
| 213 | 213 | #if defined(__GNUC__) |
| 214 | 214 | "-pthread", |
| 215 | 215 | #endif |
| 216 | "-fno-strict-aliasing", | |
| 216 | 217 | workaround_gcc_sra_miscomp ? "-fno-tree-sra" : NULL, |
| 217 | 218 | NULL, |
| 218 | 219 | }; |