summaryrefslogtreecommitdiff
path: root/Modules/CMakeSwiftInformation.cmake
diff options
context:
space:
mode:
authorYR Chen <stevapple@icloud.com>2023-03-25 16:51:50 +0800
committerBrad King <brad.king@kitware.com>2023-03-28 10:02:05 -0400
commit006e1995ebd279052290bf3e25eb814ba09a0dcc (patch)
treebba0f36344dd0d171c42d36235d8317704633f8e /Modules/CMakeSwiftInformation.cmake
parentfae6e8c2cdb5ce6049439f4defd1367b507d1e4b (diff)
downloadcmake-006e1995ebd279052290bf3e25eb814ba09a0dcc.tar.gz
Swift: Restore compatibility with old C++ driver
The `-wmo` flag added by commit 6063428de7 (Swift: Update default build flags, 2022-10-03, v3.26.0-rc1~585^2~1) behaves differently with the old driver. Detect when the old driver is being used, and avoid adding that flag. Fixes: #24641
Diffstat (limited to 'Modules/CMakeSwiftInformation.cmake')
-rw-r--r--Modules/CMakeSwiftInformation.cmake14
1 files changed, 11 insertions, 3 deletions
diff --git a/Modules/CMakeSwiftInformation.cmake b/Modules/CMakeSwiftInformation.cmake
index a75dfceea1..f524955861 100644
--- a/Modules/CMakeSwiftInformation.cmake
+++ b/Modules/CMakeSwiftInformation.cmake
@@ -78,9 +78,17 @@ if(CMAKE_GENERATOR STREQUAL "Xcode")
set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize")
else()
set(CMAKE_Swift_FLAGS_DEBUG_INIT "-Onone -g -incremental")
- set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O -wmo")
- set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g -wmo")
- set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize -wmo")
+ set(CMAKE_Swift_FLAGS_RELEASE_INIT "-O")
+ set(CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT "-O -g")
+ set(CMAKE_Swift_FLAGS_MINSIZEREL_INIT "-Osize")
+
+ # Enable Whole Module Optimization by default unless the old
+ # C++ driver is being used, which behaves differently under WMO.
+ if(NOT CMAKE_Swift_COMPILER_USE_OLD_DRIVER)
+ string(APPEND CMAKE_Swift_FLAGS_RELEASE_INIT " -wmo")
+ string(APPEND CMAKE_Swift_FLAGS_RELWITHDEBINFO_INIT " -wmo")
+ string(APPEND CMAKE_Swift_FLAGS_MINSIZEREL_INIT " -wmo")
+ endif()
endif()
if(CMAKE_EXECUTABLE_FORMAT STREQUAL "ELF")