Skip to content

Commit 2b3980b

Browse files
committed
[SwiftCompilerSources][build] Require recent Swift compiler in HOSTTOOLS mode
Some code in SwiftCompilerSources, especially the parts that use C++ interop, triggers bugs in older versions of the Swift compiler. To make sure that `HOSTTOOLS` builds don't produce obscure compiler errors or crashes, let's require a relatively new Swift compiler for `HOSTTOOLS` build.
1 parent 91c64f7 commit 2b3980b

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,19 @@ else()
204204
message(FATAL_ERROR "Need a swift toolchain building swift compiler sources")
205205
endif()
206206

207+
if(${BOOTSTRAPPING_MODE} STREQUAL "HOSTTOOLS")
208+
if(NOT SWIFT_EXEC_FOR_SWIFT_MODULES STREQUAL CMAKE_Swift_COMPILER)
209+
message(FATAL_ERROR "The Swift compiler (${CMAKE_Swift_COMPILER}) differs from the Swift compiler in SWIFT_NATIVE_SWIFT_TOOLS_PATH (${SWIFT_NATIVE_SWIFT_TOOLS_PATH}/swiftc).")
210+
endif()
211+
212+
set(min_supported_swift_version 5.5)
213+
if(CMAKE_Swift_COMPILER_VERSION VERSION_LESS "${min_supported_swift_version}")
214+
message(FATAL_ERROR
215+
"Outdated Swift compiler: building with host tools requires Swift ${min_supported_swift_version} or newer. "
216+
"Please update your Swift toolchain or switch BOOTSTRAPPING_MODE to BOOTSTRAPPING(-WITH-HOSTLIBS)? or OFF.")
217+
endif()
218+
endif()
219+
207220
add_swift_compiler_modules_library(swiftCompilerModules
208221
SWIFT_EXEC "${SWIFT_EXEC_FOR_SWIFT_MODULES}")
209222

0 commit comments

Comments
 (0)