-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Docs: CMake LTO honor global flag #3006
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
In this example, the IPO/LTO flags should not be added if the general property is already set for all targets via `CMAKE_INTERPROCEDURAL_OPTIMIZATION`. Also, if `CMAKE_INTERPROCEDURAL_OPTIMIZATION` is set to `OFF`, LTO flags should also not be added. This is sometimes needed when working around compiler bugs with IPO/LTO, e.g. on ppc64le with some toolchains.
I'd rather show this as an either-or. If your CMake is new enough (and this includes complex issues up till about 3.18, so maybe 3.18+), then |
So two independent code samples? The logic might get a bit complex in one listing. |
I was thinking more of a simple mention, like Primarily to older versions of CMake, we provide a |
I see. I actually think we have that explained in the text. I find that if someone has a CMake file that supports e.g. 3.15+ and uses our LTO logic, we need to provide a concrete example somewhere, otherwise it might be a bit confusing to people how to derive at a consistent control logic. We can move the example around, but I think it's at least as complex as in the diff, no? |
So I just went about enabling LTO fully in a repo of mine recently. Doing a "FAT" LTO worked fine, but ThinLTO kept causing the linker to segfault. I had to avoid using |
Description
In this example, the IPO/LTO flags should not be added if the general property is already set for all targets via
CMAKE_INTERPROCEDURAL_OPTIMIZATION
.Also, if
CMAKE_INTERPROCEDURAL_OPTIMIZATION
is set toOFF
, LTO flags should also not be added. This is sometimes needed when working around compiler bugs with IPO/LTO, e.g. on ppc64le with sometoolchains.
Suggested changelog entry: