www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - Windows: Link with /MT or /MTd

reply "Johan Engelen" <j j.nl> writes:
Hi all,
   Currently, we link both the release and debug versions of 
phobos and druntime with the debug version of MSVC's LIBC 
multithreaded: LIBCMTD.lib.
Actually, while reading CMakeLists.txt, I see that the release 
and debug runtime libs are compiled with the same C-flags and 
LD-flags. Only the D flags are different.
Is this intentional, or would we rather like to link with 
LIBCMT.lib in release mode?

To help the discussion, here some observations (it surprised me):
ldc2 test.d           --> links with phobos2-ldc.lib
ldc2 -d-debug test.d  --> links with phobos2-ldc.lib
ldc2 -g test.d        --> links with phobos2-ldc-debug.lib
So "-g" selects between runtime debug/release runtime versions, 
and "-d-debug" sets the "debug condition" to true (see 
http://dlang.org/version.html)

thanks,
  Johan
Apr 06 2015
next sibling parent "Johan Engelen" <j j.nl> writes:
Note that druntime 2.067 explicitly links with the release 
version libcmt.lib  (druntime/src/rt/monitor_.d(58): "pragma(lib, 
"libcmt.lib");").

LDC-merge2.067 does not link executables on Windows because of a 
library conflict due to that pragma. LDC does not need that 
pragma, and commenting out that pragma avoids the conflict.
Apr 06 2015
prev sibling parent "Kagamin" <spam here.lot> writes:
On Monday, 6 April 2015 at 15:38:57 UTC, Johan Engelen wrote:
 ldc2 test.d           --> links with phobos2-ldc.lib
 ldc2 -d-debug test.d  --> links with phobos2-ldc.lib
 ldc2 -g test.d        --> links with phobos2-ldc-debug.lib
I'd say, that's expected: -debug is for source-level debugging, that's why it's not reflected in the kind of generated code; -g is codegen-level debugging, that's why it links with appropriately compiled runtime.
Apr 06 2015