commit:     b555818fd9fe97a56c2ab3d72d968cc1e557b99c
Author:     Janne Grunau <j <AT> jannau <DOT> net>
AuthorDate: Wed Apr 30 20:00:36 2025 +0000
Commit:     Matt Turner <mattst88 <AT> gentoo <DOT> org>
CommitDate: Fri May  2 01:43:21 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b555818f

dev-util/mesa_clc: Build panfrost tools / precomp-compiler

The panfrost gallium/vulkan drivers depend on the host tool
`panfrost_compile`. Add it to mesa_clc to support cross-compilation.

This change is more complex than necessary since the asahi
gallium/vulkan drivers have a similar dependency on `asahi_clc`.

Signed-off-by: Janne Grunau <j <AT> jannau.net>
Signed-off-by: Matt Turner <mattst88 <AT> gentoo.org>

 dev-util/mesa_clc/mesa_clc-9999.ebuild | 28 +++++++++++++++++++++++++++-
 profiles/arch/base/package.use.mask    |  4 ++++
 2 files changed, 31 insertions(+), 1 deletion(-)

diff --git a/dev-util/mesa_clc/mesa_clc-9999.ebuild 
b/dev-util/mesa_clc/mesa_clc-9999.ebuild
index 6c9117799892..9b3128f4a731 100644
--- a/dev-util/mesa_clc/mesa_clc-9999.ebuild
+++ b/dev-util/mesa_clc/mesa_clc-9999.ebuild
@@ -25,7 +25,12 @@ fi
 
 LICENSE="MIT"
 SLOT="0"
-IUSE="debug"
+
+VIDEO_CARDS="panfrost"
+for card in ${VIDEO_CARDS}; do
+       IUSE_VIDEO_CARDS+=" video_cards_${card}"
+done
+IUSE="${IUSE_VIDEO_CARDS} debug"
 
 RDEPEND="
        dev-util/spirv-tools
@@ -63,6 +68,13 @@ pkg_setup() {
 }
 
 src_configure() {
+       tools_enable video_cards_panfrost panfrost
+
+       tools_list() {
+               local tools="$(sort -u <<< "${1// /$'\n'}")"
+               echo "${tools//$'\n'/,}"
+       }
+
        PKG_CONFIG_PATH="$(get_llvm_prefix)/$(get_libdir)/pkgconfig"
 
        use debug && EMESON_BUILDTYPE=debug
@@ -72,6 +84,9 @@ src_configure() {
                -Dshared-llvm=enabled
                -Dmesa-clc=enabled
                -Dinstall-mesa-clc=true
+               -Dprecomp-compiler=enabled
+               -Dinstall-precomp-compiler=true
+               -Dtools=$(tools_list "${TOOLS[*]}")
 
                -Dgallium-drivers=''
                -Dvulkan-drivers=''
@@ -86,10 +101,21 @@ src_configure() {
 
                -Db_ndebug=$(usex debug false true)
        )
+
        meson_src_configure
 }
 
 src_install() {
        dobin "${BUILD_DIR}"/src/compiler/clc/mesa_clc
        dobin "${BUILD_DIR}"/src/compiler/spirv/vtn_bindgen2
+       use video_cards_panfrost && dobin 
"${BUILD_DIR}"/src/panfrost/clc/panfrost_compile
+}
+
+# $1 - VIDEO_CARDS flag (check skipped for "--")
+# other args - names of tools to enable
+tools_enable() {
+       if [[ $1 == -- ]] || use $1; then
+               shift
+               TOOLS+=("$@")
+       fi
 }

diff --git a/profiles/arch/base/package.use.mask 
b/profiles/arch/base/package.use.mask
index 0d2adf2fedce..a8fafd0cfe23 100644
--- a/profiles/arch/base/package.use.mask
+++ b/profiles/arch/base/package.use.mask
@@ -279,6 +279,10 @@ dev-util/diffoscope haskell
 # gui-libs/egl-wayland with nvidia-drivers is only usable on some arches.
 x11-wm/mutter video_cards_nvidia
 
+# dev-util/mesa_clc with video_cards_panfrost is required to cross-compile
+# dev-libs/mesa with video_cards_panfrost
+dev-util/mesa_clc -video_cards_panfrost
+
 # Michael Orlitzky <[email protected]> (2021-03-27)
 # The clozurecl and clozurecl64 flags are now arch-specific in maxima,
 # so we mask them both by default beginning with v5.44.0-r5 where

Reply via email to