Introduce macros for language specific compiler options

Introduce new language specific __global_fooflags for C, C++ and Fortran
This looks mildly strange and suspicious since because the global flags
get pulled in indirectly via %optflags (that doesn't change here but becomes
more obvious).

Depends on previous commit (8fe5b07871)
which was done separately to make the actual change (or lack of thereof)
stand out here.

This is not supposed to change any actual values for current usages,
so if it does it's a bug.

However there's a minor bonus involved for Fortran users who can now get
the correct FFLAGS/FCFLAGS for non-autoconf projects too by using
__global_fflags/fcflags
This commit is contained in:
Panu Matilainen 2016-11-30 13:39:02 +02:00
parent 8fe5b07871
commit 3081c4e7d5
2 changed files with 14 additions and 5 deletions

13
macros
View File

@ -32,10 +32,10 @@
# way to turn it back off. # way to turn it back off.
# %_configure_disable_silent_rules 1 # %_configure_disable_silent_rules 1
%configure \ %configure \
CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \ CFLAGS="${CFLAGS:-%__global_cflags}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \ CXXFLAGS="${CXXFLAGS:-%__global_cxxflags}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%optflags -I%_fmoddir}" ; export FFLAGS ; \ FFLAGS="${FFLAGS:-%__global_fflags}" ; export FFLAGS ; \
FCFLAGS="${FCFLAGS:-%optflags -I%_fmoddir}" ; export FCFLAGS ; \ FCFLAGS="${FCFLAGS:-%__global_fcflags}" ; export FCFLAGS ; \
LDFLAGS="${LDFLAGS:-%__global_ldflags}"; export LDFLAGS; \ LDFLAGS="${LDFLAGS:-%__global_ldflags}"; export LDFLAGS; \
[ "%_configure_gnuconfig_hack" = 1 ] && for i in $(find $(dirname %{_configure}) -name config.guess -o -name config.sub) ; do \ [ "%_configure_gnuconfig_hack" = 1 ] && for i in $(find $(dirname %{_configure}) -name config.guess -o -name config.sub) ; do \
[ -f /usr/lib/rpm/redhat/$(basename $i) ] && %{__rm} -f $i && %{__cp} -fv /usr/lib/rpm/redhat/$(basename $i) $i ; \ [ -f /usr/lib/rpm/redhat/$(basename $i) ] && %{__rm} -f $i && %{__cp} -fv /usr/lib/rpm/redhat/$(basename $i) $i ; \
@ -146,6 +146,11 @@
%_hardened_ldflags %{?_hardened_build:%{_hardening_ldflags}} %_hardened_ldflags %{?_hardened_build:%{_hardening_ldflags}}
%__global_compiler_flags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches %{_hardened_cflags} %__global_compiler_flags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector-strong --param=ssp-buffer-size=4 -grecord-gcc-switches %{_hardened_cflags}
%__global_cflags %{optflags}
%__global_cxxflags %{optflags}
%__global_fflags %{optflags} -I%_fmoddir
%__global_fcflags %{optflags} -I%_fmoddir
%__global_ldflags -Wl,-z,relro %{_hardened_ldflags} %__global_ldflags -Wl,-z,relro %{_hardened_ldflags}
#============================================================================== #==============================================================================

View File

@ -6,7 +6,7 @@
Summary: Red Hat specific rpm configuration files Summary: Red Hat specific rpm configuration files
Name: redhat-rpm-config Name: redhat-rpm-config
Version: 58 Version: 59
Release: 1%{?dist} Release: 1%{?dist}
# No version specified. # No version specified.
License: GPL+ License: GPL+
@ -140,6 +140,10 @@ install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov
%{_rpmconfigdir}/macros.d/macros.kmp %{_rpmconfigdir}/macros.d/macros.kmp
%changelog %changelog
* Wed Nov 30 2016 Panu Matilainen <pmatilai@redhat.com> - 59-1
- Move global compiler flags to __global_compiler_flags macro
- Introduce separate __global_fooflags for C, C++ and Fortran
* Tue Nov 29 2016 Panu Matilainen <pmatilai@redhat.com> - 58-1 * Tue Nov 29 2016 Panu Matilainen <pmatilai@redhat.com> - 58-1
- Drop atom optimization on i686 (#1393492) - Drop atom optimization on i686 (#1393492)