]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core.git/commitdiff
nasm: Fix build with musl+clang
authorKhem Raj <raj.khem@gmail.com>
Wed, 10 Dec 2025 03:34:40 +0000 (19:34 -0800)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 18 Dec 2025 13:53:50 +0000 (13:53 +0000)
Fixes `bool` related errors w.r.t. C23

Signed-off-by: Khem Raj <raj.khem@gmail.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-devtools/nasm/nasm/0001-compiler.h-Backport-C23-support.patch [new file with mode: 0644]
meta/recipes-devtools/nasm/nasm_3.01.bb

diff --git a/meta/recipes-devtools/nasm/nasm/0001-compiler.h-Backport-C23-support.patch b/meta/recipes-devtools/nasm/nasm/0001-compiler.h-Backport-C23-support.patch
new file mode 100644 (file)
index 0000000..e182087
--- /dev/null
@@ -0,0 +1,96 @@
+From e402e82d34569b4642ffbb3344c7240d1ea07776 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem@gmail.com>
+Date: Tue, 9 Dec 2025 17:17:36 -0800
+Subject: [PATCH] compiler.h: Backport C23 support
+
+These is a collection of changes done to compiler.h post
+3.01 release. It fixes build with non-glibc ( musl )
+builds especially with clang compiler which is more
+fussy
+
+Brings in squashed changed for compiler.h from
+
+https://github.com/netwide-assembler/nasm/commit/44e89ba9b650b5e1533bca43682e167f51a3511f
+https://github.com/netwide-assembler/nasm/commit/746e7c9efa37cec9a44d84a1e96b8c38f385cc1f
+https://github.com/netwide-assembler/nasm/commit/44ec97993a28ba109f98c4514e27cef813720399#diff-8e3e9367147ea2bbe07af8d84c1e07f80f5e19ca23282426324e396ee05947ba
+https://github.com/netwide-assembler/nasm/commit/f4f7d18c06449a1859a62a10e7e24ca644032dff#diff-8e3e9367147ea2bbe07af8d84c1e07f80f5e19ca23282426324e396ee05947ba
+
+Upstream-Status: Backport [Above patches from master branch]
+
+Signed-off-by: Khem Raj <raj.khem@gmail.com>
+---
+ include/compiler.h | 42 ++++++++++++++++++------------------------
+ 1 file changed, 18 insertions(+), 24 deletions(-)
+
+--- a/include/compiler.h
++++ b/include/compiler.h
+@@ -185,19 +185,10 @@ char * pure_func strrchrnul(const char *
+ size_t strlcat(char *, const char *, size_t);
+ #endif
+
+-#if !defined(__cplusplus) || (__STDC_VERSION >= 202311L)
+ /* C++ and C23 have bool, false, and true as proper keywords */
++#if !defined(__cplusplus) && (__STDC_VERSION__ < 202311L)
+ # ifdef HAVE_STDBOOL_H
+-/* If <stdbool.h> exists, include it explicitly to prevent it from
+-   begin included later, causing the "bool" macro to be defined. */
+ #  include <stdbool.h>
+-#  ifdef bool
+-/* Force bool to be a typedef instead of a macro. What a "clever" hack
+-   this is... */
+-    typedef bool                /* The macro definition of bool */
+-#  undef bool
+-        bool;                   /* No longer the macro definition */
+-#  endif
+ # elif defined(HAVE___BOOL)
+    typedef _Bool bool;
+ #  define false 0
+@@ -205,14 +196,10 @@ size_t strlcat(char *, const char *, siz
+ # else
+ /* This is a bit dangerous, because casting to this ersatz bool
+    will not produce the same result as the standard (bool) cast.
+-   Instead, use the bool() constructor-style macro defined below. */
++   Instead, use the explicit construct !!x instead of relying on
++   implicit conversions or casts. */
+ typedef enum bool { false, true } bool;
+ # endif
+-/* This amounts to a C++-style conversion cast to bool.  This works
+-   because C ignores an argument-taking macro when used without an
+-   argument and because bool was redefined as a typedef if it previously
+-   was defined as a macro (see above.) */
+-# define bool(x) ((bool)!!(x))
+ #endif
+
+ /* Create a NULL pointer of the same type as the address of
+@@ -325,11 +312,11 @@ static inline void *mempset(void *dst, i
+  * less likely to be taken.
+  */
+ #ifdef HAVE___BUILTIN_EXPECT
+-# define likely(x)    __builtin_expect(bool(x), true)
+-# define unlikely(x)  __builtin_expect(bool(x), false)
++# define likely(x)    __builtin_expect(!!(x), true)
++# define unlikely(x)  __builtin_expect(!!(x), false)
+ #else
+-# define likely(x)    bool(x)
+-# define unlikely(x)  bool(x)
++# define likely(x)    (!!(x))
++# define unlikely(x)  (!!(x))
+ #endif
+
+ #ifdef HAVE___BUILTIN_PREFETCH
+@@ -486,4 +473,15 @@ static inline unsigned int watcom_switch
+ # define default case BOGUS_CASE: default
+ #endif
+
++#ifndef unreachable              /* C23 defines as a macro in <stddef.h> */
++# ifdef HAVE___BUILTIN_UNREACHABLE
++#  define unreachable() __builtin_unreachable()
++# else
++#  define unreachable() do { abort(); } while(1)
++# endif
++#endif
++
++/* This should be set from main() */
++extern const char *_progname;
++
+ #endif        /* NASM_COMPILER_H */
index 4f4b47d665b2e5c946eb5b24ba586cb90f307ee1..1e4719000f8811563bfc05383cb8947b8968a328 100644 (file)
@@ -8,6 +8,7 @@ LIC_FILES_CHKSUM = "file://LICENSE;md5=6178dc4f5355e40552448080e67a214b"
 SRC_URI = "http://www.nasm.us/pub/nasm/releasebuilds/${PV}/nasm-${PV}.tar.bz2 \
            file://0001-stdlib-Add-strlcat.patch \
            file://0002-Add-debug-prefix-map-option.patch \
+           file://0001-compiler.h-Backport-C23-support.patch \
            "
 
 SRC_URI[sha256sum] = "7a7b1ff3b0eef3247862f2fbe4ca605ccef770545d7af7979eba84a9d045c0b1"