As designed by Clang developers, clang should be able to automatically build HIP files with a simple call. But in Gentoo build fails: $ touch t.hip $ clang -c t.hip clang: error: cannot find ROCm device library; provide its path via '--rocm-path' or '--rocm-device-lib-path', or pass '-nogpulib' to build without ROCm device library This is a major headache for compiling many HIP/ROCm examples, which directly use Clang (e. g. https://github.com/amd/rocm-examples). Candidates for directories are defined in https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/AMDGPU.cpp#L427 and effectively resolve to /usr/lib/clang/17/amdgcn and /usr/amdgcn (where ROCM_PATH=/usr is Gentoo replacement for ROCM_PATH=/opt/rocm). This problem was discussed in https://bugzilla.redhat.com/show_bug.cgi?id=2209759 and they decided to store ROCm device libraries in /usr/lib/clang/17/amdgcn (see https://packages.fedoraproject.org/pkgs/rocm-device-libs/rocm-device-libs/fedora-39-updates.html) Quick test: # ln -s /usr/lib/amdgcn /usr/lib/clang/17/amdgcn Now "clang -c t.hip" works. I suggest to install /usr/lib/amdgcn/* to /usr/lib/clang/17/amdgcn (or `$(clang --print-resource-dir)/amdgcn` to be more precise). This will allow to remove a group of patches from existing ebuilds (search by '--rocm-path and --rocm-device-lib-path).
https://github.com/negril/gentoo/tree/sys-libs/libomp/fix_offload_install_location This is somewhat related
Please share your opinions. My suggestion is to move /usr/lib/amdgcn to /usr/lib/clang/17/amdgcn, and don't provide any symlinks, as they are not needed. I think the cleanest way to do it with all dev-libs/rocm-device-libs ebuilds (but it requires to check which other ebuilds have patches for setting --rocm-path and --rocm-device-lib-path to old path). The simpler solution is to provide a symlink in <=5.7.1, and in 6.0.0 remove the symlink. It looks that many 6.0.0 HIP/ROCm packages have hard dependency for 6.0.0 toolchain, so it should be safe. What do you think?
(In reply to Sv. Lockal from comment #2) > Please share your opinions. My suggestion is to move /usr/lib/amdgcn to > /usr/lib/clang/17/amdgcn, and don't provide any symlinks, as they are not > needed. > I agree to move /usr/lib/amdgcn to /usr/lib/clang/17/amdgcn. dev-libs/rocm-device-libs is essentially part of llvm-project that somehow does not upstreamed. > I think the cleanest way to do it with all dev-libs/rocm-device-libs ebuilds > (but it requires to check which other ebuilds have patches for setting > --rocm-path and --rocm-device-lib-path to old path). Yes, that's cleaner. However, that means simultaneous revision bump of rocm-device-libs and all revdeps, which it means some user may upgrade one package, not the other one, and cause regression, so we need to set a min revision dependency for hip. > > The simpler solution is to provide a symlink in <=5.7.1, and in 6.0.0 remove > the symlink. It looks that many 6.0.0 HIP/ROCm packages have hard dependency > for 6.0.0 toolchain, so it should be safe. So I prefer this.
The bug has been closed via the following commit(s): https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=05679cda7e4ebd139590f8918af8b66ae502cb96 commit 05679cda7e4ebd139590f8918af8b66ae502cb96 Author: Yiyang Wu <xgreenlandforwyy@gmail.com> AuthorDate: 2024-05-02 15:12:19 +0000 Commit: Sam James <sam@gentoo.org> CommitDate: 2024-06-26 09:18:54 +0000 dev-libs/rocm-device-libs: symlink bitcode to clang lib path This is the default search path for clang, so we don't need to specify --rocm-device-lib-path or --hip-device-lib-path to other packages. Closes: https://bugs.gentoo.org/922227 Signed-off-by: Yiyang Wu <xgreenlandforwyy@gmail.com> Signed-off-by: Sam James <sam@gentoo.org> dev-libs/rocm-device-libs/rocm-device-libs-5.7.1.ebuild | 9 ++++++++- dev-libs/rocm-device-libs/rocm-device-libs-6.0.0.ebuild | 7 +++++++ dev-libs/rocm-device-libs/rocm-device-libs-6.1.1.ebuild | 7 +++++++ 3 files changed, 22 insertions(+), 1 deletion(-)