Bug 1789137 - Flags injection for building packages with LTO by default
Summary: Flags injection for building packages with LTO by default
Keywords:
Status: NEW
Alias: None
Product: Fedora
Classification: Fedora
Component: redhat-rpm-config
Version: 32
Hardware: All
OS: All
high
high
Target Milestone: ---
Assignee: Florian Festi
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2020-01-08 20:16 UTC by Jeff Law
Modified: 2020-07-31 16:40 UTC (History)
12 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
Environment:
Last Closed:
Type: Bug


Attachments (Terms of Use)
Changes to redhat-rpm-config to inject LTO flags (1.56 KB, patch)
2020-01-08 20:16 UTC, Jeff Law
no flags Details | Diff

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.

https://fedoraproject.org/wiki/LTOByDefault
https://pagure.io/fesco/issue/2311

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:
1.
2.
3.

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.

https://kojipkgs.fedoraproject.org//work/tasks/643/48280643

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

%define _lto_cflags %{nil}


Note You need to log in before you can comment on or make changes to this bug.