Elliot Lee 03bb291
# Per-platform rpm configuration file.
Elliot Lee 03bb291
Elliot Lee 03bb291
#==============================================================================
Elliot Lee 03bb291
# ---- per-platform macros.
Elliot Lee 03bb291
#
Elliot Lee 03bb291
%_vendor		redhat
Elliot Lee 03bb291
%_os			linux
cb63b82
%_target_platform	%{_target_cpu}-%{_vendor}-%{_target_os}%{?_gnu}
Elliot Lee 03bb291
Elliot Lee 03bb291
#==============================================================================
Jeremy Katz 8a919b8
# ---- configure macros.  note that most of these are inherited
Jeremy Katz 8a919b8
#      from the defaults.
Elliot Lee 03bb291
#
Elliot Lee 03bb291
%_localstatedir		/var
Frederic Berat c0d2923
%_runstatedir		/run
Elliot Lee 03bb291
e606f56
%_pkgdocdir             %{_docdir}/%{name}
e606f56
%_docdir_fmt            %%{NAME}
Elliot Lee 03bb291
Jonathan Masters 9ed9b4e
%_fmoddir		%{_libdir}/gfortran/modules
Jonathan Masters 9ed9b4e
86aae60
%source_date_epoch_from_changelog 1
f1687db
%clamp_mtime_to_source_date_epoch %source_date_epoch_from_changelog
86aae60
Elliot Lee cec7d07
%_enable_debug_packages 1
98d1974
%_include_minidebuginfo 1
f6596a4
%_include_gdb_index     1
00e8557
%_debugsource_packages  1
00e8557
%_debuginfo_subpackages 1
27ac144
7562b38
# GCC toolchain
7562b38
%__cc_gcc gcc
7562b38
%__cxx_gcc g++
7562b38
%__cpp_gcc gcc -E
7562b38
7562b38
# Clang toolchain
7562b38
%__cc_clang clang
7562b38
%__cxx_clang clang++
7562b38
%__cpp_clang clang-cpp
7562b38
7562b38
# Default to the GCC toolchain
7562b38
%toolchain gcc
7562b38
7562b38
%__cc %{expand:%%{__cc_%{toolchain}}}
7562b38
%__cxx %{expand:%%{__cxx_%{toolchain}}}
7562b38
%__cpp %{expand:%%{__cpp_%{toolchain}}}
7562b38
73aefaa
# Compiler macros to use for invoking compilers in spec files for packages that
73aefaa
# want to use the default compiler and don't care which compiler that is.
3ec329b
%build_cc %{__cc}
3ec329b
%build_cxx %{__cxx}
3ec329b
%build_cpp %{__cpp}
73aefaa
Elliot Lee 03bb291
#==============================================================================
fa08f0e
# ---- compiler flags.
fa08f0e
fa08f0e
# C compiler flags.  This is traditionally called CFLAGS in makefiles.
fa08f0e
# Historically also available as %%{optflags}, and %%build sets the
fa08f0e
# environment variable RPM_OPT_FLAGS to this value.
e0e0971
%build_cflags %{optflags} %{?_distro_extra_cflags}
fa08f0e
fa08f0e
# C++ compiler flags.  This is traditionally called CXXFLAGS in makefiles.
e0e0971
%build_cxxflags %{optflags} %{?_distro_extra_cxxflags}
fa08f0e
fa08f0e
# Fortran compiler flags.  Makefiles use both FFLAGS and FCFLAGS as
fa08f0e
# the corresponding variable names.
e0e0971
%build_fflags %{optflags} -I%{_fmoddir} %{?_distro_extra_fflags}
fa08f0e
d097058
# Vala compiler flags. This is used to set VALAFLAGS.
d097058
%build_valaflags -g
d097058
9a1b602
# When clang is used as a linker driver, it does not auto-detect the LTO
9a1b602
# bytecode and neither does bfd, so we need to explicitly pass the -flto
9a1b602
# flag when linking.
76bd9dd
%_clang_extra_ldflags %{?_lto_cflags}
9a1b602
fa08f0e
# Link editor flags.  This is usually called LDFLAGS in makefiles.
fa08f0e
# (Some makefiles use LFLAGS instead.)  The default value assumes that
fa08f0e
# the flags, while intended for ld, are still passed through the gcc
fa08f0e
# compiler driver.  At the beginning of %%build, the environment
fa08f0e
# variable RPM_LD_FLAGS to this value.
e0e0971
%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}
fa08f0e
7562b38
# Expands to shell code to set the compiler/linker environment
d097058
# variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, VALAFLAGS, LDFLAGS if they
d097058
# have not been set already.  RPM_OPT_FLAGS and RPM_LD_FLAGS have already
fa08f0e
# been set implicitly at the start of the %%build section.
e345575
# LT_SYS_LIBRARY_PATH is used by libtool script.
fa08f0e
%set_build_flags \
fa08f0e
  CFLAGS="${CFLAGS:-%{build_cflags}}" ; export CFLAGS ; \
