Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

193.10. mesa-opencl-26.2.3

Mesa's OpenCL implementation, rusticl: the OpenCL ICD for the GPUs Mesa drives and for llvmpipe on the processor

Version 26.2.3, release 1
Shelf gpu — The GPU stack: Mesa, DRM, GL and Vulkan loaders and headers, shader compilers, VA-API, OpenCL
Phase 42_graphics (Graphics Stack), 107 of 189 in build order
Licence MIT
Homepage https://mesa3d.org/
Build time 30.7 SBU
Installed size 43.1 MiB in 9 files
Recipe ports/core/gpu/mesa-opencl/kpkgbuild

About

mesa-opencl is rusticl, Mesa’s OpenCL implementation, as an OpenCL installable client driver: libRusticlOpenCL.so.1 and its /etc/OpenCL/vendors/rusticl.icd, which ocl-icd’s loader reads to offer rusticl’s devices to every OpenCL program (clinfo, darktable, ffmpeg’s OpenCL filters). It is a second build of mesa’s source (see A second build of the same source): mesa is built without OpenCL, because rusticl links libclang-cpp and reads libclc’s kernels at run time, and clang is more than a gigabyte the installation medium does not carry for the few programs that compute on a GPU. Install it by name with sudo kdos update install mesa-opencl; it brings clang, libclc and spirv-llvm-translator with it.

Sources

Dependencies

Depends on: mesa, llvm, clang, libclc, spirv-llvm-translator, spirv-tools, ocl-icd, python3-mako, python3-yaml, elfutils, bison, flex, libdrm, glslang, expat, rust, bindgen, cbindgen, zlib, zstd, eudev, libdisplay-info.

Required by: no port names it.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/42_graphics/phase.env && kpkg install mesa-opencl'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/gpu/mesa-opencl.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/gpu/mesa-opencl
echo '1628058a8d2c0615975de5a15ab7bbb9638c50000b5bed9456ff423ea034a81f  mesa-26.2.3.tar.xz' | sha256sum -c -
echo 'de3145af08024dea9fa9914f381a17b8fc6034dfb00f3a84013f7ff43f29ed4c  paste-1.0.14.tar.gz' | sha256sum -c -
echo '5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77  proc-macro2-1.0.86.tar.gz' | sha256sum -c -
echo '291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef  quote-1.0.35.tar.gz' | sha256sum -c -
echo '357703d41365b4b27c590e3ed91eabb1b663f07c4c084095e60cbed4362dff0d  rustc-hash-2.1.1.tar.gz' | sha256sum -c -
echo '25aa4ce346d03a6dcd68dd8b4010bcb74e54e62c90c573f394c46eae99aba32d  syn-2.0.87.tar.gz' | sha256sum -c -
echo '3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b  unicode-ident-1.0.12.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/mesa-opencl
SRC=$SRC_ROOT/mesa-opencl-26.2.3
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf mesa-26.2.3.tar.xz -C "$SRC" --strip-components=1
tar --no-same-permissions --warning=no-unknown-keyword -xf syn-2.0.87.tar.gz -C "$SRC_ROOT"
tar --no-same-permissions --warning=no-unknown-keyword -xf unicode-ident-1.0.12.tar.gz -C "$SRC_ROOT"
tar --no-same-permissions --warning=no-unknown-keyword -xf quote-1.0.35.tar.gz -C "$SRC_ROOT"
tar --no-same-permissions --warning=no-unknown-keyword -xf proc-macro2-1.0.86.tar.gz -C "$SRC_ROOT"
tar --no-same-permissions --warning=no-unknown-keyword -xf paste-1.0.14.tar.gz -C "$SRC_ROOT"
tar --no-same-permissions --warning=no-unknown-keyword -xf rustc-hash-2.1.1.tar.gz -C "$SRC_ROOT"

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers group and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

