Talk:LTO

From Gentoo Wiki
Jump to:navigation Jump to:search
Note
This is a Talk page - please see the documentation about using talk pages. Add newer comments below older ones, sign comments using four tildes (~~~~), and indent successive comments with colons (:). Add new sections at the bottom of the page, under a heading (== ==). Please remember to mark sections as "open for discussion" using {{talk|open}}, so they will show up in the list of open discussions.

Idea: -Werror

Talk status
This discussion is done.

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 (talkcontribs) 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)
Closing discussion while user decides if they wish to add their idea to improve.
Immolo (talk) 10:13, 25 May 2023 (UTC)

Common misconception: -fuse-linker-plugin

Talk status
This discussion is done.

-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 (talkcontribs) 2023-05-20T02:01:32‎

If you think it is needed then please add.
Immolo (talk) 11:42, 21 May 2023 (UTC)
Please don't delete comments as the talk pages are only to discuss changes, if you wish to add this change then please add it to the main article.
Immolo (talk) 12:18, 22 May 2023 (UTC)
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

Talk status
This discussion is still ongoing.

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 (talkcontribs) 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=

Talk status
This discussion is still ongoing.

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

Talk status
This discussion is still ongoing.

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)