From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 68127159C9B for ; Sat, 3 Aug 2024 21:10:11 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 3BD2DE2ACA; Sat, 3 Aug 2024 21:10:06 +0000 (UTC) Received: from mail-lj1-x230.google.com (mail-lj1-x230.google.com [IPv6:2a00:1450:4864:20::230]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id E2541E29C0 for ; Sat, 3 Aug 2024 21:10:05 +0000 (UTC) Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2f149845d81so61670901fa.0 for ; Sat, 03 Aug 2024 14:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722719404; x=1723324204; darn=lists.gentoo.org; h=to:subject:message-id:date:from:mime-version:from:to:cc:subject :date:message-id:reply-to; bh=gai8l+ifPIYIe53KRoLTL0guYGvRQzGE4KTGkrcGLe0=; b=Gw8Vpi9ZzJ/36UqWScyEt4uykTJyq1Djl7v0jFGBTkB7XtC+3RZRIE/sw4ldh12wS6 AONG4Y/2tQ8LhzwHGpuTvMXVcag4Bw20t3TUnZ0WACYuBgwjVMPlxnnh9y92RE/J2yzF zF8Yb1MlAnswqY0+bSlCVqDCnF14jMC0bPeppiZH4WdBVNBrRHU98sYwaZm2Gl+KeuSB 8gcj0d0jCLoRV7jh7dXj51OAxmNDle5u1mMJcmqDA8aBpHfT19qiDEH17CKu0IZVmgGk 0IxgN8V4Wexc8fA7E6P6yd7qAWP5ySafntXCuTXmnxMzkmtlmb7veh3z/S7TL7jbTUMS SVzw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722719404; x=1723324204; h=to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=gai8l+ifPIYIe53KRoLTL0guYGvRQzGE4KTGkrcGLe0=; b=GN9PU8ig4G3kbUjCMzyQC4j/ZFHkqPblq8vxL+YvyKb4qyDuMNRI4BzRRuyhpOi5ax YreH9I0/duw8herBYBeR7CDoSYVsKGkZ8+LlHKeTOFnWDZQpM2scA9FyP0vrn3vc4oyE p7uMNUvkp4zwWJhBHjRB1WCWpjW65lRULSxPLbQtPLZpZamykcl+U7bkt+TLcgWqHA/G OIxp9xzhkbwwHkGzrnYFgCffrOb01ZSOYUqe+nRmtgtzs40l+zKNbh20gey52iB5w3B/ iYqPRgOLFkqOBw9GXwNJ1NR9QKq19RLccLoVGtDpPQ4omilody5IbLKDDVUIbSxg/Hss PJ1w== X-Gm-Message-State: AOJu0YzGqLCK56gPdeMHJg992EZiDynbBhdzU+AetZpRrMAqBOICUfxb LiNuZm2fncNqd5H6O0fKz/rjv5dHEvfejyWfwCkgg0GAq6fGT0GrYrk3XJAr55ZDR+QRIfr0ncd yxTsgFAbNVNekeDEvBxR2RCLhaUtz4/4jbsU= X-Google-Smtp-Source: AGHT+IGDLWEoHMOmRZ5FoEbLN9oErh9n+DJ9ptV//2GE2RkFonqnbVexNEtXfyS8cWp/I5XBm7uLR3h6DT8gfiAedEA= X-Received: by 2002:a2e:320e:0:b0:2ef:206c:37c4 with SMTP id 38308e7fff4ca-2f15ab0bf8fmr51497441fa.33.1722719403230; Sat, 03 Aug 2024 14:10:03 -0700 (PDT) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-dev@lists.gentoo.org Reply-to: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 From: "Sv. Lockal" Date: Sun, 4 Aug 2024 05:09:52 +0800 Message-ID: Subject: [gentoo-dev] [PATCH] rocm.eclass: add rocm_use_hipcc function and update example accordingly To: gentoo-dev@lists.gentoo.org Content-Type: text/plain; charset="UTF-8" X-Archives-Salt: 3a7483fb-9d27-4dc2-9475-ae3687e36e81 X-Archives-Hash: c88141908bfacf1650e5d334eebe1355 This adds a new function rocm_use_hipcc in rocm.eclass to be used in every src_configure, where the compiler is switched to hipcc (a. k. a. clang with extra flags). Github pull request: https://github.com/gentoo/gentoo/pull/37639 Bug: https://bugs.gentoo.org/936099 Signed-off-by: Sv. Lockal --- eclass/rocm.eclass | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/eclass/rocm.eclass b/eclass/rocm.eclass index 7039455dec6b5..44ddf4fd09a87 100644 --- a/eclass/rocm.eclass +++ b/eclass/rocm.eclass @@ -15,9 +15,13 @@ # edit USE flag to control which GPU architecture to compile. Using # ${ROCM_USEDEP} can ensure coherence among dependencies. Ebuilds can call the # function get_amdgpu_flag to translate activated target to GPU compile flags, -# passing it to configuration. Function check_amdgpu can help ebuild ensure +# passing it to configuration. Function rocm_use_hipcc switches active compiler +# to hipcc and cleans incompatible flags (useful for users with gcc-only flags +# in /etc/portage/make.conf). Function check_amdgpu can help ebuild ensure # read and write permissions to GPU device in src_test phase, throwing friendly -# error message if unavailable. +# error message if unavailable. However src_configure in general should not +# access any GPU devices. If it does, it usually means that CMakeLists.txt +# ignores AMDGPU_TARGETS in favor of autodetected GPU, which is not desired. # # @EXAMPLE: # Example ebuild for ROCm library in https://github.com/ROCmSoftwarePlatform @@ -39,14 +43,12 @@ # " # # src_configure() { -# # avoid sandbox violation -# addpredict /dev/kfd -# addpredict /dev/dri/ +# rocm_use_hipcc # local mycmakeargs=( # -DAMDGPU_TARGETS="$(get_amdgpu_flags)" # -DBUILD_CLIENTS_TESTS=$(usex test ON OFF) # ) -# CXX=hipcc cmake_src_configure +# cmake_src_configure # } # # src_test() { @@ -90,6 +92,8 @@ esac if [[ ! ${_ROCM_ECLASS} ]]; then _ROCM_ECLASS=1 +inherit flag-o-matic + # @ECLASS_VARIABLE: ROCM_VERSION # @REQUIRED # @PRE_INHERIT @@ -231,3 +235,12 @@ check_amdgpu() { } fi + +# @FUNCTION: rocm_use_hipcc +# @USAGE: rocm_use_hipcc +# @DESCRIPTION: +# switch active C and C++ compilers to hipcc and clean unsupported flags. +rocm_use_hipcc() { + export CC=hipcc CXX=hipcc + strip-unsupported-flags +}