Filter out C, C++ build flags from Fortran build flags (#2177253)
And pave the way for future front-end-specific compiler flags.
This commit is contained in:
parent
24244c4ac2
commit
7692bbaf45
@ -36,9 +36,7 @@ Individual build flags are also available through RPM macros:
|
|||||||
* `%{build_cxx}` for the command name of the C++ compiler.
|
* `%{build_cxx}` for the command name of the C++ compiler.
|
||||||
* `%{build_cpp}` for the command name of the C-compatible preprocessor.
|
* `%{build_cpp}` for the command name of the C-compatible preprocessor.
|
||||||
* `%{build_cflags}` for the C compiler flags (also known as the
|
* `%{build_cflags}` for the C compiler flags (also known as the
|
||||||
`CFLAGS` variable). Also historically available as `%{optflags}`.
|
`CFLAGS` variable).
|
||||||
Furthermore, at the start of the `%build` section, the environment
|
|
||||||
variable `RPM_OPT_FLAGS` is set to this value.
|
|
||||||
* `%{build_cxxflags}` for the C++ compiler flags (usually assigned to
|
* `%{build_cxxflags}` for the C++ compiler flags (usually assigned to
|
||||||
the `CXXFLAGS` shell variable).
|
the `CXXFLAGS` shell variable).
|
||||||
* `%{build_fflags}` for `FFLAGS` (the Fortran compiler flags, also
|
* `%{build_fflags}` for `FFLAGS` (the Fortran compiler flags, also
|
||||||
@ -50,6 +48,13 @@ Individual build flags are also available through RPM macros:
|
|||||||
driver. At the start of the `%build` section, the environment
|
driver. At the start of the `%build` section, the environment
|
||||||
variable `RPM_LD_FLAGS` is set to this value.
|
variable `RPM_LD_FLAGS` is set to this value.
|
||||||
|
|
||||||
|
The C and C++ compiler flags are historically available as the
|
||||||
|
`%{optflags}` macro. These flags may not contain flags that work with
|
||||||
|
certain languagues or compiler front ends, so the language-specific
|
||||||
|
`%build_*` are more precise. At the start of the `%build` section,
|
||||||
|
the environment variable `RPM_OPT_FLAGS` is set to the `%{optflags}`
|
||||||
|
value; similar limitations apply.
|
||||||
|
|
||||||
The variable `LT_SYS_LIBRARY_PATH` is defined here to prevent the `libtool`
|
The variable `LT_SYS_LIBRARY_PATH` is defined here to prevent the `libtool`
|
||||||
script (v2.4.6+) from hardcoding `%_libdir` into the binaries' `RPATH`.
|
script (v2.4.6+) from hardcoding `%_libdir` into the binaries' `RPATH`.
|
||||||
|
|
||||||
@ -402,6 +407,9 @@ The general (architecture-independent) build flags are:
|
|||||||
compilation performance. (This does not affect code generation.)
|
compilation performance. (This does not affect code generation.)
|
||||||
* `-Wall`: Turn on various GCC warnings.
|
* `-Wall`: Turn on various GCC warnings.
|
||||||
See the [GCC manual](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall).
|
See the [GCC manual](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wall).
|
||||||
|
* `-Wno-complain-wrong-lang`: Do not warn about front end mismatches
|
||||||
|
(e.g, using `-Werror=format-security` with Fortran). Only included
|
||||||
|
in `%optflags`, and not the front-end-specific `%build_*` macros.
|
||||||
* `-Werror=format-security`: Turn on format string warnings and treat
|
* `-Werror=format-security`: Turn on format string warnings and treat
|
||||||
them as errors.
|
them as errors.
|
||||||
See the [GCC manual](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wformat-security).
|
See the [GCC manual](https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html#index-Wformat-security).
|
||||||
|
29
macros
29
macros
@ -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} %{?_distro_extra_cflags}
|
%build_cflags %{__build_flags_lang_c} %{?_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} %{?_distro_extra_cxxflags}
|
%build_cxxflags %{__build_flags_lang_cxx} %{?_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} %{?_distro_extra_fflags}
|
%build_fflags %{__build_flags_common} -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
|
||||||
@ -308,6 +308,12 @@ print(result)
|
|||||||
# Use Zstandard compression for binary payloads
|
# Use Zstandard compression for binary payloads
|
||||||
%_binary_payload w19.zstdio
|
%_binary_payload w19.zstdio
|
||||||
|
|
||||||
|
#==============================================================================
|
||||||
|
# --- Compiler flags control.
|
||||||
|
#
|
||||||
|
# Please consult buildflags.md for parts that can be configured
|
||||||
|
# from RPM spec files.
|
||||||
|
|
||||||
%_hardening_gcc_cflags -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
|
%_hardening_gcc_cflags -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
|
||||||
%_hardening_clang_cflags --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg
|
%_hardening_clang_cflags --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg
|
||||||
%_hardening_cflags %{expand:%%{_hardening_%{toolchain}_cflags}} -fstack-protector-strong
|
%_hardening_cflags %{expand:%%{_hardening_%{toolchain}_cflags}} -fstack-protector-strong
|
||||||
@ -383,7 +389,7 @@ print(result)
|
|||||||
%_build_id_flags -Wl,--build-id=sha1
|
%_build_id_flags -Wl,--build-id=sha1
|
||||||
|
|
||||||
%_general_options -O2 %{?_lto_cflags} -fexceptions -g -grecord-gcc-switches -pipe
|
%_general_options -O2 %{?_lto_cflags} -fexceptions -g -grecord-gcc-switches -pipe
|
||||||
%_warning_options -Wall -Werror=format-security
|
%_warning_options -Wall%[%__build_for_lang_any ? " -Wno-complain-wrong-lang" : ""]%[%__build_for_lang_c + %__build_for_lang_cxx ? " -Werror=format-security" : ""]
|
||||||
%_preprocessor_defines %{_fortify_level_flags} -Wp,-D_GLIBCXX_ASSERTIONS
|
%_preprocessor_defines %{_fortify_level_flags} -Wp,-D_GLIBCXX_ASSERTIONS
|
||||||
|
|
||||||
# Common variables are no longer generated by default by gcc and clang
|
# Common variables are no longer generated by default by gcc and clang
|
||||||
@ -392,6 +398,21 @@ print(result)
|
|||||||
|
|
||||||
%__global_compiler_flags %{_general_options} %{_warning_options} %{_preprocessor_defines} %{_hardened_cflags} %{_annotation_cflags} %{_legacy_options}
|
%__global_compiler_flags %{_general_options} %{_warning_options} %{_preprocessor_defines} %{_hardened_cflags} %{_annotation_cflags} %{_legacy_options}
|
||||||
|
|
||||||
|
# Internal macros. Do not use directly. These variables can be rebound
|
||||||
|
# to suppress certain frontend-specific compiler flags (or in the case
|
||||||
|
# of __build_for_lang_any, frontend-agnostic flags). Dynamic scoping
|
||||||
|
# and shadowing redefinitions are used for the __build_for_* variables
|
||||||
|
# to remain largely compatible with existing spec files that have
|
||||||
|
# hard-coded assumptions which macros assume which other macros.
|
||||||
|
# Note: Using short-circuit evaluation with || in __build_for_* conditionals
|
||||||
|
# may result in unused-macro warnings from RPM.
|
||||||
|
%__build_for_lang_c 1
|
||||||
|
%__build_for_lang_cxx 1
|
||||||
|
%__build_for_lang_any 1
|
||||||
|
%__build_flags_common() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{optflags}
|
||||||
|
%__build_flags_lang_c() %{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{optflags}
|
||||||
|
%__build_flags_lang_cxx() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_any 0}%{optflags}
|
||||||
|
|
||||||
# Automatically trim changelog entries after 2 years
|
# Automatically trim changelog entries after 2 years
|
||||||
%_changelog_trimage %{expr:2*365*24*60*60}
|
%_changelog_trimage %{expr:2*365*24*60*60}
|
||||||
|
|
||||||
|
@ -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 258
|
%global baserelease 259
|
||||||
|
|
||||||
Summary: Red Hat specific rpm configuration files
|
Summary: Red Hat specific rpm configuration files
|
||||||
Name: redhat-rpm-config
|
Name: redhat-rpm-config
|
||||||
@ -254,6 +254,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua
|
|||||||
%doc buildflags.md
|
%doc buildflags.md
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Wed Jul 5 2023 Florian Weimer <fweimer@redhat.com> - 259-1
|
||||||
|
- Filter out C, C++ build flags from Fortran build flags (#2177253)
|
||||||
|
|
||||||
* Wed Jul 5 2023 Florian Weimer <fweimer@redhat.com> - 258-1
|
* Wed Jul 5 2023 Florian Weimer <fweimer@redhat.com> - 258-1
|
||||||
- Enable PIC mode for assembler files (#2167430)
|
- Enable PIC mode for assembler files (#2167430)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user