On inlining in D libraries

Adam D. Ruppe destructionator at gmail.com
Mon Sep 9 11:02:27 PDT 2013


On Monday, 9 September 2013 at 17:42:04 UTC, Johannes Pfau wrote:
> But compile times will explode.

Are you sure?

time dmd hello.d # import std.stdio; void main() { 
writeln("hello"); }
real    0m0.665s

$ time dmd hello.d d/dmd2/src/phobos/std/*.d
std.md5 is scheduled for deprecation. Please use std.digest.md 
instead

real    0m2.367s


That's slow for hello world, but not a dealbreaker to me since 
larger projects can easily exceed that anyway (especially with 
optimizations turned on). And that's making no attempt to only 
compile the files actually imported.

If we try to be smarter about it:

time dmd hello.d 
d/dmd2/src/phobos/std/{stdio,conv,format,string,traits,typetuple,typecons,bitmanip,system,functional,utf,uni,container,random,numeric,complex,regex,stdiobase}.d

real    0m1.119s


It's adding about 1/2 second to the compile time - note, not 
really doubling it since more complex user code would take a 
bigger fraction of the total than phobos as the app grows - 
....which really isn't awful.


At least when specifically asking for -inline, I think this is 
worth the extra compile time.


More information about the Digitalmars-d mailing list