#region LLVM installation pushd llvm %if %{with python_lit} 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 %endif %cmake_install popd 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 install -m 0755 llvm/%{_vpath_builddir}/bin/$f %{buildroot}%{install_bindir} done # Install libraries needed for unittests 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 %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 # 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 # 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. %if %{without compat_build} 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 install -p -m644 clang/bindings/python/clang/* %{buildroot}%{python3_sitelib}/clang/ %py_byte_compile %{__python3} %{buildroot}%{python3_sitelib}/clang # install scanbuild-py to python sitelib. mv %{buildroot}%{_prefix}/%{_lib}/{libear,libscanbuild} %{buildroot}%{python3_sitelib} # 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 # 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 # Add clang++-{version} symlink ln -s clang++ %{buildroot}%{_bindir}/clang++-%{maj_ver} %else # 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 # Fix permission chmod u-x %{buildroot}%{_mandir}/man1/scan-build%{exec_suffix}.1* # 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 # Fix permissions of scan-view scripts chmod a+x %{buildroot}%{install_datadir}/scan-view/{Reporter.py,startfile.py} # multilib fix %multilib_fix_c_header --file %{install_includedir}/clang/Config/config.h # remove editor integrations (bbedit, sublime, emacs, vim) rm -vf %{buildroot}%{install_datadir}/clang/clang-format-bbedit.applescript rm -vf %{buildroot}%{install_datadir}/clang/clang-format-sublime.py* # TODO: Package html docs 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 # TODO: What are the Fedora guidelines for packaging bash autocomplete files? rm -vf %{buildroot}%{install_datadir}/clang/bash-autocomplete.sh # Create sub-directories in the clang resource directory that will be # populated by other packages mkdir -p %{buildroot}%{_prefix}/lib/clang/%{maj_ver}/{bin,include,lib,share}/ # Add versioned resource directory macro mkdir -p %{buildroot}%{_rpmmacrodir}/ echo "%%clang%{maj_ver}_resource_dir %%{_prefix}/lib/clang/%{maj_ver}" >> %{buildroot}%{_rpmmacrodir}/macros.%{pkg_name_clang} # Install config file for clang %if %{maj_ver} >=18 mkdir -p %{buildroot}%{_sysconfdir}/%{pkg_name_clang}/ 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 %endif #endregion #region COMPILER-RT installation # 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} %ifarch ppc64le # Fix install path on ppc64le so that the directory name matches the triple used # by clang. 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 %endif #endregion #region OPENMP installation # Remove static libraries with equivalent shared libraries rm -rf %{buildroot}%{install_libdir}/libarcher_static.a # Remove the openmp gdb plugin for now rm -rf %{buildroot}/%{install_datadir}/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 %ifnarch %{ix86} # Remove files that we don't package, yet. rm %{buildroot}%{install_bindir}/llvm-omp-device-info rm %{buildroot}%{install_bindir}/llvm-omp-kernel-replay %endif #endregion #region LLD installation # Remove LLD's HTML documentation files rm -Rvf %{buildroot}%{install_docdir}/LLVM/lld/html %if %{without compat_build} # Required when using update-alternatives: # https://docs.fedoraproject.org/en-US/packaging-guidelines/Alternatives/ touch %{buildroot}%{_bindir}/ld install -D -m 644 -t %{buildroot}%{_mandir}/man1/ lld/docs/ld.lld.1 %endif #endregion #region LLDB installation %if %{with lldb} %multilib_fix_c_header --file %{install_includedir}/lldb/Host/Config.h # remove static libraries rm -fv %{buildroot}%{_libdir}/liblldb*.a # 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 %endif #endregion %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 # 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}