Build with LTO in release mode by default
Enables link time optimizations by default in release mode, yielding 3-12% better performance for the entire flow.
nangate45/ibex run |
Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
| No LTO | 256.417 ± 1.089 | 252.747 | 258.500 | 1.12 ± 0.01 |
| With LTO | 228.625 ± 1.979 | 223.222 | 230.904 | 1.00 |
nangate45/black_parrot run |
Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
| No LTO | 2961.542 ± 14.714 | 2937.151 | 2987.307 | 1.06 ± 0.01 |
| With LTO | 2795.283 ± 26.873 | 2725.632 | 2822.192 | 1.00 |
nangate45/ariane133 run |
Mean [s] | Min [s] | Max [s] | Relative |
|---|---|---|---|---|
| No LTO | 5807.242 ± 17.377 | 5791.852 | 5832.0591 | 1.03 ± 0.02 |
| With LTO | 5651.473 ± 71.611 | 5550.869 | 5739.271 | 1.00 |
clang-tidy review says "All clean, LGTM! :+1:"
I've tried enabling this before, but the GUI fails to run under LTO. Have you tried running the GUI?
https://github.com/InBetweenNames/gentooLTO/issues/444
Ah, no, I've only been building without the GUI. I'll try it, and if it doesn't work, I'll add another condition that checks if BUILD_GUI=off.
It also might be possible to compile the GUI without LTO and the other parts with, but I never looked into how that might work.
If LTO doesn't work out AutoFDO might be a more stable option https://gcc.gnu.org/wiki/AutoFDO/Tutorial
Please also give a summary of the impact on link time of using whatever option you settle on.
| Full build | Linking only | |
|---|---|---|
| No LTO | 8 min 23 s | 5 s |
| With LTO | 9 min 23 s | 1 min 30 s |
On GCC 13.2.1, i7-9700 (8 cores)
The GUI actually works for me with LTO (Arch Linux, Qt 5.15.12). I'll try with Clang. Also, seems like the CI is failing on Clang.
The linking only hit is too substantial to be on by default imo. I expect the full build on a bigger machine will also look worse. Let's make this an option. It could be on for the pre-built binary releases (@vvbandeira )
If it's not possible to build only the GUI without LTO, then maybe CMake can just error if both LTO and the GUI are enabled.
If we're not going to enable it by default, there's no point in this PR. Closing it.
For future reference:
- If you want to build with LTO, use
-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=ON(or-DLINK_TIME_OPTIMIZATION=ON) when configuring - The GUI worked for me with LTO (Qt 5.15.12), so this issue may have been resolved. (Also, for CI I recommend
-DBUILD_GUI=no) - Use a new-ish compiler and avoid the BFD linker (the default GNU linker). For me, BFD segfaulted with Clang. Use
gold,lld, ormold. They're much faster anyway: LTO link time with Clang+any of these is about twice as fast as GCC+BFD.
We could make it the default but there needs to be an option to turn it off for developers in an edit/compile/run loop.
For sure, you don't want LTO while developing. I'll get back to this then.
clang-tidy review says "All clean, LGTM! :+1:"
clang-tidy review says "All clean, LGTM! :+1:"
@kbieganski are you still planning to get back to this?
I'm busy with other stuff at the moment, so if anyone is willing to take over, go ahead.