diff --git a/llvm.spec b/llvm.spec index a045abc8abf36731ef90560ea6695b3c07087507..d3e7b0c8d5af75c091250828b8df22ed8720df62 100644 --- a/llvm.spec +++ b/llvm.spec @@ -1,8 +1,16 @@ %global toolchain clang +# Components enabled if supported by target architecture: +%define gold_arches x86_64 aarch64 loongarch64 +%ifarch %{gold_arches} +%bcond_without gold +%else +%bcond_with gold +%endif + Name: llvm Version: 17.0.6 -Release: 12%{?dist} +Release: 13%{?dist} Summary: Low Level Virtual Machine, modular and reusable compiler and toolchain License: Apache License v2.0 with LLVM Exceptions URL: http://llvm.org @@ -44,10 +52,15 @@ Patch3001: 0001-Clear-instructions-not-recorded-in-ErasedInstrs.patch %define patch_ver %(echo %{version} | cut -d. -f3) BuildRequires: gcc gcc-c++ clang cmake ninja-build -BuildRequires: zlib-devel libffi-devel ncurses-devel binutils-devel libedit-devel +BuildRequires: zlib-devel libffi-devel ncurses-devel libedit-devel BuildRequires: python3-sphinx +%if %{with gold} +BuildRequires: binutils-devel +%endif # for valgrind support +%ifarch %{valgrind_arches} BuildRequires: valgrind-devel +%endif # fo patchfix.py BuildRequires: python3-devel @@ -122,7 +135,13 @@ pathfix.py -i %{__python3} -p -n -k -as \ utils/update_cc_test_checks.py %build + +%ifnarch riscv64 %global _lto_cflags -flto=thin +%else +# riscv64: gold is not supported on riscv64 +%global _lto_cflags %{nil} +%endif %cmake -G Ninja \ -DCMAKE_C_FLAGS="-gdwarf-4" \ @@ -139,7 +158,9 @@ pathfix.py -i %{__python3} -p -n -k -as \ -DLLVM_ENABLE_FFI:BOOL=ON \ -DLLVM_ENABLE_RTTI:BOOL=ON \ -DLLVM_USE_PERF:BOOL=ON \ +%if %{with gold} -DLLVM_BINUTILS_INCDIR=%{_includedir} \ +%endif -DLLVM_BUILD_RUNTIME:BOOL=ON \ -DLLVM_INCLUDE_TOOLS:BOOL=ON \ -DLLVM_BUILD_TOOLS:BOOL=ON \ @@ -168,7 +189,11 @@ pathfix.py -i %{__python3} -p -n -k -as \ -DLLVM_INSTALL_SPHINX_HTML_DIR=%{_pkgdocdir}/html \ -DSPHINX_EXECUTABLE=%{_bindir}/sphinx-build-3 \ -DLLVM_INCLUDE_BENCHMARKS=OFF \ + %ifnarch riscv64 -DLLVM_UNITTEST_LINK_FLAGS="-Wl,-plugin-opt=O0" + %else + -DLLVM_UNITTEST_LINK_FLAGS="-Wl" + %endif # Build libLLVM.so first to help reduce OOM errors during concurrent building. %cmake_build --target LLVM @@ -187,9 +212,11 @@ rm -rf test/tools/UpdateTestChecks install %{_vpath_builddir}/lib64/libLLVMTestingSupport.a %{buildroot}%{_libdir} install %{_vpath_builddir}/lib64/libLLVMTestingAnnotations.a %{buildroot}%{_libdir} +%if %{with gold} # Add symlink to lto plugin in the binutils plugin directory mkdir -p %{buildroot}%{_libdir}/bfd-plugins/ ln -s -t %{buildroot}%{_libdir}/bfd-plugins/ ../LLVMgold.so +%endif (cd %{buildroot}/%{_bindir} ; ln -s llvm-config llvm-config-%{maj_ver}) @@ -222,8 +249,10 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} %{__ninja} check-all -C %{_vpath_buildd %license LICENSE.TXT %{_libdir}/libLLVM-%{maj_ver}.so %{_libdir}/libLLVM-%{maj_ver}.%{min_ver}*.so +%if %{with gold} %{_libdir}/LLVMgold.so %{_libdir}/bfd-plugins/LLVMgold.so +%endif %{_libdir}/libLTO.so* %{_libdir}/libRemarks.so* @@ -259,6 +288,10 @@ LD_LIBRARY_PATH=%{buildroot}/%{_libdir} %{__ninja} check-all -C %{_vpath_buildd %{_includedir}/llvm-gmock %changelog +* Tue Sep 02 2025 Xinlong Chen - 17.0.6-13 +- [Type] bugfix +- [DESC] disable gold for riscv64 + * Wed Aug 20 2025 chenli - 17.0.6-12 - [Type] bugfix - [DESC] Add support for RuntimeDyld on loongarch64