fa08f0e
  CXXFLAGS="${CXXFLAGS:-%{build_cxxflags}}" ; export CXXFLAGS ; \
fa08f0e
  FFLAGS="${FFLAGS:-%{build_fflags}}" ; export FFLAGS ; \
fa08f0e
  FCFLAGS="${FCFLAGS:-%{build_fflags}}" ; export FCFLAGS ; \
16122a6
  VALAFLAGS="${VALAFLAGS:-%{build_valaflags}}" ; export VALAFLAGS ; \
16122a6
  RUSTFLAGS="${RUSTFLAGS:-%{build_rustflags}}" ; export RUSTFLAGS ; \
e345575
  LDFLAGS="${LDFLAGS:-%{build_ldflags}}" ; export LDFLAGS ; \
7562b38
  LT_SYS_LIBRARY_PATH="${LT_SYS_LIBRARY_PATH:-%_libdir:}" ; export LT_SYS_LIBRARY_PATH ; \
8a5ee87
  CC="${CC:-%{__cc}}" ; export CC ; \
8a5ee87
  CXX="${CXX:-%{__cxx}}" ; export CXX
7562b38
9183c1c
# Automatically use set_build_flags macro for build, check, and
9183c1c
# install phases.
9183c1c
# Use "%undefine _auto_set_build_flags" to disable"
9183c1c
%_auto_set_build_flags 1
ce70218
%__spec_build_pre %{___build_pre} \
ce70218
  %{?_auto_set_build_flags:%{set_build_flags}} \
ce70218
  %{?_generate_package_note_file}
ce70218
31ad743
%__spec_check_pre %{___build_pre} \
31ad743
  %{?_auto_set_build_flags:%{set_build_flags}} \
31ad743
  %{?_generate_package_note_file}
