[qtbase] Fix LNK2005 in consumers defining QT_DISABLE_DEPRECATED_BEFORE#50859
[qtbase] Fix LNK2005 in consumers defining QT_DISABLE_DEPRECATED_BEFORE#50859drdanz wants to merge 1 commit intomicrosoft:masterfrom
Conversation
7854bfc to
1600466
Compare
401d034 to
b1e34da
Compare
|
Link to upstream ticket? Is this fixed in 6.11? |
On Windows static builds, compat/removed_api.cpp emits strong symbol definitions for deprecated APIs. If consumers compile with a higher QT_DISABLE_DEPRECATED_BEFORE value, those same functions become inline definitions in consumer translation units, causing LNK2005 duplicate symbol errors. Fix this in qtcoreexports.h (generated from cmake/modulecppexports.h.in) by adding a dedicated branch for static consumers that always makes QT_CORE_INLINE_SINCE, QT_CONSTEXPR_INLINE_SINCE and QT_CORE_INLINE_IMPL_SINCE produce non-inline.
b1e34da to
76470fe
Compare
No upstream ticket yet, or at least I haven't found one, and I haven't opened one yet, because I'm still trying to figure out if this is the right fix. I don't think it is fixed in 6.11, but I haven't fully investigated. |
|
#50686 rebased over this PR passed all CI checks, therefore this seems to be working properly |
|
@drdanz please submit a ticket upstream with these fixes |
|
We'll wait for the PR to be merged upstream. |
|
Apparently, setting a different Therefore I'm afraid the patch won't get merged upstream. This obviously does not work well with vcpkg sharing a single compiled library with all dependencies. I still believe that the patch is correct, it simply disables building the "disabled" deprecated APIs in the consumer (in static builds only), that are currently compiled because they are inlined. The function comments clearly say that "static builds treat everything as part of the library, so they never inline" therefore, for static consumers they should never be compiled, and should never be inlined. The alternative to this patch is probably to patch ECM (and any other dependency that should have the same problem) to not set |
On Windows static builds, compat/removed_api.cpp emits strong symbol definitions for deprecated APIs. If consumers compile with a higher QT_DISABLE_DEPRECATED_BEFORE value, those same functions become inline definitions in consumer translation units, causing LNK2005 duplicate symbol errors.
Fix this in qtcoreexports.h (generated from cmake/modulecppexports.h.in) by adding a dedicated branch for static consumers that always makes QT_CORE_INLINE_SINCE, QT_CONSTEXPR_INLINE_SINCE and QT_CORE_INLINE_IMPL_SINCE produce non-inline.
./vcpkg x-add-version --alland committing the result.