Skip to content

[build] Disable checked iterators on Windows #76550

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,17 @@ set(SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY
${SWIFT_STDLIB_MSVC_RUNTIME_LIBRARY_default}
CACHE STRING "MSVC Runtime Library for the standard library")

if("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND BOOTSTRAPPING_MODE STREQUAL "HOSTTOOLS" AND
CMAKE_BUILD_TYPE STREQUAL "Debug")
# Building with the host Swift toolchain requires linking just-built binaries
# against the host Swift runtime. In debug builds, that means linking a debug
# binary against a release binary. The MSVC linker does not normally permit
# this, since debug builds enable bounds-checked C++ iterators by default,
# which are not ABI-compatible with regular iterators. Let's instruct MSVC to
# disable bounds-checked iterators to make it possible to do a debug build of
# the Swift compiler with a host toolchain.
add_definitions(-D_ITERATOR_DEBUG_LEVEL=0)
endif()

if(BRIDGING_MODE STREQUAL "DEFAULT" OR NOT BRIDGING_MODE)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR "${SWIFT_HOST_VARIANT_SDK}" STREQUAL "WINDOWS" OR (CMAKE_Swift_COMPILER AND CMAKE_Swift_COMPILER_VERSION VERSION_LESS 5.8))
Expand Down