argp-standalone: include <alloca.h> under GCC (GCC 14+ / C23)
argp-parse.c and argp-help.c wrap the whole alloca-declaration block in '#ifndef __GNUC__', so the header is never included when building with GCC -- the code relied on GCC historically providing an implicit declaration. GCC 14 promoted -Wimplicit-function-declaration to an error and C23 removed implicit declarations, so the GCC 16 cross toolchain fails: argp-parse.c:1227:36: error: implicit declaration of function 'alloca' argp-help.c:1329:35: error: implicit declaration of function 'alloca' configure already sets HAVE_ALLOCA_H 1 and relibc's <alloca.h> defines alloca(size) as __builtin_alloca(size), which is what GCC wants. Honour HAVE_ALLOCA_H before consulting __GNUC__; non-GCC paths are untouched. Patch generated by diff against pristine source, applies at --fuzz=0, and the recipe cooks clean. Second opportunistic C23-era fix under the gnu17 migration, after libiconv.
This commit is contained in:
@@ -0,0 +1,71 @@
|
||||
Include <alloca.h> under GCC too.
|
||||
|
||||
Both argp-parse.c and argp-help.c wrap their entire alloca-declaration
|
||||
block in `#ifndef __GNUC__`, so the header is never included when
|
||||
compiling with GCC. That relied on GCC historically making `alloca`
|
||||
available through an implicit declaration.
|
||||
|
||||
GCC 14 promoted -Wimplicit-function-declaration to an error, and C23
|
||||
removed implicit declarations outright, so on the GCC 16 cross toolchain
|
||||
the build fails:
|
||||
|
||||
argp-parse.c:1227:36: error: implicit declaration of function 'alloca'
|
||||
argp-help.c:1329:35: error: implicit declaration of function 'alloca'
|
||||
|
||||
configure already detects the header correctly (config.h defines
|
||||
HAVE_ALLOCA_H 1) and relibc's <alloca.h> defines
|
||||
`alloca(size) __builtin_alloca (size)`, which is exactly what GCC wants.
|
||||
The only defect is the __GNUC__ guard skipping the include.
|
||||
|
||||
Honour HAVE_ALLOCA_H first; every non-GCC path is left untouched.
|
||||
|
||||
--- a/argp-parse.c
|
||||
+++ b/argp-parse.c
|
||||
@@ -27,6 +27,14 @@
|
||||
#endif
|
||||
|
||||
/* AIX requires this to be the first thing in the file. */
|
||||
+/* Red Bear: honour HAVE_ALLOCA_H before consulting __GNUC__. The
|
||||
+ original block is skipped entirely under GCC, which relied on GCC
|
||||
+ implicitly declaring alloca. GCC 14 made implicit declarations an
|
||||
+ error (C23 removed them), so GCC needs the real header too.
|
||||
+ relibc's <alloca.h> defines alloca(size) as __builtin_alloca(size). */
|
||||
+#if HAVE_ALLOCA_H
|
||||
+#include <alloca.h>
|
||||
+#else
|
||||
#ifndef __GNUC__
|
||||
#if HAVE_ALLOCA_H
|
||||
#include <alloca.h>
|
||||
@@ -43,6 +51,7 @@
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
+#endif /* Red Bear: HAVE_ALLOCA_H */
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
--- a/argp-help.c
|
||||
+++ b/argp-help.c
|
||||
@@ -26,6 +26,14 @@
|
||||
#endif
|
||||
|
||||
/* AIX requires this to be the first thing in the file. */
|
||||
+/* Red Bear: honour HAVE_ALLOCA_H before consulting __GNUC__. The
|
||||
+ original block is skipped entirely under GCC, which relied on GCC
|
||||
+ implicitly declaring alloca. GCC 14 made implicit declarations an
|
||||
+ error (C23 removed them), so GCC needs the real header too.
|
||||
+ relibc's <alloca.h> defines alloca(size) as __builtin_alloca(size). */
|
||||
+#if HAVE_ALLOCA_H
|
||||
+#include <alloca.h>
|
||||
+#else
|
||||
#ifndef __GNUC__
|
||||
#if HAVE_ALLOCA_H || 0
|
||||
#include <alloca.h>
|
||||
@@ -38,6 +46,7 @@
|
||||
alloca();
|
||||
#endif
|
||||
#endif
|
||||
+#endif /* Red Bear: HAVE_ALLOCA_H */
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
@@ -0,0 +1 @@
|
||||
../../../../../local/patches/argp-standalone/01-alloca-include-under-gcc.patch
|
||||
@@ -5,5 +5,8 @@ version = "0.1.0"
|
||||
[source]
|
||||
git = "https://github.com/argp-standalone/argp-standalone"
|
||||
shallow_clone = true
|
||||
patches = [
|
||||
"01-alloca-include-under-gcc.patch"
|
||||
]
|
||||
[build]
|
||||
template = "meson"
|
||||
|
||||
Reference in New Issue
Block a user