Bug 11199 – OS X DMD outputs functions to S section, erroneously prevents duplicate symbol error

Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
Mac OS X
Creation time
2013-10-08T11:29:00Z
Last change time
2015-11-16T04:40:44Z
Assigned to
nobody
Creator
luis

Comments

Comment #0 by luis — 2013-10-08T11:29:19Z
On Linux the following gives out a "multiple definition" error, as expected and desired: c/test.c: void dotest(void) { printf("C\n"); } d/test.d: extern(C) void dotest() { writeln("D"); } On OS X no error is flagged, and the C function is always called, irrespective of which order I specify the .o files to link. The cause seems to be OS X DMD (v.2.063.2) outputting the function to the S section: On Ubuntu: $ nm d/test.o | grep dotest; echo "--"; nm c/test.o | grep dotest 0000000000000000 T dotest -- 0000000000000000 T dotest On OS X: $ nm d/test.o | grep dotest; echo "--"; nm c/test.o | grep dotest 0000000000001490 S _dotest <-- not in text section, as in Linux -- 0000000000000000 T _dotest 0000000000000060 S _dotest.eh When using LDC on OS X the linking fails, as expected and desired: duplicate symbol _dotest in: d/test.o c/test.o ld: 1 duplicate symbol for architecture x86_64 The LDC .o sections are the same as the C version: $ nm d/test.o | grep dotest; echo "--"; nm c/test.o | grep dotest 0000000000000000 T _dotest 00000000000000b0 S _dotest.eh -- 0000000000000000 T _dotest 0000000000000060 S _dotest.eh
Comment #1 by nicolas.jinchereau — 2015-11-16T04:40:44Z
*** This issue has been marked as a duplicate of issue 15342 ***