New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
wxSimplebook causes link conflict #22805
Comments
Does exporting |
Thanks for reporting this, it's clearly a problem, but I'm not so sure it's This class is pretty weird in general because it exports its individual members instead of (in spite of?) not being exported itself. Unfortunately 8738110 doesn't provide much explanation, In any case we clearly need some good tests for this as this isn't the first time this gets broken, judging from the history of the code. |
Yes, the same would happen. However, the hack here is if you #include say, "splitter.h" which already uses
I actually had a similar issue with I'm not sure what the cleanest fix would be but it would require declaring template specialization in a header somewhere as extern sort of like
(Note I haven't had a chance to play with it, I hotglued/reverted problem in our CI for now) |
I've tried reproducing this bug but couldn't: after adding #pragma comment(lib, "wxmsw33u_aui")
wxSimplebook sb;
wxAuiNotebook ab; to the minimal sample (and the corresponding includes at the top), I can still link without problems using
What am I missing here? |
I'm not 100% sure what the link behavior breakage is at the moment, it might have to do with kicad building multiple object libraries under cmake which get linked into DLLs and that's where it blows up. |
I'd like to fix this in 3.2.2 if possible, but it would be great to have a way to reproduce this in order to do it. |
Yea It's been killing me to get around to this. I think the issue comes up when you use wxSimplebook in a static module and that gets pulled in by linker again into an executable or shared library that also used wxSimplebook directly within themselves. The result I believe is both link objects contain wxSimplebook that isn't tied to a singular extern and so have separate template expanded copies. So I would need to set that up as a test |
I think the solution might be as simple as creating some AFAICS this should force instantiating this class only once inside the DLL and so solve the problem. Unfortunately I am not sure if this is really going to be ABI-compatible (in fact I'm almost sure it's not), but we could at least fix this in master like this. But, again, I can't even test this myself, so it'd be great if you could please do it (I could make the PR for you to test if this would help). |
Sorry, not sure why do you need MSBuild? If you can just give/show me the minimum setup needed to see it, I can build myself. Or, as I wrote above, if can at least test my proposed fix, it could also be enough. TIA! |
Well, kicad does not make a good repro case unless you have say....a Ryzen 5900X or higher in processor, if you want the build time to be less than 12 hours (all our dependencies together are absolute monsters) :D Here, I finally wrestled it to work under a standard msbuild project within the wxwidgets source, dump the Use the DLL Debug, x64 config. |
Thanks, I can confirm that my proposed fix fixes your test case (I still get some warnings for Please let me know if you can test this with KiCad and if you still have this problem with it. TIA! |
Unfortunately because of the way we build kicad usually with vcpkg, it's a little difficult for small things to patch. I have confidence your change fixes it, since this purely has to do with the child template expansion of wxNavigationEnabled being generated outside of wx since wxSimplebook lacked any export declaration as a hint for MSVC to instead look for it during linkage. Now that you just threw it into a dummy base class that is exported, it'll be fine even if wxSimplebook itself isn't exported. |
OK, I'll merge this into master soon. I'm afraid I don't see how can we fix it without breaking the ABI in 3.2, so we'll have to leave it there. |
Well, a dumb idea is throw a #include wxListbook in the simplebook header. This way MSVC should see the exported wxListbook which also includes the same wxNavigationEnabled as a hint that the template expansion is being exported |
This is an uglier workaround than the one applied in dbbf509 (Fix link when using wxSimplebook both directly and indirectly, 2023-01-29) to master but has the advantage of preserving ABI-compatibility. See wxWidgets#22805.
If this actually fixes the problem, we should indeed do this, thanks for the idea! |
This is a linker bug introduced in 3.2.0, wxSimplebook was derived from
wxNavigationEnabled<wxBookCtrlBase>
instead ofwxBookCtrlBase
.But per the comment above it
The problem is other classes like wxAuiNotebook use wxNavigationEnabled
class WXDLLIMPEXP_AUI wxAuiNotebook : public wxNavigationEnabled<wxBookCtrlBase>
thus the wx DLLs end up with their own templated version of
wxNavigationEnabled<wxBookCtrlBase>
exported.But because wxSimplebook is an inline class, your application will also generate its own
wxNavigationEnabled<wxBookCtrlBase>
expansion.The result is a conflict if you use wxSimplebook and one of the other wx book controls.
The text was updated successfully, but these errors were encountered: