2002-06-12 12:59:50 +00:00
# Per-platform rpm configuration file.
#==============================================================================
# ---- per-platform macros.
#
%_vendor redhat
%_os linux
2002-06-28 05:25:23 +00:00
%_target_platform %{_target_cpu}-%{_vendor}-%{_target_os}%{?_gnu}
2002-06-12 12:59:50 +00:00
#==============================================================================
2002-10-03 16:31:51 +00:00
# ---- configure macros. note that most of these are inherited
# from the defaults.
2002-06-12 12:59:50 +00:00
#
%_localstatedir /var
2022-08-30 13:40:38 +00:00
%_runstatedir /run
2002-06-12 12:59:50 +00:00
2013-07-24 22:20:05 +00:00
%_pkgdocdir %{_docdir}/%{name}
%_docdir_fmt %%{NAME}
2002-06-12 12:59:50 +00:00
2008-05-06 23:08:20 +00:00
%_fmoddir %{_libdir}/gfortran/modules
2019-06-20 05:29:07 +00:00
%source_date_epoch_from_changelog 1
2022-12-19 15:27:08 +00:00
%clamp_mtime_to_source_date_epoch %source_date_epoch_from_changelog
2019-06-20 05:29:07 +00:00
2002-12-11 18:05:00 +00:00
%_enable_debug_packages 1
2012-06-27 10:32:42 +00:00
%_include_minidebuginfo 1
2017-07-31 12:43:55 +00:00
%_include_gdb_index 1
2017-07-31 12:45:06 +00:00
%_debugsource_packages 1
%_debuginfo_subpackages 1
2002-11-20 16:55:36 +00:00
2020-06-03 19:03:31 +00:00
# GCC toolchain
%__cc_gcc gcc
%__cxx_gcc g++
%__cpp_gcc gcc -E
# Clang toolchain
%__cc_clang clang
%__cxx_clang clang++
%__cpp_clang clang-cpp
# Default to the GCC toolchain
%toolchain gcc
%__cc %{expand:%%{__cc_%{toolchain}}}
%__cxx %{expand:%%{__cxx_%{toolchain}}}
%__cpp %{expand:%%{__cpp_%{toolchain}}}
2021-07-15 14:42:15 +00:00
# Compiler macros to use for invoking compilers in spec files for packages that
# want to use the default compiler and don't care which compiler that is.
2021-08-17 21:14:52 +00:00
%build_cc %{__cc}
%build_cxx %{__cxx}
%build_cpp %{__cpp}
2021-07-15 14:42:15 +00:00
2018-02-04 17:00:40 +00:00
#==============================================================================
# ---- compiler flags.
# C compiler flags. This is traditionally called CFLAGS in makefiles.
# Historically also available as %%{optflags}, and %%build sets the
# environment variable RPM_OPT_FLAGS to this value.
2023-07-05 10:46:49 +00:00
%build_cflags %{__build_flags_lang_c} %{?_distro_extra_cflags}
2018-02-04 17:00:40 +00:00
# C++ compiler flags. This is traditionally called CXXFLAGS in makefiles.
2023-07-05 10:46:49 +00:00
%build_cxxflags %{__build_flags_lang_cxx} %{?_distro_extra_cxxflags}
2018-02-04 17:00:40 +00:00
# Fortran compiler flags. Makefiles use both FFLAGS and FCFLAGS as
# the corresponding variable names.
2023-07-05 10:46:49 +00:00
%build_fflags %{__build_flags_common} -I%{_fmoddir} %{?_distro_extra_fflags}
2018-02-04 17:00:40 +00:00
2022-09-13 16:36:03 +00:00
# Vala compiler flags. This is used to set VALAFLAGS.
%build_valaflags -g
2022-05-23 23:46:48 +00:00
# When clang is used as a linker driver, it does not auto-detect the LTO
# bytecode and neither does bfd, so we need to explicitly pass the -flto
# flag when linking.
2023-06-17 12:28:45 +00:00
%_clang_extra_ldflags %{?_lto_cflags}
2022-05-23 23:46:48 +00:00
2018-02-04 17:00:40 +00:00
# Link editor flags. This is usually called LDFLAGS in makefiles.
# (Some makefiles use LFLAGS instead.) The default value assumes that
# the flags, while intended for ld, are still passed through the gcc
# compiler driver. At the beginning of %%build, the environment
# variable RPM_LD_FLAGS to this value.
2024-01-02 15:44:30 +00:00
%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_ld_pack_relocs_flags} %{_hardened_ldflags} %{_annotation_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_clang_extra_ldflags}" : "" ] %{_build_id_flags} %{?_package_note_flags} %{?_distro_extra_ldflags}
2018-02-04 17:00:40 +00:00
2020-06-03 19:03:31 +00:00
# Expands to shell code to set the compiler/linker environment
2022-09-13 16:36:03 +00:00
# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, VALAFLAGS, LDFLAGS if they
# have not been set already. RPM_OPT_FLAGS and RPM_LD_FLAGS have already
2018-02-04 17:00:40 +00:00
# been set implicitly at the start of the %%build section.
2019-03-28 12:37:17 +00:00
# LT_SYS_LIBRARY_PATH is used by libtool script.
2018-02-04 17:00:40 +00:00
%set_build_flags \
CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \
CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \
FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \
FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
2023-02-23 22:28:44 +00:00
VALAFLAGS="${VALAFLAGS:-%{build_valaflags}}" ; export VALAFLAGS ; \
RUSTFLAGS="${RUSTFLAGS:-%{build_rustflags}}" ; export RUSTFLAGS ; \
2019-03-28 12:37:17 +00:00
LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS ; \
2020-06-03 19:03:31 +00:00
LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-%_libdir:}" ; export LT_SYS_LIBRARY_PATH ; \
2020-08-20 12:45:21 +00:00
CC="${CC:-%{__cc}}" ; export CC ; \
CXX="${CXX:-%{__cxx}}" ; export CXX
2020-06-03 19:03:31 +00:00
2021-12-04 05:02:46 +00:00
# Automatically use set_build_flags macro for build, check, and
# install phases.
# Use "%undefine _auto_set_build_flags" to disable"
%_auto_set_build_flags 1
2022-01-20 21:00:46 +00:00
%__spec_build_pre %{___build_pre} \
%{?_auto_set_build_flags:%{set_build_flags}} \
%{?_generate_package_note_file}
2022-01-23 01:58:24 +00:00
%__spec_check_pre %{___build_pre} \
%{?_auto_set_build_flags:%{set_build_flags}} \
%{?_generate_package_note_file}
2021-12-04 05:02:46 +00:00
2018-12-20 10:34:27 +00:00
# Internal-only. Do not use. Expand a variable and strip the flags
# not suitable to extension builders.
%__extension_strip_flags() %{lua:
2023-05-18 12:36:24 +00:00
--the only argument to this macro is the "name" of the flags we strip (e.g. cflags, ldflags, etc.)
2018-12-20 10:34:27 +00:00
local name = rpm.expand("%{1}")
2023-05-18 12:36:24 +00:00
--store all the individual flags in a variable as a continuous string
local flags = rpm.expand("%{build_" .. name .. "}")
--create an empty table for the minimal set of flags we wanna preserve
local stripped_flags = { }
--iterate over the individual flags and store the ones we want in the table as unique keys
for flag in flags:gmatch("%S+") do
if flag:find("^%-fexceptions") or flag:find("^%-fcf%-protection") then
stripped_flags[flag] = true end
end
--print out the finalized set of flags for use by the extension builders
for k,_ in pairs(stripped_flags) do print(k .. " ") end
2018-12-20 10:34:27 +00:00
}
# Variants of CFLAGS, CXXFLAGS, FFLAGS, LDFLAGS for use within
# extension builders.
%extension_cflags %{__extension_strip_flags cflags}
%extension_cxxflags %{__extension_strip_flags cxxflags}
%extension_fflags %{__extension_strip_flags fflags}
%extension_ldflags %{__extension_strip_flags ldflags}
2018-02-04 17:00:40 +00:00
# Deprecated names. For backwards compatibility only.
%__global_cflags %{build_cflags}
%__global_cxxflags %{build_cxxflags}
%__global_fflags %{build_fflags}
%__global_fcflags %{build_fflags}
%__global_ldflags %{build_ldflags}
2020-10-05 11:38:25 +00:00
# Architecture-specific support. Internal. Do not use directly.
2023-03-09 12:28:14 +00:00
%__cflags_arch_x86_64_v2 %[0%{?rhel} == 9 ? "-march=x86-64-v2" : ""]
%__cflags_arch_x86_64_v3 %[0%{?rhel} > 9 ? "-march=x86-64-v3" : ""]
%__cflags_arch_x86_64 %{__cflags_arch_x86_64_v2} %{__cflags_arch_x86_64_v3}
2023-08-29 08:58:30 +00:00
%__cflags_arch_x86_64_common -mtune=generic -fasynchronous-unwind-tables -fstack-clash-protection -fcf-protection %{_frame_pointers_cflags} %{_frame_pointers_cflags_x86_64}
2021-01-19 19:10:22 +00:00
2020-10-05 11:38:25 +00:00
# Also used for s390.
2022-07-15 09:10:18 +00:00
%__cflags_arch_s390x %[0%{?rhel} >= 9 ? "-march=z14 -mtune=z15" : "-march=z13 -mtune=z14"]
2020-10-05 11:38:25 +00:00
2022-02-10 15:35:07 +00:00
%__cflags_arch_ppc64le %[0%{?rhel} >= 9 ? "-mcpu=power9 -mtune=power9" : "-mcpu=power8 -mtune=power8"]
2002-06-12 12:59:50 +00:00
#==============================================================================
# ---- configure and makeinstall.
#
2014-04-08 10:30:58 +00:00
%_configure_gnuconfig_hack 1
2014-01-13 19:45:57 +00:00
%_configure_libtool_hardening_hack 1
2016-10-03 21:06:03 +00:00
# If defined, _configure_disable_silent_rules will cause --disable-silent-rules
# to be added to the list of options passed to the configure script.
# Eventually we'll want to turn this on by default, but this gives packagers a
# way to turn it back off.
# %_configure_disable_silent_rules 1
2020-05-26 19:12:11 +00:00
2022-12-10 12:39:25 +00:00
# Pass --runstatedir to configure.
%_configure_use_runstatedir 1
2020-05-26 19:12:11 +00:00
# This fixes various easy resolved configure tests that are compromised by LTO.
#
# We use this within the standard %configure macro, but also make it available
# for packages which don't use %configure
#
# The first three are common ways to test for the existence of a function, so
# we ensure the reference to the function is preserved
#
# The fourth are constants used to then try to generate NaNs and other key
# floating point numbers. We then use those special FP numbers to try and
# raise a SIGFPE. By declaring x & y volatile we prevent the optimizers
# from removing the computation
#
# The fifth (and worst) addresses problems with autoconf/libtool's approach
# to extracting symbols from .o files and generating C code. In an LTO world
# types matter much more closely and you can't have an object in one context
# that is a function definition and a simple scalar variable in another.
# Thankfully HP-UX has always had that restriction and is supported by
# autoconf/libtool. The insane sed script replaces the "generic" code with
# the HP-UX version.
#
# If we do not make changes, we put the original file back. This avoids
# unnecessary rebuilds of things that may have dependencies on the configure
# files.
#
%_fix_broken_configure_for_lto \
for file in $(find . -type f -name configure -print); do \
%{__sed} -r --in-place=.backup 's/^char \\(\\*f\\) \\(\\) = /__attribute__ ((used)) char (*f) () = /g' $file; \
diff -u $file.backup $file && mv $file.backup $file \
%{__sed} -r --in-place=.backup 's/^char \\(\\*f\\) \\(\\);/__attribute__ ((used)) char (*f) ();/g' $file; \
diff -u $file.backup $file && mv $file.backup $file \
%{__sed} -r --in-place=.backup 's/^char \\$2 \\(\\);/__attribute__ ((used)) char \\$2 ();/g' $file; \
diff -u $file.backup $file && mv $file.backup $file \
%{__sed} --in-place=.backup '1{$!N;$!N};$!N;s/int x = 1;\\nint y = 0;\\nint z;\\nint nan;/volatile int x = 1; volatile int y = 0; volatile int z, nan;/;P;D' $file; \
diff -u $file.backup $file && mv $file.backup $file \
%{__sed} --in-place=.backup 's#^lt_cv_sys_global_symbol_to_cdecl=.*#lt_cv_sys_global_symbol_to_cdecl="sed -n -e '"'"'s/^T .* \\\\(.*\\\\)$/extern int \\\\1();/p'"'"' -e '"'"'s/^$symcode* .* \\\\(.*\\\\)$/extern char \\\\1;/p'"'"'"#' $file; \
diff -u $file.backup $file && mv $file.backup $file \
2020-06-04 01:09:53 +00:00
done
2020-05-26 19:12:11 +00:00
2014-01-13 19:45:57 +00:00
%configure \
2018-02-04 17:00:40 +00:00
%{set_build_flags}; \
2020-05-26 19:12:11 +00:00
[ "%{_lto_cflags}"x != x ] && %{_fix_broken_configure_for_lto}; \
2015-05-29 14:54:33 +00:00
[ "%_configure_gnuconfig_hack" = 1 ] && for i in $(find $(dirname %{_configure}) -name config.guess -o -name config.sub) ; do \
2013-04-22 11:14:06 +00:00
[ -f /usr/lib/rpm/redhat/$(basename $i) ] && %{__rm} -f $i && %{__cp} -fv /usr/lib/rpm/redhat/$(basename $i) $i ; \
done ; \
2014-01-13 19:45:57 +00:00
[ "%_configure_libtool_hardening_hack" = 1 ] && [ x != "x%{_hardened_ldflags}" ] && \
for i in $(find . -name ltmain.sh) ; do \
%{__sed} -i.backup -e 's~compiler_flags=$~compiler_flags="%{_hardened_ldflags}"~' $i \
done ; \
2010-01-22 13:34:07 +00:00
%{_configure} --build=%{_build} --host=%{_host} \\\
2003-07-15 13:44:02 +00:00
--program-prefix=%{?_program_prefix} \\\
2010-01-22 13:43:38 +00:00
--disable-dependency-tracking \\\
2016-10-03 17:55:00 +00:00
%{?_configure_disable_silent_rules:--disable-silent-rules} \\\
2003-07-15 13:38:58 +00:00
--prefix=%{_prefix} \\\
2002-06-12 12:59:50 +00:00
--exec-prefix=%{_exec_prefix} \\\
--bindir=%{_bindir} \\\
--sbindir=%{_sbindir} \\\
--sysconfdir=%{_sysconfdir} \\\
--datadir=%{_datadir} \\\
--includedir=%{_includedir} \\\
--libdir=%{_libdir} \\\
--libexecdir=%{_libexecdir} \\\
--localstatedir=%{_localstatedir} \\\
2022-12-10 12:39:25 +00:00
%{?_configure_use_runstatedir:$(grep -q "runstatedir=DIR" %{_configure} && echo '--runstatedir=%{_runstatedir}')} \\\
2002-06-12 12:59:50 +00:00
--sharedstatedir=%{_sharedstatedir} \\\
--mandir=%{_mandir} \\\
2014-01-13 19:45:57 +00:00
--infodir=%{_infodir}
2002-06-12 12:59:50 +00:00
#==============================================================================
# ---- Build policy macros.
#
2010-01-22 13:24:29 +00:00
#
#---------------------------------------------------------------------
# Expanded at beginning of %install scriptlet.
#
%__spec_install_pre %{___build_pre}\
[ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
2021-04-19 19:02:49 +00:00
mkdir -p "`dirname "$RPM_BUILD_ROOT"`"\
2010-01-22 13:24:29 +00:00
mkdir "$RPM_BUILD_ROOT"\
2021-12-04 05:02:46 +00:00
%{?_auto_set_build_flags:%{set_build_flags}}\
2010-01-22 13:24:29 +00:00
%{nil}
2002-06-12 12:59:50 +00:00
#---------------------------------------------------------------------
# Expanded at end of %install scriptlet.
#
2007-07-05 16:41:21 +00:00
%__arch_install_post /usr/lib/rpm/check-buildroot
2002-06-12 12:59:50 +00:00
2018-01-17 10:16:45 +00:00
# Build root policy macros. Standard naming:
# convert all '-' in basename to '_', add two leading underscores.
2018-01-25 19:26:12 +00:00
%__brp_ldconfig /usr/lib/rpm/redhat/brp-ldconfig
2018-01-17 10:16:45 +00:00
%__brp_compress /usr/lib/rpm/brp-compress
%__brp_strip /usr/lib/rpm/brp-strip %{__strip}
2020-01-08 18:25:43 +00:00
%__brp_strip_lto /usr/lib/rpm/redhat/brp-strip-lto %{__strip}
2018-01-17 10:16:45 +00:00
%__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump}
%__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip}
2021-05-03 15:22:14 +00:00
%__brp_check_rpaths /usr/lib/rpm/check-rpaths
2018-05-02 18:28:58 +00:00
# __brp_mangle_shebangs_exclude - shebangs to exclude
# __brp_mangle_shebangs_exclude_file - file from which to get shebangs to exclude
# __brp_mangle_shebangs_exclude_from - files to ignore
# __brp_mangle_shebangs_exclude_from_file - file from which to get files to ignore
%__brp_mangle_shebangs /usr/lib/rpm/redhat/brp-mangle-shebangs %{?__brp_mangle_shebangs_exclude:--shebangs "%{?__brp_mangle_shebangs_exclude}"} %{?__brp_mangle_shebangs_exclude_file:--shebangs-from "%{__brp_mangle_shebangs_exclude_file}"} %{?__brp_mangle_shebangs_exclude_from:--files "%{?__brp_mangle_shebangs_exclude_from}"} %{?__brp_mangle_shebangs_exclude_from_file:--files-from "%{__brp_mangle_shebangs_exclude_from_file}"}
2018-01-17 10:16:45 +00:00
2021-11-16 21:28:14 +00:00
%__brp_llvm_compile_lto_elf /usr/lib/rpm/redhat/brp-llvm-compile-lto-elf %{build_cflags} %{build_ldflags}
2021-02-10 16:59:25 +00:00
2021-06-30 17:25:29 +00:00
# note: %%__os_install_post_python is defined in python-srpm-macros and contains several policies
# redhat-rpm-config maintainers, don't remove it from %%__os_install_post unless coordinating the change with Python maintainers
# packagers, don't undefine the entire macro, see the individual macros in /usr/lib/rpm/macros.d/macros.python-srpm
2002-06-12 12:59:50 +00:00
%__os_install_post \
2018-01-25 19:26:12 +00:00
%{?__brp_ldconfig} \
2018-01-17 10:16:45 +00:00
%{?__brp_compress} \
2010-03-01 08:58:17 +00:00
%{!?__debug_package:\
2018-01-17 10:16:45 +00:00
%{?__brp_strip} \
%{?__brp_strip_comment_note} \
2010-03-01 08:58:17 +00:00
} \
2020-01-08 18:25:43 +00:00
%{?__brp_strip_lto} \
2018-01-17 10:16:45 +00:00
%{?__brp_strip_static_archive} \
2021-05-03 15:22:14 +00:00
%{?__brp_check_rpaths} \
2018-01-10 12:38:28 +00:00
%{?__brp_mangle_shebangs} \
2021-10-12 05:51:23 +00:00
%{?__brp_remove_la_files} \
2021-07-01 13:18:48 +00:00
%{__os_install_post_python} \
2002-06-12 12:59:50 +00:00
%{nil}
%__spec_install_post\
2022-06-22 10:56:17 +00:00
%[ "%{toolchain}" == "clang" ? "%{?__brp_llvm_compile_lto_elf}" : "%{nil}" ] \
2002-09-16 16:22:01 +00:00
%{?__debug_package:%{__debug_install_post}}\
2002-06-12 12:59:50 +00:00
%{__arch_install_post}\
%{__os_install_post}\
%{nil}
2002-12-14 20:37:32 +00:00
%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
%%install\
2008-05-06 23:08:20 +00:00
%{nil}
#
# Should missing buildids terminate a build?
%_missing_build_ids_terminate_build 1
2002-07-31 18:56:20 +00:00
2010-01-22 13:07:55 +00:00
# Use SHA-256 for FILEDIGESTS instead of default MD5
%_source_filedigest_algorithm 8
%_binary_filedigest_algorithm 8
2019-07-01 14:19:40 +00:00
# Use Zstandard compression for binary payloads
%_binary_payload w19.zstdio
2010-01-22 13:25:17 +00:00
2023-07-05 10:46:49 +00:00
#==============================================================================
# --- Compiler flags control.
#
# Please consult buildflags.md for parts that can be configured
# from RPM spec files.
2020-06-03 19:03:31 +00:00
%_hardening_gcc_cflags -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
%_hardening_clang_cflags --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg
%_hardening_cflags %{expand:%%{_hardening_%{toolchain}_cflags}} -fstack-protector-strong
2014-01-13 19:45:57 +00:00
# we don't escape symbols '~', '"', etc. so be careful when changing this
2020-06-03 19:03:31 +00:00
%_hardening_ldflags -Wl,-z,now %[ "%{toolchain}" == "gcc" ? "-specs=/usr/lib/rpm/redhat/redhat-hardened-ld" : "" ]
2011-09-16 20:49:56 +00:00
2020-06-03 19:03:31 +00:00
# Harden packages by default for Fedora 23+:
2015-02-12 19:11:00 +00:00
# https://fedorahosted.org/fesco/ticket/1384 (accepted on 2014-02-11)
2018-01-19 10:21:06 +00:00
# Use "%undefine _hardened_build" to disable.
2015-02-12 19:11:00 +00:00
%_hardened_build 1
2011-09-16 20:49:56 +00:00
%_hardened_cflags %{?_hardened_build:%{_hardening_cflags}}
%_hardened_ldflags %{?_hardened_build:%{_hardening_ldflags}}
2011-08-01 16:26:41 +00:00
2020-06-03 19:03:31 +00:00
# Add extra information to binary objects created by the compiler:
2017-10-03 13:53:23 +00:00
# https://pagure.io/fesco/issue/1780 (accepted on 2017-10-30)
2021-05-26 19:36:44 +00:00
# ...except on armv7hl, which has an issue whose root-cause isn't
# clear yet: https://bugzilla.redhat.com/show_bug.cgi?id=1951492
2018-01-19 10:21:06 +00:00
# Use "%undefine _annotated_build" to disable.
2020-01-20 12:50:15 +00:00
%_annotated_build 1
2020-06-03 19:03:31 +00:00
%_annobin_gcc_plugin -specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
# The annobin plugin is not built for clang yet
%_annobin_clang_plugin %dnl-fplugin=/usr/lib64/clang/`clang -dumpversion`/lib/annobin.so
2021-05-26 19:36:44 +00:00
%_annotation_plugin %{?_annotated_build:%{expand:%%{_annobin_%{toolchain}_plugin}}}
%_annotation_cflags %[ "%{_target_cpu}" == "armv7hl" ? "" : "%{_annotation_plugin}" ]
2021-08-02 10:43:26 +00:00
%_annotation_ldflags %{?_lto_cflags:%{_annotation_cflags}}
2022-06-17 10:33:00 +00:00
# Use the remove-section option to force the find-debuginfo script
# to move the annobin notes into the separate debuginfo file.
%_find_debuginfo_extra_opts %{?_annotated_build:--remove-section .gnu.build.attributes}
2017-10-03 13:53:23 +00:00
2023-11-03 17:51:14 +00:00
# Include frame pointer information by default, except on RHEL 10 and earlier
# On RHEL 11, we are enabling it for now, with the possibility of revoking it
# at a later date.
2022-12-28 20:17:38 +00:00
# https://fedoraproject.org/wiki/Changes/fno-omit-frame-pointer
2023-01-03 18:35:43 +00:00
# Use "%undefine _include_frame_pointers" to disable.
2023-11-03 17:51:14 +00:00
%_include_frame_pointers %{undefined rhel} || 0%{?rhel} >= 11
2023-01-13 13:37:12 +00:00
%_frame_pointers_cflags %{expr:0%{?_include_frame_pointers} ? "-fno-omit-frame-pointer" : ""}
%_frame_pointers_cflags_x86_64 %{expr:0%{?_include_frame_pointers} ? "-mno-omit-leaf-frame-pointer" : ""}
%_frame_pointers_cflags_aarch64 %{expr:0%{?_include_frame_pointers} ? "-mno-omit-leaf-frame-pointer" : ""}
%_frame_pointers_cflags_s390x %{expr:0%{?_include_frame_pointers} ? "-mbackchain" : ""}
2022-12-28 20:17:38 +00:00
2018-01-22 15:01:54 +00:00
# Fail linking if there are undefined symbols. Required for proper
2018-01-29 14:18:04 +00:00
# ELF symbol versioning support. Disabled by default.
2018-07-10 14:23:36 +00:00
# Use "%define _ld_strict_symbol_defs 1" to enable.
#%_ld_strict_symbol_defs 1
%_ld_symbols_flags %{?_ld_strict_symbol_defs:-Wl,-z,defs}
2018-01-22 15:01:54 +00:00
2018-07-02 21:27:51 +00:00
# https://fedoraproject.org/wiki/Changes/RemoveExcessiveLinking
2018-08-15 05:00:14 +00:00
# use "%undefine _ld_as_needed" to disable.
%_ld_as_needed 1
2018-07-10 14:45:19 +00:00
%_ld_as_needed_flags %{?_ld_as_needed:-Wl,--as-needed}
2018-07-02 21:27:51 +00:00
2024-01-03 16:18:20 +00:00
# aarch64 and s390x currently do not support packed relocations.
%_ld_pack_relocs %[ "%{_arch}" == "x86_64" || "%{_arch}" == "i386" || "%{_arch}" == "ppc64le" ]
%_ld_pack_relocs_flags %[0%{?_ld_pack_relocs} ? "-Wl,-z,pack-relative-relocs" : ""]
2024-01-02 15:44:30 +00:00
2020-07-22 03:38:41 +00:00
# LTO is the default in Fedora.
# "%define _lto_cflags %{nil}" to opt out
#
# We currently have -ffat-lto-objects turned on out of an abundance of
# caution. To remove it we need to do a check of the installed .o/.a files
# to verify they have real sections/symbols after LTO stripping. That
# way we can detect installing an unusable .o/.a file. This is on the TODO
# list for F34.
2020-07-30 16:45:53 +00:00
%_gcc_lto_cflags -flto=auto -ffat-lto-objects
2023-01-04 20:07:09 +00:00
%_clang_lto_cflags -flto=thin
2020-07-28 02:11:54 +00:00
%_lto_cflags %{expand:%%{_%{toolchain}_lto_cflags}}
2020-07-22 03:38:41 +00:00
2022-12-14 16:28:14 +00:00
# Default fortification level.
# "%define _fortify_level 2" to downgrade and
# "%define _fortify_level 0" or "%undefine _fortify_level" to disable
2023-01-16 16:04:09 +00:00
#
# We use a single -Wp here to enforce order so that ccache does not ever
# reorder them.
2022-12-14 16:28:14 +00:00
%_fortify_level 3
2023-01-16 16:04:09 +00:00
%_fortify_level_flags %[ 0%{?_fortify_level} > 0 ? "-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=%{_fortify_level}" : "" ]
2022-12-14 16:28:14 +00:00
2023-07-05 11:36:52 +00:00
# This can be set to a positive integer to obtain increasing type
# safety levels for C. See buildflags.md.
2023-09-26 16:36:28 +00:00
%build_type_safety_c 1
2023-07-05 11:36:52 +00:00
2023-07-05 06:41:53 +00:00
# Some linkers default to a build-id algorithm that is not supported by rpmbuild,
2021-11-13 00:44:22 +00:00
# so we need to specify the right algorithm to use.
%_build_id_flags -Wl,--build-id=sha1
2020-07-22 03:38:41 +00:00
%_general_options -O2 %{?_lto_cflags} -fexceptions -g -grecord-gcc-switches -pipe
2023-07-07 11:58:33 +00:00
%_warning_options -Wall%[%__build_for_lang_any && "%toolchain" == "gcc" ? " -Wno-complain-wrong-lang" : ""]%[%__build_for_lang_c + %__build_for_lang_cxx ? " -Werror=format-security" : ""]%[%__build_for_lang_c && (%build_type_safety_c >= 1) ? " -Werror=implicit-function-declaration -Werror=implicit-int" : ""]%[%__build_for_lang_c && (%build_type_safety_c >= 2) ? " -Werror=int-conversion" : ""]%[%__build_for_lang_c && (%build_type_safety_c >= 3) ? " -Werror=incompatible-pointer-types" : ""]
2022-12-14 16:28:14 +00:00
%_preprocessor_defines %{_fortify_level_flags} -Wp,-D_GLIBCXX_ASSERTIONS
2020-06-03 19:03:31 +00:00
# Common variables are no longer generated by default by gcc and clang
# If they are needed then add "%define _legacy_common_support 1" to the spec file.
%_legacy_options %{?_legacy_common_support: -fcommon}
2023-01-05 16:00:20 +00:00
%__global_compiler_flags %{_general_options} %{_warning_options} %{_preprocessor_defines} %{_hardened_cflags} %{_annotation_cflags} %{_legacy_options}
2016-11-30 11:39:02 +00:00
2023-07-05 10:46:49 +00:00
# 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.
2023-07-07 11:58:33 +00:00
# The __build_flags_no_macro_warning construct suppresses a warning
# about unused RPM macros.
2023-07-05 10:46:49 +00:00
%__build_for_lang_c 1
%__build_for_lang_cxx 1
%__build_for_lang_any 1
2023-07-07 11:58:33 +00:00
%__build_flags_no_macro_warning %[%__build_for_lang_c + %__build_for_lang_cxx + %__build_for_lang_any ? "" : ""]
%__build_flags_common() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{__build_flags_no_macro_warning}%{optflags}
%__build_flags_lang_c() %{expand:%define __build_for_lang_cxx 0}%{expand:%define __build_for_lang_any 0}%{__build_flags_no_macro_warning}%{optflags}
%__build_flags_lang_cxx() %{expand:%define __build_for_lang_c 0}%{expand:%define __build_for_lang_any 0}%{__build_flags_no_macro_warning}%{optflags}
2023-07-05 10:46:49 +00:00
2018-03-11 14:15:30 +00:00
# Automatically trim changelog entries after 2 years
2021-02-25 16:29:56 +00:00
%_changelog_trimage %{expr:2*365*24*60*60}
2018-03-11 14:15:30 +00:00
2010-01-22 13:30:02 +00:00
#==============================================================================
2014-04-27 08:58:18 +00:00
# ---- Generic auto req/prov filtering macros
2010-01-22 13:30:02 +00:00
#
# http://fedoraproject.org/wiki/PackagingDrafts/AutoProvidesAndRequiresFiltering
# prevent anything matching from being scanned for provides
%filter_provides_in(P) %{expand: \
%global __filter_prov_cmd %{?__filter_prov_cmd} %{__grep} -v %{-P} '%*' | \
}
# prevent anything matching from being scanned for requires
%filter_requires_in(P) %{expand: \
%global __filter_req_cmd %{?__filter_req_cmd} %{__grep} -v %{-P} '%*' | \
}
# filter anything matching out of the provides stream
%filter_from_provides() %{expand: \
%global __filter_from_prov %{?__filter_from_prov} | %{__sed} -e '%*' \
}
# filter anything matching out of the requires stream
%filter_from_requires() %{expand: \
%global __filter_from_req %{?__filter_from_req} | %{__sed} -e '%*' \
}
2014-04-27 08:58:18 +00:00
# actually set up the filtering bits
2010-01-22 13:30:02 +00:00
%filter_setup %{expand: \
%global _use_internal_dependency_generator 0 \
2012-11-09 11:40:39 +00:00
%global __deploop() while read FILE; do echo "${FILE}" | /usr/lib/rpm/rpmdeps -%{1}; done | /bin/sort -u \
2010-01-22 13:30:02 +00:00
%global __find_provides /bin/sh -c "%{?__filter_prov_cmd} %{__deploop P} %{?__filter_from_prov}" \
%global __find_requires /bin/sh -c "%{?__filter_req_cmd} %{__deploop R} %{?__filter_from_req}" \
}