From d698d043132d4e823be4a1ca8f698ca17af252fa Mon Sep 17 00:00:00 2001 From: Tom Stellard Date: Tue, 4 Aug 2020 18:26:08 +0000 Subject: [PATCH] Add -flto to ldflags for clang toolchain Also, add a gating CI tests to ensure that future macro changes work with clang. --- macros | 5 ++++- redhat-rpm-config.spec | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/macros b/macros index 78022c8..3a287c0 100644 --- a/macros +++ b/macros @@ -86,7 +86,10 @@ # 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_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} +# 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. +%build_ldflags -Wl,-z,relro %{_ld_as_needed_flags} %{_ld_symbols_flags} %{_hardened_ldflags} %[ "%{toolchain}" == "clang" ? "%{?_lto_cflags}" : "" ] # Expands to shell code to set the compiler/linker environment # variables CFLAGS, CXXFLAGS, FFLAGS, FCFLAGS, LDFLAGS if they have diff --git a/redhat-rpm-config.spec b/redhat-rpm-config.spec index 091af53..5daded1 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: 168 +Version: 169 Release: 1%{?dist} # No version specified. License: GPL+ @@ -212,6 +212,9 @@ install -p -m 644 -t %{buildroot}%{_rpmluadir}/fedora/srpm forge.lua %{_rpmconfigdir}/macros.d/macros.kmp %changelog +* Mon Aug 20 2020 Tom Stellard - 169-1 +- Add -flto to ldflags for clang toolchain + * Thu Aug 20 2020 Neal Gompa - 168-1 - Fix CC/CXX exports so arguments are included in exported variable - Allow overrides of CC/CXX like CFLAGS and CXXFLAGS from shell variables