ln -sf "$SRC_ROOT/syn-2.0.87" subprojects/syn-2.0.87
cp -r subprojects/packagefiles/syn-2-rs/* subprojects/syn-2.0.87/

ln -sf "$SRC_ROOT/unicode-ident-1.0.12" subprojects/unicode-ident-1.0.12
cp -r subprojects/packagefiles/unicode-ident-1-rs/* subprojects/unicode-ident-1.0.12/

ln -sf "$SRC_ROOT/quote-1.0.35" subprojects/quote-1.0.35
cp -r subprojects/packagefiles/quote-1-rs/* subprojects/quote-1.0.35/

ln -sf "$SRC_ROOT/proc-macro2-1.0.86" subprojects/proc-macro2-1.0.86
cp -r subprojects/packagefiles/proc-macro2-1-rs/* subprojects/proc-macro2-1.0.86/

ln -sf "$SRC_ROOT/paste-1.0.14" subprojects/paste-1.0.14
cp -r subprojects/packagefiles/paste-1-rs/* subprojects/paste-1.0.14/

ln -sf "$SRC_ROOT/rustc-hash-2.1.1" subprojects/rustc-hash-2.1.1
cp -r subprojects/packagefiles/rustc-hash-2-rs/* subprojects/rustc-hash-2.1.1/

export LIBCLANG_PATH=/usr/lib/
export LIBCLANG_STATIC_PATH=/usr/lib/
export RUST_BACKTRACE=1
export RUSTC="rustc -C target-feature=-crt-static"

meson setup build \
	--prefix=/usr --libdir=lib --sysconfdir=/etc \
	--buildtype=release \
	-D b_ndebug=true \
	-D opengl=false \
	-D egl=disabled \
	-D gbm=disabled \
	-D gles1=disabled \
	-D gles2=disabled \
	-D glx=disabled \
	-D glvnd=disabled \
	-D platforms= \
	-D vulkan-drivers= \
	-D vulkan-layers= \
	-D gallium-va=disabled \
	-D gallium-drivers=iris,radeonsi,nouveau,llvmpipe,zink \
	-D gallium-rusticl=true \
	-D gallium-rusticl-enable-drivers=radeonsi \
	-D llvm=enabled \
	-D shared-llvm=enabled \
	-D xmlconfig=enabled \
	-D expat=enabled \
	-D zstd=enabled \
	-D spirv-tools=enabled \
	-D lmsensors=disabled \
	-D libunwind=disabled \
	-D valgrind=disabled

meson compile -C build
DESTDIR="$PWD/stage" meson install --no-rebuild -C build

so=$(readlink "stage/usr/lib/libRusticlOpenCL.so.1")
if readelf -Ws "stage/usr/lib/$so" | awk '$5 == "LOCAL" && ($8 == "__libc" || $8 == "__libc_malloc_impl" || $8 == "__stdio_write") { f = 1 } END { exit !f }'; then
	echo "mesa-opencl: /usr/lib/$so carries a private copy of the C library" >&2
	exit 1
fi
install -Dm755 "stage/usr/lib/$so" "$PKG/usr/lib/$so"
ln -s "$so" "$PKG/usr/lib/libRusticlOpenCL.so.1"
install -Dm644 -t "$PKG/etc/OpenCL/vendors" "stage/etc/OpenCL/vendors/rusticl.icd"

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/mesa-opencl, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf mesa-opencl-26.2.3-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/mesa-opencl, and runs the triggers its paths call for.

Contents

Installed libraries: libRusticlOpenCL.so.

Installed directories: /etc/OpenCL, /usr/share/licenses/mesa-opencl.

Notes

The recipe names Mesa’s tarball under Mesa’s own file name and checksum, mesa-$version.tar.xz::<url>, and the same Rust crates, so the source archive holds one copy of each for both ports. version must equal mesa’s, and both recipes carry group = mesa, so a bump moves the two together.

The install goes into a staging directory inside the source tree, and only the library, its .so.1 link and the ICD file are copied into the package: everything else the build installs is mesa’s, and packaging it twice would give two packages the same path.

rusticl offers a device only for a driver its build enables or RUSTICL_ENABLE names. Every login shell gets RUSTICL_ENABLE=iris,radeonsi from /etc/profile.d/50-opencl.sh (see Graphics drivers), which a value set beforehand, empty included, overrides; NVIDIA, the processor and zink are offered once it names nouveau, llvmpipe or zink.