From 957a5ae56038517316f66777d8dc5f090f15c214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20R=C3=B8nne=20Petersen?= Date: Thu, 3 Apr 2025 07:24:03 +0200 Subject: [PATCH] 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. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e692027173..1b7a5779eb 100644 --- a/CMakeLists.txt +++ b/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)