From bb1961f3519d4b66f1dc23407d2efb7626a74f5c Mon Sep 17 00:00:00 2001 From: apaz-cli Date: Tue, 25 Oct 2022 15:02:56 -0500 Subject: [PATCH] Purge RPATH from libs installed with julia --- B/Binutils/build_tarballs.jl | 3 ++- C/CompilerSupportLibraries/common.jl | 4 ++++ L/LLVM/common.jl | 8 ++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/B/Binutils/build_tarballs.jl b/B/Binutils/build_tarballs.jl index 142116ce987..b631e865940 100644 --- a/B/Binutils/build_tarballs.jl +++ b/B/Binutils/build_tarballs.jl @@ -58,7 +58,8 @@ else --host=\${MACHTYPE} \\ --with-sysroot="\${prefix}/$(compiler_target)/sys-root" \\ --enable-multilib \\ - --disable-werror + --disable-werror \\ + --enable-new-dtags make -j\${nproc} make install diff --git a/C/CompilerSupportLibraries/common.jl b/C/CompilerSupportLibraries/common.jl index 71f1887cde3..300cf2d9e1a 100644 --- a/C/CompilerSupportLibraries/common.jl +++ b/C/CompilerSupportLibraries/common.jl @@ -113,6 +113,10 @@ if [[ ${target} == *apple* ]]; then done fi +for lib in libgfortran libasan libtsan libubsan liblsan; do + [ ! -f "${libdir}/${lib}.so" ] || patchelf --set-rpath "\$ORIGIN" "${libdir}/${lib}.so" +done + # Remove extraneous libraries rm -f ${libdir}/{libiconv,libxml2,libz}*.${dlext}* diff --git a/L/LLVM/common.jl b/L/LLVM/common.jl index 8f2c8195446..c0c899e32cf 100644 --- a/L/LLVM/common.jl +++ b/L/LLVM/common.jl @@ -273,6 +273,14 @@ ninja -j${nproc} -vv # Install! ninja install +shopt -s nullglob +for x in ${prefix}/lib/*.so; do + # All things that have RPATH or doesn't have $ORIGIN, + # but not those without $RUNPATH and $ORIGIN + [ -n "$(objdump -x "$x" | grep 'RPATH\|RUNPATH')" ] && \ + patchelf --set-rpath "\$ORIGIN" "$x"; +done + # Life is harsh on Windows and dynamic libraries are # expected to live alongside the binaries. So we have # to copy the *.dll from bin/ to tools/ as well...