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

    <tr>
        <th>Summary</th>
        <td>
            amdgpu-arch linking failure due to llibhsa dependency on libstdc++ from gcc >=12
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

    <tr>
      <th>Reporter</th>
      <td>
          ye-luo
      </td>
    </tr>
</table>

<pre>
    libhsa packaged in rocm 5.4.3 and 5.5.0 on machines with SLES15 SP4 depends on libstdc++ from gcc 12 https://github.com/RadeonOpenCompute/ROCm/issues/2084
It forced me to build llvm using gcc 12 which is is a too strict requirement. Otherwise, I got
```
/usr/bin/ld: /soft/compilers/rocm/rocm-5.5.0/lib/libhsa-runtime64.so.1.8.50500: undefined reference to `std::condition_variable::wait(std::unique_lock<std::mutex>&)@GLIBCXX_3.4.30'
collect2: error: ld returned 1 exit status
make[2]: *** [tools/clang/tools/amdgpu-arch/CMakeFiles/amdgpu-arch.dir/build.make:106: bin/amdgpu-arch] Error 1
```
Consider
```
find_package(hsa-runtime64 QUIET 1.2.0 HINTS ${CMAKE_INSTALL_PREFIX} PATHS /opt/rocm)
```
this is likely to be found and I cannot use DYNAMIC_HSA to workaround the issue.
Unless libhsa aggressively use new C++ features which is quite unlikely, it should not be built using gcc 12 but a much more conservative choice like gcc9.
On the llvm side, we need to test linking before using the library.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VFtv2zgT_TX0y8CCRF1sP_jBN301vrTp1inQfTIociSxpkiXl7j59wtKTrZdBAUIyySHc85czjDnZKcR16TcEkq_96FBWxFKSbmfseB7Y9cvOFfBzBojXtZKNr1jcGX8wjoUIDVYwwcokyLJgWkBZVImKRgNA-O91OjgJn0Pp4fDKSvh9LkAgVfUwkUbJRvnBSd0S-gWWmsG6DiHjELv_dWRfENoT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