From 7e20337ae5ee77db50f7a47992dfe39ff1fa4a00 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Thu, 8 Aug 2024 10:58:25 -0700 Subject: [PATCH 1/4] Enable whole-module-optimization for release builds --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index edb6cf06f9..5c35718c86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -185,6 +185,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") "-D_GNU_SOURCE") endif() +# Enable whole module optimization for release builds & incremental for debug builds +if(POLICY CMP0157) + set(CMAKE_Swift_COMPILATION_MODE "$,wholemodule,incremental>") +else() + add_compile_options($<$,$>>:-wmo>) +endif() + include(GNUInstallDirs) include(FoundationSwiftSupport) From 0cca2f1fd4984dac5aa9853b9608c2a1ad22e189 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Thu, 8 Aug 2024 11:22:14 -0700 Subject: [PATCH 2/4] Address feedback --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5c35718c86..54f40901bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,6 +41,13 @@ if(NOT SWIFT_SYSTEM_NAME) endif() endif() +# Enable whole module optimization for release builds & incremental for debug builds +if(POLICY CMP0157) + set(CMAKE_Swift_COMPILATION_MODE "$,wholemodule,incremental>") +else() + add_compile_options($<$,$>>:-wmo>) +endif() + set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) @@ -185,13 +192,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "Android") "-D_GNU_SOURCE") endif() -# Enable whole module optimization for release builds & incremental for debug builds -if(POLICY CMP0157) - set(CMAKE_Swift_COMPILATION_MODE "$,wholemodule,incremental>") -else() - add_compile_options($<$,$>>:-wmo>) -endif() - include(GNUInstallDirs) include(FoundationSwiftSupport) From a99ecc235a22e966e7859f5d51c1f5172bb5a6f6 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Thu, 8 Aug 2024 15:52:20 -0700 Subject: [PATCH 3/4] Fix build failures --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 54f40901bb..772ba0d85d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -45,7 +45,7 @@ endif() if(POLICY CMP0157) set(CMAKE_Swift_COMPILATION_MODE "$,wholemodule,incremental>") else() - add_compile_options($<$,$>>:-wmo>) + add_compile_options($<$,$>:-wmo>) endif() set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) From e20e3adddd181b076ae3c79d86ecf65ec80bed8b Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Fri, 9 Aug 2024 09:29:56 -0700 Subject: [PATCH 4/4] Don't enable WMO on Windows --- CMakeLists.txt | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 772ba0d85d..5e28bbf327 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,11 +41,14 @@ if(NOT SWIFT_SYSTEM_NAME) endif() endif() -# Enable whole module optimization for release builds & incremental for debug builds -if(POLICY CMP0157) - set(CMAKE_Swift_COMPILATION_MODE "$,wholemodule,incremental>") -else() - add_compile_options($<$,$>:-wmo>) +# Don't enable WMO on Windows due to linker failures +if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows) + # Enable whole module optimization for release builds & incremental for debug builds + if(POLICY CMP0157) + set(CMAKE_Swift_COMPILATION_MODE "$,wholemodule,incremental>") + else() + add_compile_options($<$,$>:-wmo>) + endif() endif() set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)