On Thursday, 24 August 2017 at 16:32:32 UTC, Jonathan Marler
wrote:
On Thursday, 24 August 2017 at 15:56:32 UTC, H. S. Teoh wrote:
On Thu, Aug 24, 2017 at 03:53:05PM +0000, Jonathan Marler via
Digitalmars-d wrote:
Wanted to get peoples thoughts on this. The idea is to have
a way to tell the compiler (probably with a command line
option) that you'd like to "compile imported modules".
[...]
Isn't this what rdmd already does?
T
That is one thing that rdmd does (as I mentioned in the
original post).
I just looked through the rdmd code
(https://github.com/dlang/tools/blob/master/rdmd.d) and it
looks like it invokes the compiler using "dmd -v" to get the
list of modules and then invokes the compiler again with the
modules it found to perform the full compile. So my original
thought that the logic to find modules is duplicated was
incorrect. Instead we just pay a performance hit to get the
correct list of imports since running "dmd -v" seems to take
almost as long as the actual compile itself. So this method
comes close to doubling the time it takes to compile than if
the feature was implemented in the compiler itself.
In any case, the idea is to allow the compiler to resolve this
on it's own without help from rdmd. This would remove the need
to invoke the compiler twice, once to find the imports and once
to compile. It would also allow some projects/applications
that don't use rdmd to take advantage of this feature, this may
or may not include dub (not sure on that one).
rdmd is really bad in terms of performance. If you call a single
D file with rdmd, it will always compile it twice. There was an
attempt to fix this (https://github.com/dlang/tools/pull/194),
but this has been reverted as it introduced a regression and no
one had time to look at the regression.
Moving rdmd into DMD has been on the TODO list for quite a while
and there is a consensus that the performance overhead if rdmd
isn't nice. However, IIRC there was no clear consensus on how the
integration should happen. I recall that the plan was to do try
this with "dmd as a library", but I'm not sure whether that's
really feasible ATM.