9183c1c
e80fa13
# Internal-only.  Do not use.  Expand a variable and strip the flags
e80fa13
# not suitable to extension builders.
e80fa13
%__extension_strip_flags() %{lua:
e80fa13
local name = rpm.expand("%{1}")
e80fa13
local value = " " .. rpm.expand("%{build_" .. name .. "}")
0d62146
local specs_pattern = "%s+-specs=[^%s]+"
0d62146
local lto_flags_pattern = rpm.expand("%{?_lto_cflags}"):gsub("[%-%.]", "%%%1")
357f950
local package_note_flags_pattern = "%-Wl,%S*package_note%S*"
357f950
local result = value:gsub(specs_pattern, " "):gsub(lto_flags_pattern, ""):gsub(package_note_flags_pattern, "")
e80fa13
print(result)
e80fa13
}
e80fa13
e80fa13
# Variants of CFLAGS, CXXFLAGS, FFLAGS, LDFLAGS for use within
e80fa13
# extension builders.
e80fa13
%extension_cflags %{__extension_strip_flags cflags}
e80fa13
%extension_cxxflags %{__extension_strip_flags cxxflags}
e80fa13
%extension_fflags %{__extension_strip_flags fflags}
e80fa13
%extension_ldflags %{__extension_strip_flags ldflags}
e80fa13
fa08f0e
# Deprecated names.  For backwards compatibility only.
fa08f0e
%__global_cflags %{build_cflags}
fa08f0e
%__global_cxxflags %{build_cxxflags}
fa08f0e
%__global_fflags %{build_fflags}
fa08f0e
%__global_fcflags %{build_fflags}
fa08f0e
%__global_ldflags %{build_ldflags}
fa08f0e
9bbf519
# Architecture-specific support.  Internal.  Do not use directly.
9bbf519
ee3d127
%__cflags_arch_x86_64_v2 %[0%{?rhel} == 9 ? "-march=x86-64-v2" : ""]
ee3d127
%__cflags_arch_x86_64_v3 %[0%{?rhel} > 9 ? "-march=x86-64-v3" : ""]
ee3d127
%__cflags_arch_x86_64 %{__cflags_arch_x86_64_v2} %{__cflags_arch_x86_64_v3}
0ce9e05
9bbf519
# Also used for s390.
bddb417
%__cflags_arch_s390x %[0%{?rhel} >= 9 ? "-march=z14 -mtune=z15" : "-march=z13 -mtune=z14"]
9bbf519
00cb14a
%__cflags_arch_ppc64le %[0%{?rhel} >= 9 ? "-mcpu=power9 -mtune=power9" : "-mcpu=power8 -mtune=power8"]
00cb14a
fa08f0e
#==============================================================================
Elliot Lee 03bb291
# ---- configure and makeinstall.
Elliot Lee 03bb291
#
4362927
%_configure_gnuconfig_hack	1
6c38f18
%_configure_libtool_hardening_hack	1
7359cf0
# If defined, _configure_disable_silent_rules will cause --disable-silent-rules
7359cf0
# to be added to the list of options passed to the configure script.
7359cf0
# Eventually we'll want to turn this on by default, but this gives packagers a
7359cf0
# way to turn it back off.
7359cf0
# %_configure_disable_silent_rules 1
891c721
f857d65
# Pass --runstatedir to configure.
f857d65
%_configure_use_runstatedir 1
f857d65
891c721
# This fixes various easy resolved configure tests that are compromised by LTO.
891c721
#
891c721
# We use this within the standard %configure macro, but also make it available
891c721
# for packages which don't use %configure
891c721
#
891c721
# The first three are common ways to test for the existence of a function, so
891c721
# we ensure the reference to the function is preserved
891c721
#
891c721
# The fourth are constants used to then try to generate NaNs and other key
891c721
# floating point numbers.  We then use those special FP numbers to try and
891c721
# raise a SIGFPE.  By declaring x & y volatile we prevent the optimizers
891c721
# from removing the computation
891c721
#
891c721
# The fifth (and worst) addresses problems with autoconf/libtool's approach
891c721
# to extracting symbols from .o files and generating C code.  In an LTO world
891c721
# types matter much more closely and you can't have an object in one context
891c721
# that is a function definition and a simple scalar variable in another.
891c721
# Thankfully HP-UX has always had that restriction and is supported by
891c721
# autoconf/libtool.  The insane sed script replaces the "generic" code with
891c721
# the HP-UX version.
891c721
#
891c721
# If we do not make changes, we put the original file back.  This avoids
891c721
# unnecessary rebuilds of things that may have dependencies on the configure
891c721
# files.
891c721
#
891c721
%_fix_broken_configure_for_lto \
891c721
  for file in $(find . -type f -name configure -print); do \
891c721
    %{__sed} -r --in-place=.backup 's/^char \\(\\*f\\) \\(\\) = /__attribute__ ((used)) char (*f) () = /g' $file; \
891c721
    diff -u $file.backup $file && mv $file.backup $file \
891c721
    %{__sed} -r --in-place=.backup 's/^char \\(\\*f\\) \\(\\);/__attribute__ ((used)) char (*f) ();/g' $file; \
891c721
    diff -u $file.backup $file && mv $file.backup $file \
891c721
    %{__sed} -r --in-place=.backup 's/^char \\$2 \\(\\);/__attribute__ ((used)) char \\$2 ();/g' $file; \
891c721
    diff -u $file.backup $file && mv $file.backup $file \
