mesa-git PKGBUILDs (full builds) for Arch and compatible stepchildren
Posted: Wed Jul 24, 2024 6:04 am
Seeing as I don't have complete PKGBUILDs (well, more complete) for Arch and friends posted here, I fixed up some new ones. Boyoboy, a lot has changed since I've done a full build. (I normally disable LLVM and everything but amd drivers and a few things). There are more build dependencies now, which you'll find out if you start the PKGBUILD and don't have them (good way to find out actually, it will list the packages)
The Nvidia nouveau Vulkan driver is written in Rust, so that means a functional rust toolchain (including 32 bit) is needed. It's also necessary for a few rust crates to be pulled in by the build (it's just how rust/cargo works) so we have to make an exception for them in meson's "nofallback" mode. If the projects adds any more crates as dependencies in future builds, they may have to be added to that line.
I've spent most of the night troubleshooting and testing this shit. The biggest problem was getting the lib32 vulkan-nouveau to build. The old method of including llvm-config32 in a native file doesn't work anymore, not for the Rust target. It now has to be done with a "--cross-file lib32" build switch. Goodo... that actually eliminates the llvm32.native file from the PKGBUILD anyway.
First of all, I'll display the mesa-git PKGBUILD here. The lib32-mesa-git is similar, but appropriately configured and trimmed for lib32 use. I'll provide a link to a tarball near the bottom of the post to download the PKGBUILDs.
These are simple PKGBUILDs that you can edit... straight forward to understand, not a lot of clever bollocks. This is the benefit over, say, getting them from the AUR. Also, my lib32-mesa-git PKGBUILD is complete with the new nvidia nouveau vulkan shit. Not sure who wants to use it, but this will successfully build it.
These PKGBUILDs enable the taboo video codecs that distros (not Arch!) disable now also. At least Manjaro disables these, so this is significant there.
I did not enable LTO (link time optimization) as there is a lot of shit in this build to second guess. It can sometimes cause subtle breakage, especially with less tested code. Feel free to set it to true, I do (but I don't do a full build and I know to try it without if something is weird). The setting is in the PKGBUILDs, set to false.
Also in the package, a simple build script (just a few commands), mesabuild. If you use it, it will copy over the raw mesa tree so it won't have to be cloned again. It's a big operation, and gitlab's git servers may be slow at times, so you want that. The _build directory will be cleaned out when pkgver() starts.

I also provide a script for finding and cleaning the mesa_shader_cache directories (in your home dir, and also in every stinking Steam wine prefix). The script will find and prompt for optional removal. "cleanshadercaches"
They are invalidated any time you touch Mesa, so they should be cleaned out or they will simply pile up as disconnected flotsam.
OK, here is the tarball with the PKGBUILDs
arch-mesa-PKGBUILDs-july232024.tar.gz
http://www.mikeserv.org/files/arch-mesa ... 024.tar.gz
MD5SUM 6e2da39f2974cdc806924ab016f45c42 arch-mesa-PKGBUILDs-july232024.tar.gz
http://www.mikeserv.org/files/arch-mesa ... 024.md5sum
When you install your results, for example
There are provides= and conflicts= lines in the package that will satisfy package dependencies, AND prompt for removal of conflicting distro packages during the install.
The Nvidia nouveau Vulkan driver is written in Rust, so that means a functional rust toolchain (including 32 bit) is needed. It's also necessary for a few rust crates to be pulled in by the build (it's just how rust/cargo works) so we have to make an exception for them in meson's "nofallback" mode. If the projects adds any more crates as dependencies in future builds, they may have to be added to that line.
Code: Select all
--wrap-mode=nofallback
--force-fallback-for=syn,paste
First of all, I'll display the mesa-git PKGBUILD here. The lib32-mesa-git is similar, but appropriately configured and trimmed for lib32 use. I'll provide a link to a tarball near the bottom of the post to download the PKGBUILDs.
These are simple PKGBUILDs that you can edit... straight forward to understand, not a lot of clever bollocks. This is the benefit over, say, getting them from the AUR. Also, my lib32-mesa-git PKGBUILD is complete with the new nvidia nouveau vulkan shit. Not sure who wants to use it, but this will successfully build it.
These PKGBUILDs enable the taboo video codecs that distros (not Arch!) disable now also. At least Manjaro disables these, so this is significant there.
I did not enable LTO (link time optimization) as there is a lot of shit in this build to second guess. It can sometimes cause subtle breakage, especially with less tested code. Feel free to set it to true, I do (but I don't do a full build and I know to try it without if something is weird). The setting is in the PKGBUILDs, set to false.
Code: Select all
-D b_lto=true
Code: Select all
# Maintainer: Lone_Wolf <lonewolf at xs4all dot nl>
# Contributor: Armin K. <krejzi at email dot com>
# Contributor: Kristian Klausen <klausenbusk@hotmail.com>
# Contributor: Egon Ashrafinia <e.ashrafinia@gmail.com>
# Contributor: Tavian Barnes <tavianator@gmail.com>
# Contributor: Jan de Groot <jgc@archlinux.org>
# Contributor: Andreas Radke <andyrtr@archlinux.org>
# Contributor: Thomas Dziedzic < gostrc at gmail >
# Contributor: Antti "Tera" Oja <antti.bofh@gmail.com>
# Contributor: Diego Jose <diegoxter1006@gmail.com>
# Modified by Grogan <mike at mikeserv with normal commercial TLD suffix>
# Grogan: I have not removed any credits from the original file from AUR
# that I started with, but have modified this extensively over the years.
# http://www.mikeserv.com/support/
pkgname=mesa-git
pkgdesc="an open-source implementation of the OpenGL specification, git version"
pkgver=24.3.0_devel.192433.e16a74c0237
pkgrel=1
arch=('x86_64')
makedepends=('git' 'python-mako' 'xorgproto'
'libxml2' 'libx11' 'libvdpau' 'libva' 'elfutils' 'libomxil-bellagio' 'libxrandr'
'ocl-icd' 'vulkan-icd-loader' 'libgcrypt' 'wayland' 'wayland-protocols' 'meson' 'ninja' 'llvm' 'clang' 'spirv-llvm-translator'
'rust' 'cbindgen' 'rust-bindgen')
depends=('libdrm' 'libxxf86vm' 'libxdamage' 'libxshmfence' 'libelf'
'libomxil-bellagio' 'libunwind' 'libglvnd' 'wayland' 'lm_sensors' 'libclc' 'glslang' 'llvm-libs')
optdepends=('opengl-man-pages: for the OpenGL API man pages')
provides=('mesa' 'opencl-mesa' 'vulkan-nouveau' 'vulkan-intel' 'vulkan-radeon' 'vulkan-mesa-layers' 'libva-mesa-driver' 'mesa-vdpau' 'vulkan-swrast' 'vulkan-driver' 'mesa-libgl' 'opengl-driver' 'opencl-driver')
conflicts=('mesa' 'opencl-mesa' 'vulkan-nouveau' 'vulkan-intel' 'vulkan-radeon' 'vulkan-mesa-layers' 'libva-mesa-driver' 'mesa-vdpau' 'vulkan-swrast' 'mesa-libgl')
url="https://www.mesa3d.org"
license=('custom')
source=('git+https://gitlab.freedesktop.org/mesa/mesa.git' 'LICENSE')
md5sums=('SKIP' 'SKIP')
sha512sums=('SKIP' 'SKIP')
# NOTE: The read and echo method may not always have the desired result for pkgver() depending on the tree
# One of the following cut commands will work for the case where the other git version gymnastics don't.
# Uncomment the desired line, according to the desired version string delimited by "."
# (and if so, comment out both the read and echo lines below it)
# At the time of writing it is once again fine the way it is for both main and tag checkouts
# If you would like to build a release tag instead of main, uncomment and edit the "git checkout" line within the pkgver() function below.
pkgver() {
cd mesa
#git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g' | cut -d "." -f "2 3 4"
#git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g' | cut -d "." -f "2 3 4 5"
#git describe --long | sed 's/\([^-]*-g\)/r\1/;s/-/./g' | cut -d "." -f "1 2 4"
# git checkout tags/mesa-24.1.4
read -r _ver <VERSION
echo ${_ver/-/_}.$(git rev-list --count HEAD).$(git rev-parse --short HEAD)
if [ -d _build ]; then
rm -rf _build
fi
}
# Placeholder patch line in prepare() function in case you want to add a patch.
# Don't forget to add it to the source array and add another 'SKIP' for checksums
prepare() {
# patch -Np1 -i "$srcdir"/some.patch
echo "Done Preparing"
}
## Get rid of bollocks build flags from makepkg. We want performance, not hardening and debugging/profiling. A release build will use -O3
## If you want to add -march for your CPU type, simply uncomment and edit the additional provided lines.
build () {
unset CFLAGS
unset CXXFLAGS
unset LDFLAGS
# export CFLAGS="-march=x86-64"
# export CXXFLAGS="-march=x86-64"
meson setup mesa _build \
-D buildtype=release \
-D b_ndebug=true \
-D b_lto=false \
--wrap-mode=nofallback \
--force-fallback-for=syn,paste \
-D prefix=/usr \
-D sysconfdir=/etc \
-D platforms=x11,wayland \
-D gallium-drivers=r300,r600,radeonsi,nouveau,svga,swrast,i915,virgl,iris,zink,crocus \
-D vulkan-drivers=amd,intel,nouveau,intel_hasvk,swrast \
-D vulkan-layers=device-select,intel-nullhw,overlay \
-D dri3=enabled \
-D egl=enabled \
-D gallium-extra-hud=true \
-D gallium-nine=true \
-D gallium-omx=bellagio \
-D gallium-va=enabled \
-D gallium-vdpau=enabled \
-D gallium-xa=enabled \
-D gbm=enabled \
-D gles1=disabled \
-D gles2=enabled \
-D glvnd=enabled \
-D glx=dri \
-D libunwind=enabled \
-D llvm=enabled \
-D lmsensors=enabled \
-D osmesa=true \
-D shared-glapi=enabled \
-D gallium-opencl=icd \
-D valgrind=disabled \
-D zstd=enabled \
-D microsoft-clc=disabled \
-D video-codecs=vc1dec,h264dec,h264enc,h265dec,h265enc \
-D tools=[]
ninja -C _build
}
package() {
DESTDIR="$pkgdir" ninja $NINJAFLAGS -C _build install
# indirect rendering
ln -s /usr/lib/libGLX_mesa.so.0 ${pkgdir}/usr/lib/libGLX_indirect.so.0
install -Dt "$pkgdir"/usr/share/licenses/$pkgname "$srcdir"/LICENSE
Code: Select all
#! /bin/sh
cd mesa-git
makepkg
cp -a mesa ../lib32-mesa-git
cd ../lib32-mesa-git
makepkg

I also provide a script for finding and cleaning the mesa_shader_cache directories (in your home dir, and also in every stinking Steam wine prefix). The script will find and prompt for optional removal. "cleanshadercaches"
They are invalidated any time you touch Mesa, so they should be cleaned out or they will simply pile up as disconnected flotsam.
Code: Select all
#! /bin/bash
### Clean out ~/.cache/mesa_shader_cache(_sf) and radv_builtin shaders
### Clean out the mesa_shader_cache(_sf) directories from Steam's compatdata
### Note that the fossilize cache (MESA_DISK_CACHE_SINGLE_FILE=1) isn't used by default,
### so we cover the mesa_shader_cache_sf case with a wildcard
# System specific path, you may need to edit below if the following doesn't lead
# to the real path correctly
cd "$HOME"/.steam/root/steamapps/compatdata || exit 1
COMPATDATA=$(pwd -P)
find "$COMPATDATA" -name 'mesa_shader_cache*' -exec du -sh '{}' \;
find "$HOME"/.cache -name 'mesa_shader_cache*' -exec du -sh '{}' \;
echo "Look at all the CRUD that is accumulating..."
while true; do
read -p "Do you wish to clean it out? (y/n) " yn
case $yn in
[yY] ) echo Nuking...;
break;;
[nN] ) echo Aborting...;
exit 0;;
* ) echo "Enter y or n, silly!";;
esac
done
find "$COMPATDATA" -name 'mesa_shader_cache*' -exec rm -rvf '{}' \;
rm -vf "$HOME"/.cache/radv_builtin_shaders32
rm -vf "$HOME"/.cache/radv_builtin_shaders64
rm -rvf "$HOME"/.cache/mesa_shader_cache*
arch-mesa-PKGBUILDs-july232024.tar.gz
http://www.mikeserv.org/files/arch-mesa ... 024.tar.gz
MD5SUM 6e2da39f2974cdc806924ab016f45c42 arch-mesa-PKGBUILDs-july232024.tar.gz
http://www.mikeserv.org/files/arch-mesa ... 024.md5sum
When you install your results, for example
Code: Select all
pacman -U lib32-mesa-git-24.3.0_devel.192319.dc6e6d7a2be-1-x86_64.pkg.tar.zst mesa-git-24.3.0_devel.192319.dc6e6d7a2be-1-x86_64.pkg.tar.zst