From Fedora Project Wiki

RPM Macros for Build Flags

Summary

Create "extra flag" macros to make it easier for packages to add to the default list of compiler flags.

Owner

Current status

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}

Feedback

The original proposal would have replaced every existing compiler flag in redhat-rpm-config with it's own macro. However, it was determined that this may be a little bit too confusing since there would be ambiguity about whether, for example, %global _flag_f_exceptions %{nil} would actually disable exceptions by adding -fno-exceptions to the flags or if it would just remove the -fexceptions flag. Rather than hold up other useful and fairly straight-forward changes in this proposal, the proposal owners decided to drop the flag macros from this proposal. It could be revisited in a later release.

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.
  • Policies and guidelines:
    • The Fedora packaging policy will be updated to require that packages that want to use additional flag use the new macros.
  • Trademark approval: N/A (not needed for this Change)
  • Alignment with Objectives:

Upgrade/compatibility impact

None.

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

None.

Contingency Plan

  • Contingency mechanism: (What to do? Who will do it?) Change owner will revert the update to redhat-rpm-config.
  • Contingency deadline: Beta freeze
  • Blocks release? N/A (not a System Wide Change), No

Documentation

None.

Release Notes

None.