diff options
| author | Sv. Lockal <lockalsash@gmail.com> | 2025-06-22 14:54:15 +0000 |
|---|---|---|
| committer | Sam James <sam@gentoo.org> | 2025-07-05 08:14:13 +0100 |
| commit | 2acae82eccef3486ca64d4dd2121be8fd92518ea (patch) | |
| tree | bfdd4c152c373e81033591f03c023bc33a6072d9 | |
| parent | 74d25eedd9c327fe91048b06ad81b86eb14d9cb7 (diff) | |
| download | gentoo-2acae82eccef3486ca64d4dd2121be8fd92518ea.tar.gz gentoo-2acae82eccef3486ca64d4dd2121be8fd92518ea.tar.bz2 gentoo-2acae82eccef3486ca64d4dd2121be8fd92518ea.zip | |
rocm.eclass: add rocm_use_clang and strip flags in a better way
In recent releases some ROCm packages switched from hipcc to clang++
(as hipcc is now mostly a simple wrapper that calls clang++).
New rocm_use_clang function allows to switch compiler to HIP-compatible clang.
Both hipcc and clang reject some flags when compiling *.hip files;
to clean incompatible CXXFLAGS new test-flags-HIPCXX function is used.
Bug: https://bugs.gentoo.org/957893
Signed-off-by: Sv. Lockal <lockalsash@gmail.com>
Part-of: https://github.com/gentoo/gentoo/pull/42691
Signed-off-by: Sam James <sam@gentoo.org>
| -rw-r--r-- | eclass/rocm.eclass | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/eclass/rocm.eclass b/eclass/rocm.eclass index 65726a0bc621..a7601bf43f2d 100644 --- a/eclass/rocm.eclass +++ b/eclass/rocm.eclass @@ -246,6 +246,18 @@ check_amdgpu() { fi +# @FUNCTION: _rocm_strip_unsupported_flags +# @INTERNAL +# @DESCRIPTION: +# Clean flags that are not compatible with 'amdgcn-amd-amdhsa' target. +_rocm_strip_unsupported_flags() { + strip-unsupported-flags + + # FLAGS like -mtls-dialect=* pass test-flags-CXX check, but are not supported + # bug #957893 + export CXXFLAGS=$(test-flags-HIPCXX ${CXXFLAGS}) +} + # @FUNCTION: rocm_use_hipcc # @USAGE: rocm_use_hipcc # @DESCRIPTION: @@ -267,5 +279,20 @@ rocm_use_hipcc() { # Export updated CC and CXX. Note that CC is needed even if no C code used, # as CMake checks that C compiler can compile a simple test program. export CC=hipcc CXX=hipcc - strip-unsupported-flags + _rocm_strip_unsupported_flags +} + +# @FUNCTION: rocm_use_clang +# @USAGE: rocm_use_clang +# @DESCRIPTION: +# switch active C and C++ compilers to clang/clang++, clean unsupported flags +rocm_use_clang() { + local hipclangpath + if ! hipclangpath=$(hipconfig --hipclangpath); then + die "Error: \"hipconfig --hipclangpath\" failed" + fi + + export CC="${hipclangpath}/${CHOST}-clang" + export CXX="${hipclangpath}/${CHOST}-clang++" + _rocm_strip_unsupported_flags } |
