Rename _pkg_extra_* macros to _distro_extra_* macros

The two intended uses cases for the _pkg_extra_* macros were to
make it easier for packagers to add new compile flags for use
with their package and also to make it easier to do distro wide
experiments with new flags.

However, it was pointed out on the mailing list[1] that you
can't satisfy both of these uses cases at the same time with
just one set of macros.  For example, if a packager uses
_pkg_extra_* macros to add flags specific to their own
package, then someone using _pkg_extra_* macros to
apply a new flag distro wide would override the package
specific flag.

I feel like the distro-wide use case is much more important,
so rather than create two sets of new flags, one for each use
case, I think it's best to rename the _pkg_extra_* macros
to _distro_extra_* and document that they are only meant
to be used for adding distro-wide flags and packagers should
not use this macro.

[1] https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/TOG5RHWPS3VYMM52HFGZOUJVRCGZ7VXB/
This commit is contained in:
Tom Stellard 2023-02-10 19:21:01 +00:00
parent e64c3b8273
commit e0e0971163
6 changed files with 22 additions and 19 deletions

8
macros
View File

@ -57,14 +57,14 @@
# C compiler flags. This is traditionally called CFLAGS in makefiles. # C compiler flags. This is traditionally called CFLAGS in makefiles.
# Historically also available as %%{optflags}, and %%build sets the # Historically also available as %%{optflags}, and %%build sets the
# environment variable RPM_OPT_FLAGS to this value. # environment variable RPM_OPT_FLAGS to this value.
%build_cflags %{optflags} %{?_pkg_extra_cflags} %build_cflags %{optflags} %{?_distro_extra_cflags}
# C++ compiler flags. This is traditionally called CXXFLAGS in makefiles. # C++ compiler flags. This is traditionally called CXXFLAGS in makefiles.
%build_cxxflags %{optflags} %{?_pkg_extra_cxxflags} %build_cxxflags %{optflags} %{?_distro_extra_cxxflags}
# Fortran compiler flags. Makefiles use both FFLAGS and FCFLAGS as # Fortran compiler flags. Makefiles use both FFLAGS and FCFLAGS as
# the corresponding variable names. # the corresponding variable names.
%build_fflags %{optflags} -I%{_fmoddir} %{?_pkg_extra_fflags} %build_fflags %{optflags} -I%{_fmoddir} %{?_distro_extra_fflags}
# Vala compiler flags. This is used to set VALAFLAGS. # Vala compiler flags. This is used to set VALAFLAGS.
%build_valaflags -g %build_valaflags -g
@ -79,7 +79,7 @@
# the flags, while intended for ld, are still passed through the gcc # the flags, while intended for ld, are still passed through the gcc
# compiler driver. At the beginning of %%build, the environment # compiler driver. At the beginning of %%build, the environment
# variable RPM_LD_FLAGS to this value. # variable RPM_LD_FLAGS to this value.
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_clang_extra_ldflags}" : "" ] %{_build_id_flags} %{?_package_note_flags} %{?_pkg_extra_ldflags} %build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_clang_extra_ldflags}" : "" ] %{_build_id_flags} %{?_package_note_flags} %{?_distro_extra_ldflags}
# Expands to shell code to set the compiler/linker environment # Expands to shell code to set the compiler/linker environment
# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, VALAFLAGS, LDFLAGS if they # variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, VALAFLAGS, LDFLAGS if they

View File

@ -4,7 +4,7 @@
# 2) When making changes, increment the version (in baserelease) by 1. # 2) When making changes, increment the version (in baserelease) by 1.
# rpmdev-bumpspec and other tools update the macro below, which is used # rpmdev-bumpspec and other tools update the macro below, which is used
# in Version: to get the desired effect. # in Version: to get the desired effect.
%global baserelease 251 %global baserelease 252
Summary: Red Hat specific rpm configuration files Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config Name: redhat-rpm-config
@ -252,6 +252,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
%doc buildflags.md %doc buildflags.md
%changelog %changelog
* Tue Feb 28 2023 Tom Stellard <tstellar@redhat.com> - 252-1
- Rename _pkg_extra_* macros to _distro_extra_*
* Thu Feb 23 2023 Miro Hrončok <mhroncok@redhat.com> - 251-1 * Thu Feb 23 2023 Miro Hrončok <mhroncok@redhat.com> - 251-1
- Drop the requirement of orphaned nim-srpm-macros - Drop the requirement of orphaned nim-srpm-macros
- No Fedora package uses the %%nim_arches macro - No Fedora package uses the %%nim_arches macro

View File

@ -0,0 +1,8 @@
summary: >
Check that the %_distro_extra_* macros allow users to append new flags to the
list of default flags.
require:
- rpm
test: ./runtest.sh

View File

@ -0,0 +1,6 @@
set -ex
rpm -D '%_distro_extra_cflags -Wall' -E %{build_cflags} | grep -e '\-Wall$'
rpm -D '%_distro_extra_cxxflags -Wall' -E %{build_cxxflags} | grep -e '\-Wall$'
rpm -D '%_distro_extra_ldflags -Wall' -E %{build_ldflags} | grep -e '\-Wall$'
rpm -D '%_distro_extra_fflags -Wall' -E %{build_fflags} | grep -e '\-Wall$'

View File

@ -1,8 +0,0 @@
summary: >
Check that the %_pkg_extra_* macros allow users to append new flags to the
list of default flags.
require:
- rpm
test: ./runtest.sh

View File

@ -1,6 +0,0 @@
set -ex
rpm -D '%_pkg_extra_cflags -Wall' -E %{build_cflags} | grep -e '\-Wall$'
rpm -D '%_pkg_extra_cxxflags -Wall' -E %{build_cxxflags} | grep -e '\-Wall$'
rpm -D '%_pkg_extra_ldflags -Wall' -E %{build_ldflags} | grep -e '\-Wall$'
rpm -D '%_pkg_extra_fflags -Wall' -E %{build_fflags} | grep -e '\-Wall$'