LTO (was: Compiling multiple source files --- each file separately, or all together?)
Iain Buclaw
ibuclaw at gdcproject.org
Mon Dec 29 10:18:19 UTC 2025
On Friday, 26 December 2025 at 17:38:55 UTC, Adam Wilson wrote:
> On Friday, 26 December 2025 at 10:44:21 UTC, David Given wrote:
>> When compiling C or C++, and you have multiple source files,
>> you typically compile each source file independently into a .o
>> file and then link them together. This is either done manually
>> in the build script or automatically if you pass multiple
>> source files into the compiler program.
>
> I was speaking with Walter a couple weeks ago and he thinks
> that future of DMD is unified compilation. There are a number
> of things the compiler can do when compiling all the source
> files at once that you just cannot do with independent
> compilation and Walter would like to be able to do those things.
>
> So the general recommendation from Walter is unified
> compilation.
This is the one of the key points of LTO (-flto) though -
something that I'm sure of having mentioned at most DConf's since
2013. :-)
Serialise the post-semantic (lightweight?) backend representation
into the individual `.o` files, then read it all in at the end
for unified compilation (with `-O` turned on) before linking.
More information about the Digitalmars-d
mailing list