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

    <tr>
        <th>Summary</th>
        <td>
            [LLVM] `tools/llvm-gpu-loader` introduces silent automagic dependencies on HSA and CUDA runtimes
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            cmake,
            llvm
      </td>
    </tr>

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

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

<pre>
    #132096 introduced new `llvm-gpu-loader` tool that can link to HSA and CUDA runtimes.

Both checks were added deep down the source tree, in `tools/llvm-gpu-loader/CMakeLists.txt`:

https://github.com/llvm/llvm-project/blob/bcedb368e317332d99dbdde617ebc35140b10de3/llvm/tools/llvm-gpu-loader/CMakeLists.txt#L27

https://github.com/llvm/llvm-project/blob/bcedb368e317332d99dbdde617ebc35140b10de3/llvm/tools/llvm-gpu-loader/CMakeLists.txt#L38

Neither of them features a proper `option()` to control the dependency, and on top of that, they are both marked `QUIET`, so it's **really easy** to overlook this (as we did), and end up building packages that randomly depend on either of the runtimes, or miss the specific function.

Please:

1. Do not use `QUIET` for package checks that control features included in installed tools.
2. Do not add dependency checks deep down the source tree — LLVM has a bunch of standard locations such as top `CMakeLists.txt` and `cmake/config-ix.cmake`, where people actually look for changes like these. We don't really have the resources to monitor all 528 `CMakeLists.txt` files in LLVM alone.
3. Add `option()`s to control enabling the specific dependencies, so that we can cleanly control whether they are enabled or not, rather than being automatically linked if the build system incidentally happens to have them installed.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzMlc-O2zYQxp-GvgwiUKQtSwcdnN0YLbApWrRpzyNybDGmSIGk1vHbF5S0zibdFu2tJ8OEMH--7zczGKM5O6KW7d4zIT73U0ehYkKw3eMGp9T70A5nH9xt03l9a5mQpRS8qcC4FLyeFGlwdAVWcWufh3fncXpnPWoKrO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