[fix] clang-linux - generate Windows import libraries when linking shared libraries - #610
Open
uilianries wants to merge 2 commits into
Open
[fix] clang-linux - generate Windows import libraries when linking shared libraries#610uilianries wants to merge 2 commits into
uilianries wants to merge 2 commits into
Conversation
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Signed-off-by: Uilian Ries <uilianries@gmail.com>
Contributor
Author
|
Appveyor failed due to a timeout, not because of this patch. |
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.
Proposed changes
Hello all! 👋
When building a shared library with
toolset=clang(routed toclang-linux) andtarget-os=windows, plus MSYS2clang/mingw64toolchain, the linker only ever produces the.dll. No import libraries are produced, so nothing else can link against it:However, the same source built with
toolset=gccon the same MSYS2 host, which correctly produces both:I used Boost 1.92.0 to validate the case, but https://github.com/bfgroup/b2 main branch keeps the same behavior for this part.
You can see my full build logs here with these explained scenarios:
I only observe such a problem with shared, for static, it works fine.
Doing a quick check in clang-linux.jam, I can see:
The
clang-linuxclones its generators fromgcc, but this line excludesgcc.mingw.linkandgcc.mingw.link.dll, which are conditioned on<target-os>windowsand declareIMPORT_LIBas an output.Still, both
clang-linux.linkandclang-linux.link.dllsupport producing an import library. Only the generator that would request the second output was missing.This PR removes
gcc.mingw.linkandgcc.mingw.link.dllfrom this exclusion list (I didn't test/consider Cygwin), so giving back the possibility of producing import libraries.After applying this patch directly in Boost 1.92.0 source and rebuilding Boost.Atomic with the same setup, both files are produced as expected. Please see my full build log: boost-1.92.0-windows-msys2-clang-shared-patched.log
I also updated
is_implib_expected()(it no longer excludesclang/clang-linuxontarget-os=windows) and mocks to expect--out-impliband link the exe against the import lib instead of the raw.dll.Steps to Reproduce
On Windows, with MSYS2 clang/mingw64 listed on PATH:
Environment
B2: 5.5.3 (OS=NT, jobs=12)
OS: Windows 10
Compiler: clang version 20.1.3 - Target: x86_64-w64-windows-gnu - Thread model: posix
Types of changes
What types of changes does your code introduce?
Put an
xin the boxes that applyChecklist
Put an
xin the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.Further comments
I noted this logic is present in clang-linux.jam for ages (2010), not sure if there was a limitation in the past, but for Boost 1.92.0 seems to be working in this scenario with MSYS2 + Clang.