Repository navigation
fix: link -lsynchronization via Zig's bundled API set on windows-gnu - #485
Merged
Merged
Conversation
Zig doesn't ship a `synchronization.def` MinGW import library. The
previous workaround copied `api-ms-win-core-synch-l1-2-0.def` to
`synchronization.def` inside Zig's lib directory and silently ignored
failures, so on read-only Zig installs (distro packages, Nix, snap, a
root-owned `/usr/local`, system-wide `ziglang` pip package) the link
failed with:
error: unable to find dynamic system library 'synchronization'
Rewrite `-lsynchronization` to `-lapi-ms-win-core-synch-l1-2-0` in the
linker wrapper instead. That def file ships with every Zig release and
is the API set that actually exports `WaitOnAddress`/`WakeByAddress*`,
so Zig generates the import library itself and nothing has to be
written into its lib directory.
Fixes #484
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018Tpbe6r8eorFnMJuxGNKDz
|
Wow so quick! Thank you very much :D |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #484
Problem
Zig doesn't ship a
synchronization.defMinGW import library. The workaround from #116 copiedapi-ms-win-core-synch-l1-2-0.deftosynchronization.definside Zig's lib directory and discarded the copy result. On any read-only Zig install (distro packages, Nix, snap, root-owned/usr/local, system-wideziglangpip package) nothing gets copied and the link fails with:Because cargo-zigbuild also sets
WINAPI_NO_BUNDLED_LIBRARIES=1, thelibsynchronization.abundled by thewinapi-*-pc-windows-gnucrates isn't available as a fallback either.Fix
Rewrite
-lsynchronizationto-lapi-ms-win-core-synch-l1-2-0in the linker arg filter for windows-gnu targets, and drop the def-copy code. That def file ships with every Zig release and is the API set that actually exportsWaitOnAddress/WakeByAddress*, so Zig builds the import library itself and nothing has to be written into its lib directory.Verification
cargo testpasses.synchronization.defand making Zig 0.16.0'slib-commondirectory read-only, then confirmed thehello-windowsfixture links for bothx86_64-pc-windows-gnuandi686-pc-windows-gnuwith this change.zig cc ... -lapi-ms-win-core-synch-l1-2-0also links onaarch64-windows-gnu.🤖 Generated with Claude Code
https://claude.ai/code/session_018Tpbe6r8eorFnMJuxGNKDz