Skip to content

Conversation

alexrp
Copy link
Member

@alexrp alexrp commented Jun 11, 2025

Closes #23971.

Release Notes

When encountering a declaration such as

pub extern "ws2_32" fn closesocket(s: SOCKET) callconv(.winapi) i32;

the Zig compiler will no longer automatically add the import library for ws2_32.dll as a link input. Users will now need to manually link ws2_32 either by passing -lws2_32 on the command line, or by calling b.linkSystemLibrary("ws2_32") in a build script (conditioned on target.os.tag == .windows).

This change was made because the old behavior obscured which DLLs a Windows binary actually depends on. Zig favors explicitness, and users are required to specify link dependencies explicitly for all other targets, making the old Windows behavior inconsistent. Finally, semantic analysis of Zig code having the ability to introduce new link inputs in the compilation pipeline imposed undesirable constraints on the compiler implementation.

Notably, there are two exceptions to this change: ntdll.dll and kernel32.dll. As these DLLs are always loaded into Windows processes anyway, they are also implicitly linked by the compiler. These exceptions should mitigate the ecosystem breakage somewhat.

@alexrp alexrp added breaking Implementing this issue could cause existing code to no longer compile or have different behavior. release notes This PR should be mentioned in the release notes. labels Jun 11, 2025
@alexrp alexrp requested a review from mlugg June 11, 2025 12:48
@alexrp alexrp force-pushed the sema-link-inputs branch 15 times, most recently from 49ca419 to b8fff6c Compare June 14, 2025 17:08
@alexrp alexrp force-pushed the sema-link-inputs branch 3 times, most recently from 202754f to 7226a16 Compare June 22, 2025 09:11
@alexrp alexrp force-pushed the sema-link-inputs branch from 7226a16 to c0dfe19 Compare July 5, 2025 09:50
@alexrp
Copy link
Member Author

alexrp commented Jul 5, 2025

💣

@alexrp alexrp merged commit b461d07 into ziglang:master Jul 5, 2025
10 checks passed
@alexrp alexrp deleted the sema-link-inputs branch July 5, 2025 23:00
Techatrix added a commit to ziglibs/known-folders that referenced this pull request Jul 8, 2025
Techatrix added a commit to ziglibs/known-folders that referenced this pull request Jul 8, 2025
Techatrix added a commit to zigtools/zls that referenced this pull request Jul 8, 2025
Techatrix added a commit to zigtools/zls that referenced this pull request Jul 8, 2025
KurtWagner added a commit to KurtWagner/zlinter that referenced this pull request Jul 8, 2025
```
error: lld-link: undefined symbol: SystemFunction036
```

Requires explicit Advapi32.dll since ziglang/zig#24146
scheibo added a commit to pkmn/engine that referenced this pull request Jul 8, 2025
required after ziglang/zig#24146 for RtlGenRandom used by
crypto.tlcsprng.tlsCsprngFill
KurtWagner added a commit to KurtWagner/zlinter that referenced this pull request Jul 8, 2025
Fixes `error: lld-link: undefined symbol: SystemFunction036` since ziglang/zig#24146
KurtWagner added a commit to KurtWagner/zlinter that referenced this pull request Jul 8, 2025
Fixes `error: lld-link: undefined symbol: SystemFunction036` since ziglang/zig#24146
KurtWagner added a commit to KurtWagner/zlinter that referenced this pull request Jul 8, 2025
Fixes `error: lld-link: undefined symbol: SystemFunction036` since ziglang/zig#24146
KurtWagner added a commit to KurtWagner/zlinter that referenced this pull request Jul 8, 2025
Fixes `error: lld-link: undefined symbol: SystemFunction036` since ziglang/zig#24146
KurtWagner added a commit to KurtWagner/zlinter that referenced this pull request Jul 8, 2025
Fixes `error: lld-link: undefined symbol: SystemFunction036` since ziglang/zig#24146
KurtWagner added a commit to KurtWagner/zlinter that referenced this pull request Jul 8, 2025
Fixes `error: lld-link: undefined symbol: SystemFunction036` since ziglang/zig#24146
@alexrp alexrp removed the release notes This PR should be mentioned in the release notes. label Aug 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking Implementing this issue could cause existing code to no longer compile or have different behavior.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Proposal: Free Sema from worrying about link inputs
3 participants