Bug 1789137

Summary: Flags injection for building packages with LTO by default
Product: [Fedora] Fedora Reporter: Jeff Law <law>
Component: redhat-rpm-configAssignee: Florian Festi <ffesti>
Status: NEW --- QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: high Docs Contact:
Priority: high    
Version: 32CC: ajax, ego.cordatus, ffesti, fweimer, igor.raits, john.j5live, jonathan, mcatanza, mjg, pmatilai, praiskup, tibbs
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: All   
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Description Flags
Changes to redhat-rpm-config to inject LTO flags none

Description Jeff Law 2020-01-08 20:16:44 UTC
Created attachment 1650815 [details]
Changes to redhat-rpm-config to inject LTO flags

Description of problem:
We have an in-progress Fedora change request to enable LTO by default for Fedora 32.  We want the change to apply to packages built with rpmbuild and which honor the flags injection mechanism used by redhat-rpm-config.


We know there are some packages that are not going to work with LTO as they use features which are currently incompatible with LTO -- for example top level ASM statements to implement function versioning.  So we also want to make it easy for packages to opt-out of LTO.  Ideally a single line in their .spec file should be sufficient.

openSUSE uses %{_lto_cflags} to pass in flags for LTO builds.  I see absolutely no reason to use a different name.  It's given a default value in their equivalent of redhat-rpm-config.

Packages that want to opt-out use this in their .spec file:

%define _lto_cflags %{nil}

openUSE also uses the following for packages that need an additional option for handling of archive libraries:

%global _lto_cflags %{?_lto_cflags} -ffat-lto-objects

I'm not a big fan of their opt-out and archive library handling as they encourage package maintainers to directly manipulate the compiler flags.  I would have instead had a macro which indicated the package didn't want LTO (or needed special archive library handling) and hid the flags manipulation in redhat-rpm-config.  But given openSUSE was the first mover here, I'll put my objection to their approach aside and recommend doing the same for Fedora.

Note that we're using -ffat-lto-objects and -flto-partition=one in the base LTO flags right now.  That allows us to focus on more important issues in the immediate term.  Those options will be pushed down into each package that needs them to improve build-times with LTO.  I'd like pre-approval to drop those from _lto_cflags once I've identified and fixed the packages that need that special archive handling.

From a deployment standpoint I think we should land the flags injection enablement for redhat-rpm-config at the same time as the sed hacks to fix broken configure scripts and that both should land immediately after Jakub drops in gcc-10 into rawhide.

So the immediate goal is to get agreement on the flags injection patch, but not install it just yet.  Assuming we can reach agreement on the flags injection and configure script fixes, I'm happy to own committing the bits just after Jakub drops in gcc-10 to rawhide.

pull-request will be submitted shortly.

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:

Actual results:

Expected results:

Additional info:

Comment 1 Ben Cotton 2020-02-11 17:36:55 UTC
This bug appears to have been reported against 'rawhide' during the Fedora 32 development cycle.
Changing version to 32.

Comment 2 Michael Catanzaro 2020-07-07 12:41:12 UTC
Can this be closed?

Comment 3 Jeff Law 2020-07-08 22:07:44 UTC
Not yet.  We need the opt-outs in place first.  I've been dropping those in on/off the last couple weeks and expect to wrap that up this week (there's ~200 of them across F33 and I'm trying to make sure we document each reasonably well in the affected .spec file, so it takes time).  Once the opt-outs in place we'll look to push the actual LTO enablement in redhat-rpm-config.

Comment 4 Michael J Gruber 2020-07-31 16:14:05 UTC
So, is LTO in place but no opt-out? A couple of build failures in rawhide seem to indicate that but I might be wrong.


Comment 5 Michael Catanzaro 2020-07-31 16:40:10 UTC
To opt out:

%define _lto_cflags %{nil}