From Fedora Project Wiki

Remove Excessive Linking

Summary

Pass --as-needed flag the linker through default system-wide LDFLAGS.

Owner

Current status

  • Targeted release: Fedora 29
  • Last updated: 2018-07-03
  • Tracker bug: <will be assigned by the Wrangler>

Detailed Description

The flag (--as-needed) tells the linker to link in the produced binary only the libraries containing symbols actually used by the binary itself. This binary can be either a final executale or another library.

The use of the --as-needed flag allows the linker to avoid linking extra libraries in a binary. This not only improves startup times (as the loader does not have to load all the libraries for every step) but might avoid the full initialization of big frameworks.

Benefit to Fedora

No real tests on Fedora has been made, so no real numbers in this section. But theoretically,

  • Better startup times (since loader doesn't have to load all the libraries)
  • Smaller metadata (since less dependencies are recorded in final binaries)

Scope

  • Proposal owners: Add -Wl,--as-needed into RPM_LD_FLAGS (in redhat-rpm-config).
  • Other developers: Nothing should break, but immediate work-around would be to disable this flag (will be provided in redhat-rpm-config) and fix real issue later.
  • Release engineering: #7604 (mass rebuild is desired after this change).
  • Policies and guidelines: Add information how to turn it off (TODO link to FPC ticket).
  • Trademark approval: N/A (not needed for this Change)

Upgrade/compatibility impact

None for end-users. Developers which build their own packages might notice and should be guided how to fix / workaround issue.

How To Test

Install newest redhat-rpm-config package and build your package.

User Experience

See Benefit to Fedora section.

Dependencies

None.

Contingency Plan

  • Contingency mechanism: Owners will revert change in redhat-rpm-config and make it opt-in rather than opt-out.
  • Contingency deadline: Beta freeze.
  • Blocks release? No
  • Blocks product? Everything

Documentation

Only Packaging Guidelines needs to be updated.

Release Notes