From 23b1f6a3bd960728bf958fc46f85da3759c6a8e0 Mon Sep 17 00:00:00 2001 From: Tim Angus Date: Tue, 19 Aug 2025 10:46:16 +0100 Subject: [PATCH] Add -fno-string-aliasing (issue #760) --- cmake/compilers/gnu.cmake | 7 +++++-- cmake/tools/CMakeLists.txt | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/cmake/compilers/gnu.cmake b/cmake/compilers/gnu.cmake index 4ead36d9..e46d1318 100644 --- a/cmake/compilers/gnu.cmake +++ b/cmake/compilers/gnu.cmake @@ -16,7 +16,10 @@ add_compile_options(-Wall -Wimplicit -Wstrict-aliasing=2 -Wmissing-format-attribute -Wdisabled-optimization -Werror-implicit-function-declaration) -add_compile_options(-Wno-strict-aliasing - -Wno-format-zero-length -Wno-format-nonliteral) +add_compile_options(-Wno-format-zero-length -Wno-format-nonliteral) + +# There are lots of instances of union based aliasing in the code +# that rely on the compiler not optimising them away, so disable it +add_compile_options(-fno-strict-aliasing) set(CMAKE_INSTALL_PREFIX /opt/quake3) diff --git a/cmake/tools/CMakeLists.txt b/cmake/tools/CMakeLists.txt index 4fbf0dd9..d4251039 100644 --- a/cmake/tools/CMakeLists.txt +++ b/cmake/tools/CMakeLists.txt @@ -65,8 +65,10 @@ set(LBURG_SOURCES ) add_executable(q3asm ${Q3ASM_SOURCES}) +target_compile_options(q3asm PRIVATE -fno-strict-aliasing) set_output_dirs(q3asm) add_executable(q3lcc ${Q3LCC_SOURCES}) +target_compile_options(q3asm PRIVATE -fno-strict-aliasing) set_output_dirs(q3lcc) add_dependencies(q3lcc q3rcc q3cpp)