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

Conversation

egorzhdan
Copy link
Contributor

Trying to run a debug build of the Swift compiler with a host Swift toolchain on Windows was failing with a linker error due to a mismatched _ITERATOR_DEBUG_LEVEL macro.

This avoids the linker error by disabling bounds-checked iterators on Windows. See the inline comment for details.

@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

CMakeLists.txt Outdated
@@ -419,6 +419,16 @@ 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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can only halogen in an unsupported build, as debug builds are known to be problematic in general. Can you please also add an explicit build configuration check here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, added a check for a debug build.

Trying to run a debug build of the Swift compiler with a host Swift toolchain on Windows was failing with a linker error due to a mismatched `_ITERATOR_DEBUG_LEVEL` macro.

This avoids the linker error by disabling bounds-checked iterators on Windows. See the inline comment for details.
@egorzhdan egorzhdan force-pushed the egorzhdan/msvc-checked-iterators branch from 0fe5b10 to 7fad3e7 Compare September 18, 2024 15:51
@egorzhdan
Copy link
Contributor Author

@swift-ci please smoke test

Copy link
Member

@compnerd compnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not too fond of this as the debug mode builds are not expected to work currently, but if this helps ...

@egorzhdan
Copy link
Contributor Author

Yeah, I think being able to run a debug build is quite helpful, at least I tend to do that when investigating PR test failures on Windows. Looking forward to Windows debug builds being officially supported in the future 🙂

@egorzhdan egorzhdan merged commit 97bc7c2 into main Sep 19, 2024
3 checks passed
@egorzhdan egorzhdan deleted the egorzhdan/msvc-checked-iterators branch September 19, 2024 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants