#102 Add -flto to ldflags for clang toolchain
Closed 3 years ago by ignatenkobrain. Opened 3 years ago by tstellar.
rpms/ tstellar/redhat-rpm-config clang-flto-ldflags  into  master

file added
+12
@@ -0,0 +1,12 @@ 

+ --- !Policy

+ product_versions:

+   - fedora-*

+ decision_context: bodhi_update_push_testing

+ rules:

+   - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}

+ --- !Policy

+ product_versions:

+   - fedora-*

+ decision_context: bodhi_update_push_stable

+ rules:

+   - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional}

file modified
+4 -1
@@ -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

file modified
+4 -1
@@ -6,7 +6,7 @@ 

  

  Summary: Red Hat specific rpm configuration files

  Name: redhat-rpm-config

- Version: 167

+ Version: 168

  Release: 1%{?dist}

  # No version specified.

  License: GPL+
@@ -212,6 +212,9 @@ 

  %{_rpmconfigdir}/macros.d/macros.kmp

  

  %changelog

+ * Mon Aug 03 2020 Tom Stellard <tstellar@redhat.com> - 168-1

+ - Add -flto to ldflags for clang toolchain

+ 

  * Mon Aug 03 2020 2020 Troy Dawson <tdawson@redhat.com> - 167-1

  - Add Requires: kernel-srpm-macros

  

file added
+14
@@ -0,0 +1,14 @@ 

+ - hosts: localhost

+   roles:

+   - role: standard-test-basic

+     tags:

+       - classic

+     required_packages:

+       - redhat-rpm-config

+       - rpm

+       - clang

+     repositories:

+       - repo: https://src.fedoraproject.org/tests/clang.git

+         dest: clang

+     tests:

+       - clang/fedora-flags

Also, add a gating CI tests to ensure that future macro changes work
with clang.

Shouldn't we create lto_ldflags and make it empty for gcc ?

I did it this way so that the current recommended way of disabling LTO would still work:

%define _lto_cflags %{nil}

rebased onto 1376750

3 years ago

Merged & built... Really not interested in adding random tests with horrible syntax.

Pull-Request has been closed by ignatenkobrain

3 years ago