Bug 14178 – C++ linux name mangling does not handle standard abbreviations for const types

Status
RESOLVED
Resolution
FIXED
Severity
major
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2015-02-14T20:40:54Z
Last change time
2018-06-08T08:44:23Z
Keywords
C++, mangling
Assigned to
No Owner
Creator
Guillaume Chatelet

Comments

Comment #0 by chatelet.guillaume — 2015-02-14T20:40:54Z
There is a name mangling issue in dmd related to the compression of usual stl types when the type is const eg. dmd will mangle 'std::vector<int>::size() const' as '_ZNK3std6vectorIiSaIiEE4sizeEv' where it should be mangled '_ZNKSt6vectorIiSaIiEE4sizeEv'. Note 'std' is being compressed into 'St'. I believe this is coming from https://github.com/D-Programming-Language/dmd/blob/master/src/cppmangle.c#L453 which tests only the non const type pattern. According to http://mentorembedded.github.io/cxx-abi/abi.html#mangling-compression this substitution seems illegal "Note that substitutable components are the represented symbolic constructs, not their associated mangling character strings." This lead to undefined reference when linking.
Comment #1 by chatelet.guillaume — 2015-03-18T09:04:58Z
FYI, I'm working on this one right now.
Comment #2 by dsp — 2015-07-07T10:37:04Z
I think we aren't handling the optional CV-qualifier [0] correctly. [0] http://mentorembedded.github.io/cxx-abi/abi.html#mangle.type
Comment #3 by chatelet.guillaume — 2015-07-07T10:44:46Z
Many things are broken with the current implementation : template substitutions, abbreviations. I'm rewriting the mangling code but it's quite complicated. The test suite is pretty incomplete too, this is the first thing I want to fix.
Comment #4 by dsp — 2015-07-07T11:33:06Z
I have a hacky implementation for that particular issue, but if you rewritting the mangeling code it might hold off.
Comment #5 by chatelet.guillaume — 2015-07-07T12:11:36Z
I expect it to take quite some time for me to have it right. This might be worth submitting you fix meanwhile.
Comment #6 by bugzilla — 2017-02-09T10:02:57Z
(In reply to Guillaume Chatelet from comment #3) > Many things are broken with the current implementation : template > substitutions, abbreviations. It'd be nice to see a list of these.
Comment #7 by chatelet.guillaume — 2017-02-09T12:01:52Z
Comment #8 by bugzilla — 2017-10-26T06:56:25Z
any progress with this?
Comment #9 by chatelet.guillaume — 2017-10-26T09:34:51Z
Unfortunately no. I can't find the time to work on this anymore :(
Comment #10 by pro.mathias.lang — 2018-06-08T07:31:40Z
*** Issue 18957 has been marked as a duplicate of this issue. ***
Comment #11 by github-bugzilla — 2018-06-08T08:44:22Z
Commit pushed to master at https://github.com/dlang/dmd https://github.com/dlang/dmd/commit/cce909b19a1e6b03a182d2a1d488841e2cc64b53 Merge pull request #8341 from TurkeyMan/mangle_std Fix issue 14178 - extern(C++) doesn't mangle 'std' correctly on posix systems merged-on-behalf-of: Mathias LANG <[email protected]>