Enabled LTO (Link Time Optimization) except for gui.#9069
Conversation
- LTO-on causes a crash due to Qt used in gui library. Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
|
On debian11 Rocky8 has various undefined references too. @vvbandeira is the compiler version different on these platforms? |
|
103s for an incremental build is somewhat painful. @QuantamHD @calewis do you have any suggestions for improving that? |
Note: data shown is for a 64-core machine, while CI and internal dev VMs are all 32-core, so absolute runtime might be greater than 103s |
|
@maliberty The LTO is also active on all the CPP tests which is noticeably slower to build as well (they probably don't need this on) |
You don't need to build with LTO enabled for development or running tests. Is there a specific thing LTO incremental builds are bottlenecking? There are ways of build profiling to figure out what is taking a long time, but it's been awhile since I used them. |
| # LTO setting must come after project() for proper compiler detection | ||
| option(LINK_TIME_OPTIMIZATION "Flag to control link time optimization: on by default" ON) | ||
|
|
||
| string(TOUPPER "${CMAKE_BUILD_TYPE}" UPPER_BUILD_TYPE) |
There was a problem hiding this comment.
You don't need to jump through these hoops (at least not with newer cmakes, I didn't check with old ones). You can do:
option(LINK_TIME_OPTIMIZATION "Flag to control link time optimization: on by default" ON)
if (LINK_TIME_OPTIMIZATION)
include(CheckIPOSupported)
# 1. Check if the compiler/linker even supports LTO
check_ipo_supported(RESULT lto_supported OUTPUT lto_error)
if(lto_supported)
message(STATUS "LTO/IPO is supported and will be enabled for Release builds")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELEASE TRUE)
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO TRUE)
else()
message(STATUS "LTO/IPO not supported: ${lto_error}")
endif()
endif()
instead which avoids any string manipulation. You can set it for specific configs: https://cmake.org/cmake/help/latest/prop_tgt/INTERPROCEDURAL_OPTIMIZATION.html
There was a problem hiding this comment.
Applied your code with a slight modification.
- Release: LTO-on
- RelWithDebInfo: LTO-off
- Debug: LTO-off
|
@maliberty if this is an issue for the default build because of testing or something, we should take: out of the top level cmake file. And let the person building (or the tool) make the decision about which config they want. |
|
@calewis that code just establishes a default if CMAKE_BUILD_TYPE is unset |
I'm aware, but |
|
That is not a true assumption - many users still build from source. |
…ug build types Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
|
@maliberty New experiment data.
|
|
Regarding the CI fails, Debian11Can we upgrade the GNU compiler version? Rocky-linux8[2025-12-19T02:51:29.509Z] #9 168.7 /opt/rh/gcc-toolset-13/root/usr/libexec/gcc/x86_64-redhat-linux/13/ld: /usr/local/lib64/libspdlog.a(spdlog.cpp.o): in function <------ Is the static library compiled with old compiler?
|
| else() | ||
| message(STATUS "LTO/IPO is disabled") | ||
| endif() | ||
| message(STATUS "LTO/IPO is not supported: ${lto_error}") |
There was a problem hiding this comment.
This is going to print when lto is supported.
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
I tested this, but disabling LTO for non-openroad targets does not improve build time dramatically. Moreover, disabling LTO for non-openroad executables require non-trivial code changes, which incurs a maintenance issue (whenever a new test executable is created, the LTO-off configuration should be added for the executable). IMO, disabling LTO for non-openroad executables has more cons than pros. |
I brought it up before, but I don't see incremental release builds being slow as a big deal. Just my 2 cents. |
|
Based on your measurements I think we should have release w/LTO, release w/o LTO (for developers), and debug. |
The incremental build time difference is too big (Release w/o LTO: 7s vs. Release w/ LTO: 106s). But no good idea to get performance gain w/ trivial build time loss.
@calewis BTW, LTO is also disabled by default in Bazel build setting. What are your thoughts on enabling LTO (full-lto or thin-lto) by default in Bazel? Is it ok? |
|
At Google the default bazel build is fastbuild which is like O2. In order of devs doing things then it goes -c opt (O3), then --config=release (LTO). I would say it's an anti-pattern to enable LTO by default. |
|
Thank you for sharing your thoughts! |
|
I expect general people building OR will just use whatever the default is. LTO seems like it gives them the best experience as they will likely build rarely and run often. I think working on closed-source software inside a professional organization is different. |
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
Not that we are perfect now (an I personally don't think it's a hill worth dying on), but |
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
I also thought about the possibility of a new issue occurring by @maliberty What do you think? |
Signed-off-by: Jaehyun Kim <jhkim@precisioninno.com>
|
clang-tidy review says "All clean, LGTM! 👍" |
| set(LTO_UNSUPPORTED_OS TRUE) | ||
| message(STATUS "Detected Rocky Linux 8: LTO will be disabled due to known build issues") | ||
| endif() | ||
| endif() |
There was a problem hiding this comment.
Disabled LTO in CMake for Debian11 & Rocky Linux 8 to avoid the build issues.
|
@oharboe FYI |
|
Let's see if -O3 is a problem in practice. We can always back it off if needed. |
Revert "Merge pull request #9069 from The-OpenROAD-Project-staging/se…
|
Could you comment on why this was reverted ? |
|
Failed the ORFS CI completely. Once it is resolved we will reinstate it. |




So far, LTO has been disabled because LTO-on causes a crash due to Qt used in gui library.
We can enable LTO globally if we selectively disable LTO for gui library.
Fixes #9050