August 02, 2005
DMD has some issues with template code compiled into libraries.  Specifically, if that template code uses DBC and the library was compiled with the -release flag set, any code building against that template module in debug mode will generate linker errors.  From what I can tell, it seems that DMD generates function calls for contract validation.  These functions are not generated during the library build because of the -release flag, but as templates as dynamically generated, any end-user application building in debug-mode will attempt to link to these nonexistent functions.

I've found a temporary fix for Ares that seems to work just fine for all-template modules: build those particular files in debug mode and link the obj files into the library.  Since templates are generated dynamically, all the obj file will contain are the DBC functions--the actual template functions will be generated dynamically using whatever flags the user specifies.  So the only overhead is the definition of these DBC functions in the static library.  The obvious problem is that these modules can only contain template code, as we want everything else to build using the standard library options.

I'm not sure how best to handle this, but perhaps DMD could offer a flag to generate contract functions for templates even if -release is set?  For the moment, I don't mind splitting up my modules based on content, but this isn't a long-term solution.


Sean


August 02, 2005
It's probably a good idea to have a fully debug version of the library and a fully release version of the library. If your license allows for it, it is a great thing (also makes it easier when debugging to know if it's a library fault or your program fault that causes the segfault, heh).
-JC
August 02, 2005
In article <dcoooc$2l0d$1@digitaldaemon.com>, Joshua Cearley says...
>
>It's probably a good idea to have a fully debug version of the library and a fully release version of the library. If your license allows for it, it is a great thing (also makes it easier when debugging to know if it's a library fault or your program fault that causes the segfault, heh).

True enough.  But should this be necessary in order to compile?  Also, DMD is that it auto-links "phobos.lib," so it would have to be changed to link in a "phobos_debug.lib" if the -release flag is not specified.


Sean


Top | Discussion index | About this forum | D home