mesa: Fix build with C23 implementing once_flag
PATCH 1/2 mesa: Fix build with C23 implementing once_flag
This is needed to build with glibc 2.43+
Signed-off-by Khem Raj <[email protected]>
--- ...once_flag-ONCE_FLAG_INIT-when-presen.patch | 78 +++++++++++++++++++ meta/recipes-graphics/mesa/mesa.inc | 1 + 2 files changed, 79 insertions(+) create mode 100644 meta/recipes-graphics/mesa/files/0001-c11-use-glibc-s-once_flag-ONCE_FLAG_INIT-when-presen.patch
meta/recipes-graphics/mesa/files/0001-c11-use-glibc-s-once_flag-ONCE_FLAG_INIT-when-presen.patch new file +78 -0
@@ -0,0 +1,78 @@ +From 6afe3c2ed510dd68d5bb3048a313cdd7b7eff5fc Mon Sep 17 00:00:00 2001 +From: Khem Raj <[email protected]> +Date: Wed, 5 Nov 2025 13:32:52 -0800 +Subject: [PATCH] =?UTF-8?q?c11:=20use=20glibc=E2=80=99s=20once=5Fflag/ONCE?= + =?UTF-8?q?=5FFLAG=5FINIT=20when=20present?= +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +don’t build Mesa’s call_once shim on such systems + +glibc recently grew C11/C23 one-time initialization primitives (commit +a7ddbf456d97, released with 2.42+) [1], providing once_flag and +ONCE_FLAG_INIT via bits/types/once_flag.h and advertising their +presence with __once_flag_defined. Mesa’s C11 shim currently typedefs +once_flag to pthread_once_t, defines ONCE_FLAG_INIT as +PTHREAD_ONCE_INIT, and implements call_once() using pthread_once(). + +On new glibc this causes two problems during Mesa build: + +typedef redefinition: + +src/c11/threads.h:121:25: error: typedef redefinition with different types +('pthread_once_t' vs '__once_flag') + +pointer type mismatch when calling pthread_once() with the glibc +once_flag: + +error: incompatible pointer types passing 'once_flag *' to parameter of type 'pthread_once_t *' + +This patch makes Mesa prefer the system-provided types/initializers when +available and only keep the shim otherwise. + +[1] https://sourceware.org/git/?p=glibc.git;a=commit;h=a7ddbf456d97 + +Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38272] +Signed-off-by: Khem Raj <[email protected]> +--- + src/c11/impl/threads_posix.c | 3 ++- + src/c11/threads.h | 4 ++++ + 2 files changed, 6 insertions(+), 1 deletion(-) + +diff --git a/src/c11/impl/threads_posix.c b/src/c11/impl/threads_posix.c +index 3b8692482bb..b108ba4ae0f 100644 +--- a/src/c11/impl/threads_posix.c ++++ b/src/c11/impl/threads_posix.c +@@ -46,12 +46,13 @@ impl_thrd_routine(void *p) + + /*--------------- 7.25.2 Initialization functions ---------------*/ + // 7.25.2.1 ++#ifndef USE_SYSTEM_CALL_ONCE + void + call_once(once_flag *flag, void (*func)(void)) + { + pthread_once(flag, func); + } +- ++#endif + + /*------------- 7.25.3 Condition variable functions -------------*/ + // 7.25.3.1 +diff --git a/src/c11/threads.h b/src/c11/threads.h +index dbcb3459a9b..a6c6f38aa85 100644 +--- a/src/c11/threads.h ++++ b/src/c11/threads.h +@@ -118,8 +118,12 @@ typedef pthread_cond_t cnd_t; + typedef pthread_t thrd_t; + typedef pthread_key_t tss_t; + typedef pthread_mutex_t mtx_t; ++#ifdef __once_flag_defined ++# define USE_SYSTEM_CALL_ONCE 1 ++#else + typedef pthread_once_t once_flag; + # define ONCE_FLAG_INIT PTHREAD_ONCE_INIT ++#endif + # ifdef PTHREAD_DESTRUCTOR_ITERATIONS + # define TSS_DTOR_ITERATIONS PTHREAD_DESTRUCTOR_ITERATIONS + # else
meta/recipes-graphics/mesa/mesa.inc +1 -0
@@ -17,6 +17,7 @@ PE = "2" SRC_URI = "https://archive.mesa3d.org/mesa-${PV}.tar.xz \ file://0001-meson-misdetects-64bit-atomics-on-mips-clang.patch \ file://0001-freedreno-don-t-encode-build-path-into-binaries.patch \ + file://0001-c11-use-glibc-s-once_flag-ONCE_FLAG_INIT-when-presen.patch \ " SRC_URI[sha256sum] = "bb6243e7a6f525febfa1e6ab50827ca4d4bfdad73812377b0ca9b6c50998b03e"
PATCH 2/2 spirv-llvm-translator: Upgrade to 21.1.2
[Backport to 21] Implement SPV_INTEL_predicated_io extension (#3370) (#3386)
[Backport to 21] Fix incorrect translation for AtomicCmpExchangeWeak builtin ptr arg type. (#3390) (#3392)
Signed-off-by Khem Raj <[email protected]>
---
...lvm-translator_21.1.1.bb => spirv-llvm-translator_21.1.2.bb} | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
rename meta/recipes-graphics/spir/{spirv-llvm-translator_21.1.1.bb => spirv-llvm-translator_21.1.2.bb} (94%)meta/recipes-graphics/spir/spirv-llvm-translator_21.1.2.bb renamed from meta/recipes-graphics/spir/spirv-llvm-translator_21.1.1.bb +1 -1
@@ -6,7 +6,7 @@ LIC_FILES_CHKSUM = "file://LICENSE.TXT;md5=47e311aa9caedd1b3abf098bd7814d1d" # pattern: llvm_branch_200, currently there are no minor releases, so, no llvm_branch_201 SPIRV_BRANCH = "llvm_release_${@oe.utils.trim_version('${PV}', 1).replace('.', '')}0" -SRCREV = "29758b55816c14abb3e4142d42aca7a95bf46710" +SRCREV = "a37544fc0bb90b4e8b8d755580119c018891dfa4" SRC_URI = " \ git://github.com/KhronosGroup/SPIRV-LLVM-Translator;protocol=https;tag=v${PV};branch=${SPIRV_BRANCH} \ "