Talk:LTO
Before creating a discussion or leaving a comment, please read about using talk pages. To create a new discussion, click here. Comments on an existing discussion should be signed using
~~~~
:
A comment [[User:Larry|Larry]] 13:52, 13 May 2024 (UTC) : A reply [[User:Sally|Sally]] 05:32, 15 October 2024 (UTC) :: Your reply ~~~~
Idea: -Werror
Based on the work going on with the Gentoo tinderbox, and confirmed anecdotally, the adding -Werror=odr -Werror=lto-type-mismatch -Werror=strict-aliasing
can help replace subtle runtime failures with obvious compile failures. Making incompatible packages more obvious. The downside is that users may never trigger the runtime behaviour that would lead to the crash, and will definitely see the compile failure. — The preceding unsigned comment was added by Anthonyryan1 (talk • contribs) 2023-05-20T02:01:32
- I tried to keep this pretty simple for users when writing so left this idea as being highlighted in Project:Toolchain/LTO in the See also section for those that like to enjoy troubleshoot more. If you have a better way to do this though then please add.
- Immolo (talk) 11:37, 21 May 2023 (UTC)
Common misconception: -fuse-linker-plugin
-flto
in CFLAGS
, CXXFLAGS
, etc. implies -fuse-linker-plugin
Citation: https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html#index-fuse-linker-plugin — The preceding unsigned comment was added by Anthonyryan1 (talk • contribs) 2023-05-20T02:01:32
- This particular section of the discussion was meant Q&A style rather than a discussion. I added it because there's been a lot of historical confusion about how to enable LTO on the Gentoo forums, reddit's /r/gentoo etc and various blogs. I felt it was worth noting in the discussion page. The citation linked above authoritatively states it is not necessary. I just wanted the note preserved here for future editors who may be coming to this page with imperfect information, as I was.
- Anthonyryan1 (talk) 11:42, 21 May 2023 (UTC)
Common misconception: LDFLAGS
Is it necessary to specify -flto
in LDFLAGS
? Should it be specified as -Wl,-flto
or -flto
Citation needed. — The preceding unsigned comment was added by Anthonyryan1 (talk • contribs) 2023-05-20T02:01:32
- AFAIK it is not required anymore. Their are old forums posts that do say it's needed and I can see the GentooLTO overlay hasn't enabled it. If there is a better citation available then it would be great to have added but currently I can't find one I'm happy to add.
- Immolo (talk) 11:46, 21 May 2023 (UTC)
Update for -flto=
GCC now throws warnings when -flto is passed with no arguments or as -flto=1. -flto=jobserver attempts to detect jobs from the makefile jobserver but not all makefiles/ebuilds set this up correctly and gcc will fallback to -flto=auto. -flto=auto is basically just -flto={nproc}. Doing this has a pretty decent change of overloading user machines since we all pass --jobs x in our makeopts and some have --jobs x in our EMERGE_DEFAULT_OPTS. So someone already maxing out their cores with their job paralleling options is adding a square of more processes to it by using jobserver (in a non-trivial amount of cases) or auto. I propose adding a note to make your -flto argument the same as your makeopts jobs argument to avoid the generation of these warnings while not potentially overloading your system by use of the auto option/fallback.
See this thread from GCC patch mailing list for more info: https://inbox.sourceware.org/gcc-patches/CAFiYyc0CXeDVazbSebSb+RtP8nruSXa=CTRNBxZ4G4MRHKfgmA@mail.gmail.com/T/
Obiwanjacobi (talk) 03:30, 29 November 2023 (UTC)
-fno-lto does not always work
I noticed that media-video/ffmpeg
does not work with the -fno-lto -Wno-error-...
overrides, something about the way it calls the linker.
I propose changing nolto.conf
to the base flags instead of the overrides.
Crocodillian (talk) 13:58, 10 January 2024 (UTC)
Use -flto for gcc but -flto=thin for clang
On a default gcc system some packages still compile with clang, for example chromium and firefox. With CFLAGS="... -flto ..." linking with clang takes hours and uses tens of gigabytes of memory. Is there an easy option to use -flto=thin for clang compilation instead?
Khumarahn (talk) 18:48, 21 April 2024 (UTC)
- You can override per-package CFLAGS using /etc/portage/package.env. I don't think there's a special environment variable for Clang. — Waldo Lemmer 02:38, 22 April 2024 (UTC)
- Talk pages are really just for discussions about article additions and corrections, so you probably won't get an answer here. However, once you do find a solution, feel free to add it to LTO. You can create a discussion here if you need help with that.
- — Waldo Lemmer 08:21, 22 April 2024 (UTC)