Skip to content

Commit e2aae92

Browse files
zboszorrpurdie
authored andcommitted
mesa: add support for RustiCL under PACKAGECONFIG "opencl"
Mesa now has two OpenCL implementations: Clover (older one) and RustiCL (newer one). Extend the "opencl" package config to include both implementations into the libopencl-mesa (-dev) packages. As the Clover implementation is in maintenance mode and is expected to be removed at Mesa 25.2, it doesn't make sense to split the packages or to provide two config options. Signed-off-by: Zoltán Böszörményi <[email protected]> [DB: merged "rusticl" and "clover" back to "opencl", reworked rust inheritance] Signed-off-by: Dmitry Baryshkov <[email protected]> Signed-off-by: Richard Purdie <[email protected]>
1 parent d3033ae commit e2aae92

File tree

2 files changed

+81
-5
lines changed

2 files changed

+81
-5
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
From b9cf34f39ca7e7546508ce2ab1f053edef5fc201 Mon Sep 17 00:00:00 2001
2+
From: Dmitry Baryshkov <[email protected]>
3+
Date: Wed, 26 Mar 2025 17:47:09 +0200
4+
Subject: [PATCH] rusticl: provide cross-compilation arguments to LLVM bindgen
5+
invocation
6+
7+
Correctly generating LLVM bindings requires several croos-compilation
8+
arguments. Provide them to rust.bindgen(). Karol Herbst on IRC suggested
9+
that a proper fix should be to fix meson's rust.bindgen() to support
10+
cross-compilation. Carry this patch until meson is fixed.
11+
12+
Upstream-Status: Inappropriate [OE-Specific]
13+
Signed-off-by: Dmitry Baryshkov <[email protected]>
14+
---
15+
meson_options.txt | 14 ++++++++++++++
16+
src/gallium/frontends/rusticl/meson.build | 8 ++++++++
17+
2 files changed, 22 insertions(+)
18+
19+
diff --git a/meson_options.txt b/meson_options.txt
20+
index 0147cafcb146..f73e83fded18 100644
21+
--- a/meson_options.txt
22+
+++ b/meson_options.txt
23+
@@ -796,3 +796,17 @@ option(
24+
value : false,
25+
description : 'Install the drivers internal shader compilers (if needed for cross builds).'
26+
)
27+
+
28+
+option(
29+
+ 'bindgen-includedir',
30+
+ type : 'string',
31+
+ value : '',
32+
+ description : 'system-wide include directory for cross-generating LLVM bindings'
33+
+ )
34+
+
35+
+option(
36+
+ 'bindgen-target',
37+
+ type : 'string',
38+
+ value : '',
39+
+ description : 'Clang target for cross-generating LLVM bindings'
40+
+ )
41+
diff --git a/src/gallium/frontends/rusticl/meson.build b/src/gallium/frontends/rusticl/meson.build
42+
index a5d1dcf3abb9..480c220b7f5f 100644
43+
--- a/src/gallium/frontends/rusticl/meson.build
44+
+++ b/src/gallium/frontends/rusticl/meson.build
45+
@@ -180,13 +180,21 @@ rusticl_opencl_gen = static_library(
46+
],
47+
)
48+
49+
+bindgen_c_args = []
50+
+bindgen_target = get_option('bindgen-target')
51+
+if bindgen_target != ''
52+
+ bindgen_c_args += [ '-target', bindgen_target ]
53+
+endif
54+
+
55+
rusticl_llvm_bindings_rs = rust.bindgen(
56+
input : 'rusticl_llvm_bindings.hpp',
57+
output : 'rusticl_llvm_bindings.rs',
58+
c_args : [
59+
rusticl_bindgen_c_args,
60+
pre_args,
61+
+ bindgen_c_args,
62+
],
63+
+ include_directories : get_option('bindgen-includedir'),
64+
dependencies : [
65+
dep_clang,
66+
dep_llvm,

meta/recipes-graphics/mesa/mesa.inc

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ PE = "2"
1717
SRC_URI = "https://archive.mesa3d.org/mesa-${PV}.tar.xz \
1818
file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \
1919
file://0001-freedreno-don-t-encode-build-path-into-binaries.patch\
20+
file://0001-rusticl-provide-cross-compilation-arguments-to-LLVM-.patch \
2021
"
2122

2223
SRC_URI[sha256sum] = "adf904d083b308df95898600ffed435f4b5c600d95fb6ec6d4c45638627fdc97"
@@ -45,7 +46,7 @@ PROVIDES = " \
4546
virtual/mesa \
4647
"
4748

48-
inherit meson pkgconfig python3native gettext features_check
49+
inherit meson pkgconfig python3native gettext features_check rust
4950

5051
BBCLASSEXTEND = "native nativesdk"
5152

@@ -84,6 +85,9 @@ PACKAGECONFIG = " \
8485
${@bb.utils.contains('DISTRO_FEATURES', 'vulkan', 'zink', '', d)} \
8586
"
8687

88+
# skip all Rust dependencies if we are not building OpenCL"
89+
INHIBIT_DEFAULT_RUST_DEPS = "${@bb.utils.contains('PACKAGECONFIG', 'opencl', '', '1', d)}"
90+
8791
PACKAGECONFIG:append:x86 = " libclc gallium-llvm"
8892
PACKAGECONFIG:append:x86-64 = " libclc gallium-llvm"
8993
PACKAGECONFIG:append:class-native = " libclc gallium-llvm r600"
@@ -139,9 +143,15 @@ PACKAGECONFIG[gles] = "-Dgles1=enabled -Dgles2=enabled, -Dgles1=disabled -Dgles2
139143
# "egl" requires "opengl"
140144
PACKAGECONFIG[egl] = "-Degl=enabled, -Degl=disabled"
141145

146+
BINDGEN_TARGET = "${TARGET_ARCH}-${TARGET_OS}${@['-gnu', ''][d.getVar('LIBCEXTENSION') != '']}"
147+
142148
# "opencl" also requires libclc and gallium-llvm to be present in PKGCONFIG!
143149
# Be sure to enable them both for the target and for the native build.
144-
PACKAGECONFIG[opencl] = "-Dgallium-opencl=icd,-Dgallium-opencl=disabled,"
150+
PACKAGECONFIG[opencl] = " \
151+
-Dgallium-opencl=icd -Dgallium-rusticl=true -Dbindgen-includedir=${STAGING_INCDIR} -Dbindgen-target=${BINDGEN_TARGET},\
152+
-Dgallium-opencl=disabled -Dgallium-rusticl=false, \
153+
bindgen-cli-native \
154+
"
145155

146156
PACKAGECONFIG[broadcom] = ""
147157
PACKAGECONFIG[etnaviv] = ",,python3-pycparser-native"
@@ -241,7 +251,7 @@ RDEPENDS:libgles3-mesa-dev += "libgles2-mesa-dev"
241251
RDEPENDS:libgles2-mesa += "libgles3-mesa"
242252
ALLOW_EMPTY:libgles3-mesa = "1"
243253

244-
RDEPENDS:libopencl-mesa += "${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'libclc spirv-tools', '', d)}"
254+
RDEPENDS:libopencl-mesa += "${@bb.utils.contains('PACKAGECONFIG', 'opencl', 'libclc spirv-tools spirv-llvm-translator', '', d)}"
245255

246256
PACKAGES =+ "libegl-mesa libegl-mesa-dev \
247257
libosmesa libosmesa-dev \
@@ -347,7 +357,7 @@ FILES:libgles1-mesa = "${libdir}/libGLESv1*.so.*"
347357
FILES:libgles2-mesa = "${libdir}/libGLESv2.so.*"
348358
FILES:libgl-mesa = "${libdir}/libGL.so.*"
349359
FILES:libglx-mesa = "${libdir}/libGLX*.so.*"
350-
FILES:libopencl-mesa = "${libdir}/libMesaOpenCL.so.* ${libdir}/gallium-pipe/*.so ${sysconfdir}/OpenCL/vendors/mesa.icd"
360+
FILES:libopencl-mesa = "${libdir}/lib*OpenCL.so.* ${libdir}/gallium-pipe/*.so ${sysconfdir}/OpenCL/vendors/*.icd"
351361
FILES:libglapi = "${libdir}/libglapi.so.*"
352362
FILES:libosmesa = "${libdir}/libOSMesa.so.*"
353363
FILES:libxatracker = "${libdir}/libxatracker.so.*"
@@ -361,7 +371,7 @@ FILES:libglapi-dev = "${libdir}/libglapi.*"
361371
FILES:libgles1-mesa-dev = "${libdir}/libGLESv1*.* ${includedir}/GLES ${libdir}/pkgconfig/glesv1*.pc"
362372
FILES:libgles2-mesa-dev = "${libdir}/libGLESv2.* ${includedir}/GLES2 ${libdir}/pkgconfig/glesv2.pc"
363373
FILES:libgles3-mesa-dev = "${includedir}/GLES3"
364-
FILES:libopencl-mesa-dev = "${libdir}/libMesaOpenCL.so"
374+
FILES:libopencl-mesa-dev = "${libdir}/lib*OpenCL.so"
365375
FILES:libosmesa-dev = "${libdir}/libOSMesa.* ${includedir}/GL/osmesa.h ${libdir}/pkgconfig/osmesa.pc"
366376
FILES:libxatracker-dev = "${libdir}/libxatracker.so ${libdir}/libxatracker.la \
367377
${includedir}/xa_tracker.h ${includedir}/xa_composite.h ${includedir}/xa_context.h \

0 commit comments

Comments
 (0)