Skip to content

Commit d7e45ab

Browse files
authored
Merge pull request #75557 from rintaro/package-cmo-beta4
[CMake] Enable package CMO only in newer compilers
2 parents 8189840 + 39af141 commit d7e45ab

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

Diff for: cmake/modules/SwiftCompilerCapability.cmake

+20-2
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,19 @@ macro(swift_supports_implicit_module module_name out_var)
2121
)
2222
endmacro()
2323

24+
function(swift_get_swiftlang_version out_var)
25+
execute_process(
26+
COMMAND "${CMAKE_Swift_COMPILER}" -version
27+
OUTPUT_VARIABLE output ERROR_VARIABLE output
28+
RESULT_VARIABLE result
29+
TIMEOUT 10
30+
)
31+
32+
if(output MATCHES [[swiftlang-([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)]])
33+
set("${out_var}" "${CMAKE_MATCH_1}" PARENT_SCOPE)
34+
endif()
35+
endfunction()
36+
2437
# Get "package cross-module-optimization" compiler arguments suitable for the compiler.
2538
function(swift_get_package_cmo_support out_var)
2639
# > 6.0 : Fixed feature.
@@ -42,8 +55,13 @@ function(swift_get_package_cmo_support out_var)
4255
-Xfrontend -experimental-package-bypass-resilience
4356
)
4457
if(result)
45-
set(${out_var} EXPERIMENTAL PARENT_SCOPE)
46-
return()
58+
# Package CMO is implmented in Xcode 16 Beta 4 (swiftlang-6.0.0.6.8) or later.
59+
# Consider it's not supported in non Xcode toolchain with "-experimental" options.
60+
swift_get_swiftlang_version(swiftlang_version)
61+
if(swiftlang_version AND swiftlang_version VERSION_GREATER_EQUAL 6.0.0.6)
62+
set(${out_var} EXPERIMENTAL PARENT_SCOPE)
63+
return()
64+
endif()
4765
endif()
4866

4967
# < 6.0 : Not supported.

0 commit comments

Comments
 (0)