[m-users.] Link-time optimization
foolkingcrown at gmail.com
Sat Jun 13 12:09:04 AEST 2020
It's not just enough to put the LTO flags in the CFLAGS, since the
standard library (which accounts for much of the executable size in my
There is an LTO option during configuration, although I only seriously
tested it for MSVC since that's my main target on Windows and shared
libraries aren't possible with Mercury in that configuration. That
will reduce the resulting exe file by quite a lot.
The LTO flags are implemented for gcc and clang as well as MSVC, but I
am unsure if it's done in an optimal way (a large part of why it's
marked as experimental I believe).
Using LTO will also cause the linking steps to be quite long, since
it's basically compiling the entire Mercury runtime and standard
library at that point. But the file size is quite a bit smaller. The
actual performance change is pretty minor from my experience over just
intermodule optimization, since intermodule-optimization tends to be
very effective before the actual grade's compiler even gets the code.
More information about the users