From 1654df4ed3574e0ae16ba4e293479cc5be2a5223 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Mon, 27 May 2024 09:16:41 +0200 Subject: [PATCH] Make lto handling similar to current rawhide Have a --with lto_build option, where LTO is enabled by default for everything except i686 and riscv. Use that flag to condition whether `-DLLVM_UNITTEST_LINK_FLAGS` is passed. Additionally, make use of the new Fat LTO functionality in rawhide to use `-fno-lto` instead of `-Wl,-plugin-opt=O0` to save more time linking unit tests. --- build.spec.inc | 6 ++++++ globals.spec.inc | 11 +++++++++++ 2 files changed, 17 insertions(+) diff --git a/build.spec.inc b/build.spec.inc index adeba87..a027314 100644 --- a/build.spec.inc +++ b/build.spec.inc @@ -193,7 +193,13 @@ cd llvm %ifarch x86_64 -DCMAKE_SHARED_LINKER_FLAGS="$LDFLAGS -Wl,-z,cet-report=error" \ %endif +%if %{with lto_build} +%if 0%{?fedora} >= 41 + -DLLVM_UNITTEST_LINK_FLAGS="-fno-lto" +%else -DLLVM_UNITTEST_LINK_FLAGS="-Wl,-plugin-opt=O0" +%endif +%endif # Build libLLVM.so first. This ensures that when libLLVM.so is linking, there # are no other compile jobs running. This will help reduce OOM errors on the diff --git a/globals.spec.inc b/globals.spec.inc index 01dad73..cafcec7 100644 --- a/globals.spec.inc +++ b/globals.spec.inc @@ -9,6 +9,17 @@ %bcond_with compat_build %bcond_without check +# Disable LTO on x86 and riscv in order to reduce memory consumption. +%ifarch %ix86 riscv64 +%bcond_with lto_build +%else +%bcond_without lto_build +%endif + +%if %{without lto_build} +%global _lto_cflags %nil +%endif + # We are building with clang for faster/lower memory LTO builds. # See https://docs.fedoraproject.org/en-US/packaging-guidelines/#_compiler_macros %global toolchain clang