Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Julien Olivain <ju.o@free.fr>
To: buildroot@buildroot.org
Subject: [Buildroot] [git commit] package/m4: fix build failure with host-gcc 15
Date: Sun, 4 May 2025 19:36:21 +0200	[thread overview]
Message-ID: <20250504174247.184F2863D7@busybox.osuosl.org> (raw)

commit: https://git.buildroot.net/buildroot/commit/?id=7a07a9d155b8f601d68f07ee0ed1dc8d48907644
branch: https://git.buildroot.net/buildroot/commit/?id=refs/heads/master

When compiling host-m4 1.4.19 with a host gcc 15 (which is the version
included in Fedora 42, released on 2025-04-15), compilation fails with
error:

    In file included from gl_avltree_oset.h:21,
                     from gl_avltree_oset.c:21:
    gl_oset.h:275:1: warning: 'nodiscard' attribute ignored [-Wattributes]
      275 | GL_OSET_INLINE _GL_ATTRIBUTE_NODISCARD int
          | ^~~~~~~~~~~~~~
    gl_oset.h:275:40: error: expected identifier or '(' before 'int'
      275 | GL_OSET_INLINE _GL_ATTRIBUTE_NODISCARD int
          |                                        ^~~

This error is due to the gnulib copy included in m4 1.4.19, which does
not detect properly the default C language standard of gcc 15 which
has been changed from "gnu17" to "gnu23". See [1]. Note that m4 1.4.19
is the latest version available at the time of this commit, and was
released in May 2021. The issue is tracked upstream in [2].

Upcoming m4 release is expected to fix this issue, by updating its
gnulib copy. See [3], which states: "Update to comply with newer C
standards, and inherit portability improvements from gnulib".

Until this new m4 version is released, this commit fixes the issue by
forcing the C langage standard to "-std=gnu17" (the previous gcc
default) when host-gcc 15 is detected.

Note that the "-std=gnu17" option was introduced in gcc 8. See [4].
This is the reason why this patch adds this option only when the
problematic gcc 15 version is detected.

See also the discussions around this patch at [5].

Fixes:
https://autobuild.buildroot.org/results/1c33ef0a710cfae13e496485787b351c8f951217/
(and many, many others)

[1] https://gcc.gnu.org/gcc-15/changes.html#c
[2] https://savannah.gnu.org/support/?111150
[3] https://git.savannah.gnu.org/cgit/m4.git/commit/?h=branch-1.4&id=a22c9802dd7e724eaefb21dc21d84ac2d3a49c89
[4] https://gcc.gnu.org/gcc-8/changes.html#c
[5] https://lore.kernel.org/buildroot/CAPWx8vsoJUt8YMJG1aUqFRK1=yizNbgjVjGL1Q1+9ygjJGnZLA@mail.gmail.com/

Signed-off-by: Joseph Zikusooka (ZIK) <zik@jambula.net>
Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
[Julien:
 - change mail url to lore.kernel.org for stable link
 - reword, reflow and add extra info in the commit log
 - force -std=gnu17 only when host gcc-15 is detected
 - add a comment in .mk to remove the workaround at next bump
]
Signed-off-by: Julien Olivain <ju.o@free.fr>
---
 package/m4/m4.mk | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/package/m4/m4.mk b/package/m4/m4.mk
index 39ad898b10..f5e1e27ad8 100644
--- a/package/m4/m4.mk
+++ b/package/m4/m4.mk
@@ -10,4 +10,14 @@ M4_SITE = $(BR2_GNU_MIRROR)/m4
 M4_LICENSE = GPL-3.0+
 M4_LICENSE_FILES = COPYING
 
+# gcc-15 defaults to -std=gnu23 which is incorrectly detected and
+# generates build failures in the gnulib copy included in
+# m4-1.4.19. We workaround this by forcing the previous gcc default
+# standard, which is -std=gnu17 only when host gcc is >= 15. This
+# workaround can be removed when m4 will be updated to a version
+# including a fix for gcc-15.
+ifeq ($(BR2_HOST_GCC_AT_LEAST_15),y)
+HOST_M4_CONF_ENV = CFLAGS="$(HOST_CFLAGS) -std=gnu17"
+endif
+
 $(eval $(host-autotools-package))
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

             reply	other threads:[~2025-05-04 17:42 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-04 17:36 Julien Olivain [this message]
2025-05-14 11:33 ` [Buildroot] [git commit] package/m4: fix build failure with host-gcc 15 Luca Ceresoli 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=20250504174247.184F2863D7@busybox.osuosl.org \
    --to=ju.o@free.fr \
    --cc=buildroot@buildroot.org \
    /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