From 010fde75c882a34e113791ea28709ff460279a94 Mon Sep 17 00:00:00 2001 From: Saleem Abdulrasool Date: Thu, 25 May 2023 09:42:57 -0700 Subject: [PATCH] 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. --- CMakeLists.txt | 4 ++++ cmake/modules/AddSwiftHostLibrary.cmake | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 25df18647c7..80ff9ccff69 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,10 @@ set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib/${SWIFT_HOST_LIBRARI set(CMAKE_MACOSX_RPATH YES) +option(SWIFT_SYNTAX_ENABLE_WMO_PRE_3_26 + "Enable Whole Module Optimization (WMO) - requires swift-driver" + $>,$>,YES,NO>) + include(AddSwiftHostLibrary) # Ensure that we do not link the _StringProcessing module. But we can diff --git a/cmake/modules/AddSwiftHostLibrary.cmake b/cmake/modules/AddSwiftHostLibrary.cmake index 4ec93305bf1..e6d3d4db4b6 100644 --- a/cmake/modules/AddSwiftHostLibrary.cmake +++ b/cmake/modules/AddSwiftHostLibrary.cmake @@ -56,11 +56,9 @@ function(add_swift_host_library name) -emit-module-interface-path;${module_interface_file} >) - if(NOT CMAKE_BUILD_TYPE STREQUAL "Debug") + if(CMAKE_VERSION VERSION_LESS 3.26.0 AND SWIFT_SYNTAX_ENABLE_WMO_PRE_3_26) target_compile_options(${name} PRIVATE - $<$: - -wmo - >) + $<$:-wmo>) endif() # NOTE: workaround for CMake not setting up include flags yet