[Issue 15342] New: DMD outputs all functions as COMDAT on OSX
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Nov 15 20:39:28 PST 2015
https://issues.dlang.org/show_bug.cgi?id=15342
Issue ID: 15342
Summary: DMD outputs all functions as COMDAT on OSX
Product: D
Version: D2
Hardware: All
OS: Mac OS X
Status: NEW
Severity: major
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: nicolas.jinchereau at gmail.com
DMD emits all functions as COMDAT on OSX, even non-template functions.
The offending code in DMD:
https://github.com/D-Programming-Language/dmd/blob/a907543f21590b2ae56eb6c41d61e24cb25a1dc2/src/glue.c#L866-L870
To verify the problem:
<a.d> and <b.d> with same code
import std.stdio;
extern(C) void a() { printf("foo"); }
<a.cpp> and <b.cpp> with same code
#include <stdio.h>
extern "C" void a() { printf("foo"); }
Compiling with DMD, this works (it shouldn't)
dmd a.d -c -ofa.o
dmd b.d -c -ofb.o
dmd a.o b.o -shared
Compiling with GCC, this fails (as it should)
gcc a.cpp -c -oa.o
gcc b.cpp -c -ob.o
gcc a.o b.o -shared
duplicate symbol _a in:
a.o
b.o
ld: 1 duplicate symbol for architecture x86_64
------------
I've tried removed the special case in glue.c(cited above), but when I try to
link an executable, I get this error:
ld: GOT load reloc does not point to a movq instruction in
'_D4core7runtime19defaultTraceHandlerFPvZ16DefaultTraceInfo7fixlineMxFAxaNkKG4096aZAxa'
from built/lib/libphobos2.a(runtime_1f3_792.o) for architecture x86_64
--
More information about the Digitalmars-d-bugs
mailing list