From 10f88a7d358798eaabff337db483480f7e66ccb3 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 8 Oct 2024 09:49:43 +0000 Subject: [PATCH] Only disable rpath during installation We currently disable rpath during both build and install. Instead, we use LD_LIBRARY_PATH to allow the built clang to find the libLLVM.so etc objects. However, this does not work well if the system clang and the clang being built have the same version. During the build, we use both the system clang and the just-built clang, and they need to use the system and just-built shared objects respectively. However, use of LD_LIBRARY_PATH causes us to always use the just-built objects as long as the versions match. This is a problem in two scenarios: When building compat packages for the current system LLVM version, we mix system clang with compat libraries, which assume different paths. And when building release candidates, a build using a previous rc of a newer rc may use ABI-incompatible objects, because we don't version sonames on rc versions. Fix this by keeping the rpath during the build and only stripping it on installation using the CMAKE_SKIP_INSTALL_RPATH option. For manually installed binaries, we need to also manually strip the rpath using chrpath. This way system clang will use system libraries, and just-built clang will use just-built libraries. --- llvm.spec | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/llvm.spec b/llvm.spec index b3fe8b6..d8d073c 100644 --- a/llvm.spec +++ b/llvm.spec @@ -240,6 +240,7 @@ BuildRequires: gcc BuildRequires: gcc-c++ BuildRequires: clang BuildRequires: cmake +BuildRequires: chrpath BuildRequires: ninja-build BuildRequires: zlib-devel BuildRequires: libffi-devel @@ -805,8 +806,6 @@ export ASMFLAGS="%{build_cflags}" %define _find_debuginfo_dwz_opts %{nil} %endif -export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/%{build_libdir}" - cd llvm #region LLVM lit @@ -941,11 +940,19 @@ popd -DBUILD_SHARED_LIBS:BOOL=OFF \\\ -DCMAKE_BUILD_TYPE=RelWithDebInfo \\\ -DCMAKE_INSTALL_PREFIX=%{install_prefix} \\\ - -DCMAKE_SKIP_RPATH:BOOL=ON \\\ -DENABLE_LINKER_BUILD_ID:BOOL=ON \\\ -DOFFLOAD_INSTALL_LIBDIR=%{unprefixed_libdir} \\\ -DPython3_EXECUTABLE=%{__python3} +# During the build, we use both the system clang and the just-built clang, and +# they need to use the system and just-built shared objects respectively. If +# we use LD_LIBRARY_PATH to point to our build directory, the system clang +# may use the just-built shared objects instead, which may not be compatible +# even if the version matches (e.g. when building compat libs or different rcs). +# Instead, we make use of rpath during the build and only strip it on +# installation using the CMAKE_SKIP_INSTALL_RPATH option. +%global cmake_config_args %{cmake_config_args} -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON + %if 0%{?fedora} || 0%{?rhel} > 9 %global cmake_config_args %{cmake_config_args} -DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON %endif @@ -1057,6 +1064,7 @@ mkdir -p %{buildroot}/%{_bindir} for f in %{test_binaries} do install -m 0755 llvm/%{_vpath_builddir}/bin/$f %{buildroot}%{install_bindir} + chrpath --delete %{buildroot}%{install_bindir}/$f done # Install libraries needed for unittests