FHS F2.1: mesa_shader_cache -> /var/cache/mesa

First migration of the Class C cache work: the Mesa shader cache moves
from the LibreELEC-style /storage/.cache/mesa_shader_cache to the
Arch-standard /var/cache/mesa.

Implementation follows the bridge-symlink pattern systemd already uses
for /etc/*: the archr meta-package creates /var/cache/mesa as a
build-time symlink into /storage/.cache/mesa_shader_cache. Mesa,
runemu.sh and any inspector see the FHS path; writes still land on the
storage overlay so the cache survives reboots.

archr/package.mk: mkdir /var/cache, ln -sf the symlink.

quirks/profile.d/041-panfrost: MESA_SHADER_CACHE_DIR=/var/cache/mesa.
Comment explains the bridge so future readers do not assume tmpfs.

runemu.sh: create the cache dir through /var/cache/mesa instead of
the legacy /storage path. Comment updated to mention the symlink.

systemd/tmpfiles.d/z_01_archr.conf is intentionally left targeting the
backing path /storage/.cache/mesa_shader_cache: it is internal plumbing
that must guarantee the real overlay dir exists; /var/cache/mesa is
the surface, /storage/.cache/mesa_shader_cache stays the substrate.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
Douglas Teles
2026-06-23 15:51:37 -03:00
parent 2227151d46
commit a5b1862117
3 changed files with 15 additions and 4 deletions
+6
View File
@@ -46,6 +46,12 @@ EOF
# Always install the update script
mkdir -p $INSTALL/usr/share/bootloader
find_file_path bootloader/update.sh && cp -av ${FOUND_PATH} ${INSTALL}/usr/share/bootloader
### FHS bridge symlinks: make Arch-standard cache locations resolve into
### the /storage overlay. Apps and inspection tools see /var/cache/<x>;
### writes land in /storage/.cache/<x> (rw overlay).
mkdir -p ${INSTALL}/var/cache
ln -sf /storage/.cache/mesa_shader_cache ${INSTALL}/var/cache/mesa
}
post_install() {
@@ -419,7 +419,10 @@ get_gpu_performance_level >/tmp/.gpu_performance_level
### root path itself when MESA_SHADER_CACHE_DIR points somewhere new; the
### result is silent fall-through to "no cache" and a stutter every time
### the user re-launches a game whose shaders should already be hot.
[ -d /storage/.cache/mesa_shader_cache ] || mkdir -p /storage/.cache/mesa_shader_cache 2>/dev/null
### /var/cache/mesa is a symlink into /storage/.cache/mesa_shader_cache
### installed by the archr meta-package; create through the symlink so
### the underlying overlay path exists.
[ -d /var/cache/mesa ] || mkdir -p /var/cache/mesa 2>/dev/null
if [ "${DEVICE_HAS_FAN}" = "true" ]
then
@@ -14,7 +14,9 @@ export PAN_MESA_DEBUG=forcepack
# Skip GL error checking — emulators don't query glGetError defensively.
export MESA_NO_ERROR=1
# Persistent shader cache on /storage to survive reboots and avoid
# recompilation every launch. Mesa creates the dir on first write.
export MESA_SHADER_CACHE_DIR=/storage/.cache/mesa_shader_cache
# Persistent shader cache via the FHS bridge symlink set up by the
# archr meta-package: /var/cache/mesa -> /storage/.cache/mesa_shader_cache.
# Surfaces an Arch-friendly path while the writes still land on the rw
# storage overlay so the cache survives reboots.
export MESA_SHADER_CACHE_DIR=/var/cache/mesa
export MESA_SHADER_CACHE_MAX_SIZE=128MB