Skip to content

Commit

Permalink
Configure rpath in llvm so it can find runtime libraries. (#70)
Browse files Browse the repository at this point in the history
Progress on #69 (the amdgpu-arch tool was failing).
  • Loading branch information
stellaraccident authored Feb 6, 2025
1 parent 3a6784b commit 7ba9eba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions compiler/pre_hook_amd-llvm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,19 @@ set(LLVM_EXTERNAL_PROJECTS "amddevice-libs" CACHE STRING "Enable extra projects"
set(CLANG_RESOURCE_DIR "../lib/clang/${LLVM_VERSION_MAJOR}" CACHE STRING "Resource dir" FORCE)
set(ROCM_DEVICE_LIBS_BITCODE_INSTALL_LOC_NEW "lib/clang/${LLVM_VERSION_MAJOR}/amdgcn" CACHE STRING "New devicelibs loc" FORCE)
set(ROCM_DEVICE_LIBS_BITCODE_INSTALL_LOC_OLD "amdgcn" CACHE STRING "Old devicelibs loc" FORCE)

# Disable default RPath handling on Linux and enforce our own project-wide:
# * Executables and libraries can always search their adjacent lib directory
# (which may be the same as the origin for libraries).
# * Files in lib/llvm/(bin|lib) should search the project-wide lib/ directory
# so that dlopen of runtime files from the compiler can work.
# * One might think that only EXEs need to be build this way, but the dlopen
# utilities can be compiled into libLLVM, in which case, that RUNPATH is
# primary.
if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
set(CMAKE_SKIP_BUILD_RPATH ON)
set(CMAKE_SKIP_INSTALL_RPATH ON)
# Single quotes in the flags are needed to properly escape the $ORIGIN.
string(APPEND CMAKE_EXE_LINKER_FLAGS " '-Wl,--enable-new-dtags,--rpath,$ORIGIN/../lib:$ORIGIN/../../../lib'")
string(APPEND CMAKE_SHARED_LINKER_FLAGS " '-Wl,--enable-new-dtags,--rpath,$ORIGIN/../lib:$ORIGIN/../../../lib'")
endif()

0 comments on commit 7ba9eba

Please sign in to comment.