llvm-bolt18/llvm-bolt.spec

194 lines
5.7 KiB
RPMSpec
Raw Normal View History

2023-12-04 11:32:04 +08:00
%bcond_with check
%bcond_without toolchain_clang
%if %{with toolchain_clang}
%global toolchain clang
%endif
2023-12-04 11:32:04 +08:00
%global maj_ver 18
%global min_ver 1
%global patch_ver 8
2023-12-04 11:32:04 +08:00
%global bolt_version %{maj_ver}.%{min_ver}.%{patch_ver}
%global bolt_srcdir llvm-project-%{bolt_version}.src
%global _scl_prefix /opt/openEuler
%{?scl:%scl_package %scl}
%{!?scl:%global scl_prefix llvm-toolset-%{maj_ver}-}
%{!?scl:%global pkg_name %{name}}
%global install_prefix %{!?scl:%{_scl_prefix}/llvm-toolset-%{maj_ver}/root}%{_prefix}
%global install_datadir %{!?scl:%{_scl_prefix}/llvm-toolset-%{maj_ver}/root}%{_datadir}
2023-12-04 11:32:04 +08:00
%global install_bindir %{install_prefix}/bin
%global install_libdir %{install_prefix}/lib
%global install_docdir %{install_prefix}/share/doc
%global max_link_jobs 2
Name: %{?scl_prefix}llvm-bolt
2023-12-04 11:32:04 +08:00
Version: %{bolt_version}
Release: 2
2021-11-29 15:55:32 +08:00
Summary: BOLT is a post-link optimizer developed to speed up large applications
License: Apache 2.0
2023-12-04 11:32:04 +08:00
URL: https://github.com/llvm/llvm-project/tree/main/bolt
Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{bolt_version}/%{bolt_srcdir}.tar.xz
Source1: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{bolt_version}/%{bolt_srcdir}.tar.xz.sig
2021-11-29 15:55:32 +08:00
2023-12-04 11:32:04 +08:00
# BOLT is not respecting the component split of LLVM and requires some private
# headers in order to compile itself. Try to disable as much libraries as
# possible in order to reduce build time.
#Patch0: rm-llvm-libs.diff
2023-12-04 11:32:04 +08:00
BuildRequires: gcc
BuildRequires: gcc-c++
BuildRequires: cmake
BuildRequires: ninja-build
BuildRequires: zlib-devel
BuildRequires: python3-lit
BuildRequires: python3-psutil
BuildRequires: doxygen
%if %{with toolchain_clang}
BuildRequires: clang
%endif
2021-11-29 15:55:32 +08:00
%{?scl:Requires: %scl_runtime}
2021-11-29 15:55:32 +08:00
%description
BOLT is a post-link optimizer developed to speed up large applications.
It achieves the improvements by optimizing application's code layout based
on execution profile gathered by sampling profiler, such as Linux perf tool.
2023-12-04 11:32:04 +08:00
%package doc
Summary: Documentation for BOLT
BuildArch: noarch
Requires: %{pkg_name} = %{version}-%{release}
2023-12-04 11:32:04 +08:00
%description doc
Documentation for the BOLT optimizer
2021-11-29 15:55:32 +08:00
%prep
2023-12-04 11:32:04 +08:00
%autosetup -n %{bolt_srcdir} -p1
%build
%{cmake} -G Ninja -S llvm \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DCMAKE_INSTALL_PREFIX=%{install_prefix} \
-DCMAKE_SKIP_RPATH=ON \
-DLLVM_DIR=%{install_libdir}/cmake/llvm \
-DLLVM_TABLEGEN_EXE=%{install_bindir}/llvm-tblgen \
-DLLVM_BUILD_UTILS:BOOL=ON \
-DBOLT_INCLUDE_DOCS:BOOL=ON \
-DLLVM_INCLUDE_TESTS:BOOL=ON \
-DBUILD_SHARED_LIBS:BOOL=OFF \
-DLLVM_LINK_LLVM_DYLIB:BOOL=OFF \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DBOLT_INCLUDE_TESTS:BOOL=ON \
-DLLVM_EXTERNAL_LIT=%{_bindir}/lit \
-DLLVM_ENABLE_PROJECTS="bolt" \
-DLLVM_PARALLEL_LINK_JOBS=%{max_link_jobs} \
%if "%{toolchain}" == "clang"
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++ \
%endif
2021-11-29 15:55:32 +08:00
%ifarch %ix86 x86_64
2023-12-04 11:32:04 +08:00
-DLLVM_TARGETS_TO_BUILD="X86"
2021-11-29 15:55:32 +08:00
%endif
%ifarch aarch64
2023-12-04 11:32:04 +08:00
-DLLVM_TARGETS_TO_BUILD="AArch64"
2021-11-29 15:55:32 +08:00
%endif
2023-12-04 11:32:04 +08:00
# Set LD_LIBRARY_PATH now because we skip rpath generation and the build uses
# some just built libraries.
export LD_LIBRARY_PATH=%{_builddir}/%{bolt_srcdir}/%{_vpath_builddir}/%{_lib}
%ninja_build bolt
2021-11-29 15:55:32 +08:00
%install
%ninja_install bolt
# Remove extera llvm files.
find %{buildroot}%{install_prefix} \
! -name "llvm-bolt" \
! -name "merge-fdata" \
! -name "perf2bolt" \
! -name "llvm-boltdiff" \
! -name "llvm-bolt-heatmap" \
! -name "libbolt_rt_hugify.a" \
! -name "libbolt_rt_instr.a" \
-type f,l -exec rm -f '{}' \;
2023-12-04 11:32:04 +08:00
# Remove files installed during the build phase.
rm -f %{buildroot}/%{_builddir}/%{bolt_srcdir}/%{_vpath_builddir}/%{_lib}/lib*.a
2023-12-04 11:32:04 +08:00
# There currently is not support upstream for building html doc from BOLT
install -d %{buildroot}%{install_docdir}
mv bolt/README.md bolt/docs/*.md %{buildroot}%{install_docdir}
2024-11-27 10:43:51 +08:00
%check
%if %{with check}
2023-12-04 11:32:04 +08:00
%ifarch aarch64
# Failing test cases on aarch64
rm bolt/test/cache+-deprecated.test bolt/test/bolt-icf.test bolt/test/R_ABS.pic.lld.cpp
%endif
export LD_LIBRARY_PATH=%{_builddir}/%{bolt_srcdir}//%{_vpath_builddir}/%{_lib}
2023-12-04 11:32:04 +08:00
export DESTDIR=%{buildroot}
%ninja_build check-bolt
2023-12-04 11:32:04 +08:00
# Remove files installed during the check phase.
rm -f %{buildroot}/%{_builddir}/%{bolt_srcdir}/%{_vpath_builddir}/%{_lib}/lib*.a
2023-12-04 11:32:04 +08:00
%endif
2021-11-29 15:55:32 +08:00
%files
%license bolt/LICENSE.TXT
2023-12-04 11:32:04 +08:00
%{install_bindir}/llvm-bolt
%{install_bindir}/llvm-boltdiff
%{install_bindir}/merge-fdata
%{install_bindir}/perf2bolt
%{install_bindir}/llvm-bolt-heatmap
%ifnarch riscv64
2023-12-04 11:32:04 +08:00
%{install_libdir}/libbolt_rt_hugify.a
%{install_libdir}/libbolt_rt_instr.a
%endif
2023-12-04 11:32:04 +08:00
%files doc
%doc %{install_docdir}
2021-11-29 15:55:32 +08:00
%changelog
* Mon Dec 23 2024 laokz <zhangkai@iscas.ac.cn> - 18.1.8-2
- riscv64: not package non-exist .a files
* Fri Dec 6 2024 liyunfei <liyunfei33@huawei.com> - 18.1.8-1
- init for Multi-Version LLVM-18.1.8
2024-11-27 10:43:51 +08:00
* Tue Nov 12 2024 Funda Wang <fundawang@yeah.net> - 17.0.6-3
- adopt to new cmake macro
- build with gcc now, as llvm/clang will produce linking error
against libLLVMTableGen.a now
* Fri Jul 5 2024 liyunfei <liyunfei33@huawei.com> - 17.0.6-2
- Add toolchain_clang build support
2023-12-04 11:32:04 +08:00
* Mon Dec 4 2023 zhoujing <zhoujing106@huawei.com> 17.0.6-1
- Update to 17.0.6
* Thu Jun 15 2023 Xiong Zhou <xiongzhou4@huawei.com> 0-2.20211016.gitb72f753
- Type:backport
- ID:NA
- SUG:NA
- DESC: Handle data at the beginning of a function when disassembling and building CFG.
* Mon Dec 19 2022 liyancheng <412998149@qq.com> 0-1.20211016.gitb72f753
- Type:fix
- ID:NA
- SUG:NA
- DESC: Add debuginfo package and delete rpath in binary
2021-11-29 15:55:32 +08:00
* Mon Nov 29 2021 liyancheng <412998149@qq.com>
- Type:Init
- ID:NA
- SUG:NA
2024-11-27 10:43:51 +08:00
- DESC:Init llvm-bolt repository