891c721
    %{__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; \
891c721
    diff -u $file.backup $file && mv $file.backup $file \
891c721
    %{__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; \
891c721
    diff -u $file.backup $file && mv $file.backup $file \
2c5594c
  done
891c721
6c38f18
%configure \
fa08f0e
  %{set_build_flags}; \
891c721
  [ "%{_lto_cflags}"x != x ] && %{_fix_broken_configure_for_lto}; \
a91c848
  [ "%_configure_gnuconfig_hack" = 1 ] && for i in $(find $(dirname %{_configure}) -name config.guess -o -name config.sub) ; do \
2a55717
      [ -f /usr/lib/rpm/redhat/$(basename $i) ] && %{__rm} -f $i && %{__cp} -fv /usr/lib/rpm/redhat/$(basename $i) $i ; \
2a55717
  done ; \
6c38f18
  [ "%_configure_libtool_hardening_hack" = 1 ] && [ x != "x%{_hardened_ldflags}" ] && \
6c38f18
      for i in $(find . -name ltmain.sh) ; do \
6c38f18
        %{__sed} -i.backup -e 's~compiler_flags=$~compiler_flags="%{_hardened_ldflags}"~' $i \
6c38f18
      done ; \
f2e3413
  %{_configure} --build=%{_build} --host=%{_host} \\\
Elliot Lee 4ccbbe7
	--program-prefix=%{?_program_prefix} \\\
850eda5
	--disable-dependency-tracking \\\
a0145ec
	%{?_configure_disable_silent_rules:--disable-silent-rules} \\\
Elliot Lee a2894a5
	--prefix=%{_prefix} \\\
Elliot Lee 03bb291
	--exec-prefix=%{_exec_prefix} \\\
Elliot Lee 03bb291
	--bindir=%{_bindir} \\\
Elliot Lee 03bb291
	--sbindir=%{_sbindir} \\\
Elliot Lee 03bb291
	--sysconfdir=%{_sysconfdir} \\\
Elliot Lee 03bb291
	--datadir=%{_datadir} \\\
Elliot Lee 03bb291
	--includedir=%{_includedir} \\\
Elliot Lee 03bb291
	--libdir=%{_libdir} \\\
Elliot Lee 03bb291
	--libexecdir=%{_libexecdir} \\\
Elliot Lee 03bb291
	--localstatedir=%{_localstatedir} \\\
f857d65
	%{?_configure_use_runstatedir:$(grep -q "runstatedir=DIR" %{_configure} && echo '--runstatedir=%{_runstatedir}')} \\\
Elliot Lee 03bb291
	--sharedstatedir=%{_sharedstatedir} \\\
Elliot Lee 03bb291
	--mandir=%{_mandir} \\\
6c38f18
	--infodir=%{_infodir}
Elliot Lee 03bb291
Elliot Lee 03bb291
#==============================================================================
Elliot Lee 03bb291
# ---- Build policy macros.
Elliot Lee 03bb291
#
159a65f
#
159a65f
#---------------------------------------------------------------------
159a65f
#	Expanded at beginning of %install scriptlet.
159a65f
#
159a65f
159a65f
%__spec_install_pre %{___build_pre}\
159a65f
    [ "$RPM_BUILD_ROOT" != "/" ] && rm -rf "${RPM_BUILD_ROOT}"\
Ben Burton fdce9c6
    mkdir -p "`dirname "$RPM_BUILD_ROOT"`"\
159a65f
    mkdir "$RPM_BUILD_ROOT"\
9183c1c
    %{?_auto_set_build_flags:%{set_build_flags}}\
159a65f
%{nil}
159a65f
Elliot Lee 03bb291
#---------------------------------------------------------------------
Elliot Lee 03bb291
#	Expanded at end of %install scriptlet.
Elliot Lee 03bb291
#
Elliot Lee 03bb291
Jesse Keating 9b11fc2
%__arch_install_post   /usr/lib/rpm/check-buildroot
Elliot Lee 03bb291
c4646d7
# Build root policy macros. Standard naming:
c4646d7
# convert all '-' in basename to '_', add two leading underscores.
12ace9b
%__brp_ldconfig /usr/lib/rpm/redhat/brp-ldconfig
c4646d7
%__brp_compress /usr/lib/rpm/brp-compress
c4646d7
%__brp_strip /usr/lib/rpm/brp-strip %{__strip}
20749d9
%__brp_strip_lto /usr/lib/rpm/redhat/brp-strip-lto %{__strip}
c4646d7
%__brp_strip_comment_note /usr/lib/rpm/brp-strip-comment-note %{__strip} %{__objdump}
c4646d7
%__brp_strip_static_archive /usr/lib/rpm/brp-strip-static-archive %{__strip}
139bc59
%__brp_check_rpaths /usr/lib/rpm/check-rpaths
f7e8f73
# __brp_mangle_shebangs_exclude - shebangs to exclude
f7e8f73
# __brp_mangle_shebangs_exclude_file - file from which to get shebangs to exclude
f7e8f73
# __brp_mangle_shebangs_exclude_from - files to ignore
f7e8f73
# __brp_mangle_shebangs_exclude_from_file - file from which to get files to ignore
f7e8f73
%__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}"}
c4646d7
2f1ae3a
%__brp_llvm_compile_lto_elf /usr/lib/rpm/redhat/brp-llvm-compile-lto-elf %{build_cflags} %{build_ldflags}
391eca3
74e11b4
# note: %%__os_install_post_python is defined in python-srpm-macros and contains several policies
74e11b4
# redhat-rpm-config maintainers, don't remove it from %%__os_install_post unless coordinating the change with Python maintainers
74e11b4
# packagers, don't undefine the entire macro, see the individual macros in /usr/lib/rpm/macros.d/macros.python-srpm
74e11b4
Elliot Lee 03bb291
%__os_install_post    \
12ace9b
    %{?__brp_ldconfig} \
c4646d7
    %{?__brp_compress} \
055d0b7
    %{!?__debug_package:\
c4646d7
    %{?__brp_strip} \
c4646d7
    %{?__brp_strip_comment_note} \
055d0b7
    } \
20749d9
    %{?__brp_strip_lto} \
c4646d7
    %{?__brp_strip_static_archive} \
139bc59
    %{?__brp_check_rpaths} \
257a3a9
    %{?__brp_mangle_shebangs} \
ccc728d
    %{?__brp_remove_la_files} \
cfdc80c
    %{__os_install_post_python} \
Elliot Lee 03bb291
%{nil}
Elliot Lee 03bb291
Elliot Lee 03bb291
%__spec_install_post\
6024b1e
    %[ "%{toolchain}" == "clang" ? "%{?__brp_llvm_compile_lto_elf}" : "%{nil}" ] \
61fb9e2
    %{?__debug_package:%{__debug_install_post}}\
Elliot Lee 03bb291
    %{__arch_install_post}\
Elliot Lee 03bb291
    %{__os_install_post}\
Elliot Lee 03bb291
%{nil}
Elliot Lee 03bb291
Tim Powers 1640cd5
%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
Tim Powers 1640cd5
%%install\
Jonathan Masters 9ed9b4e
%{nil}
Jonathan Masters 9ed9b4e
Elliot Lee 00cbca9
#
Jonathan Masters 9ed9b4e
# Should missing buildids terminate a build?
Jonathan Masters 9ed9b4e
%_missing_build_ids_terminate_build    1
Elliot Lee f0352fc
e2a80f3
# Use SHA-256 for FILEDIGESTS instead of default MD5
e2a80f3
%_source_filedigest_algorithm 8
e2a80f3
%_binary_filedigest_algorithm 8
e2a80f3
38d0d92
# Use Zstandard compression for binary payloads
38d0d92
%_binary_payload w19.zstdio
e56e816
7562b38
%_hardening_gcc_cflags   -specs=/usr/lib/rpm/redhat/redhat-hardened-cc1
7562b38
%_hardening_clang_cflags --config /usr/lib/rpm/redhat/redhat-hardened-clang.cfg
7562b38
%_hardening_cflags	 %{expand:%%{_hardening_%{toolchain}_cflags}} -fstack-protector-strong
6c38f18
# we don't escape symbols '~', '"', etc. so be careful when changing this
7562b38
%_hardening_ldflags	 -Wl,-z,now %[ "%{toolchain}" == "gcc" ? "-specs=/usr/lib/rpm/redhat/redhat-hardened-ld" : "" ]
5034f24
7562b38
# Harden packages by default for Fedora 23+:
d9235d2
# https://fedorahosted.org/fesco/ticket/1384 (accepted on 2014-02-11)
3bf139f
# Use "%undefine _hardened_build" to disable.
d9235d2
%_hardened_build	1
5034f24
%_hardened_cflags	%{?_hardened_build:%{_hardening_cflags}}
5034f24
%_hardened_ldflags	%{?_hardened_build:%{_hardening_ldflags}}
5181193
7562b38
# Add extra information to binary objects created by the compiler:
b5ea4b2
# https://pagure.io/fesco/issue/1780 (accepted on 2017-10-30)
Arjun Shankar b6b865f
# ...except on armv7hl, which has an issue whose root-cause isn't
Arjun Shankar b6b865f
# clear yet: https://bugzilla.redhat.com/show_bug.cgi?id=1951492
3bf139f
# Use "%undefine _annotated_build" to disable.
fff3459
%_annotated_build	1
7562b38
%_annobin_gcc_plugin	-specs=/usr/lib/rpm/redhat/redhat-annobin-cc1
7562b38
# The annobin plugin is not built for clang yet
7562b38
%_annobin_clang_plugin	%dnl-fplugin=/usr/lib64/clang/`clang -dumpversion`/lib/annobin.so
Arjun Shankar b6b865f
%_annotation_plugin     %{?_annotated_build:%{expand:%%{_annobin_%{toolchain}_plugin}}}
Arjun Shankar b6b865f
%_annotation_cflags     %[ "%{_target_cpu}" == "armv7hl" ? "" : "%{_annotation_plugin}" ]
bc8fa85
%_annotation_ldflags	%{?_lto_cflags:%{_annotation_cflags}}
e7f4716
# Use the remove-section option to force the find-debuginfo script
e7f4716
# to move the annobin notes into the separate debuginfo file.
e7f4716
%_find_debuginfo_extra_opts %{?_annotated_build:--remove-section .gnu.build.attributes}
b5ea4b2
9e10bb6
# Include frame pointer information by default, except on RHEL
04a4350
# https://fedoraproject.org/wiki/Changes/fno-omit-frame-pointer
f080fb9
# Use "%undefine _include_frame_pointers" to disable.
9e10bb6
%_include_frame_pointers %{undefined rhel}
6ef1a40
%_frame_pointers_cflags %{expr:0%{?_include_frame_pointers} ? "-fno-omit-frame-pointer" : ""}
6ef1a40
%_frame_pointers_cflags_x86_64 %{expr:0%{?_include_frame_pointers} ? "-mno-omit-leaf-frame-pointer" : ""}
6ef1a40
%_frame_pointers_cflags_aarch64 %{expr:0%{?_include_frame_pointers} ? "-mno-omit-leaf-frame-pointer" : ""}
6ef1a40
%_frame_pointers_cflags_s390x %{expr:0%{?_include_frame_pointers} ? "-mbackchain" : ""}
04a4350
078af19
# Fail linking if there are undefined symbols.  Required for proper
8d6c6d0
# ELF symbol versioning support.  Disabled by default.
68e4ff2
# Use "%define _ld_strict_symbol_defs 1" to enable.
68e4ff2
#%_ld_strict_symbol_defs		1
68e4ff2
%_ld_symbols_flags		%{?_ld_strict_symbol_defs:-Wl,-z,defs}
078af19
85e473f
# https://fedoraproject.org/wiki/Changes/RemoveExcessiveLinking
357550f
# use "%undefine _ld_as_needed" to disable.
357550f
%_ld_as_needed		1
ce50624
%_ld_as_needed_flags	%{?_ld_as_needed:-Wl,--as-needed}
85e473f
5baaf4a
# LTO is the default in Fedora.
5baaf4a
#   "%define _lto_cflags %{nil}"  to opt out
5baaf4a
#
5baaf4a
# We currently have -ffat-lto-objects turned on out of an abundance of
5baaf4a
# caution.  To remove it we need to do a check of the installed .o/.a files
5baaf4a
# to verify they have real sections/symbols after LTO stripping.  That
5baaf4a
# way we can detect installing an unusable .o/.a file.  This is on the TODO
5baaf4a
# list for F34.
4637e1b
%_gcc_lto_cflags	-flto=auto -ffat-lto-objects
60ee618
%_clang_lto_cflags	-flto=thin
06f1d52
%_lto_cflags		%{expand:%%{_%{toolchain}_lto_cflags}}
5baaf4a
4c05f3c
# Default fortification level.
4c05f3c
#   "%define _fortify_level 2" to downgrade and
4c05f3c
#   "%define _fortify_level 0" or "%undefine _fortify_level" to disable
Siddhesh Poyarekar 1b98c06
#
Siddhesh Poyarekar 1b98c06
# We use a single -Wp here to enforce order so that ccache does not ever
Siddhesh Poyarekar 1b98c06
# reorder them.
4c05f3c
%_fortify_level		3
Siddhesh Poyarekar 1b98c06
%_fortify_level_flags	%[ 0%{?_fortify_level} > 0 ? "-Wp,-U_FORTIFY_SOURCE,-D_FORTIFY_SOURCE=%{_fortify_level}" : "" ]
4c05f3c
95f28bd
# Some linkers default to a build-id algoritim that is not supported by rpmbuild,
95f28bd
# so we need to specify the right algorithm to use.
95f28bd
%_build_id_flags	-Wl,--build-id=sha1
95f28bd
5baaf4a
%_general_options       -O2 %{?_lto_cflags} -fexceptions -g -grecord-gcc-switches -pipe
7562b38
%_warning_options       -Wall -Werror=format-security
4c05f3c
%_preprocessor_defines  %{_fortify_level_flags} -Wp,-D_GLIBCXX_ASSERTIONS
7562b38
7562b38
# Common variables are no longer generated by default by gcc and clang
7562b38
# If they are needed then add "%define _legacy_common_support 1" to the spec file.
7562b38
%_legacy_options	%{?_legacy_common_support: -fcommon}
7562b38
9ce7719
%__global_compiler_flags %{_general_options} %{_warning_options} %{_preprocessor_defines} %{_hardened_cflags} %{_annotation_cflags} %{_legacy_options}
3081c4e
8c5d5de
# Automatically trim changelog entries after 2 years
3d7758a
%_changelog_trimage	%{expr:2*365*24*60*60}
8c5d5de
b5b2aed
#==============================================================================
20a4569
# ---- Generic auto req/prov filtering macros
b5b2aed
#
b5b2aed
# http://fedoraproject.org/wiki/PackagingDrafts/AutoProvidesAndRequiresFiltering
b5b2aed
b5b2aed
# prevent anything matching from being scanned for provides
b5b2aed
%filter_provides_in(P) %{expand: \
b5b2aed
%global __filter_prov_cmd %{?__filter_prov_cmd} %{__grep} -v %{-P} '%*' | \
b5b2aed
}
b5b2aed
b5b2aed
# prevent anything matching from being scanned for requires
b5b2aed
%filter_requires_in(P) %{expand: \
b5b2aed
%global __filter_req_cmd %{?__filter_req_cmd} %{__grep} -v %{-P} '%*' | \
b5b2aed
}
b5b2aed
b5b2aed
# filter anything matching out of the provides stream
b5b2aed
%filter_from_provides() %{expand: \
b5b2aed
%global __filter_from_prov %{?__filter_from_prov} | %{__sed} -e '%*' \
b5b2aed
}
b5b2aed
b5b2aed
# filter anything matching out of the requires stream
b5b2aed
%filter_from_requires() %{expand: \
b5b2aed
%global __filter_from_req %{?__filter_from_req} | %{__sed} -e '%*' \
b5b2aed
}
b5b2aed
20a4569
# actually set up the filtering bits
b5b2aed
%filter_setup %{expand: \
b5b2aed
%global _use_internal_dependency_generator 0 \
1891cc0
%global __deploop() while read FILE; do echo "${FILE}" | /usr/lib/rpm/rpmdeps -%{1}; done | /bin/sort -u \
b5b2aed
%global __find_provides /bin/sh -c "%{?__filter_prov_cmd} %{__deploop P} %{?__filter_from_prov}" \
b5b2aed
%global __find_requires /bin/sh -c "%{?__filter_req_cmd}  %{__deploop R} %{?__filter_from_req}" \
b5b2aed
}