ソースを参照

package/m4: fix build failure with host-gcc 15

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>
(cherry picked from commit 7a07a9d155b8f601d68f07ee0ed1dc8d48907644)
Signed-off-by: Thomas Perale <thomas.perale@mind.be>
Joseph Zikusooka (ZIK) 3 ヶ月 前
コミット
4cf750826f
1 ファイル変更10 行追加0 行削除
  1. 10 0
      package/m4/m4.mk

+ 10 - 0
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))