From 20e13c1af3f65d3ad4616f2c51b2544d843341f1 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Thu, 8 Aug 2024 10:51:33 -0700 Subject: [PATCH 1/4] Enable whole-module-optimization in release builds --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2afb0787e..7da0b48b5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,6 +112,13 @@ if(CMAKE_SYSTEM_NAME STREQUAL "WASI") "SHELL:$<$:-Xcc -D_WASI_EMULATED_MMAN>") 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(SwiftFoundationSwiftSupport) From b69c1fae2077b69fc32c58ae04f9bbcfafa778a0 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Thu, 8 Aug 2024 11:21:31 -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 7da0b48b5..c051b4d7f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,6 +35,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) @@ -112,13 +119,6 @@ if(CMAKE_SYSTEM_NAME STREQUAL "WASI") "SHELL:$<$:-Xcc -D_WASI_EMULATED_MMAN>") 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(SwiftFoundationSwiftSupport) From afcb5460085b685e57ca96096e4c86cf0728007b Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Thu, 8 Aug 2024 15:51:50 -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 c051b4d7f..cf4826f06 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -39,7 +39,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 21aef2ae5f8ac2550416ceae2e0aa28b19ebb4e7 Mon Sep 17 00:00:00 2001 From: Jeremy Schonfeld Date: Fri, 9 Aug 2024 09:29:17 -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 cf4826f06..108b65726 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,11 +35,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)