Skip to content

Commit 21a4b13

Browse files
committed
build: repair the build for newer MSVC release
The newer VS2019 releases require conditional explicit support from C++2a unconditionally. This was added into the newer clang, but the clang for the 5.3 release does not have this. Add this workaround instead.
1 parent d24649a commit 21a4b13

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

cmake/modules/SwiftWindowsSupport.cmake

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,12 @@ macro(swift_swap_compiler_if_needed target)
9696
set(CMAKE_C_COMPILER ${CLANG_LOCATION}/clang${CMAKE_EXECUTABLE_SUFFIX})
9797
set(CMAKE_CXX_COMPILER ${CLANG_LOCATION}/clang++${CMAKE_EXECUTABLE_SUFFIX})
9898
endif()
99+
100+
# Add a workaround for older clang-cl with a newer MSVC runtime. MSVC
101+
# 16.27 ships with a C++ compiler that enables conditional explicit from
102+
# C++20 unconditionally. Newer clang supports this, but the 5.3 release
103+
# branch clang does not. Add a workaround.
104+
add_compile_definitions($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:_HAS_CONDITIONAL_EXPLICIT=0>)
99105
else()
100106
message(SEND_ERROR "${target} requires a clang based compiler")
101107
endif()

stdlib/CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ else()
5555
add_compile_options(-fno-sanitize=all)
5656
endif()
5757

58+
# Add a workaround for older clang-cl with a newer MSVC runtime. MSVC 16.27
59+
# ships with a C++ compiler that enables conditional explicit from C++20
60+
# unconditionally. Newer clang supports this, but the 5.3 release branch clang
61+
# does not. Add a workaround.
62+
add_compile_definitions($<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:_HAS_CONDITIONAL_EXPLICIT=0>)
63+
5864
# Do not enforce checks for LLVM's ABI-breaking build settings.
5965
# The Swift runtime uses some header-only code from LLVM's ADT classes,
6066
# but we do not want to link libSupport into the runtime. These checks rely

0 commit comments

Comments
 (0)