Package specific RPM Macros For Build Flags
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
Create âextra flagâ macros to make it easier for packages to add to the default list of compiler flags.
This is a follow up to the: Changes/RPMMacrosForBuildFlags - Fedora Project Wiki
Owner
- Name: Michal Schorm
- Email: mschorm@redhat.com
Detailed Description
The macros file in the redhat-rpm-config package contains a list of default compiler flags for packages to use when compiling C, C++, and Fortran packages. This change will add new macros to redhat-rpm-config which will make it easier for packages to add their own compiler flags.
The proposed macros for adding new flags are:
%_pkg_extra_cflags %_pkg_extra_cxxflags %_pkg_extra_fflags %_pkg_extra_ldflags
These will be added to %{build_cflags}, %{build_cxxflags}, %{build_fflags}, and %{build_ldflags} respectively to allow packages to add their own flags to the default list: e.g.
%build_cflags %{optflags} %{_pkg_extra_cflags}
Note:
This is a followup for the previously accepted change:
that was implemented as:
but later changed to:
My goal is to re-implement the original solution, which would create the _pkg_extra macros, to grant the package maintainers an elegant, clean and simple way to make the per-package adjustments to the build flags.
Currently, this is done by editing the CFLAGS etc. environmental variables directly and re-exporting them. That sometimes cause issues that could be avoided by using macro instead.
Also, when set by macro, the flags adjustment will be present in every â%set_build_flagsâ call, not just in-between of the manual adjustment and the end of the RPMbuild phase (%build, %install, %check, etc.).
Feedback
Benefit to Fedora
- It will provide a standard way to add to the list of default compiler flags.
- It will make it easier to determine which packages add compiler flags by doing a simple grep of the spec files.
- It will make it easier for toolchain developers to experiment with adding new flags to the distribution as this can be done with a simple macro definition instead of patching redhat-rpm-config.
Scope
-
Proposal owners:
- Proposal owners will update the redhat-rpm-config package and add the new macros.
- Proposal owners will test the changes to ensure that the correct flags are still being used.
-
Other developers:
- Other developers may, but are not required to, update their packages to use the new macros.
-
Release engineering: #Releng issue number
-
Policies and guidelines: N/A (not needed for this Change)
- The Tree - rpms/redhat-rpm-config - src.fedoraproject.org will be updated to document this macro
- The Fedora packaging policy will be updated to state that packages that want to use additional flag SHOULD use the new macros.
-
Trademark approval: N/A (not needed for this Change)
-
Alignment with the Fedora Strategy:
Upgrade/compatibility impact
None.
Early Testing (Optional)
Do you require âQA Blueprintâ support? Y/N
How To Test
- This can be tested by inspecting the value of the %{build_cflags}, %{build_cxxflags}, %{build_fflags}, and %{build_ldflags} and ensuring they are the same before and after the change.
- This can be tested by modifying some of the new macros in a spec file and ensuring that the changes appear in the appropriate macro mentioned above.
User Experience
This is a change for developers and will have no impact to the user experience.
Dependencies
A PR must be approved and merged to the âredhat-rpm-configâ package. A PR must be approved and merged to the Fedora Packaging Guidelines.
Contingency Plan
-
Contingency mechanism: Change owner will revert the update to redhat-rpm-config.
-
Contingency deadline: Beta freeze
-
Blocks release? No
Documentation
need to be done
N/A (not a System Wide Change)
Release Notes
None.
Last edited by @amoloney 2025-06-02T20:43:32Z
Last edited by @amoloney 2025-06-02T20:43:32Z