Our template emission strategy is broken

David Nadlinger via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 11 06:55:19 PST 2015


On Wednesday, 11 November 2015 at 14:31:54 UTC, Martin Nowak 
wrote:
> OK let's clarify the terminology first.
>
> separate compilation: -c single_source.d
> incremental compilation: -c source_a.d source_b.d (as well as 
> -c -ofsingle.o source_a.d source_b.d)
> library compilation: -lib all_pkg_sources
>
> Separate compilation works fine (and predictable) but is slow 
> (due to reparsing), you do need to link all objects from all 
> your sources though.
> Choosing this strategy makes sense to mitigate OOM issues.
>
> Incremental compilation doesn't work b/c templates are easily 
> emitted into different objects, causing all sorts of linker 
> errors. It works somewhat when you delete all objects and 
> recompile all of them.
>
> Library compilation works and recompiles a whole library 
> whenever something changes.
> It's fast b/c modules/semantic can be reused by the compiler.
> Choose this strategy unless your running into OOM issues.

That terminology seems a bit misleading for discussing the 
problem at hand. There is nothing incremental about compiling 
per-package with a single .o file, and it is in fact rather 
similar to what you call "library compilation". As noted on 
Bugzilla, the particular template instantiation bug that was 
plaguing Weka occurs with "-lib" just the same as it does with 
"-c -osingleobj.o".

  — David


More information about the Digitalmars-d mailing list