Skip to content

Commit 67e4f11

Browse files
authored
Merge pull request #74662 from z2oh/fix-windows-build-vs-17.10
[windows] Allow compiler and STL version mismatch
2 parents d3ff97d + e49fa3e commit 67e4f11

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-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: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ if ($PinnedBuild -eq "") {
152152
"AMD64" {
153153
$PinnedBuild = "https://download.swift.org/swift-5.10.1-release/windows10/swift-5.10.1-RELEASE/swift-5.10.1-RELEASE-windows10.exe"
154154
$PinnedSHA256 = "3027762138ACFA1BBE3050FF6613BBE754332E84C9EFA5C23984646009297286"
155+
$PinnedVersion = "5.10.1"
155156
}
156157
"ARM64" {
157158
# TODO(hjyamauchi) once we have an arm64 release, fill in PinnedBuild and PinnedSHA256.
@@ -739,6 +740,13 @@ function Get-PinnedToolchainRuntime() {
739740
return "$BinaryCache\toolchains\${PinnedToolchain}\PFiles64\Swift\runtime-development\usr\bin"
740741
}
741742

743+
function Get-PinnedToolchainVersion() {
744+
if (Test-Path variable:PinnedVersion) {
745+
return $PinnedVersion
746+
}
747+
return "5.10.1"
748+
}
749+
742750
function TryAdd-KeyValue([hashtable]$Hashtable, [string]$Key, [string]$Value) {
743751
if (-not $Hashtable.Contains($Key)) {
744752
$Hashtable.Add($Key, $Value)
@@ -1311,6 +1319,14 @@ function Build-Compilers() {
13111319
}
13121320
}
13131321

1322+
# The STL in VS 17.10 requires Clang 17 or higher, but Swift toolchains prior to version 6 include older versions
1323+
# of Clang. If bootstrapping with an older toolchain, we need to relax to relax this requirement with
1324+
# ALLOW_COMPILER_AND_STL_VERSION_MISMATCH.
1325+
$SwiftFlags = @();
1326+
if ([System.Version](Get-PinnedToolchainVersion) -lt [System.Version]"6.0") {
1327+
$SwiftFlags += @("-Xcc", "-D_ALLOW_COMPILER_AND_STL_VERSION_MISMATCH");
1328+
}
1329+
13141330
Build-CMakeProject `
13151331
-Src $SourceCache\llvm-project\llvm `
13161332
-Bin $CompilersBinaryCache `
@@ -1323,6 +1339,7 @@ function Build-Compilers() {
13231339
-Defines ($TestingDefines + @{
13241340
CLANG_TABLEGEN = (Join-Path -Path $BuildTools -ChildPath "clang-tblgen.exe");
13251341
CLANG_TIDY_CONFUSABLE_CHARS_GEN = (Join-Path -Path $BuildTools -ChildPath "clang-tidy-confusable-chars-gen.exe");
1342+
CMAKE_Swift_FLAGS = $SwiftFlags;
13261343
LLDB_PYTHON_EXE_RELATIVE_PATH = "python.exe";
13271344
LLDB_PYTHON_EXT_SUFFIX = ".pyd";
13281345
LLDB_PYTHON_RELATIVE_PATH = "lib/site-packages";

0 commit comments

Comments
 (0)