Skip to content

Commit 00acea4

Browse files
committed
[windows] Allow compiler and STL version mismatch
VS 17.10 introduced a requirement on Clang 17, but the pinned Swift toolchain used to bootstrap the compilers (a 5.10 snapshot) uses Clang 16. We can relax this version requirement with ALLOW_COMPILER_AND_STL_VERSION_MISMATCH which needs to be set for all CMAKE_Swift_FLAGS when building the compilers, as well as explicitly in SwiftCompilerSources as the invocation of swiftc there is via custom_command
1 parent a8713ad commit 00acea4

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

SwiftCompilerSources/CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,13 @@ function(add_swift_compiler_modules_library name)
181181
# Workaround a crash in the LoadableByAddress pass
182182
# https://github.com/apple/swift/issues/73254
183183
list(APPEND swift_compile_options "-Xllvm" "-sil-disable-pass=loadable-address")
184+
185+
# The STL in VS 17.10 requires Clang 17 or higher, but bootstrapping generally uses toolchains with older versions
186+
# versions of Clang. Swift 6 toolchains are the first to include Clang 17, so if we are on Windows and using an
187+
# earlier toolchain, we need to relax to relax this requirement with ALLOW_COMPILER_AND_STL_VERSION_MISMATCH.
188+
if (CMAKE_Swift_COMPILER_VERSION VERSION_LESS 6.0)
189+
list(APPEND swift_compile_options "-Xcc" "-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH")
190+
endif()
184191
else()
185192
list(APPEND sdk_option "-I" "${swift_exec_bin_dir}/../lib" "-I" "${sdk_path}/usr/lib")
186193
endif()

utils/build.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,7 @@ function Build-Compilers() {
13231323
-Defines ($TestingDefines + @{
13241324
CLANG_TABLEGEN = (Join-Path -Path $BuildTools -ChildPath "clang-tblgen.exe");
13251325
CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path -Path $BuildTools -ChildPath "clang-tidy-confusable-chars-gen.exe");
1326+
CMAKE_Swift_FLAGS = @("-Xcc", "-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH");
13261327
LLDB_PYTHON_EXE_RELATIVE_PATH = "python.exe";
13271328
LLDB_PYTHON_EXT_SUFFIX = ".pyd";
13281329
LLDB_PYTHON_RELATIVE_PATH = "lib/site-packages";

0 commit comments

Comments
 (0)