From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 6D4AD158074 for ; Sat, 05 Jul 2025 07:16:24 +0000 (UTC) Received: from lists.gentoo.org (bobolink.gentoo.org [140.211.166.189]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) (Authenticated sender: relay-lists.gentoo.org@gentoo.org) by smtp.gentoo.org (Postfix) with ESMTPSA id 5814A3420F0 for ; Sat, 05 Jul 2025 07:16:24 +0000 (UTC) Received: from bobolink.gentoo.org (localhost [127.0.0.1]) by bobolink.gentoo.org (Postfix) with ESMTP id C1B2F11055B; Sat, 05 Jul 2025 07:16:14 +0000 (UTC) Received: from smtp.gentoo.org (woodpecker.gentoo.org [140.211.166.183]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by bobolink.gentoo.org (Postfix) with ESMTPS id BC2C711055B for ; Sat, 05 Jul 2025 07:16:14 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange x25519) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 75E8A342156 for ; Sat, 05 Jul 2025 07:16:14 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 20B872DE2 for ; Sat, 05 Jul 2025 07:16:13 +0000 (UTC) From: "Sam James" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Sam James" Message-ID: <1751699653.2acae82eccef3486ca64d4dd2121be8fd92518ea.sam@gentoo> Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/ X-VCS-Repository: repo/gentoo X-VCS-Files: eclass/rocm.eclass X-VCS-Directories: eclass/ X-VCS-Committer: sam X-VCS-Committer-Name: Sam James X-VCS-Revision: 2acae82eccef3486ca64d4dd2121be8fd92518ea X-VCS-Branch: master Date: Sat, 05 Jul 2025 07:16:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 0a67c0c9-4b2d-48d9-bbf3-46fa675322a9 X-Archives-Hash: 616dbd473fa0ca7aec11c2f66c790486 commit: 2acae82eccef3486ca64d4dd2121be8fd92518ea Author: Sv. Lockal gmail com> AuthorDate: Sun Jun 22 14:54:15 2025 +0000 Commit: Sam James gentoo org> CommitDate: Sat Jul 5 07:14:13 2025 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=2acae82e 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 gmail.com> Part-of: https://github.com/gentoo/gentoo/pull/42691 Signed-off-by: Sam James gentoo.org> eclass/rocm.eclass | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) 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 }