Skip to content

Commit 6366ebb

Browse files
committed
build: add an option to control WMO
WMO requires the new swift-driver which requires an early swift-driver or a host toolchain that has Swift. Since the only platform that guarantees this currently is Darwin, use a conditional value for the option, defaulting to `NO` for most other targets. This should repair the build on Windows.
1 parent 239de6c commit 6366ebb

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/${SWIFT_HOST_LIBRARI
2323

2424
set(CMAKE_MACOSX_RPATH YES)
2525

26+
option(SWIFT_DRIVER_ENABLE_WMO
27+
"Enable Whole Module Optimization (WMO) - requires swift-driver"
28+
$<IF:$<PLATFORM_ID:Darwin>,YES,NO>)
29+
2630
include(AddSwiftHostLibrary)
2731

2832
# Ensure that we do not link the _StringProcessing module. But we can

cmake/modules/AddSwiftHostLibrary.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ function(add_swift_host_library name)
5656
-emit-module-interface-path;${module_interface_file}
5757
>)
5858

59-
if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
59+
if(SWIFT_DRIVER_ENABLE_WMO)
6060
target_compile_options(${name} PRIVATE
6161
$<$<COMPILE_LANGUAGE:Swift>:
6262
-wmo

0 commit comments

Comments
 (0)