digitalmars.D.learn - Why does RDMD evaluate templates twice?
- Andrej Mitrovic (20/29) May 18 2011 This is a very odd behavior I've been seeing for quite a while now with ...
- Nick Sabalausky (24/59) May 18 2011 When you run RDMD, it invokes DMD twice: The first time is *just* to fin...
- Nick Sabalausky (2/8) May 18 2011
- Nick Sabalausky (2/13) May 18 2011
- Nick Sabalausky (2/16) May 18 2011
- Andrej Mitrovic (1/1) May 18 2011 Yeah I see it now, thanks Nick. Thought it was a bug. :]
This is a very odd behavior I've been seeing for quite a while now with RDMD. DMD doesn't recreate this behavior. Take this module: module test; template Foo(T) { pragma(msg, "test"); } alias Foo!int a; // alias Foo!double b; void main() { } Notice one of the instantiations is commented out. $ is my prompt, > are the printed results: $ rdmd test.dtest test$ rdmd test.dtestThe first time I run it, it instantiates (or evaluates) the template twice. The second time I run rdmd, with no changes to the module, it only evaluates the template once. Now I comment out the second instantiation in the module and try again: $ rdmd test.dtest test test test$ rdmd test.dtest testQuite weird. I'm thinking this could cause some kind of slowdown. Anyone have a clue what's going on here?
May 18 2011
"Andrej Mitrovic" <none none.none> wrote in message news:ir1tv8$12ch$1 digitalmars.com...This is a very odd behavior I've been seeing for quite a while now with RDMD. DMD doesn't recreate this behavior. Take this module: module test; template Foo(T) { pragma(msg, "test"); } alias Foo!int a; // alias Foo!double b; void main() { } Notice one of the instantiations is commented out. $ is my prompt, > are the printed results: $ rdmd test.dWhen you run RDMD, it invokes DMD twice: The first time is *just* to find out all the dependencies. Then it checks the dependencies to see if the executable needs to be rebuilt. If so, it passes all the dependencies to DMD to compile for real. You can run it like this to see the DMD-invoking commands RDMD makes: $ rdmd --chatty test.d If you've changed test.d (and anything it depends on), then you'll see it runds dmd twice, each time with a different command. If you haven't changed test.d (or anything it depends on), then it'll only run the first command: the one to find the dependencies. You can see it without templates, too: // test.d import std.stdio; pragma(msg, "Compile Time"); void main() { writeln("Runtime"); }test test$ rdmd test.dtestThe first time I run it, it instantiates (or evaluates) the template twice. The second time I run rdmd, with no changes to the module, it only evaluates the template once. Now I comment out the second instantiation in the module and try again: $ rdmd test.dtest test test test$ rdmd test.dtest testQuite weird. I'm thinking this could cause some kind of slowdown. Anyone have a clue what's going on here?rdmd --chatty test.ddmd -v -o- "test.d" >test.d.deps Compile Time dmd -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E84 689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07B F23""test.d"Compile TimeRuntime> rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile TimeRuntime
May 18 2011
"Nick Sabalausky" <a a.a> wrote in message news:ir2750$1hd2$1 digitalmars.com...rdmd --chatty test.ddmd -v -o- "test.d" >test.d.deps Compile Time md -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E84 689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07BFF23""test.d CompileTimeRuntime> rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompileTimeRuntime>That got messed up, trying again (and note that I'm on windows, hence the">" prompt):// test.dimport std.stdio;pragma(msg, "Compile Time");void main(){ writeln("Runtime");}> rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile Timedmd -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E84 689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F60 E847689B6FC07BFF23" "test.d"Compile TimeRuntime> rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile TimeRuntime
May 18 2011
"Nick Sabalausky" <a a.a> wrote in message news:ir27ao$1hob$1 digitalmars.com..."Nick Sabalausky" <a a.a> wrote in message news:ir2750$1hd2$1 digitalmars.com...rdmd --chatty test.ddmd -v -o- "test.d" >test.d.deps Compile Time d -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E84 689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07BFF23""test.d"Com ileTimeRuntime>rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompileTimeRuntime>Thatgot messed up, trying again (and note that I'm on windows, hence the">"prompt):// test.dimport std.stdio;pragma(msg, "Compile Time");voidmain(){ writeln("Runtime");}> rdmd --chatty test.ddmd -v -o- "test.d">test.d.depsCompileimedmd -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E84 689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F60 E847689B6FC07BFF23" "test.d"Compile TimeRuntime>rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile TimeRuntime>What the hell is wrong with my NG client? One more try:// test.dimport std.stdio;pragma(msg, "Compile Time");void main(){ writeln("Runtime");}> rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile Timedmd -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E84 689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F60 E847689B6FC07BFF23" "test.d"Compile TimeRuntime> rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile TimeRuntime
May 18 2011
"Nick Sabalausky" <a a.a> wrote in message news:ir27fa$1hs0$1 digitalmars.com..."Nick Sabalausky" <a a.a> wrote in message news:ir27ao$1hob$1 digitalmars.com..."Nick Sabalausky" <a a.a> wrote in message news:ir2750$1hd2$1 digitalmars.com...rdmd --chatty test.ddmd -v -o- "test.d" >test.d.deps Compile Time -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E84 689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07BFF23""test.d"Com ileTimeRuntime>rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompileTimeRuntime>Thatgotmessed up, trying again (and note that I'm on windows, hencethe">"prompt):// test.dimport std.stdio;pragma(msg, "CompileTime");voidmain(){ writeln("Runtime");}> rdmd --chatty test.ddmd -v -o-"test.d">test.d.depsCompileimedmd -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E84 689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07B F23""test.d"Compile TimeRuntime>rdmd --chatty test.ddmd -v -o- "test.d">test.d.depsCompile TimeRuntime>What the hell is wrong with my NG client?One more try:// test.dimport std.stdio;pragma(msg, "Compile Time");voidmain(){ writeln("Runtime");}> rdmd --chatty test.ddmd -v -o- "test.d">test.d.depsCompileimedmd -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E84 689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F60 E847689B6FC07BFF23" "test.d"Compile TimeRuntime>rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile TimeRuntime>Oh well, fuck it. In any case, run "rdmd --chatty test.d" a couple times andyou'll see.
May 18 2011
Yeah I see it now, thanks Nick. Thought it was a bug. :]
May 18 2011