Skip to content

Backport build and Windows fixes for 5.9 #794

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 6 commits into from
Jun 8, 2023

Conversation

compnerd
Copy link
Member

@compnerd compnerd commented Jun 6, 2023

Backport a number of changes from main to the 5.9 release

  • Windows fixes
    • explicitly specify the callback calling convention to prevent a miscoompilation
    • fix a semaphore initialisation issue on Windows
  • Build Changes
    • Use an overlay to use the correct modulemap for dispatch that allows us to avoid a build race condition and fix building dispatch with an installed copy of libdispatch

tristanlabelle and others added 6 commits June 6, 2023 10:32
Avoid polluting the build directory a small amount given that we can use
`-fmodule-map-file=` for the C/C++ build of libdispatch.  Unfortunately,
for the Swift build, we need to have the file copied over due to the
umbrella header resolution.

Hopefully this reduces some of the race conditions that we have seen in
the build.

Thanks to @dgregor for reminding me of the flag!
Use a VFS overlay to avoid polluting the source tree.
There is a subtle difference between libdispatch built dynamically and
statically: DispatchStubs.  We erroneously emit ObjC runtime calls into
the build and the stubs provides a shim to provide a definition on
non-ObjC runtime enabled targets.  When built dynamically, this is
internalised and distributed as part of dispatch.dll/libdispatch.so,
however when built statically, the consumer is responsible for linking
against DispatchStubs.  The modulemap reflects this and we need to
ensure that we correctly provide that modulemap.

Thanks to @MaxDesiatov for the help with debugging and testing a fix for
this!

Fixes: rdar://23335318
The `WaitChain*` functions require linking against AdvAPI32.
This function is the initializer for the semaphore.  The seamphore
storage itself may be stack allocated (or heap allocated) but without
guarantee of 0-initialisation.  As a result, the subsequent CAS for the
atomic replacement will fail silently, leaving the previously non-zero
value in place, indicating that the value is a valid handle.  This would
fail randomly and would ultimately result in a crash in the
`CloseHandle` call associated with the clean up.

This issue was identified by SwiftLint on Windows.
@compnerd compnerd requested review from etcwilde and rokhinip June 6, 2023 17:35
@compnerd
Copy link
Member Author

compnerd commented Jun 6, 2023

@swift-ci please test

@compnerd
Copy link
Member Author

compnerd commented Jun 6, 2023

CC: @bnbarham

Copy link
Contributor

@etcwilde etcwilde left a comment

Choose a reason for hiding this comment

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

Looks good to me.

Cherry-Picks:

Explanation: Prevents the dispatch build from copying generated files into the source directory during the build. The copying results in an occasional race in CI, causing a spurious failure. Also fixed a calling-convention mismatch on Windows.

Risk: The risk to Darwin platforms is effectively nothing since this repository is not built for or shipped on Darwin.

Reviewed By: @etcwilde @MaxDesiatov @compnerd @tristanlabelle @bnbarham

@compnerd
Copy link
Member Author

compnerd commented Jun 6, 2023

Please test with following PRs:
swiftlang/swift-corelibs-xctest#446

@swift-ci please test

@compnerd compnerd merged commit 731d5c6 into swiftlang:release/5.9 Jun 8, 2023
@compnerd compnerd deleted the 5.9-fixes branch June 8, 2023 01:01
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.

3 participants