Skip to content

Commit 10f88a7

Browse files
committed
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.
1 parent 4f254e5 commit 10f88a7

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

llvm.spec

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ BuildRequires: gcc
240240
BuildRequires: gcc-c++
241241
BuildRequires: clang
242242
BuildRequires: cmake
243+
BuildRequires: chrpath
243244
BuildRequires: ninja-build
244245
BuildRequires: zlib-devel
245246
BuildRequires: libffi-devel
@@ -805,8 +806,6 @@ export ASMFLAGS="%{build_cflags}"
805806
%define _find_debuginfo_dwz_opts %{nil}
806807
%endif
807808

808-
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:`pwd`/%{build_libdir}"
809-
810809
cd llvm
811810

812811
#region LLVM lit
@@ -941,11 +940,19 @@ popd
941940
-DBUILD_SHARED_LIBS:BOOL=OFF \\\
942941
-DCMAKE_BUILD_TYPE=RelWithDebInfo \\\
943942
-DCMAKE_INSTALL_PREFIX=%{install_prefix} \\\
944-
-DCMAKE_SKIP_RPATH:BOOL=ON \\\
945943
-DENABLE_LINKER_BUILD_ID:BOOL=ON \\\
946944
-DOFFLOAD_INSTALL_LIBDIR=%{unprefixed_libdir} \\\
947945
-DPython3_EXECUTABLE=%{__python3}
948946

947+
# During the build, we use both the system clang and the just-built clang, and
948+
# they need to use the system and just-built shared objects respectively. If
949+
# we use LD_LIBRARY_PATH to point to our build directory, the system clang
950+
# may use the just-built shared objects instead, which may not be compatible
951+
# even if the version matches (e.g. when building compat libs or different rcs).
952+
# Instead, we make use of rpath during the build and only strip it on
953+
# installation using the CMAKE_SKIP_INSTALL_RPATH option.
954+
%global cmake_config_args %{cmake_config_args} -DCMAKE_SKIP_INSTALL_RPATH:BOOL=ON
955+
949956
%if 0%{?fedora} || 0%{?rhel} > 9
950957
%global cmake_config_args %{cmake_config_args} -DPPC_LINUX_DEFAULT_IEEELONGDOUBLE=ON
951958
%endif
@@ -1057,6 +1064,7 @@ mkdir -p %{buildroot}/%{_bindir}
10571064
for f in %{test_binaries}
10581065
do
10591066
install -m 0755 llvm/%{_vpath_builddir}/bin/$f %{buildroot}%{install_bindir}
1067+
chrpath --delete %{buildroot}%{install_bindir}/$f
10601068
done
10611069

10621070
# Install libraries needed for unittests

0 commit comments

Comments
 (0)