diff --git a/local/patches/argp-standalone/01-alloca-include-under-gcc.patch b/local/patches/argp-standalone/01-alloca-include-under-gcc.patch new file mode 100644 index 0000000000..4293d58006 --- /dev/null +++ b/local/patches/argp-standalone/01-alloca-include-under-gcc.patch @@ -0,0 +1,71 @@ +Include 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 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 defines alloca(size) as __builtin_alloca(size). */ ++#if HAVE_ALLOCA_H ++#include ++#else + #ifndef __GNUC__ + #if HAVE_ALLOCA_H + #include +@@ -43,6 +51,7 @@ + #endif + #endif + #endif ++#endif /* Red Bear: HAVE_ALLOCA_H */ + + #ifdef _WIN32 + #include +--- 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 defines alloca(size) as __builtin_alloca(size). */ ++#if HAVE_ALLOCA_H ++#include ++#else + #ifndef __GNUC__ + #if HAVE_ALLOCA_H || 0 + #include +@@ -38,6 +46,7 @@ + alloca(); + #endif + #endif ++#endif /* Red Bear: HAVE_ALLOCA_H */ + + #include + #include diff --git a/recipes/wip/dev/other/argp-standalone/01-alloca-include-under-gcc.patch b/recipes/wip/dev/other/argp-standalone/01-alloca-include-under-gcc.patch new file mode 120000 index 0000000000..71691bb579 --- /dev/null +++ b/recipes/wip/dev/other/argp-standalone/01-alloca-include-under-gcc.patch @@ -0,0 +1 @@ +../../../../../local/patches/argp-standalone/01-alloca-include-under-gcc.patch \ No newline at end of file diff --git a/recipes/wip/dev/other/argp-standalone/recipe.toml b/recipes/wip/dev/other/argp-standalone/recipe.toml index 0074b6bca4..6c0a290789 100644 --- a/recipes/wip/dev/other/argp-standalone/recipe.toml +++ b/recipes/wip/dev/other/argp-standalone/recipe.toml @@ -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"