Link time optimization in D

Alex Makhotin alex at bitprox.com
Tue Jun 1 00:56:47 PDT 2010


Walter Bright wrote:
> retard wrote:
>> I thought the DMD's approach required sources for each module and GCC 
>> supported LTO even when only object / library files were provided.
> 
> DMD does require the sources, or at least the sources you'd like to have 
> inlined. GCC requires all the sources used to be compiled with a special 
> switch:
> 
> "When using multiple steps, it is strongly recommended to use exactly 
> the same optimization and machine-dependent options in all commands, 
> because conflicting options during compilation and link-time may lead to 
> strange errors."
> 
> https://lwn.net/Articles/387122/

So the best way to build release version(assuming two-phase build) 
should be:

1. Synchronize DMD compilation switches with DMD link switches(-release 
-O -inline).
2. Pass all the project sources in one DMD cmd line, compile.
3. Link produced object file with other libs.

Am I correct?
Does single-phase(compile-link in one command line) give optimization 
gain with the DMD?


-- 
Alex Makhotin,
the founder of BITPROX,
http://bitprox.com


More information about the Digitalmars-d mailing list