Link time optimization in D

Jacob Carlborg doob at me.com
Tue Jun 1 04:08:25 PDT 2010


On 2010-06-01 12:01, Vladimir Panteleev wrote:
> On Tue, 01 Jun 2010 10:56:47 +0300, Alex Makhotin <alex at bitprox.com> wrote:
>
>> 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?
>
> "-release -O -inline" are all compiler switches, and do not apply to the
> linker.
>
> Speaking of link-time optimization:
>
> I assume that the standard library is not subjected to link-time
> optimization, because all code is used from the .lib.
>
> Doesn't this mean that standard library functions will never be inlined?
> Even very short functions, that merely return a value? (e.g. range.length)

The sources are available. Compared to C/C++, D doesn't use header files 
(at least not Phobos).

> I suppose that the same applies to the runtime, but if the runtime
> functions were short enough to be inlined, the compiler could just
> generate the appropriate machine code instead.
>


-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list