package/flex: fix GCC 15.x build issue
PATCH 1/1 package/flex: fix GCC 15.x build issue
Fixes:
https://autobuild.buildroot.net/results/924b1015d4b81385409ef00f1a14be3ca1959c8e/
As part of building flex for the target a few files are built for the host, including a rpl_malloc() implementation containing a malloc() forward declaration without any function parameters.
GCC 15 defaults to -std=gnu23, which handles function declarations without parameters differently from earlier C standards leading to compilation errors:
../lib/malloc.c:6:12: warning: conflicting types for built-in function 'malloc'; expected 'void *(long unsigned int)' [-Wbuiltin-declaration-mismatch]
6 | void *malloc ();
| ^~~~~~
../lib/malloc.c:5:1: note: 'malloc' is declared in header '<stdlib.h>'
4 | #include <sys/types.h>
+++ |+#include <stdlib.h>
5 |../lib/malloc.c: In function 'rpl_malloc':../lib/malloc.c:16:15: error: too many arguments to function 'malloc'; expected 0, have 1
https://gcc.gnu.org/gcc-15/porting_to.html#c23-fn-decls-without-parameters
Add a patch submitted upstream to correct the prototype.
--- ...04-Match-malloc-signature-to-its-use.patch | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 package/flex/0004-Match-malloc-signature-to-its-use.patch
package/flex/0004-Match-malloc-signature-to-its-use.patch new file +27 -0
@@ -0,0 +1,27 @@ +From 4b142954b54a57a9b0af0a9661056a9c39a8fa95 Mon Sep 17 00:00:00 2001 +From: Richard Barnes <[email protected]> +Date: Wed, 2 Oct 2024 10:35:09 -0700 +Subject: [PATCH] Match `malloc` signature to its use + +Upstream: https://github.com/westes/flex/pull/674 +Signed-off-by: Peter Korsgaard <[email protected]> +--- + lib/malloc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/malloc.c b/lib/malloc.c +index 75e8ef9..701b9b3 100755 +--- a/lib/malloc.c ++++ b/lib/malloc.c +@@ -3,7 +3,7 @@ + + #include <sys/types.h> + +- void *malloc (); ++ void *malloc (size_t n); + + /* Allocate an N-byte block of memory from the heap. + If N is zero, allocate a 1-byte block. */ +-- +2.39.5 +
Signature · 6 lines
2.39.5 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 18 lines · Peter Korsgaard
Fixes:
https://autobuild.buildroot.net/results/924b1015d4b81385409ef00f1a14be3ca1959c8e/As part of building flex for the target a few files are built for the host, including a
rpl_malloc()implementation containing amalloc()forward declaration without any function parameters.GCC 15 defaults to -std=gnu23, which handles function declarations without parameters differently from earlier C standards leading to compilation errors:
../lib/malloc.c:6:12: warning: conflicting types for built-in function 'malloc'; expected 'void *(long unsigned int)' [-Wbuiltin-declaration-mismatch]6 | void *malloc (); | ^~~~~~ ../lib/malloc.c:5:1: note: 'malloc' is declared in header '<stdlib.h>' 4 | #include <sys/types.h> +++ |+#include <stdlib.h> 5 |
Quoted 8 lines
../lib/malloc.c: In function 'rpl_malloc':../lib/malloc.c:16:15: error: too many arguments to function 'malloc'; expected 0, have 1https://gcc.gnu.org/gcc-15/porting_to.html#c23-fn-decls-without-parameters
Add a patch submitted upstream to correct the prototype.
Signed-off-by Peter Korsgaard <[email protected]>
Applied to master, thanks.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
Quoted 18 lines · Peter Korsgaard
Fixes:
https://autobuild.buildroot.net/results/924b1015d4b81385409ef00f1a14be3ca1959c8e/As part of building flex for the target a few files are built for the host, including a
rpl_malloc()implementation containing amalloc()forward declaration without any function parameters.GCC 15 defaults to -std=gnu23, which handles function declarations without parameters differently from earlier C standards leading to compilation errors:
../lib/malloc.c:6:12: warning: conflicting types for built-in function 'malloc'; expected 'void *(long unsigned int)' [-Wbuiltin-declaration-mismatch]6 | void *malloc (); | ^~~~~~ ../lib/malloc.c:5:1: note: 'malloc' is declared in header '<stdlib.h>' 4 | #include <sys/types.h> +++ |+#include <stdlib.h> 5 |
Quoted 8 lines
../lib/malloc.c: In function 'rpl_malloc':../lib/malloc.c:16:15: error: too many arguments to function 'malloc'; expected 0, have 1https://gcc.gnu.org/gcc-15/porting_to.html#c23-fn-decls-without-parameters
Add a patch submitted upstream to correct the prototype.
Signed-off-by Peter Korsgaard <[email protected]>
Applied to 2025.02.x, thanks.
Regards,
Arnout
Quoted 28 lines
--- ...04-Match-malloc-signature-to-its-use.patch | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+)create mode 100644
package/flex/0004-Match-malloc-signature-to-its-use.patchpackage/flex/0004-Match-malloc-signature-to-its-use.patch new file +17
-0@@ -0,0 +1,27 @@ +From 4b142954b54a57a9b0af0a9661056a9c39a8fa95 Mon Sep 17 00:00:00 2001 +From: Richard Barnes <[email protected]> +Date: Wed, 2 Oct 2024 10:35:09 -0700 +Subject: [PATCH] Match `malloc` signature to its use + +Upstream: https://github.com/westes/flex/pull/674 +Signed-off-by: Peter Korsgaard <[email protected]> +--- + lib/malloc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/malloc.c b/lib/malloc.c +index 75e8ef9..701b9b3 100755 +--- a/lib/malloc.c ++++ b/lib/malloc.c +@@ -3,7 +3,7 @@ +
package/flex/0004-Match-malloc-signature-to-its-use.patch line 27
Quoted 10 lines
package/flex/0004-Match-malloc-signature-to-its-use.patch new file +10
-0+ #include <sys/types.h> + +- void *malloc (); ++ void *malloc (size_t n); + + /* Allocate an N-byte block of memory from the heap. + If N is zero, allocate a 1-byte block. */ +-- +2.39.5 +
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot