[amdgpu-arch] Dynamically load the HSA runtime if not found during the build
authorJoseph Huber <jhuber6@vols.utk.edu>
Mon, 16 Jan 2023 16:56:24 +0000 (10:56 -0600)
committerJoseph Huber <jhuber6@vols.utk.edu>
Mon, 16 Jan 2023 19:13:45 +0000 (13:13 -0600)
commitf6ace23172e5930be0e7cc602f50e1e9c54d7a9a
tree312e1c62a1521ccbb6708269e49565428242426f
parenta8be1a3dd3b61fb8aef19b5c14737edc6211c5b7
[amdgpu-arch] Dynamically load the HSA runtime if not found during the build

We use the `amdgpu-arch` tool to query the installed GPUs at runtime.
One problem is that this tool is currently not build if the person
building the LLVM binary does not have the HSA runtime on their system.
This means that if someone built and distrubted an installation of LLVM
without HSA, then the user will not be able to use it even if they have
it on their system.

This patch makes us build this tool unconditionally and adds extra logic
to dynamically load HSA if it's present.

Reviewed By: JonChesterfield

Differential Revision: https://reviews.llvm.org/D141859
clang/tools/amdgpu-arch/AMDGPUArch.cpp
clang/tools/amdgpu-arch/CMakeLists.txt