[WIP] core.stdcpp.{exception,typeinfo}: Fix D/C++ symbol conflicts and undefined D vtable entries#2788
[WIP] core.stdcpp.{exception,typeinfo}: Fix D/C++ symbol conflicts and undefined D vtable entries#2788kinke wants to merge 1 commit intodlang:masterfrom
Conversation
src/core/stdcpp/exception.d
Outdated
| version (GenericBaseException) | ||
| { | ||
| /// | ||
| ~this() nothrow; |
There was a problem hiding this comment.
Not declaring the dtor means it gets an implicit one (base class has one), and that one collides with the C++ one. [For MSVC, everything is defined inline in the C++ headers, so the implicit one does the job.]
src/core/stdcpp/exception.d
Outdated
| /// | ||
| ~this() nothrow; | ||
| /// | ||
| override const(char)* what() const nothrow; |
There was a problem hiding this comment.
Required to have the vtable generated on the D side feature the right override in that vtable slot.
| final bool before(const type_info rhs) const; | ||
| final const(char)* name(__type_info_node* p = &__type_info_root_node) const; | ||
| final bool before(const type_info rhs) const nothrow; | ||
| final const(char)* name(__type_info_node* p = &__type_info_root_node) const nothrow; |
There was a problem hiding this comment.
That's actually the wrong signature for VS 2017 (which takes no params), but I guess DMD has to maintain VS 2010 compatibility or whatever.
There was a problem hiding this comment.
We have -extern-std=, so we can version the C++ code according to the C++ version it binds to.
src/core/stdcpp/typeinfo.d
Outdated
| class bad_cast : exception | ||
| { | ||
| this(const(char)* msg = "bad cast"); | ||
| this(const(char)* msg = "bad cast") nothrow { super(msg); } |
There was a problem hiding this comment.
Defined inline in C++ header.
src/core/stdcpp/typeinfo.d
Outdated
| void dtor1(); // consume destructor slot in vtbl[] | ||
| void dtor2(); // consume destructor slot in vtbl[] | ||
| void dtor1() {} // consume destructor slot in vtbl[] | ||
| void dtor2() {} // consume destructor slot in vtbl[] |
There was a problem hiding this comment.
The vtable on the D side needs dummy definitions to put into the first 2 vtable slots.
There was a problem hiding this comment.
O_o ... this is like 12 months out of date. Put an actual destructor.
src/core/stdcpp/typeinfo.d
Outdated
| //~this(); | ||
| override const(char)* what() const; | ||
| this() nothrow {} | ||
| ~this() nothrow; |
There was a problem hiding this comment.
Again, implicit dtor colliding with C++ one when linking in libstdc++.
|
Due to Phobos including druntime, Phobos would need to be adapted, i.e., linking shared Phobos against lib[std]c++ too. |
0b43ad6 to
96b0394
Compare
|
Thanks for your pull request and interest in making D better, @kinke! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + druntime#2788" |
That's a huge issue IMO. We can't link druntime/phobos with the C++ standard library for the sake of those bindings. |
|
It only affects the shared libraries and should thus just be an additional dependency to |
|
I also think it is bad if we need to link with the C++ standard library, even if it is only for the shared libraries. In my opinion that is too high a price to pay for the convenience of having C++ bindings in the D std library. Simply moving the bindings into their own separate package seems much more appropriate. |
|
Pinging @TurkeyMan. |
|
These are the exact 2 modules that I didn't write... I think the need a complete overhaul, but i'll give this patch a better look when I'm home. These functions aren't templates, and we don't want druntime to depend on the C++ runtime. All these functions are basically 1-liners, so we should just mirror the C++ implementation, and not extern. |
5f1e950 to
665b571
Compare
|
Where's this at now? I can't really see from the CI output what's going on here. |
|
Had some time to re-look into this and tried the See the 2nd paragraph in ldc-developers/ldc#3158 (comment) as to why |
|
Yeah, I was gonna say, |
... and missing D vtable entries.
I guess that's solvable by providing him with a finished implementation. ;) - None of my business though. |
|
Revived as #3552 |
Fixes linker errors for the LDC druntime test runner.
Used source refs: libstdc++, libc++, Visual Studio 2017 headers