From bbde47842b6cadfad2680dedb86ff267337632fc Mon Sep 17 00:00:00 2001 From: Seth Flynn Date: Mon, 20 Jan 2025 20:35:37 -0500 Subject: [PATCH] feat: use better compile flags for mingw Signed-off-by: Seth Flynn (cherry picked from commit e66f447ce5bca996b0a12fac02216b2b6ab8ccb6) --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c6d90af5..7a0ac672b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -78,6 +78,13 @@ else() # ATL's pack list needs more than the default 1 Mib stack on windows if(WIN32) set(CMAKE_EXE_LINKER_FLAGS "-Wl,--stack,8388608 ${CMAKE_EXE_LINKER_FLAGS}") + + # -ffunction-sections and -fdata-sections help reduce binary size + # -mguard=cf enables Control Flow Guard + # TODO: Look into -gc-sections to further reduce binary size + foreach(lang C CXX) + set("CMAKE_${lang}_FLAGS_RELEASE" "-ffunction-sections -fdata-sections -mguard=cf") + endforeach() endif() endif()