<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/120902>120902</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            [mlir] `-DLLVM_DISTRIBUTION_COMPONENTS=mlir_c_runner_utils` seems to unnecessarily require installing `MLIRSparseTensorRuntime`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            mlir
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          mgorny
      </td>
    </tr>
</table>

<pre>
    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
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMVs9z6jgS_mvERWWXEUlIDhz4YfK8jxgKzNv3Ti7ZbmxNZMkjyWH9329JNiHsZDNzmMNUcZC7W59are9rmmrNSgEwQ_cLdL8a0dZUUs3qUirRjTJZdLMIkWmNT0xQzjt8luqViRJLgRuav9LSfrxsoj0-SYWfQRgpfZxUgPNWKRAG15QJrAFqjY10-7ECh1UqoAaRpduqDRUF5VIAzlrGC42pKHDRcZZhJrShnFPDpMCZNJWPv8kzvIGyu00FChCZamw3m8pmZCpqhkPPSorSR8EcBfP-Lq22Iegh8FabzY-XdBUdkn20OCbRNk6X25fdNg7j5IAeApuxfmXNJYM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