mingw: Rename mingw32.lib to libmingw32.lib.#23284
Merged
alexrp merged 1 commit intoziglang:masterfrom Mar 18, 2025
alexrp:libmingw32
Merged
mingw: Rename mingw32.lib to libmingw32.lib.#23284alexrp merged 1 commit intoziglang:masterfrom alexrp:libmingw32
mingw: Rename mingw32.lib to libmingw32.lib.#23284alexrp merged 1 commit intoziglang:masterfrom
alexrp:libmingw32
Conversation
LLD expects the library file name (minus extension) to be exactly libmingw32. By calling it mingw32 previously, we prevented it from being detected as being in LLD's list of libraries that are excluded from the MinGW-specific auto-export mechanism. https://github.com/llvm/llvm-project/blob/b9d27ac252265839354fffeacaa8f39377ed7424/lld/COFF/MinGW.cpp#L30-L56 As a result, a DLL built for *-windows-gnu with Zig would export a bunch of internal MinGW symbols. This sometimes worked out fine, but it could break at link or run time when linking an EXE with a DLL, where both are targeting *-windows-gnu and thus linking separate copies of mingw32.lib. In #23204, this manifested as the linker getting confused about _gnu_exception_handler() because it was incorrectly exported by the DLL while also being defined in the mingw32.lib that was being linked into the EXE. Closes #23204.
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.
LLD expects the library file name (minus extension) to be exactly
libmingw32. By calling itmingw32previously, we prevented it from being detected as being in LLD's list of libraries that are excluded from the MinGW-specific auto-export mechanism.https://github.com/llvm/llvm-project/blob/b9d27ac252265839354fffeacaa8f39377ed7424/lld/COFF/MinGW.cpp#L30-L56
As a result, a DLL built for
*-windows-gnuwith Zig would export a bunch of internal MinGW symbols. This sometimes worked out fine, but it could break at link or run time when linking an EXE with a DLL, where both are targeting*-windows-gnuand thus linking separate copies ofmingw32.lib. In #23204, this manifested as the linker getting confused about_gnu_exception_handler()because it was incorrectly exported by the DLL while also being defined in themingw32.libthat was being linked into the EXE.Closes #23204.
Related: #22415