From Fedora Project Wiki


Thin LTO Build Flag

This is a proposed Change for Fedora Linux.
This document represents a proposed Change. As part of the Changes process, proposals are publicly announced in order to receive community feedback. This proposal will only be implemented if approved by the Fedora Engineering Steering Committee.

Summary

At present, many packages are built with fat link time optimization (LTO) objects. This can increase RAM requirements and build times. There is a build flag to disable LTO completely. But by using slim objects, one can still have the performance and size improvements offered by LTO with less of a build time cost.


Owner


Current status

Detailed Description

As indicated at https://stackoverflow.com/questions/13799452/what-is-the-difference-in-gcc-between-lto-and-fat-lto-objects a thin object allows for faster compilation times than a fat object and requires less memory. Adding this as a possible option would give an intermediate option between using fat objects and no link time optimization. This would enable more codes to benefit from easy incorporation of LTO without a substantial increase in compilation times.

Feedback

Benefit to Fedora

Fedora would benefit from more efficient use of build resources while still getting optimized executables and libraries. There has been a related discussion on https://fedoraproject.org/wiki/Changes/LTOBuildImprovements

Scope

  • Proposal owners:

The proposal owner (Benson Muite) will create a macro that enables LTO with thin objects. In the gcc compiler suite, this will replace the build flag -ffat-lto-objects by -fno-fat-lto-objects At present %global _lto_cflags %nil is used to disable LTO (see https://fedoraproject.org/wiki/LTOByDefault). A possible modification is %global _lto_cflags %slim.

  • Other developers:

Using this flag will be an option. Would suggest other developers try using LTO with slim objects first before disabling LTO completely. If it seems like it would be helpful to be adopted as default, this can be done in a further system wide change.

No expected changes.

  • Policies and guidelines: N/A (not needed for this Change)

If the change is adopted and after it has been tested, we should consider updating the packaging guidelines that when importing a new C/C++ or Fortran package, packagers should test if using a slim LTO is sufficient instead of disabling LTO altogether.

  • Trademark approval: N/A (not needed for this Change)
  • Alignment with the Fedora Strategy:

General alignment with having an efficient operating system that uses sustainable development practices, but no specific community goal.

Upgrade/compatibility impact

No changes needed.


Early Testing (Optional)

Do you require 'QA Blueprint' support? Y/N

How To Test

The main thing to test will be modifying spec files for C, C++ or Fortran that use the GCC compiler suite to try using thin objects by setting a macro and then rebuilding When previously a fat object has been used, one should check if there are faster build times and reasonable performance of the resulting outputs. If LTO had been disable due to excessive build times or RAM use, one should test if builds are now possible and if the resulting outputs are more efficient.


User Experience

  • Packages will spend less time waiting for builds to complete
  • Users should get a larger number of optimized packages provided

Dependencies

Only rpm macros package needs to be changed.


Contingency Plan

  • Contingency mechanism: Implement by the next freeze
  • Contingency deadline: Ideally would implement by Fedora 45 release, but before fedora 46 is also fine.
  • Blocks release? No


Documentation

Packaging guidelines will be updated to document the new option.

See:

N/A (not a System Wide Change)

Release Notes

Release notes should not require any changes.