Skip to content

Commit e48b05f

Browse files
committed
[SwiftCompilerSources] Enable use of the -min-runtime-version option.
Turn on the use of `-min-runtime-version` when building the compiler. rdar://121522431
1 parent c226bf3 commit e48b05f

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,11 @@ include(FetchContent)
101101
check_language(Swift)
102102
if(CMAKE_Swift_COMPILER)
103103
enable_language(Swift)
104+
set(DEFAULT_SWIFT_MIN_RUNTIME_VERSION "${CMAKE_Swift_COMPILER_VERSION}")
104105
else()
105106
message(STATUS "WARNING! Did not find a host compiler swift?! Can not build
106107
any compiler host sources written in Swift")
108+
set(DEFAULT_SWIFT_MIN_RUNTIME_VERSION)
107109
endif()
108110

109111
# A convenience pattern to match Darwin platforms. Example:
@@ -464,6 +466,10 @@ set(SWIFT_DARWIN_MODULE_ARCHS "" CACHE STRING
464466
targets on Darwin platforms. These targets are in addition to the full \
465467
library targets.")
466468

469+
set(SWIFT_MIN_RUNTIME_VERSION "${DEFAULT_SWIFT_MIN_RUNTIME_VERSION}" CACHE STRING
470+
"Specify the minimum version of the runtime that we target when building \
471+
the compiler itself. This is used on non-Darwin platforms to ensure \
472+
that it's possible to build the compiler using host tools.")
467473

468474
#
469475
# User-configurable Android specific options.

SwiftCompilerSources/CMakeLists.txt

+6
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,13 @@ function(add_swift_compiler_modules_library name)
106106
"-Xcc" "-std=c++17"
107107
"-Xcc" "-DCOMPILED_WITH_SWIFT" "-Xcc" "-DSWIFT_TARGET"
108108
"-Xcc" "-UIBOutlet" "-Xcc" "-UIBAction" "-Xcc" "-UIBInspectable")
109+
109110
if (NOT BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS")
111+
if(SWIFT_MIN_RUNTIME_VERSION)
112+
list(APPEND swift_compile_options
113+
"-Xfrontend" "-min-runtime-version"
114+
"-Xfrontend" "${SWIFT_MIN_RUNTIME_VERSION}")
115+
endif()
110116
list(APPEND swift_compile_options "-Xfrontend" "-disable-implicit-string-processing-module-import")
111117
endif()
112118

utils/build-script-impl

+9
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,9 @@ KNOWN_SETTINGS=(
116116
darwin-toolchain-require-use-os-runtime "0" "When setting up a plist for a toolchain, require the users of the toolchain to link against the OS instead of the packaged toolchain runtime. 0 for false, 1 for true"
117117
darwin-xcrun-toolchain "default" "the name of the toolchain to use on Darwin"
118118

119+
## Runtime options
120+
min-runtime-version "" "Used to specify the minimum host runtime version when building the compiler on non-Darwin platforms"
121+
119122
## WebAssembly/WASI Options
120123
wasi-sysroot "" "An absolute path to the wasi-sysroot that will be used as a libc implementation for Wasm builds"
121124

@@ -750,6 +753,12 @@ function set_build_options_for_host() {
750753
)
751754
fi
752755

756+
if [[ ! -z "${MIN_RUNTIME_VERSION}" ]]; then
757+
swift_cmake_options+=(
758+
-DSWIFT_MIN_RUNTIME_VERSION="${MIN_RUNTIME_VERSION}"
759+
)
760+
fi
761+
753762
swift_cmake_options+=(
754763
-DSWIFT_DARWIN_DEPLOYMENT_VERSION_OSX="${DARWIN_DEPLOYMENT_VERSION_OSX}"
755764
-DSWIFT_DARWIN_DEPLOYMENT_VERSION_IOS="${DARWIN_DEPLOYMENT_VERSION_IOS}"

0 commit comments

Comments
 (0)