From 88e2574c64378f1baadbaa2c9ba482f05daf97ea Mon Sep 17 00:00:00 2001 From: diviocity Date: Mon, 30 Nov 2026 22:36:24 +0100 Subject: [PATCH] Fix Nouveau reference counting with the Vinix SDK --- ports/mesa/BOOTSTRAP.md | 2 ++ ports/mesa/PKGBUILD.vile | 9 +++++++-- ports/mesa/nouveau-atomic-refcount.patch | 24 ++++++++++++++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 ports/mesa/nouveau-atomic-refcount.patch diff --git a/ports/mesa/BOOTSTRAP.md b/ports/mesa/BOOTSTRAP.md index 6bd1638..7d37bf4 100644 --- a/ports/mesa/BOOTSTRAP.md +++ b/ports/mesa/BOOTSTRAP.md @@ -8,6 +8,8 @@ Mesa 24.2.8 uses a native `intel_clc` to compile the built-in shaders for the x8 The build-host generator’s Meson configure found LLVM 19.1.4, clang-cpp, libclc 0.2.0, SPIRV-Tools 2024.4.1 and LLVMSPIRVLib 19.1.0.0. Clang 19 compiled the generator’s `clc_helpers.cpp` with `CXXFLAGS="-O0 -g0"` on the 1 GiB worker. The configure log and compiler commands are in `xorg/llvm/work/intel-clc-02` on the release worker. +Mesa 24.2.8's Nouveau build failed when GCC's atomic fast-integer type and the Vinix SDK's `uint_fast32_t` had different widths. The recipe uses `atomic_uint` with an `unsigned int` comparison value and builds the affected Ninja object before the rest of Mesa. The worker reproduced the original x86_64 compile error, then built and ran the corrected decrement test against the Vinix SDK on each architecture. Each probe decremented two to one and preserved one. See `foundation/mesa-nouveau-atomic-proof-01`, receipt SHA-256 `ed9f9b6416a151f6e44c6e187168ae06f8e42def55b82b12155e2fe4b3dda966`. + Both target Mesa profiles build the Zink Gallium backend with Mesa's Vulkan headers. If a client selects Zink, the driver opens `libvulkan.so.1` at runtime. The loader is therefore a driver-specific dependency that an ELF `DT_NEEDED` scan cannot detect. The software EGL and GLX checks exercise the software Gallium backend. [Zink loader selection in Mesa 24.2.8](https://gitlab.freedesktop.org/mesa/mesa/-/blob/mesa-24.2.8/src/gallium/drivers/zink/zink_screen.c#L3293) ## Sharing a builder diff --git a/ports/mesa/PKGBUILD.vile b/ports/mesa/PKGBUILD.vile index 0a12b3e..0898a44 100644 --- a/ports/mesa/PKGBUILD.vile +++ b/ports/mesa/PKGBUILD.vile @@ -11,18 +11,23 @@ defpkgbuild(mesa, #:source, ["https://archive.mesa3d.org/mesa-24.2.8.tar.xz", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/mesa/29401.patch", "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/mesa/23630.patch", - "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/mesa/riscv64-tls.patch"], + "https://raw.githubusercontent.com/alpinelinux/aports/a7de3e63cc8015474a4feadd8bb7c0ecc097b1fa/main/mesa/riscv64-tls.patch", + "nouveau-atomic-refcount.patch"], #:sha256sums, ["999d0a854f43864fc098266aaf25600ce7961318a1e2e358bff94a7f53580e30", "2975b35c7cc0c66074bc38b906863c9b5da90718b2c7764f78b6486466f15061", "9f29a0cebfebdc8f9aab2452b86b289f863d128f67e197fcb5ad5a886c74dfc1", - "57cb89d086c4c3c0e4fbac3f84ab7409ac13df2a7c540f677d87c1ee8676076f"], + "57cb89d086c4c3c0e4fbac3f84ab7409ac13df2a7c540f677d87c1ee8676076f", + "7dbd1aa85acb5e818964fb44baf69bff1c3f065dee4141c8010d7975856d8438"], #:prepare, fn() { for-each(fn(file) { run("patch", "--batch", "-d", "mesa-24.2.8", "-p1", "-i", string-append("../", file)) }, list("29401.patch", "23630.patch", "riscv64-tls.patch")) + ; The bootstrap compiler and target libc can use different fast integer widths. + run("patch", "--batch", "--fuzz=0", "-d", "mesa-24.2.8", "-p1", "-i", "../nouveau-atomic-refcount.patch") }, #:build, fn() { run("vinix-mesa", "current", "mesa-24.2.8", "build") + run("vinix-ninja", "build", "src/nouveau/winsys/libnouveau_ws.a.p/nouveau_bo.c.o") run("vinix-ninja", "build", "all") }, #:check, fn() { diff --git a/ports/mesa/nouveau-atomic-refcount.patch b/ports/mesa/nouveau-atomic-refcount.patch new file mode 100644 index 0000000..c9eece1 --- /dev/null +++ b/ports/mesa/nouveau-atomic-refcount.patch @@ -0,0 +1,24 @@ +--- a/src/nouveau/winsys/nouveau_bo.c ++++ b/src/nouveau/winsys/nouveau_bo.c +@@ -237,7 +237,7 @@ + static bool +-atomic_dec_not_one(atomic_uint_fast32_t *counter) ++atomic_dec_not_one(atomic_uint *counter) + { +- uint_fast32_t old = *counter; ++ unsigned int old = *counter; + while (1) { + assert(old != 0); + if (old == 1) +--- a/src/nouveau/winsys/nouveau_bo.h ++++ b/src/nouveau/winsys/nouveau_bo.h +@@ -9,3 +9,3 @@ + #include +-using std::atomic_uint_fast32_t; ++using std::atomic_uint; + #else +@@ -40,3 +40,3 @@ + enum nouveau_ws_bo_flags flags; +- atomic_uint_fast32_t refcnt; ++ atomic_uint refcnt; + }; -- 2.56.1