Skip to content
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

[mlir] -DLLVM_DISTRIBUTION_COMPONENTS=mlir_c_runner_utils seems to unnecessarily require installing MLIRSparseTensorRuntime #120902

Open
mgorny opened this issue Dec 22, 2024 · 1 comment
Labels
cmake Build system in general and CMake in particular mlir

Comments

@mgorny
Copy link
Member

mgorny commented Dec 22, 2024

I'm finally working on packaging MLIR for Gentoo. The current main seems to work really great, for standalone builds and dylib installation both. However, there's one thing that seems wrong.

I'm using -DLLVM_DISTRIBUTION_COMPONENTS to skip installing the static libraries. However, if I include mlir_c_runner_utils shared library in them, CMake fails:

-- Configuring done (5.1s)
CMake Error: install(EXPORT "MLIRTargets" ...) includes target "mlir_c_runner_utils" which requires target "MLIRSparseTensorEnums" that is not in any export set.
CMake Error: install(EXPORT "MLIRTargets" ...) includes target "mlir_c_runner_utils" which requires target "MLIRSparseTensorRuntime" that is not in any export set.
-- Generating done (3.4s)
CMake Generate step failed.  Build files cannot be regenerated correctly.

Please correct me if I'm wrong, but if I understand correctly, MLIRSparseTensorRuntime is only used as an implementation detail of mlir_c_runner_utils and isn't used otherwise. So I don't think it should be necessary to install the static library at all, and something is going wrong within the build system dependencies.

My current (work-in-progress) CMake invocation is the following:

cmake -C /tmp/portage/llvm-core/mlir-20.0.0_pre20241221/work/mlir_build/gentoo_common_config.cmake -G Ninja -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_INSTALL_PREFIX=/usr/lib/llvm/20 -DLLVM_ROOT=/usr/lib/llvm/20 -DBUILD_SHARED_LIBS=OFF -DLLVM_BUILD_LLVM_DYLIB=ON -DMLIR_BUILD_MLIR_C_DYLIB=OFF -DMLIR_LINK_MLIR_DYLIB=ON -DMLIR_INCLUDE_TESTS=no -DLLVM_DISTRIBUTION_COMPONENTS=mlir-cmake-exports;mlir-headers;MLIR;mlir_arm_runner_utils;mlir_arm_sme_abi_stubs;mlir_async_runtime;mlir_c_runner_utils;mlir_float16_utils;mlir_runner_utils;mlir-cpu-runner;mlir-linalg-ods-yaml-gen;mlir-lsp-server;mlir-opt;mlir-pdll;mlir-pdll-lsp-server;mlir-query;mlir-reduce;mlir-rewrite;mlir-tblgen;mlir-translate;tblgen-lsp-server;tblgen-to-irdl; -DLLVM_BUILD_UTILS=ON -DPython3_EXECUTABLE=/usr/bin/python3.13 -DLLVM_BUILD_TOOLS=ON -DMLIR_ENABLE_CUDA_RUNNER=OFF -DMLIR_ENABLE_ROCM_RUNNER=OFF -DMLIR_ENABLE_SYCL_RUNNER=OFF -DMLIR_ENABLE_SPIRV_CPU_RUNNER=OFF -DMLIR_ENABLE_VULKAN_RUNNER=OFF -DMLIR_ENABLE_BINDINGS_PYTHON=OFF -DMLIR_INSTALL_AGGREGATE_OBJECTS=OFF -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_TOOLCHAIN_FILE=/tmp/portage/llvm-core/mlir-20.0.0_pre20241221/work/mlir_build/gentoo_toolchain.cmake /tmp/portage/llvm-core/mlir-20.0.0_pre20241221/work/mlir
@github-actions github-actions bot added the mlir label Dec 22, 2024
@mgorny
Copy link
Member Author

mgorny commented Dec 22, 2024

I think the problem is that these linked libraries are specified as PUBLIC, which implies that anything linking to them will also implicitly link to the static libraries. I think PUBLIC is rather an uncommon choice for shared libraries, and PRIVATE should be used instead, i.e.:

diff --git a/mlir/lib/ExecutionEngine/CMakeLists.txt b/mlir/lib/ExecutionEngine/CMakeLists.txt
index cf44a02cf5cb..bebe44b8a0d2 100644
--- a/mlir/lib/ExecutionEngine/CMakeLists.txt
+++ b/mlir/lib/ExecutionEngine/CMakeLists.txt
@@ -169,7 +169,7 @@ if(LLVM_ENABLE_PIC)
 
     EXCLUDE_FROM_LIBMLIR
 
-    LINK_LIBS PUBLIC
+    LINK_LIBS PRIVATE
     mlir_float16_utils
     MLIRSparseTensorEnums
     MLIRSparseTensorRuntime

And this indeed resolves the problem for me. This is probably the case for some of the other shared libraries there as well.

@EugeneZelenko EugeneZelenko added the cmake Build system in general and CMake in particular label Dec 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cmake Build system in general and CMake in particular mlir
Projects
None yet
Development

No branches or pull requests

2 participants