Thread overview | ||||||||
---|---|---|---|---|---|---|---|---|
|
May 19, 2011 Why does RDMD evaluate templates twice? | ||||
---|---|---|---|---|
| ||||
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.d > test > test $ rdmd test.d > test The 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.d > test > test > test > test $ rdmd test.d > test > test Quite weird. I'm thinking this could cause some kind of slowdown. Anyone have a clue what's going on here? |
May 19, 2011 Re: Why does RDMD evaluate templates twice? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Andrej Mitrovic | "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.d >> test >> test > > $ rdmd test.d >> test > > The 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.d >> test >> test >> test >> test > > $ rdmd test.d >> test >> test > > Quite weird. I'm thinking this could cause some kind of slowdown. Anyone have a clue what's going on here? > When 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"); } > rdmd --chatty test.d dmd -v -o- "test.d" >test.d.deps Compile Time dmd -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E847689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07BFF23""test.d"Compile TimeRuntime> rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile TimeRuntime |
May 19, 2011 Re: Why does RDMD evaluate templates twice? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | "Nick Sabalausky" <a@a.a> wrote in message news:ir2750$1hd2$1@digitalmars.com... > > >> rdmd --chatty test.d > dmd -v -o- "test.d" >test.d.deps > Compile Time > > md -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E847689B6FC07BFF23.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-A8FD055311F603E847689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07BFF23" "test.d"Compile TimeRuntime> rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile TimeRuntime |
May 19, 2011 Re: Why does RDMD evaluate templates twice? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | "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.d >> dmd -v -o- "test.d" >test.d.deps >> Compile Time >> >> >> d -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E847689B6FC07BFF23.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>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-A8FD055311F603E847689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07BFF23" "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-A8FD055311F603E847689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07BFF23" "test.d"Compile TimeRuntime> rdmd --chatty test.ddmd -v -o- "test.d" >test.d.depsCompile TimeRuntime |
May 19, 2011 Re: Why does RDMD evaluate templates twice? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | "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.d >>> dmd -v -o- "test.d" >test.d.deps >>> Compile Time >>> >>> >>> >>> -of"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\test-d-A8FD055311F603E847689B6FC07BFF23.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>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-A8FD055311F603E847689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07BFF23""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-A8FD055311F603E847689B6FC07BFF23.exe" -od"C:\DOCUME~1\NICKSA~1\LOCALS~1\Temp\.rdmd\rdmd-test.d-A8FD055311F603E847689B6FC07BFF23" "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 19, 2011 Re: Why does RDMD evaluate templates twice? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Nick Sabalausky | Yeah I see it now, thanks Nick. Thought it was a bug. :] |
Copyright © 1999-2021 by the D Language Foundation