From 839ba57c7f41798dddd43495bb0b2cf312bd0f6f Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Wed, 12 Aug 2020 11:42:54 +0200 Subject: [PATCH] contrib/rpm: enable LTO by default on Fedora 33 With Fedora 33, LTO will be enabled by default via CFLAGS in redhat-rpm-config ([1]). That basically sets "CFLAGS=-flto -ffat-lto-objects". Note that we have our own configure/meson option to enable LTO. With "--with-lto" we set CFLAGS="-flto -flto-partition=none". This is necessary due ([2], [3]). So, disable Fedora's automatism, but turn on the suitable configure option to get working LTO. [1] https://src.fedoraproject.org/rpms/redhat-rpm-config/c/5baaf4a99cc77572d3496a7000674098bef7ed68?branch=master [2] e6cf4213a774 ('build: fix building with LTO') [3] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=48200#c28 --- contrib/fedora/rpm/NetworkManager.spec | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/contrib/fedora/rpm/NetworkManager.spec b/contrib/fedora/rpm/NetworkManager.spec index 637e71f5fb..fada458d6a 100644 --- a/contrib/fedora/rpm/NetworkManager.spec +++ b/contrib/fedora/rpm/NetworkManager.spec @@ -59,7 +59,11 @@ %bcond_without regen_docs %bcond_with debug %bcond_with test +%if 0%{?fedora} >= 33 +%bcond_without lto +%else %bcond_with lto +%endif %bcond_with sanitizer %if 0%{?fedora} %bcond_without connectivity_fedora @@ -134,6 +138,11 @@ %global ebpf_enabled "no" %endif +# Fedora 33 enables LTO by default by setting CFLAGS="-flto -ffat-lto-objects". +# However, we also require "-flto -flto-partition=none", so disable Fedora's +# default and use our configure option --with-lto instead. +%define _lto_cflags %{nil} + ############################################################################### Name: NetworkManager