From patchwork Tue Nov 3 23:16:04 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "mark.yang" X-Patchwork-Id: 102829 Received: from lgeamrelo11.lge.com (lgeamrelo11.lge.com [156.147.23.51]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.2705.1793747773085312755 for ; Tue, 03 Nov 2026 15:16:13 -0800 Authentication-Results: mx.groups.io; dkim=none (message not signed); spf=pass (domain: lge.com, ip: 156.147.23.51, mailfrom: mark.yang@lge.com) Received: from unknown (HELO lgeamrelo04.lge.com) (156.147.1.127) by 156.147.23.51 with ESMTP; 4 Nov 2026 08:16:10 +0900 X-Original-SENDERIP: 156.147.1.127 X-Original-MAILFROM: mark.yang@lge.com Received: from unknown (HELO markyang..) (10.177.122.207) by 156.147.1.127 with ESMTP; 4 Nov 2026 08:16:10 +0900 X-Original-SENDERIP: 10.177.122.207 X-Original-MAILFROM: mark.yang@lge.com From: mark.yang@lge.com To: openembedded-core@lists.openembedded.org Cc: Khem Raj , Martin Jansa , "mark.yang" Subject: [PATCH 3/6] multilib_header_wrapper.h: support musl Date: Wed, 4 Nov 2026 08:16:04 +0900 Message-ID: <20261103231607.4021851-4-mark.yang@lge.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20261103231607.4021851-1-mark.yang@lge.com> References: <20261103231607.4021851-1-mark.yang@lge.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Tue, 03 Nov 2026 23:16:17 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/249307 From: "mark.yang" Pick the -32/-64 variant on musl from the musl headers in the sysroot, or from __SIZEOF_POINTER__ when both variants are there. glibc multilib is unchanged. This brings back __MHWORDSIZE, dropped in 3a6ba47ede. musl defines __WORDSIZE in sys/reg.h and sys/user.h, and a wrapper included after them would redefine it. The first wrapper in a translation unit sets it as follows: 1. Already defined: used as is. SWIG has no __has_include, so musl recipes that run it over wrapped headers pass -D__MHWORDSIZE=. 2. Only bits/alltypes-32.h or only bits/alltypes-64.h: 32 or 64. This is a recipe sysroot, which has one musl variant. 3. bits/alltypes.h with both variants: __SIZEOF_POINTER__ * 8. This is an SDK sysroot. 4. Otherwise: __WORDSIZE from bits/wordsize.h, as before. musl installs bits/alltypes-32.h or -64.h now that its bits headers are wrapped. bpf needs no __bpf__ check. 6d8c7e3426 removed the old one, which set 64. A lib32 recipe that builds eBPF with clang -target bpf gets 8-byte pointers, so the pointer size alone would pick the -64.h headers. Its sysroot has only the -32.h ones, and rule 2 picks those. Signed-off-by: mark.yang --- scripts/multilib_header_wrapper.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/scripts/multilib_header_wrapper.h b/scripts/multilib_header_wrapper.h index 88f3193812..cb7ebb8c10 100644 --- a/scripts/multilib_header_wrapper.h +++ b/scripts/multilib_header_wrapper.h @@ -5,9 +5,23 @@ * */ -#include +#ifndef __MHWORDSIZE +# if defined(__has_include) +# if __has_include() && !__has_include() +# define __MHWORDSIZE 32 /* musl, 32-bit only */ +# elif __has_include() && !__has_include() +# define __MHWORDSIZE 64 /* musl, 64-bit only */ +# elif __has_include() +# define __MHWORDSIZE (__SIZEOF_POINTER__ * 8) /* musl, both (SDK) */ +# endif +# endif +# ifndef __MHWORDSIZE +# include /* glibc */ +# define __MHWORDSIZE __WORDSIZE +# endif +#endif -#if __WORDSIZE == 32 +#if __MHWORDSIZE == 32 #ifdef _MIPS_SIM @@ -23,9 +37,9 @@ #include #endif -#elif __WORDSIZE == 64 +#elif __MHWORDSIZE == 64 #include #else #error "Unknown __WORDSIZE detected" -#endif /* matches #if __WORDSIZE == 32 */ +#endif /* matches #if __MHWORDSIZE == 32 */