2023-10-12 09:15:14 +00:00
|
|
|
#region LLVM installation
|
|
|
|
|
2024-07-22 12:25:34 +00:00
|
|
|
pushd llvm
|
|
|
|
|
|
|
|
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
|
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}
|
|
|
|
|
|
|
|
%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}
|
|
|
|
do
|
|
|
|
install -m 0755 llvm/%{_vpath_builddir}/bin/$f %{buildroot}%{_bindir}
|
|
|
|
done
|
|
|
|
|
|
|
|
%multilib_fix_c_header --file %{install_includedir}/llvm/Config/llvm-config.h
|
|
|
|
|
|
|
|
# Install libraries needed for unittests
|
|
|
|
%global build_libdir llvm/%{_vpath_builddir}/%{_lib}
|
|
|
|
|
|
|
|
install %{build_libdir}/libLLVMTestingSupport.a %{buildroot}%{_libdir}
|
|
|
|
install %{build_libdir}/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
|
|
|
|
|
|
|
|
%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
|
|
|
|
|
|
|
|
# Fix multi-lib
|
|
|
|
%multilib_fix_c_header --file %{install_includedir}/llvm/Config/llvm-config.h
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# 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}/%{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}
|
|
|
|
|
|
|
|
mkdir -p %{buildroot}%{pkg_datadir}/llvm/cmake
|
|
|
|
cp -Rv cmake/* %{buildroot}%{pkg_datadir}/llvm/cmake
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region CLANG installation
|
|
|
|
|
|
|
|
%if %{with compat_build}
|
|
|
|
|
2024-05-13 13:13:03 +00:00
|
|
|
# TODO(kkleine): I don't know if the removal of every binary
|
|
|
|
# below is what we want to do in big-merge for compat packages.
|
|
|
|
# Re-evaluate this!
|
|
|
|
|
2023-10-12 09:15:14 +00:00
|
|
|
# Remove binaries/other files
|
|
|
|
rm -Rf %{buildroot}%{install_bindir}
|
|
|
|
rm -Rf %{buildroot}%{install_prefix}/share
|
|
|
|
rm -Rf %{buildroot}%{install_prefix}/libexec
|
|
|
|
# Remove scanview-py helper libs
|
|
|
|
rm -Rf %{buildroot}%{install_prefix}/lib/{libear,libscanbuild}
|
|
|
|
|
|
|
|
%else
|
|
|
|
|
|
|
|
# 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.
|
|
|
|
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.
|
|
|
|
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
|
|
|
|
|
|
|
# Fix permissions of scan-view scripts
|
|
|
|
chmod a+x %{buildroot}%{_datadir}/scan-view/{Reporter.py,startfile.py}
|
|
|
|
|
|
|
|
# multilib fix
|
|
|
|
%multilib_fix_c_header --file %{_includedir}/clang/Config/config.h
|
|
|
|
|
|
|
|
# Move emacs integration files to the correct directory
|
|
|
|
mkdir -p %{buildroot}%{_emacs_sitestartdir}
|
|
|
|
for f in clang-format.el clang-rename.el clang-include-fixer.el; do
|
|
|
|
mv %{buildroot}{%{_datadir}/clang,%{_emacs_sitestartdir}}/$f
|
|
|
|
done
|
|
|
|
|
|
|
|
# remove editor integrations (bbedit, sublime, emacs, vim)
|
|
|
|
rm -vf %{buildroot}%{_datadir}/clang/clang-format-bbedit.applescript
|
|
|
|
rm -vf %{buildroot}%{_datadir}/clang/clang-format-sublime.py*
|
|
|
|
|
|
|
|
# TODO: Package html docs
|
|
|
|
rm -Rvf %{buildroot}%{_docdir}/LLVM/clang/html
|
|
|
|
rm -Rvf %{buildroot}%{_docdir}/LLVM/clang-tools/html
|
2024-06-26 07:37:20 +00:00
|
|
|
rm -Rvf %{buildroot}%{_datadir}/clang-doc/clang-doc-default-stylesheet.css
|
|
|
|
rm -Rvf %{buildroot}%{_datadir}/clang-doc/index.js
|
2023-10-12 09:15:14 +00:00
|
|
|
|
|
|
|
# TODO: What are the Fedora guidelines for packaging bash autocomplete files?
|
|
|
|
rm -vf %{buildroot}%{_datadir}/clang/bash-autocomplete.sh
|
|
|
|
|
|
|
|
# Create Manpage symlinks
|
|
|
|
ln -s clang.1.gz %{buildroot}%{_mandir}/man1/clang++.1.gz
|
|
|
|
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
|
|
|
|
|
|
|
|
# Add clang++-{version} symlink
|
|
|
|
ln -s clang++ %{buildroot}%{_bindir}/clang++-%{maj_ver}
|
|
|
|
|
|
|
|
|
|
|
|
# Fix permission
|
|
|
|
chmod u-x %{buildroot}%{_mandir}/man1/scan-build.1*
|
|
|
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
%if %{without compat_build}
|
|
|
|
# Add a symlink in /usr/bin to clang-format-diff
|
|
|
|
ln -s %{_datadir}/clang/clang-format-diff.py %{buildroot}%{_bindir}/clang-format-diff
|
|
|
|
%endif
|
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
%if %{without compat_build}
|
|
|
|
|
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
|
|
|
|
|
|
|
|
%endif
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region OPENMP installation
|
|
|
|
|
|
|
|
%if %{without compat_build}
|
|
|
|
|
|
|
|
# Remove static libraries with equivalent shared libraries
|
|
|
|
rm -rf %{buildroot}%{_libdir}/libarcher_static.a
|
|
|
|
|
|
|
|
# Remove the openmp gdb plugin for now
|
|
|
|
rm -rf %{buildroot}/%{_datarootdir}/gdb
|
|
|
|
# # 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.
|
|
|
|
rm %{buildroot}%{install_bindir}/llvm-omp-device-info
|
|
|
|
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
|
|
|
%endif
|
|
|
|
|
|
|
|
#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
|
|
|
|
rm -Rvf %{buildroot}%{_docdir}/LLVM/lld/html
|
|
|
|
|
2024-05-03 11:12:47 +00:00
|
|
|
%if %{with compat_build}
|
|
|
|
# Add version suffix to binaries
|
|
|
|
mkdir -p %{buildroot}%{_bindir}
|
|
|
|
for f in %{buildroot}/%{install_bindir}/*; do
|
|
|
|
filename=`basename $f`
|
|
|
|
ln -s ../../%{install_bindir}/$filename %{buildroot}/%{_bindir}/$filename-%{maj_ver}
|
|
|
|
done
|
|
|
|
%else
|
|
|
|
# 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
|
|
|
|
|
|
|
%post -n %{pkg_name_lld}
|
|
|
|
%{_sbindir}/update-alternatives --install %{_bindir}/ld ld %{_bindir}/ld.lld 1
|
|
|
|
|
|
|
|
%postun -n %{pkg_name_lld}
|
|
|
|
if [ $1 -eq 0 ] ; then
|
|
|
|
%{_sbindir}/update-alternatives --remove ld %{_bindir}/ld.lld
|
|
|
|
fi
|
|
|
|
%endif
|
|
|
|
|
2024-05-23 14:05:18 +00:00
|
|
|
#endregion
|
2024-07-01 11:30:45 +00:00
|
|
|
|
|
|
|
#region LLDB installation
|
|
|
|
%multilib_fix_c_header --file %{install_includedir}/lldb/Host/Config.h
|
|
|
|
|
|
|
|
# remove static libraries
|
2024-07-02 16:08:10 +00:00
|
|
|
rm -fv %{buildroot}%{_libdir}/liblldb*.a
|
2024-07-01 11:30:45 +00:00
|
|
|
|
|
|
|
# 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
|
|
|
|
|
|
|
|
# remove bundled six.py
|
|
|
|
rm -f %{buildroot}%{python3_sitearch}/six.*
|
|
|
|
#endregion
|