Skip to content

Commit 2c6dee1

Browse files
CMake: Enable WMO for Release builds
The new interpreter heavily benefits from WMO and it's even slower than the old one without it. This change enables WMO for Release builds for CMake builds as it's not enabled by default. Use `CMAKE_Swift_COMPILATION_MODE` if CMake 3.29 or newer is used, and fall back to `add_compile_options` if older. https://cmake.org/cmake/help/latest/prop_tgt/Swift_COMPILATION_MODE.html
1 parent 16a7a63 commit 2c6dee1

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,13 @@ project(WasmKit LANGUAGES C Swift)
77
set(SWIFT_VERSION 5)
88
set(CMAKE_Swift_LANGUAGE_VERSION ${SWIFT_VERSION})
99

10+
# Enable whole module optimization for Release or RelWithDebInfo builds.
11+
if(POLICY CMP0157)
12+
set(CMAKE_Swift_COMPILATION_MODE $<IF:$<CONFIG:Release,RelWithDebInfo>,wholemodule,incremental>)
13+
else()
14+
add_compile_options($<$<AND:$<COMPILE_LANGUAGE:Swift>,$<CONFIG:Release,RelWithDebInfo>>:-wmo>)
15+
endif()
16+
1017
if(CMAKE_VERSION VERSION_LESS 3.21)
1118
get_property(parent_dir DIRECTORY PROPERTY PARENT_DIRECTORY)
1219
if(NOT parent_dir)

0 commit comments

Comments
 (0)