mesa-clc: native host build of mesa_clc + vtn_bindgen2 for cross builds

A Redox cross build cannot run the target shader-precompile tools on the host,
so build them natively once and feed them to the cross Mesa via
-Dmesa-clc=system -Dprecomp-compiler=system. Native meson build against
llvm-native's CLEAN host LLVM/Clang (the redoxer toolchain's llvm-config emits
-I<toolchain>/include, which holds Redox target libc headers that poison host
g++), host system deps (libdrm/expat/zlib/zstd), and our host-built
SPIRV-Tools/LLVMSPIRVLib/libclc (pkg-config with absolute .pc prefixes; native
pkg-config, not the cross wrapper). Driver-agnostic tools, so iris-only (no
amdgpu-LLVM needed); they serve radeonsi/radv in the cross build too.
This commit is contained in:
2026-07-31 15:32:38 +03:00
parent 41d0ff60d9
commit caa2fb48b8
2 changed files with 120 additions and 0 deletions
+119
View File
@@ -0,0 +1,119 @@
[package]
name = "mesa-clc"
# NATIVE (host) build of Mesa's build-time shader compilers: mesa_clc,
# vtn_bindgen2 and the driver precomp tools (intel_clc, ...). The cross Mesa
# build cannot run Redox target binaries on the host, so it consumes these via
# -Dmesa-clc=system -Dprecomp-compiler=system. Version tracks Mesa.
version = "26.1.4"
description = "Native host build of Mesa's mesa_clc / vtn_bindgen2 / precomp shader tools, consumed by the cross Mesa build (-Dmesa-clc=system -Dprecomp-compiler=system)."
[source]
tar = "https://gitlab.freedesktop.org/mesa/mesa/-/archive/mesa-26.1.4/mesa-mesa-26.1.4.tar.gz"
blake3 = "2299cd27430592c9a4a21c6345e74d5df278f4cd5839875ffd75abc3c1e988f9"
upstream = "https://gitlab.freedesktop.org/mesa/mesa"
[build]
template = "custom"
# Host toolchain LLVM/clang (all-five targets) + our host-built SPIRV/libclc are
# reused; the Manjaro host supplies the common build deps (libdrm, expat, zlib,
# python). llvm-native provides a host clang/LLVM dev tree if the toolchain one
# is insufficient. spirv-* / libclc are staged so native pkg-config resolves them.
dependencies = [
"llvm-native",
"spirv-tools",
"spirv-llvm-translator",
"libclc",
]
dev-dependencies = [
"llvm-native.dev",
"llvm-native.runtime",
]
script = '''
DYNAMIC_INIT
# NATIVE build: drop every cross-compile flag so host gcc/g++ target the host.
unset LDFLAGS CFLAGS CXXFLAGS CPPFLAGS
export CC=/usr/bin/gcc
export CXX=/usr/bin/g++
# Use llvm-native's CLEAN host LLVM/Clang (staged in the sysroot at usr/bin).
# Do NOT use the redoxer toolchain's llvm-config: its includedir
# (<toolchain>/include) also holds the Redox *target* libc headers
# (features.h/stdlib.h without __GLIBC_USE) next to the llvm headers, and
# `llvm-config --cxxflags` emits `-I<that dir>`, which shadows host glibc and
# breaks the native g++ compile (host libstdc++ os_defines.h fails on
# __GLIBC_USE). llvm-native's includedir is clean (llvm headers only). mesa_clc/
# vtn_bindgen2 are driver-agnostic, so an X86-only host LLVM is sufficient.
export PATH="${COOKBOOK_SYSROOT}/usr/bin:${PATH}"
export LD_LIBRARY_PATH="${COOKBOOK_SYSROOT}/usr/lib:${LD_LIBRARY_PATH:-}"
# DYNAMIC_INIT points pkg-config at the CROSS wrapper (sysroot-only) via
# PKG_CONFIG / PKG_CONFIG_LIBDIR / PKG_CONFIG_SYSROOT_DIR. This is a NATIVE build,
# so override to the host pkg-config and let it search BOTH the host system dirs
# (libzstd/libdrm/expat from Manjaro /usr) AND the staged sysroot (our host-built
# SPIRV-Tools/LLVMSPIRVLib/libclc). We rewrite the staged .pc prefixes to the
# absolute sysroot path and drop PKG_CONFIG_SYSROOT_DIR so host .pc (prefix=/usr)
# are not re-rooted.
export PKG_CONFIG=/usr/bin/pkg-config
unset PKG_CONFIG_SYSROOT_DIR
unset PKG_CONFIG_PATH
export PKG_CONFIG_LIBDIR="${COOKBOOK_SYSROOT}/usr/lib/pkgconfig:/usr/lib/pkgconfig:/usr/share/pkgconfig"
for _pc in "${COOKBOOK_SYSROOT}"/usr/lib/pkgconfig/*.pc; do
[ -f "$_pc" ] || continue
sed -i "s|^prefix=/usr\$|prefix=${COOKBOOK_SYSROOT}/usr|" "$_pc"
done
# Do NOT add a global -I${COOKBOOK_SYSROOT}/usr/include: that would inject the
# Redox relibc headers (features.h/stdlib.h without __GLIBC_USE) ahead of the
# host glibc/libstdc++ headers and break the native compile. pkg-config (with
# the absolute .pc prefixes above) and llvm-config supply the correct per-
# dependency include/lib paths for LLVMSPIRVLib/SPIRV-Tools/libclc/LLVM.
# Configure a NATIVE mesa restricted to the shader compilers. No window-system
# platforms / GL runtime — we only need the clc/precomp tool executables.
meson setup build-clc "${COOKBOOK_SOURCE}" \
--buildtype=release \
--prefix=/usr \
-Dmesa-clc=enabled \
-Dinstall-mesa-clc=true \
-Dprecomp-compiler=enabled \
-Dinstall-precomp-compiler=true \
-Dgallium-drivers=iris \
-Dvulkan-drivers=intel \
-Dllvm=enabled \
-Dshared-llvm=enabled \
-Dplatforms= \
-Degl=disabled \
-Dglx=disabled \
-Dgbm=disabled \
-Dgles1=disabled \
-Dgles2=disabled \
-Dopengl=true \
-Dshared-glapi=enabled \
-Dvideo-codecs= \
-Dgallium-va=disabled \
-Dgallium-extra-hud=false \
-Dvalgrind=disabled \
-Dlibunwind=disabled \
-Dzstd=enabled \
-Dshader-cache=disabled
# Build the tool executables by their ninja output paths (ninja targets are
# paths, not bare names). intel_clc is only present when the intel driver's clc
# path is configured — build it only if it is a known target.
_targets="src/compiler/clc/mesa_clc src/compiler/spirv/vtn_bindgen2"
if ninja -C build-clc -t targets all 2>/dev/null | grep -q "src/intel/compiler/intel_clc:"; then
_targets="$_targets src/intel/compiler/intel_clc"
fi
ninja -C build-clc $_targets
# Stage every tool executable we built into usr/bin.
mkdir -p "${COOKBOOK_STAGE}/usr/bin"
for t in $_targets; do
if [ -x "build-clc/$t" ]; then
cp "build-clc/$t" "${COOKBOOK_STAGE}/usr/bin/"
else
echo "mesa-clc: WARN target build-clc/$t not found after build"
fi
done
ls -la "${COOKBOOK_STAGE}/usr/bin/"
'''
+1
View File
@@ -0,0 +1 @@
../../local/recipes/dev/mesa-clc