From 85e473f982a92204832d57fc13bdd5bccc27078d Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Mon, 2 Jul 2018 22:27:51 +0100 Subject: [PATCH] Add option to add -Wl,--as-needed into LDFLAGS Signed-off-by: Igor Gnatenko --- macros | 7 ++++++- redhat-rpm-config.spec | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/macros b/macros index cd32c84..b900503 100644 --- a/macros +++ b/macros @@ -44,7 +44,7 @@ # 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. -%build_ldflags -Wl,-z,relro %{_ld_symbols_flags} %{_hardened_ldflags} +%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} # Expands to shell code to seot the compiler/linker environment # variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have @@ -218,6 +218,11 @@ #%_ld_strict_symbol_defs 1 %_ld_symbols_flags %{?_ld_strict_symbol_defs:-Wl,-z,defs} +# https://fedoraproject.org/wiki/Changes/RemoveExcessiveLinking +# use "%define _ld_as_needed 1" to enable. +#%_ld_as_needed 1 +%_ld_as_needed_flags %{?_as_needed_build:-Wl,--as-needed} + %__global_compiler_flags -O2 -g -pipe -Wall -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wp,-D_GLIBCXX_ASSERTIONS -fexceptions -fstack-protector-strong -grecord-gcc-switches %{_hardened_cflags} %{_annotated_cflags} # Automatically trim changelog entries after 2 years diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 3af2e60..b495529 100644 --- a/redhat-rpm-config.spec +++ b/redhat-rpm-config.spec @@ -6,7 +6,7 @@ Summary: Red Hat specific rpm configuration files Name: redhat-rpm-config -Version: 115 +Version: 116 Release: 1%{?dist} # No version specified. License: GPL+ @@ -183,6 +183,9 @@ install -p -m 755 -t %{buildroot}%{_rpmconfigdir} kmod.prov %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Tue Jul 10 2018 Igor Gnatenko - 116-1 +- Add option to add -Wl,--as-needed into LDFLAGS + * Mon Jul 09 2018 Kalev Lember - 115-1 - Disable non-functional ppc64 support for ldc packages