Commit 957a5ae560

Alex Rønne Petersen <alex@alexrp.com>
2025-04-03 07:24:03
cmake: Pass -fno-sanitize=undefined when building zig2.
We build zig2.c and compiler_rt.c with -O0 but then proceed to link with -O3. So zig2.o and compiler_rt.o will have references to ubsan-rt symbols, but the -O3 causes the compiler to not link ubsan-rt. We don't actually need the safety here, so just explicitly disable ubsan.
1 parent c3e88a2
Changed files (1)
CMakeLists.txt
@@ -809,7 +809,7 @@ if(MSVC)
 else()
   set(ZIG_WASM2C_COMPILE_FLAGS "-std=c99 -O2")
   set(ZIG1_COMPILE_FLAGS "-std=c99 -Os")
-  set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-stack-protector")
+  set(ZIG2_COMPILE_FLAGS "-std=c99 -O0 -fno-sanitize=undefined -fno-stack-protector")
   if(APPLE)
     set(ZIG2_LINK_FLAGS "-Wl,-stack_size,0x10000000")
   elseif(MINGW)