ToolChain/LTO - Ubuntu Wiki (2024)

This page describes the approach to use link time optimizations for package builds starting with Ubuntu 21.04.

Contents

  1. Summary
  2. Implementation
    1. LTO exclusion list
  3. Testing
  4. Known issues
  5. References

Summary

Link time optimization (LTO) is a way to run optimizations across multiple translation units, enabling more opportunities for optimizations at link time. Each source file is translated to an intermediate representation, which is then used at link to build an executable or a shared object/library. The optimizations allow for faster code and smaller files.

Compiler flags for LTO are injected in dpkg-buildflags, and can be overridden in the package build. LTO will be enabled on amd64, arm64, ppc64el and s390x.

Implementation

LTO is enabled on all 64bit architectures, except for riscv64, aiming to not slowing down the riscv64 builds further.

On architectures where LTO is disabled, it can be enabled in the rules file by

  • exportDEB_BUILD_MAINT_OPTIONS=optimize=+lto

It can be disabled by

  • exportDEB_BUILD_MAINT_OPTIONS=optimize=-lto

Enabling lto adds the flags -flto=auto-ffat-lto-objects to CFLAGS, CXXFLAGS, OBJCFLAGS ... and the flag -flto=auto to LDFLAGS. -ffat-lto-objects is used to generate both the intermediate representation and the object code in the object files, the latter needed to ship .o and .a files in packages. All intermediate code is stripped out by dh_strip.

Building with -ffat-lto-objects slows down the build a bit, however we have around 2000 packages shipping .o and .a files. If a package doesn't ship these object files, then a package can remove the -ffat-lto-objects option.

LTO exclusion list

This is the least ugly workaround we came up with, without having to fix build failures at the same time, when we enable LTO. It will go away at some time.

The package lto-disabled-list contains a text file, listing source packages and architectures where LTO should not be enabled, allowing the package to build without modifying it. When adding a package to this list, please make sure that either a Debian or a Launchpad issue is on file. Please only use lto-disabled-list for packages not in main. Packages in main should either be fixed or worked around in the package itself.

Testing

Two archive test rebuilds were done to watch for regressions introduced by adding the LTO flags.

First test rebuild (using GCC 9):

Second test rebuild (using GCC 10):

Regressions are build failures failing in the LTO build, but not in the reference build.

Known issues

  • Link time optimization lets the compiler use more memory than a normal link step. Work arounds are reducing the parallelism, or serialization of different link time optimizations.
  • C++ symbols files differ, usually because some symbols for template instantiations are optimized out.
  • GCC and clang use different LTO options. The injected flags use the GCC variants.
  • The feature area optimize is not yet implemented in Debian dpkg. It will appear in dpkg 1.21.x. Patches using this area can be safely forwarded to Debian. The area will just be ignored.

References

Link time optimizations are already enabled in other Linux distributions, such as:

Plans for Debian:

ToolChain/LTO - Ubuntu Wiki (2024)
Top Articles
Security features for Google Nest Wifi and Google Wifi
Hertz Still Can't Keep Track Of Cars, Threatens Reader Who Returned Vehicle On Time - View from the Wing
Po Box 7250 Sioux Falls Sd
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Avonlea Havanese
Obituary (Binghamton Press & Sun-Bulletin): Tully Area Historical Society
Words From Cactusi
Barstool Sports Gif
Acbl Homeport
Azeroth Pilot Reloaded - Addons - World of Warcraft
Bros Movie Wiki
Springfield Mo Craiglist
Love In The Air Ep 9 Eng Sub Dailymotion
Craftology East Peoria Il
Eva Mastromatteo Erie Pa
Mzinchaleft
Palm Coast Permits Online
NHS England » Winter and H2 priorities
Bj Alex Mangabuddy
Unity - Manual: Scene view navigation
Governor Brown Signs Legislation Supporting California Legislative Women's Caucus Priorities
Hampton University Ministers Conference Registration
Jordan Poyer Wiki
How to Make Ghee - How We Flourish
Walmart Pharmacy Near Me Open
Beaufort 72 Hour
Kirk Franklin Mother Debra Jones Age
Kroger Feed Login
4Oxfun
JVID Rina sauce set1
Marokko houdt honderden mensen tegen die illegaal grens met Spaanse stad Ceuta wilden oversteken
Ou Football Brainiacs
Miles City Montana Craigslist
Angel Haynes Dropbox
Publix Christmas Dinner 2022
Craftsman Yt3000 Oil Capacity
Kamzz Llc
4083519708
Mckinley rugzak - Mode accessoires kopen? Ruime keuze
Second Chance Apartments, 2nd Chance Apartments Locators for Bad Credit
13 Fun & Best Things to Do in Hurricane, Utah
Pain Out Maxx Kratom
6576771660
Here's Everything You Need to Know About Baby Ariel
Lady Nagant Funko Pop
Crigslist Tucson
Devotion Showtimes Near Showplace Icon At Valley Fair
552 Bus Schedule To Atlantic City
Diccionario De Los Sueños Misabueso
Sam's Club Fountain Valley Gas Prices
Latest Posts
Article information

Author: Kieth Sipes

Last Updated:

Views: 6396

Rating: 4.7 / 5 (67 voted)

Reviews: 82% of readers found this page helpful

Author information

Name: Kieth Sipes

Birthday: 2001-04-14

Address: Suite 492 62479 Champlin Loop, South Catrice, MS 57271

Phone: +9663362133320

Job: District Sales Analyst

Hobby: Digital arts, Dance, Ghost hunting, Worldbuilding, Kayaking, Table tennis, 3D printing

Introduction: My name is Kieth Sipes, I am a zany, rich, courageous, powerful, faithful, jolly, excited person who loves writing and wants to share my knowledge and understanding with you.