2023-10-12 09:15:14 +00:00
|
|
|
#region LLVM installation
|
|
|
|
|
2024-07-22 12:25:34 +00:00
|
|
|
pushd llvm
|
|
|
|
|
2024-07-30 14:59:07 +00:00
|
|
|
%if %{with python_lit}
|
2024-07-22 12:25:34 +00:00
|
|
|
pushd utils/lit
|
|
|
|
%py3_install
|
|
|
|
|
|
|
|
# Strip out #!/usr/bin/env python
|
|
|
|
sed -i -e '1{\@^#!/usr/bin/env python@d}' %{buildroot}%{python3_sitelib}/lit/*.py
|
|
|
|
popd
|
2024-07-30 14:59:07 +00:00
|
|
|
%endif
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
%cmake_install
|
|
|
|
|
2024-07-22 12:25:34 +00:00
|
|
|
popd
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
mkdir -p %{buildroot}/%{_bindir}
|
|
|
|
|
|
|
|
# Install binaries needed for lit tests
|
|
|
|
%global test_binaries llvm-isel-fuzzer llvm-opt-fuzzer
|
|
|
|
|
|
|
|
for f in %{test_binaries}
|
|
|
|
do
|
2024-07-31 11:27:03 +00:00
|
|
|
install -m 0755 llvm/%{_vpath_builddir}/bin/$f %{buildroot}%{install_bindir}
|
2023-10-12 09:15:14 +00:00
|
|
|
done
|
|
|
|
|
|
|
|
# Install libraries needed for unittests
|
2024-07-31 11:27:03 +00:00
|
|
|
install %{build_libdir}/libLLVMTestingSupport.a %{buildroot}%{install_libdir}
|
|
|
|
install %{build_libdir}/libLLVMTestingAnnotations.a %{buildroot}%{install_libdir}
|
|
|
|
|
|
|
|
# Fix multi-lib
|
|
|
|
%multilib_fix_c_header --file %{install_includedir}/llvm/Config/llvm-config.h
|
|
|
|
|
|
|
|
%if %{without compat_build}
|
|
|
|
|
|
|
|
# Fix some man pages
|
|
|
|
ln -s llvm-config.1 %{buildroot}%{_mandir}/man1/llvm-config%{exec_suffix}-%{__isa_bits}.1
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
%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
|
|
|
|
|
|
|
|
# Create ld.so.conf.d entry
|
|
|
|
mkdir -p %{buildroot}%{_sysconfdir}/ld.so.conf.d
|
|
|
|
cat >> %{buildroot}%{_sysconfdir}/ld.so.conf.d/%{pkg_name_llvm}-%{_arch}.conf << EOF
|
|
|
|
%{install_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
|
|
|
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
mkdir -p %{buildroot}%{pkg_datadir}/llvm/cmake
|
|
|
|
cp -Rv cmake/* %{buildroot}%{pkg_datadir}/llvm/cmake
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region CLANG installation
|
|
|
|
|
2024-07-31 12:38:37 +00:00
|
|
|
# Add a symlink in /usr/bin to clang-format-diff
|
|
|
|
ln -s %{install_datadir}/clang/clang-format-diff.py %{buildroot}%{install_bindir}/clang-format-diff
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
# File in the macros file for other packages to use. We are not doing this
|
|
|
|
# in the compat package, because the version macros would # conflict with
|
|
|
|
# eachother if both clang and the clang compat package were installed together.
|
2024-07-31 12:38:37 +00:00
|
|
|
%if %{without compat_build}
|
2023-10-12 09:15:14 +00:00
|
|
|
install -p -m0644 -D %{SOURCE2005} %{buildroot}%{_rpmmacrodir}/macros.%{pkg_name_clang}
|
|
|
|
sed -i -e "s|@@CLANG_MAJOR_VERSION@@|%{maj_ver}|" \
|
|
|
|
-e "s|@@CLANG_MINOR_VERSION@@|%{min_ver}|" \
|
|
|
|
-e "s|@@CLANG_PATCH_VERSION@@|%{patch_ver}|" \
|
|
|
|
%{buildroot}%{_rpmmacrodir}/macros.%{pkg_name_clang}
|
|
|
|
|
|
|
|
# install clang python bindings
|
|
|
|
mkdir -p %{buildroot}%{python3_sitelib}/clang/
|
|
|
|
# If we don't default to true here, we'll see this error:
|
|
|
|
# install: omitting directory 'bindings/python/clang/__pycache__'
|
|
|
|
# NOTE: this only happens if we include the gdb plugin of libomp.
|
|
|
|
# Remove the plugin with command and we're good: rm -rf %{buildroot}/%{_datarootdir}/gdb
|
2024-07-08 10:32:57 +00:00
|
|
|
install -p -m644 clang/bindings/python/clang/* %{buildroot}%{python3_sitelib}/clang/
|
2023-10-12 09:15:14 +00:00
|
|
|
%py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/clang
|
|
|
|
|
|
|
|
# install scanbuild-py to python sitelib.
|
2024-09-02 08:01:03 +00:00
|
|
|
mv %{buildroot}%{_prefix}/lib/{libear,libscanbuild} %{buildroot}%{python3_sitelib}
|
2024-07-17 09:48:33 +00:00
|
|
|
# Cannot use {libear,libscanbuild} style expansion in py_byte_compile.
|
|
|
|
%py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/libear
|
|
|
|
%py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/libscanbuild
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
# Move emacs integration files to the correct directory
|
|
|
|
mkdir -p %{buildroot}%{_emacs_sitestartdir}
|
2024-09-19 07:47:59 +00:00
|
|
|
for f in clang-format.el clang-include-fixer.el; do
|
2023-10-12 09:15:14 +00:00
|
|
|
mv %{buildroot}{%{_datadir}/clang,%{_emacs_sitestartdir}}/$f
|
|
|
|
done
|
2024-09-19 07:47:59 +00:00
|
|
|
%if %{maj_ver} < 20
|
|
|
|
mv %{buildroot}{%{_datadir}/clang,%{_emacs_sitestartdir}}/clang-rename.el
|
|
|
|
%endif
|
2023-10-12 09:15:14 +00:00
|
|
|
|
2024-08-01 14:27:02 +00:00
|
|
|
# Add clang++-{version} symlink
|
|
|
|
ln -s clang++ %{buildroot}%{_bindir}/clang++-%{maj_ver}
|
|
|
|
|
|
|
|
%else
|
|
|
|
|
2024-07-31 12:38:37 +00:00
|
|
|
# Fix permission
|
2024-08-01 14:27:02 +00:00
|
|
|
chmod u-x %{buildroot}%{_mandir}/man1/scan-build%{exec_suffix}.1*
|
2024-07-31 12:38:37 +00:00
|
|
|
|
|
|
|
# Not sure where to put these python modules for the compat build.
|
|
|
|
rm -Rf %{buildroot}%{install_libdir}/{libear,libscanbuild}
|
|
|
|
|
|
|
|
# Not sure where to put the emacs integration files for the compat build.
|
|
|
|
rm -Rf %{buildroot}%{install_datadir}/clang/*.el
|
|
|
|
|
|
|
|
# Add clang++-{version} symlink
|
|
|
|
ln -s ../../%{install_bindir}/clang++ %{buildroot}%{install_bindir}/clang++-%{maj_ver}
|
|
|
|
|
|
|
|
%endif
|
|
|
|
|
2024-08-02 11:39:18 +00:00
|
|
|
# Create Manpage symlinks
|
|
|
|
ln -s clang%{exec_suffix}.1.gz %{buildroot}%{_mandir}/man1/clang++%{exec_suffix}.1.gz
|
|
|
|
%if %{without compat_build}
|
|
|
|
ln -s clang.1.gz %{buildroot}%{_mandir}/man1/clang-%{maj_ver}.1.gz
|
|
|
|
ln -s clang.1.gz %{buildroot}%{_mandir}/man1/clang++-%{maj_ver}.1.gz
|
|
|
|
%endif
|
|
|
|
|
2024-07-31 12:38:37 +00:00
|
|
|
# Fix permissions of scan-view scripts
|
2024-07-31 15:57:48 +00:00
|
|
|
chmod a+x %{buildroot}%{install_datadir}/scan-view/{Reporter.py,startfile.py}
|
2024-07-31 12:38:37 +00:00
|
|
|
|
|
|
|
# multilib fix
|
2024-07-31 15:57:48 +00:00
|
|
|
%multilib_fix_c_header --file %{install_includedir}/clang/Config/config.h
|
2024-07-31 12:38:37 +00:00
|
|
|
|
2023-10-12 09:15:14 +00:00
|
|
|
# remove editor integrations (bbedit, sublime, emacs, vim)
|
2024-07-31 15:57:48 +00:00
|
|
|
rm -vf %{buildroot}%{install_datadir}/clang/clang-format-bbedit.applescript
|
|
|
|
rm -vf %{buildroot}%{install_datadir}/clang/clang-format-sublime.py*
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
# TODO: Package html docs
|
2024-07-31 15:57:48 +00:00
|
|
|
rm -Rvf %{buildroot}%{install_docdir}/LLVM/clang/html
|
|
|
|
rm -Rvf %{buildroot}%{install_docdir}/LLVM/clang-tools/html
|
|
|
|
rm -Rvf %{buildroot}%{install_datadir}/clang-doc/clang-doc-default-stylesheet.css
|
|
|
|
rm -Rvf %{buildroot}%{install_datadir}/clang-doc/index.js
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
# TODO: What are the Fedora guidelines for packaging bash autocomplete files?
|
2024-07-31 15:57:48 +00:00
|
|
|
rm -vf %{buildroot}%{install_datadir}/clang/bash-autocomplete.sh
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
# Create sub-directories in the clang resource directory that will be
|
|
|
|
# populated by other packages
|
2024-05-28 07:25:39 +00:00
|
|
|
mkdir -p %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/{bin,include,lib,share}/
|
2023-10-12 09:15:14 +00:00
|
|
|
|
2024-07-31 15:57:48 +00:00
|
|
|
# Add versioned resource directory macro
|
2024-07-31 12:40:12 +00:00
|
|
|
mkdir -p %{buildroot}%{_rpmmacrodir}/
|
2024-08-01 09:59:21 +00:00
|
|
|
echo "%%clang%{maj_ver}_resource_dir %%{_prefix}/lib/clang/%{maj_ver}" >> %{buildroot}%{_rpmmacrodir}/macros.%{pkg_name_clang}
|
2024-07-31 12:40:12 +00:00
|
|
|
|
2023-10-12 09:15:14 +00:00
|
|
|
# Install config file for clang
|
|
|
|
%if %{maj_ver} >=18
|
|
|
|
mkdir -p %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/
|
2024-05-15 13:02:24 +00:00
|
|
|
echo "--gcc-triple=%{_target_cpu}-redhat-linux" >> %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/%{_target_platform}-clang.cfg
|
|
|
|
echo "--gcc-triple=%{_target_cpu}-redhat-linux" >> %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/%{_target_platform}-clang++.cfg
|
2023-10-12 09:15:14 +00:00
|
|
|
%endif
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region COMPILER-RT installation
|
|
|
|
|
2024-05-28 13:57:25 +00:00
|
|
|
# Triple where compiler-rt libs are installed. If it differs from llvm_triple, then there is
|
|
|
|
# also a symlink llvm_triple -> compiler_rt_triple.
|
|
|
|
%global compiler_rt_triple %{llvm_triple}
|
|
|
|
|
2023-10-12 09:15:14 +00:00
|
|
|
%ifarch ppc64le
|
|
|
|
# Fix install path on ppc64le so that the directory name matches the triple used
|
|
|
|
# by clang.
|
2024-05-28 13:57:25 +00:00
|
|
|
mv %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/powerpc64le-redhat-linux-gnu %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}
|
|
|
|
%endif
|
|
|
|
|
|
|
|
%ifarch %{ix86}
|
|
|
|
# Fix install path on ix86 so that the directory name matches the triple used
|
|
|
|
# by clang on both actual ix86 (i686) and on x86_64 with -m32 (i386):
|
|
|
|
%global compiler_rt_triple i386-redhat-linux-gnu
|
|
|
|
%if "%{llvm_triple}" != "%{compiler_rt_triple}"
|
|
|
|
ln -s %{compiler_rt_triple} %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/lib/%{llvm_triple}
|
|
|
|
%endif
|
2023-10-12 09:15:14 +00:00
|
|
|
%endif
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region OPENMP installation
|
|
|
|
|
|
|
|
# Remove static libraries with equivalent shared libraries
|
2024-08-01 14:13:17 +00:00
|
|
|
rm -rf %{buildroot}%{install_libdir}/libarcher_static.a
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
# Remove the openmp gdb plugin for now
|
2024-08-01 14:13:17 +00:00
|
|
|
rm -rf %{buildroot}/%{install_datadir}/gdb
|
2023-10-12 09:15:14 +00:00
|
|
|
# # TODO(kkleine): These was added to avoid a permission issue
|
|
|
|
# chmod go+w %{buildroot}/%{_datarootdir}/gdb/python/ompd/ompdModule.so
|
|
|
|
# chmod +w %{buildroot}/%{_datarootdir}/gdb/python/ompd/ompdModule.so
|
|
|
|
|
2024-05-23 14:05:18 +00:00
|
|
|
%ifnarch %{ix86}
|
2024-05-13 13:05:48 +00:00
|
|
|
# Remove files that we don't package, yet.
|
2024-09-11 08:08:23 +00:00
|
|
|
%if %{maj_ver} >= 20
|
|
|
|
rm %{buildroot}%{install_bindir}/llvm-offload-device-info
|
|
|
|
%else
|
2024-07-31 12:41:13 +00:00
|
|
|
rm %{buildroot}%{install_bindir}/llvm-omp-device-info
|
2024-09-11 08:08:23 +00:00
|
|
|
%endif
|
2024-05-13 13:05:48 +00:00
|
|
|
rm %{buildroot}%{install_bindir}/llvm-omp-kernel-replay
|
2024-05-23 14:05:18 +00:00
|
|
|
%endif
|
2024-05-13 13:05:48 +00:00
|
|
|
|
2023-10-12 09:15:14 +00:00
|
|
|
#endregion
|
2024-05-03 11:12:47 +00:00
|
|
|
|
|
|
|
#region LLD installation
|
|
|
|
|
2024-05-07 14:46:16 +00:00
|
|
|
# Remove LLD's HTML documentation files
|
2024-08-01 14:13:17 +00:00
|
|
|
rm -Rvf %{buildroot}%{install_docdir}/LLVM/lld/html
|
2024-05-07 14:46:16 +00:00
|
|
|
|
2024-07-31 15:19:30 +00:00
|
|
|
%if %{without compat_build}
|
2024-05-03 11:12:47 +00:00
|
|
|
# Required when using update-alternatives:
|
|
|
|
# https://docs.fedoraproject.org/en-US/packaging-guidelines/Alternatives/
|
|
|
|
touch %{buildroot}%{_bindir}/ld
|
|
|
|
|
2024-07-08 10:32:57 +00:00
|
|
|
install -D -m 644 -t %{buildroot}%{_mandir}/man1/ lld/docs/ld.lld.1
|
2024-05-03 11:12:47 +00:00
|
|
|
%endif
|
|
|
|
|
2024-05-23 14:05:18 +00:00
|
|
|
#endregion
|
2024-07-01 11:30:45 +00:00
|
|
|
|
|
|
|
#region LLDB installation
|
2024-07-30 14:59:07 +00:00
|
|
|
%if %{with lldb}
|
2024-07-01 11:30:45 +00:00
|
|
|
%multilib_fix_c_header --file %{install_includedir}/lldb/Host/Config.h
|
|
|
|
|
|
|
|
# python: fix binary libraries location
|
|
|
|
liblldb=$(basename $(readlink -e %{buildroot}%{_libdir}/liblldb.so))
|
|
|
|
ln -vsf "../../../${liblldb}" %{buildroot}%{python3_sitearch}/lldb/_lldb.so
|
|
|
|
%py_byte_compile %{__python3} %{buildroot}%{python3_sitearch}/lldb
|
2024-07-30 14:59:07 +00:00
|
|
|
%endif
|
2024-07-01 11:30:45 +00:00
|
|
|
#endregion
|
2024-08-01 10:55:17 +00:00
|
|
|
|
|
|
|
%if %{with compat_build}
|
|
|
|
# Add version suffix to binaries. Do this at the end so it includes any
|
|
|
|
# additional binaries that may be been added by other steps.
|
|
|
|
for f in %{buildroot}/%{install_bindir}/*; do
|
|
|
|
filename=`basename $f`
|
|
|
|
if echo $filename | grep -e '%{maj_ver}'; then
|
|
|
|
continue
|
|
|
|
fi
|
|
|
|
ln -s ../../%{install_bindir}/$filename %{buildroot}/%{_bindir}/$filename%{exec_suffix}
|
|
|
|
done
|
|
|
|
%endif
|
2024-08-01 12:24:01 +00:00
|
|
|
|
|
|
|
# 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}/%{install_bindir}/llvm-config %{buildroot}/%{install_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}/%{install_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
|
|
|
|
|
|
|
|
rm %{buildroot}%{_bindir}/llvm-config%{exec_suffix}
|
|
|
|
(cd %{buildroot}/%{install_bindir} ; ln -s llvm-config llvm-config%{exec_suffix}-%{__isa_bits} )
|
|
|
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
# ghost presence
|
|
|
|
touch %{buildroot}%{_bindir}/llvm-config%{exec_suffix}
|
|
|
|
|
2024-08-08 14:33:26 +00:00
|
|
|
%if %{with bundle_compat_lib}
|
|
|
|
install -m 0755 ../llvm-compat-libs/lib/libLLVM.so.%{compat_maj_ver}* %{buildroot}%{_libdir}
|
|
|
|
install -m 0755 ../llvm-compat-libs/lib/libclang.so.%{compat_maj_ver}* %{buildroot}%{_libdir}
|
|
|
|
install -m 0755 ../llvm-compat-libs/lib/libclang-cpp.so.%{compat_maj_ver}* %{buildroot}%{_libdir}
|
|
|
|
%endif
|