-
-
Notifications
You must be signed in to change notification settings - Fork 606
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
Fix issue 14086 - Invalid extern C++ name for constructor #8265
Conversation
Thanks for your pull request and interest in making D better, @TurkeyMan! 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 references
Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#8265" |
Please rename the commit messaged to ensure the dlang-bot establishes a relationship between this PR and the bugzilla issue. I usually make the PR title and commit message the same. |
Adding the "Vision" label as this is congruent with item 4 of Vision 2018H1
|
It's in the PR header... that is included in the comment when pulled. |
99002c6
to
a874b6f
Compare
Why is DAutoTest red? I had this problem last PR too... |
It complains about your terse changelog entry:
|
When calling an extern(C++) ctor implemented in D from C++, one needs to be aware that the ctor assumes the instance is pre-initialized with Wrt. destruction, the ABIs diverge when it comes to destructing by-value arguments - for C++, the caller destructs it (and passes a ref to the callee), while D compilers move the argument and let the callee destruct the param. This also happens when using |
@kinke I've been desperately searching for this document!! It's really hard to start to address these issues with no information available. |
Next port of call is to attempt to make the behaviours of |
At least for MSVC++, I didn't find anything official either (wrt. C++ ABI; the platform/C ABI is documented); I just 'reverse-engineered' the ABI details by studying the C++ assembly for various test structs. I did so recently for DIP 1014 (postMove hook; => ldc-developers/ldc#2702), that's how I know about x86_64 POSIX, and today's MSVC tests led to ldc-developers/ldc#2706. ;) |
But for D? The details for D should be published somewhere. |
@kinke Are you on IM? I have a zillion questions I need quick answers to :/ |
It’s usually quite difficult to find documentation for these kinds of things. You usually find out when implementing a compiler. |
No surprise there. The original VC++ was based on the ABI used by Zortech C++ :-) We sold a lot of Zortech C++ compilers into Microsoft before they started implementing C++. The COM ABI is directly the ABI used by ZTC++ for virtual functions. @kinke is quite right that not only is there no document for this, when such documents exist they tend to be all lies. The only reliable way is to write test cases, compile them, and examine the object file. BTW, I didn't realize that Posix does these things differently. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approving despite the problems @kinke reported. At least matching the mangling is a good first step.
Thanks. My next struggle is trying to work out how __xdtor is fabricated, and mangle THAT symbol as C++ dtor instead of the explicit dtor. __xdtor does what C++ expects. |
@TurkeyMan: That's here. |
Huh... I don't understand why semaphore says it failed? |
Okay, seriously... after how ever many hours waiting for the CI to build, then it fails. |
Destructor mangles correctly, but constructor does not.
This has wasted a lot of time with people trying to understand link problems with
extern(C++)
.As with the dtor, the ABI appears to be perfectly compatible... so, mangling correctly.
Also, fixed the virtual-ness mangling of the destructor. Windows dtor mangling only half-worked.