Reggae [was Building C++ modules]

H. S. Teoh hsteoh at quickfur.ath.cx
Tue Aug 13 18:33:41 UTC 2019


On Tue, Aug 13, 2019 at 06:06:48PM +0000, Atila Neves via Digitalmars-d wrote:
> On Tuesday, 13 August 2019 at 09:13:50 UTC, Jacob Carlborg wrote:
[...]
> > I suggest you look into incremental compilation, if you haven't done
> > that already. I'm not talking about recompiling a whole file and
> > relink.  I'm talking incremental lexing, parsing, semantic analyzing
> > and code generation. That is, recompile only those characters that
> > have changed in a source file and what depends on it.
> 
> That's basically what I want.

I suppose in C++, with its overcomplex lexing/parsing, this could
potentially be significant savings.  But based on what Walter has said
about storing binary forms of the source code (which is basically what
you'll end up doing if you really want to implement incremental
compilation in the above sense), it's not much more efficient than
(re)lexing and (re)parsing the entire file.

Plus, the way dmd currently works, the AST is mutated by the various
semantic passes, so you can't really do something like caching the AST
and rewriting subtrees of it based on what changed in the source file,
either.  And even if you could, I'm not sure it will be much more
efficient than just recompiling the entire file. (Assuming reasonable
file sizes, that is -- obviously, if you have a 100,000-line source
file, then you might want to look into refactoring that into smaller
chunks, for many other reasons.)

Templates & CTFE, though, are well-known and acknowledged performance
hogs.  If anything, I'd focus on improving templates and CTFE instead of
worrying too much about incremental compilation in the sense Jacob
describes. (Speaking of which, when is newCTFE landing in master? :-/)


T

-- 
Жил-был король когда-то, при нём блоха жила.


More information about the Digitalmars-d mailing list