From 4209d418d6fe24b244ef681a12df426ba9aa33e3 Mon Sep 17 00:00:00 2001 From: Ben Barham Date: Mon, 22 May 2023 17:51:49 -0700 Subject: [PATCH] [CMake] Use WMO for release builds This has a significant (5x) speed up when running our performance tests on eg. apple/swift-docc. (cherry picked from commit d9d09e8cd55933d8f5761349569477636989d4f7) --- cmake/modules/AddSwiftHostLibrary.cmake | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/modules/AddSwiftHostLibrary.cmake b/cmake/modules/AddSwiftHostLibrary.cmake index 11acde9f52d..4ec93305bf1 100644 --- a/cmake/modules/AddSwiftHostLibrary.cmake +++ b/cmake/modules/AddSwiftHostLibrary.cmake @@ -56,6 +56,13 @@ function(add_swift_host_library name) -emit-module-interface-path;${module_interface_file} >) + if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + target_compile_options(${name} PRIVATE + $<$: + -wmo + >) + endif() + # NOTE: workaround for CMake not setting up include flags yet set_target_properties(${name} PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${module_dir}