[PATCH] D63637: Do not set an RPATH on statically-linked LLVM executables.
Reid Kleckner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 21 09:00:29 PDT 2019
rnk added a comment.
> This RPATH breaks the ability to run executables from the build area if
> the host compiler provides a libc++ and we also build an
> ABI-incompatible libc++ as part of the same monorepo compilation.
This is the RPATH we set:
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
I believe LLVM_LIBDIR_SUFFIX is typically empty.
This is a pretty normal convention, and it should work from the build directory and the install directory. It just says, if there are shared libraries, go to ${root}/bin/../lib/ and search for any shared libs there first.
I think maybe we shouldn't build libc++, and any other shared libraries that might conflict with system shared libraries, into ${builddir}/lib. Don't we install libcxx into lib/clang/9.0.0/lib/... in the end anyway, or is libcxx not treated as a compiler runtime library?
================
Comment at: llvm/cmake/modules/AddLLVM.cmake:756
- if(NOT ARG_NO_INSTALL_RPATH)
- llvm_setup_rpath(${name})
+ if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
+ set(USE_SHARED USE_SHARED)
----------------
mgorny wrote:
> I think this is also needed when building with `BUILD_SHARED_LIBS`. Possibly also when the target explicitly links to one of the shared-only libraries.
Yep.
================
Comment at: llvm/cmake/modules/AddLLVM.cmake:758
+ set(USE_SHARED USE_SHARED)
+ if(NOT ARG_NO_INSTALL_RPATH)
+ llvm_setup_rpath(${name})
----------------
chandlerc wrote:
> Just to make sure I understand correctly, *any* time we build a shared library of some form, we'll get here? Even if its `libclang.so` or some such?
>
> Provided I've understood correctly, then this make sense. However, I wonder, won't this still fail for things like c-index-test?
I think we only come here for executables, but yes, your concern about `c-index-test` seems warranted. In the standard, static configuration, libclang seems to be a shared library, and c-index-test links to it. Without the rpath, it probably won't find it. But, this code sets the "install rpath", and I think cmake actually goes back and tweaks the rpath when it does the install step, so maybe this won't affect that.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D63637/new/
https://reviews.llvm.org/D63637
More information about the llvm-commits
mailing list