Skip to content

Update ucrt.modulemap for Windows SDK 10.0.26100 #79751

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 8 commits into from
Mar 18, 2025

Conversation

Steelskin
Copy link
Contributor

@Steelskin Steelskin commented Mar 3, 2025

Windows SDK 10.0.26100 added an include to compiler intrinsics headers in wchar.h. In turn, these headers include malloc.h, stdlib.h and stddef.h from ucrt, this leads to a cyclic dependency between the ucrt and compiler intrinsics modules. Furthermore, Clang 19 (from Swift 6.1) intrinsics headers sometimes clash with the ucrt headers dependencies.

These changes separate the problematic headers into different standalone modules.

Fixes: compnerd/swift-build#909
Fixes: #79745

@Steelskin Steelskin requested a review from a team as a code owner March 3, 2025 22:32
@compnerd
Copy link
Member

compnerd commented Mar 3, 2025

@swift-ci please smoke test

@compnerd
Copy link
Member

compnerd commented Mar 4, 2025

@swift-ci please test Windows platform

1 similar comment
@compnerd
Copy link
Member

compnerd commented Mar 4, 2025

@swift-ci please test Windows platform

@compnerd
Copy link
Member

@swift-ci please smoke test

@Steelskin Steelskin force-pushed the fabrice/update-ucrt-modulemap branch from fbf4b6b to 2e24d71 Compare March 10, 2025 23:12
@compnerd
Copy link
Member

@swift-ci please test Windows platform

@compnerd
Copy link
Member

C:\Users\swift-ci\jenkins\workspace\swift-PR-windows\swift-system\Sources\System\Internals\Syscalls.swift:258:10: error: cannot find 'getenv' in scope
256 |   _ name: UnsafePointer<CChar>
257 | ) -> UnsafeMutablePointer<CChar>? {
258 |   return getenv(name)
    |          `- error: cannot find 'getenv' in scope
259 | }
260 |

Steelskin and others added 5 commits March 11, 2025 16:26
Windows SDK 10.0.26100 added an include to compiler intrinsics headers
in `wchar.h`. In turn, these headers include `malloc.h`, `stdlib.h` and
`stddef.h` from `ucrt`, this leads to a cyclic dependency between the
`ucrt` and compiler intrinsics modules.

These changes separate the 3 headers (`malloc.h`, `stdlib.h` and
`stddef.h`) into 3 different standalone modules.
Pull in corecrt in the `_complex` module as well. While the simple test case worked for this modularisation, the build of `CRT` on the older WinSDK would fail as:

```
C:\Program Files (x86)\Windows Kits\10\include\10.0.22621.0\ucrt\complex.h:12:10: error: 'corecrt.h' file not found
 10 | #define _COMPLEX
 11 | 
 12 | #include <corecrt.h>
    |          `- error: 'corecrt.h' file not found
 13 | 
 14 | #if (_CRT_HAS_CXX17 == 1) && !defined(_CRT_USE_C_COMPLEX_H)

C:/Users/swift-ci/jenkins/workspace/swift-PR-windows/swift/stdlib/public/Platform/ucrt.swift:15:19: error: could not build C module '_complex'

13 | @_exported import ucrt // Clang module
14 | // Extra clang module that's split out from ucrt:
15 | @_exported import _complex
   |                   `- error: could not build C module '_complex'
16 | 
17 | @available(swift, deprecated: 3.0, message: "Please use 'Double.pi' or '.pi' to get the value of correct type and avoid casting.")

```
These modules needed to be split up to allow for resolving circularity. Add exports for the new standalone modules to repair expectations.
The headers already add `extern "C"` blocks.
@Steelskin Steelskin force-pushed the fabrice/update-ucrt-modulemap branch from 2e24d71 to 6920af6 Compare March 11, 2025 23:26
@compnerd
Copy link
Member

@swift-ci please test Windows platform

The header can include `<ccomplex>`.
@compnerd
Copy link
Member

@swift-ci please test Windows platform

@compnerd
Copy link
Member

@swift-ci please test Windows platform

1 similar comment
@compnerd
Copy link
Member

@swift-ci please test Windows platform

@compnerd
Copy link
Member

@swift-ci please test Windows platform

@compnerd
Copy link
Member

@swift-ci please smoke test Linux platform

@compnerd
Copy link
Member

@swift-ci please smoke test macOS platform

@compnerd compnerd merged commit 5e3bd9f into swiftlang:main Mar 18, 2025
3 checks passed
@shahmishal
Copy link
Member

We should cherry-pick this into release/6.1. cc: @Steelskin @compnerd

Steelskin added a commit to Steelskin/swift that referenced this pull request Mar 19, 2025
@Steelskin
Copy link
Contributor Author

We should cherry-pick this into release/6.1. cc: @Steelskin @compnerd

Here is the cherry-pick: #80144

Steelskin added a commit to Steelskin/swift that referenced this pull request Mar 19, 2025
This was removed in swiftlang#79751 but is required in some cases.
Steelskin added a commit to Steelskin/swift that referenced this pull request Mar 21, 2025
These were split out in swiftlang#79751. However, this split is not needed for
these. Furthermore, modulemaps have bugs when it comes to re-exporting
some modules, resulting in missing exports.
@Steelskin Steelskin deleted the fabrice/update-ucrt-modulemap branch March 25, 2025 18:46
DivineDominion added a commit to DivineDominion/swift-cross-ui that referenced this pull request May 10, 2025
stackotter pushed a commit to stackotter/swift-cross-ui that referenced this pull request May 10, 2025
* enable swift build since swiftlang/swift-package-manager#6644 is fixed

* update compnerd/gha-setup-swift to v0.3.0

* use latest Windows and Swift 6.1

There are now fixes to compnerd/swift-build#909 and
swiftlang/swift#79751, swiftlang/swift#80144 is merged.

* enable building WinUIBackend

* specify which target to build to avoid missing Gtk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants