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