Summary: OS X: Should extern(D) symbols include another
OS/Version: Mac OS X
--- Comment #0 from klickverbot <c...@klickverbot.at> 2012-06-07 15:30:14 PDT
On OS X, all symbol names by default have a leading underscore. For example,
the C `printf` function is represented as `_printf`. This mangling scheme is
expected at least by the system GDB and several other tools, which strip the
leading underscore when rendering symbol names.
Currently (DMD 2.060 Git), however, extern(D) symbols only have a single
leading underscore as well. For example, `void foo()` in a module called test
becomes `_D4test3fooFZv`, which in turn would be displayed by GDB as
This seems wrong, as the D ABI requires a leading underscore as part of the
symbol name itself. If another underscore was added, it would e.g. the above
function to be correctly displayed in GDB as `_D4test3fooFZv`.
This is not merely a cosmetic issue, as other compilers have to follow the same
My proposal would be to modify the Mach obj backend of DMD to also emit the
additional underscore, instead of modifying LDC (and possibly GDC as well),
1) It would cause the names to be displayed as described in the spec in the
2) The LLVM toolchain adds the underscore automatically, which seems to be a
strong indication of the common practice, and
3) indeed, GCC also emits C++ functions with two underscores, e.g.
__ZN4llvm10error_code7successEv (and the ABI describes the mangling with a
single leading underscore as well).
I already have a set of changes for this ready to be submitted as a pull
request, in case this route is agreed on.
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------