From e32d57dd90c809b72f098417eeaf9327eae63ac6 Mon Sep 17 00:00:00 2001 From: Vayle <76063792+Valorith@users.noreply.github.com> Date: Thu, 2 Oct 2025 23:02:10 -0400 Subject: [PATCH] Disable PCH for patch sources compiled with -O0 Disables precompiled headers for specific patch source files that are compiled with -O0 on UNIX. This avoids Clang errors caused by __OPTIMIZE__ macro state mismatches between the PCH and translation units. --- common/CMakeLists.txt | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 2a3c3ad72..1cd88b9e6 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -843,6 +843,11 @@ ENDIF (UNIX) IF (EQEMU_BUILD_PCH) TARGET_PRECOMPILE_HEADERS(common PRIVATE pch/std-pch.h) + # Avoid PCH/__OPTIMIZE__ mismatch when compiling certain patch sources with -O0 + # These files are compiled with -O0 on UNIX (see COMPILE_FLAGS above), which + # disables the __OPTIMIZE__ predefined macro. Disabling PCH for them prevents + # Clang from erroring due to macro state differences between the PCH and TU. + SET_SOURCE_FILES_PROPERTIES("patches/sod.cpp" "patches/sof.cpp" "patches/rof.cpp" "patches/rof2.cpp" "patches/uf.cpp" PROPERTIES SKIP_PRECOMPILE_HEADERS ON) ENDIF () SET(LIBRARY_OUTPUT_PATH ${PROJECT_BINARY_DIR}/bin)