From 01d683b6a91a33bda5b2dcf82575be0c1e5449e8 Mon Sep 17 00:00:00 2001 From: Maksim Levental Date: Fri, 27 Dec 2024 00:04:12 -0600 Subject: [PATCH] [mlir] Don't set RPATH for libMLIR By default [`llvm_add_library`](https://github.com/llvm/llvm-project/blob/94837c8b5761d20310947be5d2e1e568f67e8c0c/llvm/cmake/modules/AddLLVM.cmake#L681) calls `llvm_setup_rpath`, which has the strange effect that even libs inside of `install/lib` have non-empty self-referential `RPATH`s; e.g., on Mac ``` $ llvm-install/lib/libMLIR.dylib | grep RPATH -A4 cmd LC_RPATH cmdsize 32 path @loader_path/../lib (offset 12) ``` which is bad/awkward if you want to move `libMLIR` (like into a wheel...). Now possibly we want to do this for all shlibs but I think we definitely want to do this for `libMLIR` because it should have no runtime lib deps (at least until [this](https://github.com/llvm/llvm-project/issues/108253) lands). --- mlir/tools/mlir-shlib/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/mlir/tools/mlir-shlib/CMakeLists.txt b/mlir/tools/mlir-shlib/CMakeLists.txt index a33c70c5807be..293409a51f27e 100644 --- a/mlir/tools/mlir-shlib/CMakeLists.txt +++ b/mlir/tools/mlir-shlib/CMakeLists.txt @@ -35,6 +35,7 @@ if(LLVM_BUILD_LLVM_DYLIB) MLIR SHARED EXCLUDE_FROM_LIBMLIR + NO_INSTALL_RPATH ${INSTALL_WITH_TOOLCHAIN} mlir-shlib.cpp ${_OBJECTS}