Skip to content

Commit cbfdb47

Browse files
author
Dentcho Bankov
committed
Fix for 3795.
Prepend each argument in D_LINKER_ARGS with "-Wl," when using GDMD. The above is needed because the arguments reported by GDMD are what is passed to COLLECT2 while D_LINKER_ARGS are later passed to CXX. The problem with that is that without "-Wl," prefix the -Bstatic and -Bdynamic arguments before and after -lgphobos and -libgdruntime are dropped. And that is a problem because without these the produced LDC is linked dynamically to libgphobos and libgdruntime so these have to be available whereever LDC is used. Once libgphobos and libgdruntime were linked statically several symbol conflicts were revealed which are fixed by moving the offending symbols within "version (LDC)" blocks.
1 parent 054df3a commit cbfdb47

File tree

2 files changed

+29
-17
lines changed

2 files changed

+29
-17
lines changed

cmake/Modules/ExtractDMDSystemLinker.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ if("${D_COMPILER_ID}" STREQUAL "GDMD")
6969
set(D_LINKER_ARGS)
7070
foreach(arg ${linker_line})
7171
if("${arg}" MATCHES ^-L.*|^-l.*|^-B.*)
72-
list(APPEND D_LINKER_ARGS "${arg}")
72+
list(APPEND D_LINKER_ARGS "-Wl,${arg}")
7373
endif()
7474
endforeach()
7575
else()

dmd/root/rmem.d

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,12 @@ static if (OVERRIDE_MEMALLOC)
220220
// That scheme is faster and comes with less memory overhead than using a
221221
// disabled GC alone.
222222

223-
extern (C) void* _d_allocmemory(size_t m_size) nothrow
223+
version (LDC)
224224
{
225-
return allocmemory(m_size);
225+
extern (C) void* _d_allocmemory(size_t m_size) nothrow
226+
{
227+
return allocmemory(m_size);
228+
}
226229
}
227230

228231
private void* allocClass(const ClassInfo ci) nothrow pure
@@ -242,13 +245,16 @@ static if (OVERRIDE_MEMALLOC)
242245

243246
extern (C) void* _d_newitemU(const TypeInfo ti) nothrow;
244247

245-
extern (C) Object _d_newclass(const ClassInfo ci) nothrow
248+
version (LDC)
246249
{
247-
const initializer = ci.initializer;
250+
extern (C) Object _d_newclass(const ClassInfo ci) nothrow
251+
{
252+
const initializer = ci.initializer;
248253

249-
auto p = mem.isGCEnabled ? allocClass(ci) : allocmemoryNoFree(initializer.length);
250-
memcpy(p, initializer.ptr, initializer.length);
251-
return cast(Object) p;
254+
auto p = mem.isGCEnabled ? allocClass(ci) : allocmemoryNoFree(initializer.length);
255+
memcpy(p, initializer.ptr, initializer.length);
256+
return cast(Object) p;
257+
}
252258
}
253259

254260
version (LDC)
@@ -262,19 +268,25 @@ static if (OVERRIDE_MEMALLOC)
262268
}
263269
}
264270

265-
extern (C) void* _d_newitemT(TypeInfo ti) nothrow
271+
version (LDC)
266272
{
267-
auto p = mem.isGCEnabled ? _d_newitemU(ti) : allocmemoryNoFree(ti.tsize);
268-
memset(p, 0, ti.tsize);
269-
return p;
273+
extern (C) void* _d_newitemT(TypeInfo ti) nothrow
274+
{
275+
auto p = mem.isGCEnabled ? _d_newitemU(ti) : allocmemoryNoFree(ti.tsize);
276+
memset(p, 0, ti.tsize);
277+
return p;
278+
}
270279
}
271280

272-
extern (C) void* _d_newitemiT(TypeInfo ti) nothrow
281+
version (LDC)
273282
{
274-
auto p = mem.isGCEnabled ? _d_newitemU(ti) : allocmemoryNoFree(ti.tsize);
275-
const initializer = ti.initializer;
276-
memcpy(p, initializer.ptr, initializer.length);
277-
return p;
283+
extern (C) void* _d_newitemiT(TypeInfo ti) nothrow
284+
{
285+
auto p = mem.isGCEnabled ? _d_newitemU(ti) : allocmemoryNoFree(ti.tsize);
286+
const initializer = ti.initializer;
287+
memcpy(p, initializer.ptr, initializer.length);
288+
return p;
289+
}
278290
}
279291

280292
// TypeInfo.initializer for compilers older than 2.070

0 commit comments

Comments
 (0)