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.
This commit is contained in:
Nikita Popov 2024-05-27 09:16:41 +02:00 committed by Timm Bäder
parent 3ddc01eec2
commit 1115746e65
2 changed files with 17 additions and 0 deletions

View file

@ -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

View file

@ -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