Comment #0 by dlang-bugzilla — 2015-11-15T02:26:29Z
Bare-bones (no runtime) Win32/64 program:
///////////////////// test.d ////////////////////
import core.sys.windows.windows;
import std.conv : to;
extern(C)
void start()
{
static immutable msg = "Hello!".to!(TCHAR[]);
MessageBox(null, msg.ptr, msg.ptr, 0);
ExitProcess(0);
}
pragma(startaddress, start);
/////////////////////////////////////////////////
Compiles and links fine on Win32 (OMF), but with Win64 (COFF):
C:\Test> dmd -release -betterC -c -m64 test.d
C:\Test> link /SUBSYSTEM:CONSOLE /ENTRY:start test.obj user32.lib kernel32.lib
Microsoft (R) Incremental Linker Version 12.00.30723.0
Copyright (C) Microsoft Corporation. All rights reserved.
test.obj : error LNK2001: unresolved external symbol _D12TypeInfo_Aya6__initZ
test.obj : error LNK2019: unresolved external symbol memcpy referenced in function _D6object14__T7_rawDupTaZ7_rawDupFNaNbANgaZANga
test.obj : error LNK2001: unresolved external symbol _D14TypeInfo_Const6__vtblZ
test.obj : error LNK2019: unresolved external symbol _D10TypeInfo_a6__initZ referenced in function _D6object20__T12_getPostblitTaZ12_getPostblitFNaNbNiNeZDFNaNbNiNfKaZv
test.obj : error LNK2019: unresolved external symbol _d_newarrayU referenced in function _D6object14__T7_rawDupTaZ7_rawDupFNaNbANgaZANga
test.obj : error LNK2019: unresolved external symbol _D6object7__arrayZ referenced in function _D6object19__T11_doPostblitTaZ11_doPostblitFNaNbNiNfAaZv
test.obj : error LNK2001: unresolved external symbol _D10TypeInfo_k6__initZ
test.obj : error LNK2019: unresolved external symbol _D11TypeInfo_Aa6__initZ referenced in function _D6object14__T7_rawDupTaZ7_rawDupFNaNbANgaZANga
test.obj : error LNK2019: unresolved external symbol _D6object8TypeInfo8postblitMxFPvZv referenced in function _D6object20__T12_getPostblitTaZ12_getPostblitFNaNbNiNeZDFNaNbNiNfKaZv
test.exe : fatal error LNK1120: 9 unresolved externals
It looks like DMD generates pdata sections which refer (and thus pull in) std.conv.to (and all its dependencies), even though it is never called at runtime (only compilation).
Maybe the -betterC switch can disable pdata sections.
Comment #1 by dlang-bugzilla — 2015-11-15T03:09:37Z
Curiously, linking succeeds with UniLink. Lowering priority.
Comment #2 by robert.schadek — 2024-12-13T18:45:47Z