Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Giulio Benetti <giulio.benetti@benettiengineering.com>
To: buildroot@buildroot.org
Cc: "Hervé Codina" <herve.codina@bootlin.com>,
	"Giulio Benetti" <giulio.benetti@benettiengineering.com>
Subject: [Buildroot] [PATCH] package/libfutils: fix build with gcc >= 16
Date: Tue, 24 Nov 2026 18:24:11 +0100	[thread overview]
Message-ID: <20261124172411.1613844-1-giulio.benetti@benettiengineering.com> (raw)

ATOMIC_VAR_INIT() has been removed in C23, so with gcc >= 16 the build
fails with:

src/random.c:338:31: error: implicit declaration of function 'ATOMIC_VAR_INIT'; did you mean 'ATOMIC_FLAG_INIT'? [-Wimplicit-function-declaration]

So let's add a local patch that initializes the atomic variable
directly.

Fixes:
https://autobuild.buildroot.org/results/819/8195c40c826e1b85ced2aec5d1e8705542a82c93/

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
---
 ...01-random-drop-ATOMIC_VAR_INIT-usage.patch | 47 +++++++++++++++++++
 1 file changed, 47 insertions(+)
 create mode 100644 package/libfutils/0001-random-drop-ATOMIC_VAR_INIT-usage.patch

diff --git a/package/libfutils/0001-random-drop-ATOMIC_VAR_INIT-usage.patch b/package/libfutils/0001-random-drop-ATOMIC_VAR_INIT-usage.patch
new file mode 100644
index 0000000000..17aa454b94
--- /dev/null
+++ b/package/libfutils/0001-random-drop-ATOMIC_VAR_INIT-usage.patch
@@ -0,0 +1,47 @@
+From d79dd390211e9509c769662b11fe0c2857d6d3f2 Mon Sep 17 00:00:00 2001
+From: Giulio Benetti <giulio.benetti@benettiengineering.com>
+Date: Tue, 24 Nov 2026 17:08:31 +0100
+Subject: [PATCH] random: drop ATOMIC_VAR_INIT() usage
+
+ATOMIC_VAR_INIT() has been deprecated in C17 and removed in C23, so with
+gcc >= 16 (that defaults to -std=gnu23) <stdatomic.h> doesn't provide it
+anymore and the build fails with:
+
+src/random.c:338:31: error: implicit declaration of function 'ATOMIC_VAR_INIT'; did you mean 'ATOMIC_FLAG_INIT'? [-Wimplicit-function-declaration]
+src/random.c:338:31: error: initializer element is not constant
+
+Since C17 an atomic object with static storage duration can be
+initialized directly, so let's do that and drop the local fallback
+definition of ATOMIC_VAR_INIT() too.
+
+Upstream: https://github.com/Parrot-Developers/libfutils/pull/2
+Signed-off-by: Giulio Benetti <giulio.benetti@benettiengineering.com>
+---
+ src/random.c | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/src/random.c b/src/random.c
+index 7c6a9a5..4236489 100644
+--- a/src/random.c
++++ b/src/random.c
+@@ -92,8 +92,6 @@ ULOG_DECLARE_TAG(futils_random);
+ 
+ #if !defined(HAVE_STDATOMIC) && defined(__GNUC__)
+ 
+-#define ATOMIC_VAR_INIT(v) (v)
+-
+ /* codecheck_ignore[NEW_TYPEDEFS] */
+ typedef unsigned int atomic_uint;
+ 
+@@ -335,7 +333,7 @@ struct pool {
+ 	uint8_t buffer[512];
+ };
+ 
+-static atomic_uint seed_era = ATOMIC_VAR_INIT(1); /* current seed era */
++static atomic_uint seed_era = 1; /* current seed era */
+ 
+ #ifdef HAVE_THREAD_LOCAL
+ 
+-- 
+2.47.3
+
-- 
2.47.3

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

             reply	other threads:[~2026-11-24 17:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-24 17:24 Giulio Benetti [this message]
2026-11-24 17:45 ` [Buildroot] [PATCH] package/libfutils: fix build with gcc >= 16 Herve Codina via buildroot
2026-11-25  9:42 ` Yegor Yefremov
2026-11-25 19:49 ` Julien Olivain via buildroot

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261124172411.1613844-1-giulio.benetti@benettiengineering.com \
    --to=giulio.benetti@benettiengineering.com \
    --cc=buildroot@buildroot.org \
    --cc=herve.codina@bootlin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox