D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 11199 - OS X DMD outputs functions to S section, erroneously prevents duplicate symbol error
Summary: OS X DMD outputs functions to S section, erroneously prevents duplicate symbo...
Status: RESOLVED DUPLICATE of issue 15342
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: All Mac OS X
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-10-08 11:29 UTC by Luís Marques
Modified: 2015-11-16 04:40 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Luís Marques 2013-10-08 11:29:19 UTC
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 forsaken 2015-11-16 04:40:44 UTC

*** This issue has been marked as a duplicate of issue 15342 ***