[PATCH] D25304: cmake: Set the proper rpath in add_llvm_executable and llvm_add_library

Peter Levine via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 9 19:29:28 PDT 2016


plevine added inline comments.


================
Comment at: cmake/modules/AddLLVM.cmake:494
+    else()
+      set_target_properties( ${name} PROPERTIES BUILD_WITH_INSTALL_RPATH OFF )
+      set_property(TARGET ${name} APPEND_STRING PROPERTY INSTALL_RPATH ":${LLVM_LIBRARY_DIR}")
----------------
beanz wrote:
> plevine wrote:
> > beanz wrote:
> > > Why are you setting this off? This doesn't seem right to me.
> > Whenever building clang with BUILD_WITH_INSTALL_RPATH set to ON, it fails with 
> > > warning: libclangLex.so.4.0, needed by lib32/libclangFormat.so.4.0.0, not found (try using -rpath or -rpath-link)
> > > /usr/lib/gcc/x86_64-pc-linux-gnu/6.2.0/../../../../x86_64-pc-linux-gnu/bin/ld: warning: libclangAST.so.4.0, needed by lib32/libclangToolingCore.so.4.0.0, not found (try using -rpath or -rpath-link)
> > 
> > along with undefined reference errors pertaining to clang library symbols.  The libraries do include in their rpath "$ORIGIN/../lib32" which does correctly point back to the library directory even at build time so I admit I'm at a loss.  Regardless, clang does build correctly with BUILD_WITH_INSTALL_RPATH set to OFF and the correct and necessary  rpath exists at runtime.  I'm open to any insight you can offer and any changes you would suggest.
> Unfortunately I'm not sure I'm the right person to help with the Linux issue here. What I can say is that I did not see this issue on Darwin, and if you turn BUILD_WITH_INSTALL_RPATH off on Darwin the binaries get the wrong rpath in the build tree.
[[ https://sourceware.org/bugzilla/show_bug.cgi?id=16936 | Here's the problem ]].  The build-time linker doesn't respect `$ORIGIN` whether with `-rpath` or `--rpath-link`.  When testing on the command line in the build directory, by changing `$ORIGIN/../lib32` to  `./lib32` it links fine.


https://reviews.llvm.org/D25304





More information about the llvm-commits mailing list