From 6223a10d44cc9451145cee88776a04f40735afb5 Mon Sep 17 00:00:00 2001 From: Zhongling He Date: Thu, 13 Apr 2023 18:45:35 +0800 Subject: [PATCH] refactor rpm spec --- llvm.spec | 161 +++++++++++++++++++----------------------------------- 1 file changed, 55 insertions(+), 106 deletions(-) diff --git a/llvm.spec b/llvm.spec index 669e03e..34fb691 100644 --- a/llvm.spec +++ b/llvm.spec @@ -1,11 +1,9 @@ -%define anolis_release 2 +%define anolis_release 3 -# We are building with clang for faster/lower memory LTO builds. %global toolchain clang %undefine _include_frame_pointers -# Components enabled if supported by target architecture: %define gold_arches x86_64 aarch64 loongarch64 %ifarch %{gold_arches} %bcond_without gold @@ -16,48 +14,43 @@ %bcond_with compat_build %bcond_without check -# BEFORE bumping maj_ver, one should always fork a repository with current -# maj_ver, and submit the forked repository with compat_build, which will -# produce llvm%{maj_ver}-libs. Otherwise uninstallable clang will cause the -# whole toolchain unusable. -%global maj_ver 16 -%global min_ver 0 -%global patch_ver 1 -%global llvm_srcdir llvm-%{maj_ver}.%{min_ver}.%{patch_ver}.src -%global cmake_srcdir cmake-%{maj_ver}.%{min_ver}.%{patch_ver}.src -%global third_party_srcdir third-party-%{maj_ver}.%{min_ver}.%{patch_ver}.src +%global targets_to_build "all" +%global experimental_targets_to_build "AVR" + +%global build_install_prefix %{buildroot}%{install_prefix} + +%global llvm_triple %{_target_platform} + +%undefine _py3_shebang_P %global _lto_cflags -flto=thin +%global third_party_srcdir third-party-%{maj_ver}.%{min_ver}.%{patch_ver}.src +%global cmake_srcdir cmake-%{maj_ver}.%{min_ver}.%{patch_ver}.src +%global llvm_srcdir llvm-%{maj_ver}.%{min_ver}.%{patch_ver}.src +%global patch_ver 1 +%global min_ver 0 +%global maj_ver 16 %if %{with compat_build} -%global pkg_name llvm%{maj_ver} -%global exec_suffix -%{maj_ver} -%global install_prefix %{_libdir}/%{name} -%global install_bindir %{install_prefix}/bin -%global install_includedir %{install_prefix}/include -%global install_libdir %{install_prefix}/lib - -%global pkg_bindir %{install_bindir} -%global pkg_includedir %{_includedir}/%{name} %global pkg_libdir %{install_libdir} +%global pkg_includedir %{_includedir}/%{name} +%global pkg_bindir %{install_bindir} + +%global install_libdir %{install_prefix}/lib +%global install_includedir %{install_prefix}/include +%global install_bindir %{install_prefix}/bin +%global install_prefix %{_libdir}/%{name} +%global exec_suffix -%{maj_ver} +%global pkg_name llvm%{maj_ver} %else -%global pkg_name llvm -%global install_prefix /usr -%global install_libdir %{_libdir} -%global pkg_bindir %{_bindir} -%global pkg_libdir %{install_libdir} %global exec_suffix %{nil} +%global pkg_libdir %{install_libdir} +%global pkg_bindir %{_bindir} +%global install_libdir %{_libdir} +%global install_prefix /usr +%global pkg_name llvm %endif -%global targets_to_build "all" -%global experimental_targets_to_build "AVR" - -%global build_install_prefix %{buildroot}%{install_prefix} - -%global llvm_triple %{_target_platform} -# Don't add -P to Python shebangs -# The executable Python scripts in /usr/share/opt-viewer/ import each other -%undefine _py3_shebang_P Name: llvm Version: %{maj_ver}.%{min_ver}.%{patch_ver} @@ -70,37 +63,21 @@ Source0: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ve Source2: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}/%{cmake_srcdir}.tar.xz Source4: https://github.com/llvm/llvm-project/releases/download/llvmorg-%{maj_ver}.%{min_ver}.%{patch_ver}/%{third_party_srcdir}.tar.xz -# Backport from LLVM 17. Patch0: D145763.diff -# See https://reviews.llvm.org/D137890 for the next two patches Patch2: 0001-llvm-Add-install-targets-for-gtest.patch -# Patching third-party dir with a 200 offset in patch number Patch201: 0201-third-party-Add-install-targets-for-gtest.patch -BuildRequires: gcc -BuildRequires: gcc-c++ -BuildRequires: clang -BuildRequires: cmake -BuildRequires: ninja-build -BuildRequires: zlib-devel -BuildRequires: libffi-devel -BuildRequires: libxml2-devel -BuildRequires: ncurses-devel -BuildRequires: python3-psutil -BuildRequires: python3-sphinx -BuildRequires: python3-recommonmark -BuildRequires: python3-yaml +BuildRequires: gcc gcc-c++ clang cmake ninja-build zlib-devel libffi-devel +BuildRequires: libxml2-devel ncurses-devel python3-psutil python3-sphinx +BuildRequires: python3-recommonmark python3-yaml %if %{with gold} BuildRequires: binutils-devel %endif %ifarch %{valgrind_arches} -# Enable extra functionality when run the LLVM JIT under valgrind. BuildRequires: valgrind-devel %endif -# LLVM's LineEditor library will use libedit if it is available. BuildRequires: libedit-devel -# We need python3-devel for %%py3_shebang_fix BuildRequires: python3-devel BuildRequires: python3-setuptools @@ -109,24 +86,22 @@ Requires: %{name}-libs = %{version}-%{release} Provides: llvm(major) = %{maj_ver} %description -LLVM is a compiler infrastructure designed for compile-time, link-time, -runtime, and idle-time optimization of programs from arbitrary programming -languages. The compiler infrastructure includes mirror sets of programming -tools as well as libraries with equivalent functionality. +LLVM is a framework for building and optimizing compilers for various +programming languages. It consists of a set of libraries and tools that can +perform analysis and transformation of programs at different stages: +compile-time, link-time, runtime, and idle-time. The framework also provides +a common intermediate representation (IR) that can be used to implement +language-specific front ends and back ends. LLVM supports a wide range of +projects, from industrial-strength compilers to specialized JIT applications +to small research projects. You can find more information about LLVM in its +online documentation or in several introductory papers and presentations. + %package devel Summary: Libraries and header files for LLVM Requires: %{name} = %{version}-%{release} Requires: %{name}-libs = %{version}-%{release} -# The installed LLVM cmake files will add -ledit to the linker flags for any -# app that requires the libLLVMLineEditor, so we need to make sure -# libedit-devel is available. Requires: libedit-devel -# The installed cmake files reference binaries from llvm-test and llvm-static. -# We tried in the past to split the cmake exports for these binaries out into -# separate files, so that llvm-devel would not need to Require these packages, -# but this caused bugs (rhbz#1773678) and forced us to carry two non-upstream -# patches. Requires: %{name}-static = %{version}-%{release} %if %{without compat_build} Requires: %{name}-test = %{version}-%{release} @@ -196,8 +171,6 @@ This is the main package for llvm-toolset. %endif %prep %setup -T -q -b 2 -n %{cmake_srcdir} -# TODO: It would be more elegant to set -DLLVM_COMMON_CMAKE_UTILS=%{_builddir}/%{cmake_srcdir}, -# but this is not a CACHED variable, so we can't actually set it externally :( cd .. mv %{cmake_srcdir} cmake %setup -T -q -b 4 -n %{third_party_srcdir} @@ -214,7 +187,6 @@ mv %{third_party_srcdir} third-party utils/update_cc_test_checks.py %build -# Copy CFLAGS into ASMFLAGS, so -fcf-protection is used when compiling assembly files. export ASMFLAGS=$CFLAGS %cmake -G Ninja \ @@ -271,20 +243,17 @@ export ASMFLAGS=$CFLAGS %if %{without compat_build} -DLLVM_VERSION_SUFFIX='' \ %endif - -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON \ - -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ - -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \ - -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF \ - -DLLVM_DEFAULT_TARGET_TRIPLE=%{llvm_triple} \ - -DSPHINX_WARNINGS_AS_ERRORS=OFF \ - -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ - -DLLVM_INSTALL_SPHINX_HTML_DIR=%{_pkgdocdir}/html \ + -DLLVM_INCLUDE_BENCHMARKS=OFF \ -DSPHINX_EXECUTABLE=%{_bindir}/sphinx-build-3 \ - -DLLVM_INCLUDE_BENCHMARKS=OFF + -DLLVM_INSTALL_SPHINX_HTML_DIR=%{_pkgdocdir}/html \ + -DCMAKE_INSTALL_PREFIX=%{install_prefix} \ + -DSPHINX_WARNINGS_AS_ERRORS=OFF \ + -DLLVM_DEFAULT_TARGET_TRIPLE=%{llvm_triple} \ + -DLLVM_INSTALL_TOOLCHAIN_ONLY:BOOL=OFF \ + -DLLVM_BUILD_EXTERNAL_COMPILER_RT:BOOL=ON \ + -DLLVM_LINK_LLVM_DYLIB:BOOL=ON \ + -DLLVM_BUILD_LLVM_DYLIB:BOOL=ON -# 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 -# builders without having to artificially limit the number of concurrent jobs. %cmake_build --target LLVM %cmake_build @@ -295,10 +264,8 @@ mkdir -p %{buildroot}/%{_bindir} %if %{without compat_build} -# Fix some man pages ln -s llvm-config.1 %{buildroot}%{_mandir}/man1/llvm-config%{exec_suffix}-%{__isa_bits}.1 -# Install binaries needed for lit tests %global test_binaries llvm-isel-fuzzer llvm-opt-fuzzer for f in %{test_binaries} @@ -306,10 +273,8 @@ do install -m 0755 %{_vpath_builddir}/bin/$f %{buildroot}%{_bindir} done -# Remove testing of update utility tools rm -rf test/tools/UpdateTestChecks -# Install libraries needed for unittests %if 0%{?__isa_bits} == 64 %global build_libdir %{_vpath_builddir}/lib64 %else @@ -321,66 +286,49 @@ install %{build_libdir}/libLLVMTestingAnnotations.a %{buildroot}%{_libdir} %global install_srcdir %{buildroot}%{_datadir}/llvm/src -# Install gtest sources so clang can use them for gtest install -d %{install_srcdir} install -d %{install_srcdir}/utils/ cp -R ../third-party/unittest %{install_srcdir}/utils/ -# Clang needs these for running lit tests. cp utils/update_cc_test_checks.py %{install_srcdir}/utils/ cp -R utils/UpdateTestChecks %{install_srcdir}/utils/ %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 %else -# Add version suffix to binaries for f in %{buildroot}/%{install_bindir}/*; do filename=`basename $f` ln -s ../../%{install_bindir}/$filename %{buildroot}/%{_bindir}/$filename%{exec_suffix} done -# Move header files mkdir -p %{buildroot}/%{pkg_includedir} ln -s ../../../%{install_includedir}/llvm %{buildroot}/%{pkg_includedir}/llvm ln -s ../../../%{install_includedir}/llvm-c %{buildroot}/%{pkg_includedir}/llvm-c -# Create ld.so.conf.d entry mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d cat >> %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{name}-%{_arch}.conf << EOF %{pkg_libdir} EOF -# Add version suffix to man pages and move them to mandir. mkdir -p %{buildroot}/%{_mandir}/man1 for f in %{build_install_prefix}/share/man/man1/*; do filename=`basename $f | cut -f 1 -d '.'` mv $f %{buildroot}%{_mandir}/man1/$filename%{exec_suffix}.1 done -# Remove opt-viewer, since this is just a compatibility package. rm -Rf %{build_install_prefix}/share/opt-viewer %endif -# llvm-config special casing. llvm-config is managed by update-alternatives. -# the original file must remain available for compatibility with the CMake -# infrastructure. Without compat, cmake points to the symlink, with compat it -# points to the original file. %if %{without compat_build} mv %{buildroot}/%{pkg_bindir}/llvm-config %{buildroot}/%{pkg_bindir}/llvm-config%{exec_suffix}-%{__isa_bits} -# We still maintain a versionned symlink for consistency across llvm versions. -# This is specific to the non-compat build and matches the exec prefix for -# compat builds. An isa-agnostic versionned symlink is also maintained in the (un)install -# steps. (cd %{buildroot}/%{pkg_bindir} ; ln -s llvm-config%{exec_suffix}-%{__isa_bits} llvm-config-%{maj_ver}-%{__isa_bits} ) -# ghost presence touch %{buildroot}%{_bindir}/llvm-config-%{maj_ver} %else @@ -390,7 +338,6 @@ rm %{buildroot}%{_bindir}/llvm-config%{exec_suffix} %endif -# ghost presence touch %{buildroot}%{_bindir}/llvm-config%{exec_suffix} cp -Rv ../cmake/Modules/* %{buildroot}%{pkg_libdir}/cmake/llvm @@ -398,11 +345,9 @@ cp -Rv ../cmake/Modules/* %{buildroot}%{pkg_libdir}/cmake/llvm %generate_compatibility_deps %check -# non reproducible errors rm test/tools/dsymutil/X86/swift-interface.test %if %{with check} -# FIXME: use %%cmake_build instead of %%__ninja LD_LIBRARY_PATH=%{buildroot}/%{pkg_libdir} %{__ninja} check-all -C %{_vpath_builddir} %endif @@ -537,9 +482,13 @@ fi %files toolset %license LICENSE.TXT + %endif %changelog +* Thu Apr 13 2023 Zhongling - 16.0.1-3 +- Refactor rpm spec + * Fri Apr 7 2023 Funda Wang - 16.0.1-2 - Install googletest files for clang -- Gitee