authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-08-07 03:02:58-04:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-08-09 15:24:42+02:00
log821d122c82af499c2a5b2fc0223cf399faa10d16
tree9af6c54f3c7ef4959153e1b325ebdb8fda99875b
parent49e20bd9dd0291c40d9f24e8333449b8ecc95040

bootstrap: change/enable c compiler optimizations for zig1/zig2


1 files changed, 6 insertions(+), 13 deletions(-)

CMakeLists.txt+6-13
......@@ -602,24 +602,17 @@ if(MSVC)
602602 set(ZIG2_COMPILE_FLAGS "/Od")
603603 set(ZIG2_LINK_FLAGS "/STACK:16777216 /FORCE:MULTIPLE")
604604else()
605 set(ZIG_WASM2C_COMPILE_FLAGS "-std=c99 -O2")
606 set(ZIG1_COMPILE_FLAGS "-std=c99 -Os -fno-strict-aliasing")
607 set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector -fno-strict-aliasing")
605 set(ZIG_WASM2C_COMPILE_FLAGS "-std=c99")
606 set(ZIG1_COMPILE_FLAGS "-std=c99 -Oz -fno-strict-aliasing")
607 set(ZIG2_COMPILE_FLAGS "-std=c99 -Oz -fno-sanitize=undefined -fno-stack-protector -fno-strict-aliasing")
608 if(CMAKE_C_COMPILER_ID STREQUAL "Clang" AND ZIG_HOST_TARGET_ARCH STREQUAL "s390x")
609 string(REPLACE -Oz -O0 ZIG2_COMPILE_FLAGS "${ZIG2_COMPILE_FLAGS}") # llvm 22 assertion failure
610 endif()
608611 # Must match the condition in build.zig.
609612 if(ZIG_HOST_TARGET_ARCH MATCHES "^(arm|thumb)(eb)?$" OR ZIG_HOST_TARGET_ARCH EQUAL "hexagon" OR ZIG_HOST_TARGET_ARCH MATCHES "^powerpc(64)?(le)?$")
610613 set(ZIG1_COMPILE_FLAGS "${ZIG1_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
611614 set(ZIG2_COMPILE_FLAGS "${ZIG2_COMPILE_FLAGS} -ffunction-sections -fdata-sections")
612615 endif()
613 if(APPLE)
614 set(ZIG2_LINK_FLAGS "-Wl,-stack_size,0x10000000")
615 elseif(MINGW)
616 set(ZIG2_LINK_FLAGS "-Wl,--stack,0x10000000")
617 # Solaris/illumos ld(1) does not provide a --stack-size option.
618 elseif(CMAKE_HOST_SOLARIS)
619 unset(ZIG2_LINK_FLAGS)
620 else()
621 set(ZIG2_LINK_FLAGS "-Wl,-z,stack-size=0x10000000")
622 endif()
623616 if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
624617 # Prevent GCC from miscompiling 'zig2.c'. See also 'GCC_BUG_119085_PRESENT' workaround details in 'bootstrap.c'.
625618 if (