-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[MLIR][ExecutionEngine] Introduce shared library #87067
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This commit introduces a shared library for the MLIR execution engine. This library is only built when `LLVM_BUILD_LLVM_DYLIB` is set. Having such a library allows downstream users to depend on the execution engine without giving up dynamic linkage. This is especially important for CPU runner style tools, as they link against large parts of MLIR and LLVM.
@llvm/pr-subscribers-mlir-execution-engine @llvm/pr-subscribers-mlir Author: Christian Ulmann (Dinistro) ChangesThis commit introduces a shared library for the MLIR execution engine. This library is only built when It is alternatively possible to modify the Full diff: https://github.com/llvm/llvm-project/pull/87067.diff 1 Files Affected:
diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index b7e448d5417ea9..a091944b9ee7df 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -97,6 +97,29 @@ add_mlir_library(MLIRExecutionEngine
MLIRTargetLLVMIRExport
)
+if(LLVM_BUILD_LLVM_DYLIB)
+ # Build a shared library for the execution engine. Some downstream projects
+ # use this library to build their own CPU runners while preserving dynamic
+ # linkage.
+ add_mlir_library(MLIRExecutionEngineShared
+ ExecutionEngine.cpp
+ SHARED
+
+ EXCLUDE_FROM_LIBMLIR
+
+ ADDITIONAL_HEADER_DIRS
+ ${MLIR_MAIN_INCLUDE_DIR}/mlir/ExecutionEngine
+
+ # Ensures that all necessary dependencies are resolved.
+ DEPENDS
+ MLIRExecutionEngine
+
+ LINK_LIBS PUBLIC
+ LLVM
+ MLIR
+ )
+endif()
+
get_property(dialect_libs GLOBAL PROPERTY MLIR_DIALECT_LIBS)
add_mlir_library(MLIRJitRunner
JitRunner.cpp
|
I recently started building my mlir wheels with
Sanity checking (numba-mlir) mlevental@maksims-mbp llvm-project % otool -L mlir/_mlir_libs/libmlir_async_runtime.dylib
mlir/_mlir_libs/libmlir_async_runtime.dylib:
@rpath/libmlir_async_runtime.dylib (compatibility version 0.0.0, current version 0.0.0)
@loader_path/libLLVM.dylib (compatibility version 1.0.0, current version 19.0.0)
/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 1300.36.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1319.0.0) so that's unfortunate. I'm guessing if I do a Went and checked the CMake and found this PR. Note sure how Btw futzing with the paths (eg by moving
|
Just confirming that indeed on linux we see the same linking:
|
I'm not sure I follow either: why do think there is a relationship between your issue and this PR?
In this case it links to a particular version of libLLVM (libLLVM-4731abf8.so) and find a path to it, what do you mean by "the same linking"? Were you hoping that there wouldn't be any mention of libLLVM here? |
It was a hypothesis based on likely causes ( Do you know how else it would be possible
The same linking behavior (the hash isn't important) i.e., it's not only on Mac |
If I have to guess, I would think it comes from:
inside |
So maybe this the correct answer but then I don't understand why eg some of the other libraries in this very same touched CMake don't inherit the link dep:
Note, the answer isn't
but
|
Oh duh it's probably because they don't use anything from |
Yes, that is probably it. In general, I would have thought that runtime support libraries like this should not have linked in llvm support at all, but that is an opinion I'm not going to fight for. There are a lot of problems with the things tied to ExecutionEngine and I take a live and let live attitude to it, while trying to not end up in too much of a support burden. If the build was set up differently, there should be a static only support library variant built with hidden visibility. And that should be used for such cases. But that would be pretty hard to layer properly without breaking support out as its own thing and doing structural build upgrades on it. |
This reverts commit 631ae59.
This reverts commit 631ae59.
Hi, this doesn't seem to build for me on windows using mingw. See #106859 for more details, thanks. |
This reverts commit 631ae59.
This commit introduces a shared library for the MLIR execution engine. This library is only built when
LLVM_BUILD_LLVM_DYLIB
is set. Having such a library allows downstream users to depend on the execution engine without giving up dynamic linkage. This is especially important for CPU runner-style tools, as they link against large parts of MLIR and LLVM.It is alternatively possible to modify the
MLIRExecutionEngine
target whenLLVM_BUILD_LLVM_DYLIB
is set, to avoid duplicated libraries.