From c7a6f9bc31c026c5e4adcd1691f88daca4374358 Mon Sep 17 00:00:00 2001 From: Yuta Saito Date: Sun, 13 Oct 2024 16:58:36 +0900 Subject: [PATCH] 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 --- CMakeLists.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 470d8254..19eecd80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,13 @@ project(WasmKit LANGUAGES C Swift) set(SWIFT_VERSION 5) set(CMAKE_Swift_LANGUAGE_VERSION ${SWIFT_VERSION}) +# Enable whole module optimization for Release or RelWithDebInfo builds. +if(POLICY CMP0157) + set(CMAKE_Swift_COMPILATION_MODE $,wholemodule,incremental>) +else() + add_compile_options($<$,$>:-wmo>) +endif() + if(CMAKE_VERSION VERSION_LESS 3.21) get_property(parent_dir DIRECTORY PROPERTY PARENT_DIRECTORY) if(NOT parent_dir)