Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [git commit] package/m4: fix build failure with host-gcc 15
@ 2025-05-04 17:36 Julien Olivain
  2025-05-14 11:33 ` Luca Ceresoli via buildroot
  0 siblings, 1 reply; 2+ messages in thread
From: Julien Olivain @ 2025-05-04 17:36 UTC (permalink / raw)
  To: buildroot

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Buildroot] [git commit] package/m4: fix build failure with host-gcc 15
  2025-05-04 17:36 [Buildroot] [git commit] package/m4: fix build failure with host-gcc 15 Julien Olivain
@ 2025-05-14 11:33 ` Luca Ceresoli via buildroot
  0 siblings, 0 replies; 2+ messages in thread
From: Luca Ceresoli via buildroot @ 2025-05-14 11:33 UTC (permalink / raw)
  To: Julien Olivain; +Cc: buildroot

Hello Julian, All,

On Sun, 4 May 2025 19:36:21 +0200
Julien Olivain <ju.o@free.fr> wrote:

> 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:

[...]

> +ifeq ($(BR2_HOST_GCC_AT_LEAST_15),y)
> +HOST_M4_CONF_ENV = CFLAGS="$(HOST_CFLAGS) -std=gnu17"
> +endif

While this patch fixes builds with gcc 15 on the master branch, there
is currently no fix on the 2025.02.x LTS branch.

This patch does not fix 2025.02.x however, because
BR2_HOST_GCC_AT_LEAST_15 does not exist on that branch, thus the ifeq
never triggers.

I tested this patch on 2025.02.1 as it was originally submitted [1],
unconditionally applying -std=gnu17, and it fixes the host-m4 build on
Fedora 42 (gcc 15.1.1). However I suspect it would not break host-m4 on
hosts with an older gcc version.

I instead tried cherry-picking these two patches on 2025.02.1:

  cca8d68461e6 ("Config.in: introduce BR2_HOST_GCC_AT_LEAST_{12..15}")
  7a07a9d155b8 ("package/m4: fix build failure with host-gcc 15") <this commit>

With those, host-m4 built successfully.

Would it be OK to apply both of these on 2025.02.x?

[1] https://lore.kernel.org/buildroot/20250503135217.490404-2-zik@jambula.net/

Luca

-- 
Luca Ceresoli, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-05-14 11:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-04 17:36 [Buildroot] [git commit] package/m4: fix build failure with host-gcc 15 Julien Olivain
2025-05-14 11:33 ` Luca Ceresoli via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox