[llvm] [offload] Give libLLVMOffloadKernel a working rpath in a shared-library build (PR #218629)
Larry Meadows via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 25 01:18:00 PDT 2026
https://github.com/lfmeadow created https://github.com/llvm/llvm-project/pull/218629
libLLVMOffloadKernel links against libLLVMOffload and finds it through an
`$ORIGIN` rpath, which resolves only if the two land in the same directory.
`add_llvm_library` puts the kernel library in LLVM's `lib` while libLLVMOffload
is in `lib/<triple>`, so every test that loads it fails at startup with
libLLVMOffload.so: cannot open shared object file: No such file or directory
Set `LIBRARY_OUTPUT_DIRECTORY` the way `RUNTIME_OUTPUT_DIRECTORY` already is.
## Testing
Based on `main` at 65d6b72e5e12. CMake only, no test changes. With shared
libraries and `LLVM_ENABLE_RUNTIMES=...;openmp;offload`, the kernel library now
lands beside libLLVMOffload and loads.
>From 8b74fdeed62c8ed39686244f5a239ffaab8f081e Mon Sep 17 00:00:00 2001
From: Larry Meadows <Lawrence.Meadows at amd.com>
Date: Fri, 21 Aug 2026 22:16:32 -0500
Subject: [PATCH] [offload] Give libLLVMOffloadKernel a working rpath in a
shared-library build
libLLVMOffloadKernel links against libLLVMOffload and finds it through an
$ORIGIN rpath, which resolves only if the two land in the same directory. Set
LIBRARY_OUTPUT_DIRECTORY the way RUNTIME_OUTPUT_DIRECTORY already is.
Co-authored-by: Cursor <cursoragent at cursor.com>
---
offload/languages/kernel/CMakeLists.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/offload/languages/kernel/CMakeLists.txt b/offload/languages/kernel/CMakeLists.txt
index ff0bb81c7f017..e2fef39a1b041 100644
--- a/offload/languages/kernel/CMakeLists.txt
+++ b/offload/languages/kernel/CMakeLists.txt
@@ -66,6 +66,7 @@ target_compile_definitions(LLVMOffloadKernel PRIVATE
set_target_properties(LLVMOffloadKernel PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${LLVM_LIBRARY_OUTPUT_INTDIR}/${OFFLOAD_TARGET_SUBDIR}"
+ LIBRARY_OUTPUT_DIRECTORY "${LLVM_LIBRARY_OUTPUT_INTDIR}/${OFFLOAD_TARGET_SUBDIR}"
POSITION_INDEPENDENT_CODE ON
INSTALL_RPATH "$ORIGIN"
BUILD_RPATH "$ORIGIN:${CMAKE_CURRENT_BINARY_DIR}/..")
More information about the llvm-commits
mailing list