Skip to content

Commit 1ff9114

Browse files
authored
Enable WMO for release builds (swiftlang#5059) (swiftlang#5062)
1 parent 644d7a6 commit 1ff9114

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ if(NOT SWIFT_SYSTEM_NAME)
4141
endif()
4242
endif()
4343

44+
# Don't enable WMO on Windows due to linker failures
45+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
46+
# Enable whole module optimization for release builds & incremental for debug builds
47+
if(POLICY CMP0157)
48+
set(CMAKE_Swift_COMPILATION_MODE "$<IF:$<CONFIG:Release>,wholemodule,incremental>")
49+
else()
50+
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Swift>,$<CONFIG:Release>>:-wmo>)
51+
endif()
52+
endif()
53+
4454
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
4555
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
4656
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)

0 commit comments

Comments
 (0)