From f6afaf28ef3a2c3188df761e5f6b8fe2ddb3c1ae Mon Sep 17 00:00:00 2001 From: esrrhs Date: Fri, 6 Nov 2026 23:39:33 +0800 Subject: [PATCH] build(windows): align optimization flags with Linux Windows/MinGW was pinned to -O0 while Linux and macOS use -O3 (-O0 only for USE_COV builds). The WIN32 branch has no explanation in history: git log -S'-O0' traces it back to the initial tree, carried over by 01c2ed23 (Replace the repository with fakelua master). With CMAKE_BUILD_TYPE=Release, CMAKE_CXX_FLAGS_RELEASE appends -O3 after CMAKE_CXX_FLAGS, so the command line was effectively '... -O0 -O3 ...' and GCC used -O3 anyway. The -O0 only applied to builds without a config and made the intent misleading. Drop the WIN32 branch so Windows shares the same policy as Linux: -O0 for coverage builds, -O3 otherwise. --- CMakeLists.txt | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05c1bf0b..8299964a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,11 +37,7 @@ if (USE_COV) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage -fprofile-update=atomic") endif () -IF (WIN32) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0") - # native IO 用 libevent(select),不再用 Boost.Asio。 -ELSEIF (APPLE) +IF (APPLE) if (USE_COV) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0 -Wno-non-pod-varargs") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0") @@ -50,6 +46,7 @@ ELSEIF (APPLE) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O3") endif () ELSE () + # Windows (MinGW) and Linux share the same policy: -O0 only for coverage builds. if (USE_COV) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O0") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")