Skip to content

Commit dd2ce3d

Browse files
authored
[LLVM] Add per-target runtime directory to rpath (llvm#199755)
Summary: This simply adds the LLVM_DEFAULT_TARGET_TRIPLE to the LLVM build's rpath if present. This keeps things hermetic for the library (offload) that depends on it. The reason this is required is because `llvm-gpu-loader` calls `DynamicLibrary` on the Offload runtime. However, in a shared library build the actual call is in libLLVMSupport.so, which does not have this RPath, so `dlopen` delegates to that which does not know how to find it. The only options to fix this are to use `dlopen` directly in the loader, or add the rpath to the LLVM binaries. I think this makes sense for LLVM, because the target-specific directory can contain LLVM related libraries.
1 parent b65a71d commit dd2ce3d

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

llvm/cmake/modules/AddLLVM.cmake

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2691,6 +2691,10 @@ function(llvm_setup_rpath name)
26912691
elseif(UNIX)
26922692
set(_build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}" ${extra_libdir})
26932693
set(_install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}")
2694+
if(LLVM_ENABLE_PER_TARGET_RUNTIME_DIR AND NOT APPLE)
2695+
list(APPEND _build_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}")
2696+
list(APPEND _install_rpath "\$ORIGIN/../lib${LLVM_LIBDIR_SUFFIX}/${LLVM_DEFAULT_TARGET_TRIPLE}")
2697+
endif()
26942698
if("${CMAKE_SYSTEM_NAME}" MATCHES "(FreeBSD|DragonFly)")
26952699
set_property(TARGET ${name} APPEND_STRING PROPERTY
26962700
LINK_FLAGS " -Wl,-z,origin ")

0 commit comments

Comments
 (0)