package/make: fix conflicting prototypes for getenv and getopt
PATCH 1/1 package/make: fix conflicting prototypes for getenv and getopt
GCC 15 defaults to C23, which rejects old-style K&R empty parameter list declarations that conflict with typed prototypes in system headers.
Fix getenv() declarations in lib/fnmatch.c and src/getopt.c, and fix getopt() declarations in src/getopt.h to match the prototypes in <stdlib.h> and <unistd.h>.
--- ...ing-prototypes-for-getenv-and-getopt.patch | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100644 package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch new file +60 -0
@@ -0,0 +1,60 @@ +From: Buildroot Maintainer <[email protected]> +Date: Sat, 21 Feb 2026 12:00:00 +0000 +Subject: [PATCH] fix conflicting prototypes for getenv and getopt + +Fixes build error with GCC 15 and musl libc. + +Signed-off-by: Buildroot Maintainer <[email protected]> +--- + lib/fnmatch.c | 2 +- + src/getopt.c | 2 +- + src/getopt.h | 4 ++-- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/lib/fnmatch.c b/lib/fnmatch.c +--- a/lib/fnmatch.c ++++ b/lib/fnmatch.c +@@ -121,7 +121,7 @@ + whose names are inconsistent. */ + + # if !defined _LIBC && !defined getenv +-extern char *getenv (); ++extern char *getenv (const char *__name); + # endif + + # ifndef errno +diff --git a/src/getopt.c b/src/getopt.c +--- a/src/getopt.c ++++ b/src/getopt.c +@@ -202,7 +202,7 @@ + whose names are inconsistent. */ + + #ifndef getenv +-extern char *getenv (); ++extern char *getenv (const char *__name); + #endif + + static char * +diff --git a/src/getopt.h b/src/getopt.h +--- a/src/getopt.h ++++ b/src/getopt.h +@@ -102,7 +102,7 @@ + errors, only prototype getopt for the GNU C library. */ + extern int getopt (int argc, char *const *argv, const char *shortopts); + #else /* not __GNU_LIBRARY__ */ +-extern int getopt (); ++extern int getopt (int argc, char *const *argv, const char *shortopts); + #endif /* __GNU_LIBRARY__ */ + extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +@@ -116,7 +116,7 @@ + const struct option *longopts, int *longind, + int long_only); + #else /* not __STDC__ */ +-extern int getopt (); ++extern int getopt (int argc, char *const *argv, const char *shortopts); + extern int getopt_long (); + extern int getopt_long_only (); + +-- +2.43.0
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Shubham,
for context: Bernd sent a different solution for this problem a while ago.
https://patchwork.ozlabs.org/project/buildroot/patch/[email protected]/
Quoted 19 lines · Shubham Chakraborty
GCC 15 defaults to C23, which rejects old-style K&R empty parameter list declarations that conflict with typed prototypes in system headers.
Fix
getenv()declarations inlib/fnmatch.candsrc/getopt.c, and fixgetopt()declarations insrc/getopt.hto match the prototypes in <stdlib.h> and <unistd.h>.Signed-off-by Shubham Chakraborty <[email protected]>--- ...ing-prototypes-for-getenv-and-getopt.patch | 60 +++++++++++++++++++ 1 file changed, 60 insertions(+)create mode 100644
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patchpackage/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch new file +0
-0
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch line 6
Quoted 6 lines
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch new file +6
-0@@ -0,0 +1,60 @@ +From: Buildroot Maintainer <[email protected]> +Date: Sat, 21 Feb 2026 12:00:00 +0000> +Subject: [PATCH] fix conflicting prototypes for getenv and getopt + +Fixes build error with GCC 15 and musl libc. + +Signed-off-by: Buildroot Maintainer <[email protected]>
This is not a correct signoff, you'll need to add your personal signed-off-by.
The patch is also missing an Upstream: tag, describing where this has been submitted upstream, or why that is not applicable/feasible.
A variation of this is carried by alpine [1] and another one has actually been posted to the make ML [2].
Can you maybe follow up on the upstream submission and resubmit the patch with correct signoff and upstream tag?
I've marked the patch as Changes Requested in patchwork.
[...]
Best,
Marcus
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
PATCH v2 1/1 package/make: fix conflicting prototypes for getenv and getopt
In reply to Shubham ChakrabortyGCC 15 defaults to C23, which rejects old-style K&R empty parameter list declarations that conflict with typed prototypes in system headers. This is particularly visible when using non-glibc C libraries (e.g. musl).
Fixes:lib/fnmatch.c:124:14: error: conflicting types for 'getenv'; have 'char *(void)'
| 124 | extern char *getenv (); | | ^~~~~~
Fix getenv() declarations in lib/fnmatch.c and src/getopt.c, and fix getopt() declarations in src/getopt.h to match the prototypes in <stdlib.h> and <unistd.h>.
Upstream: https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html
---
v1 -> v2:
- Add Upstream: tag with link to bug-make mailing list (Marcus)
- Include specific GCC 15 error log in commit message
- Improve commit description with more technical context
- Update patch headers to standard format
--- ...ing-prototypes-for-getenv-and-getopt.patch | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch new file +70 -0
@@ -0,0 +1,70 @@ +From b64b62d00cb64b62d00cb64b62d00cb64b62d00c Mon Sep 17 00:00:00:00 2001 +From: Shubham Chakraborty <[email protected]> +Date: Sat, 21 Feb 2026 12:00:00 +0000 +Subject: [PATCH] fix conflicting prototypes for getenv and getopt + +GCC 15 defaults to C23, which rejects old-style K&R empty parameter +list declarations that conflict with typed prototypes in system headers. + +Fix getenv() declarations in lib/fnmatch.c and src/getopt.c, and +fix getopt() declarations in src/getopt.h to match the prototypes +in <stdlib.h> and <unistd.h>. + +This fixes build errors like: +error: conflicting types for 'getenv'; have 'char *(void)' + +Upstream: https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html +Signed-off-by: Shubham Chakraborty <[email protected]> +--- + lib/fnmatch.c | 2 +- + src/getopt.c | 2 +- + src/getopt.h | 4 ++-- + 3 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/lib/fnmatch.c b/lib/fnmatch.c +--- a/lib/fnmatch.c ++++ b/lib/fnmatch.c +@@ -121,7 +121,7 @@ + whose names are inconsistent. */ + + # if !defined _LIBC && !defined getenv +-extern char *getenv (); ++extern char *getenv (const char *__name); + # endif + + # ifndef errno +diff --git a/src/getopt.c b/src/getopt.c +--- a/src/getopt.c ++++ b/src/getopt.c +@@ -202,7 +202,7 @@ + whose names are inconsistent. */ + + #ifndef getenv +-extern char *getenv (); ++extern char *getenv (const char *__name); + #endif + + static char * +diff --git a/src/getopt.h b/src/getopt.h +--- a/src/getopt.h ++++ b/src/getopt.h +@@ -102,7 +102,7 @@ + errors, only prototype getopt for the GNU C library. */ + extern int getopt (int argc, char *const *argv, const char *shortopts); + #else /* not __GNU_LIBRARY__ */ +-extern int getopt (); ++extern int getopt (int argc, char *const *argv, const char *shortopts); + #endif /* __GNU_LIBRARY__ */ + extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +@@ -116,7 +116,7 @@ + const struct option *longopts, int *longind, + int long_only); + #else /* not __STDC__ */ +-extern int getopt (); ++extern int getopt (int argc, char *const *argv, const char *shortopts); + extern int getopt_long (); + extern int getopt_long_only (); + +-- +2.43.0
Signature · 6 lines
2.53.0 _______________________________________________ buildroot mailing list [email protected] https://lists.buildroot.org/mailman/listinfo/buildroot
Hi Shubham
Quoted 40 lines · Shubham Chakraborty
GCC 15 defaults to C23, which rejects old-style K&R empty parameter list declarations that conflict with typed prototypes in system headers. This is particularly visible when using non-glibc C libraries (e.g. musl).
Fixes:
lib/fnmatch.c:124:14: error: conflicting types for 'getenv'; have 'char *(void)'| 124 | extern char *getenv (); | | ^~~~~~Fix
getenv()declarations inlib/fnmatch.candsrc/getopt.c, and fixgetopt()declarations insrc/getopt.hto match the prototypes in <stdlib.h> and <unistd.h>.Upstream: https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html
Signed-off-by Shubham Chakraborty <[email protected]>---
v1 -> v2:
- Add Upstream: tag with link to bug-make mailing list (Marcus)
- Include specific GCC 15 error log in commit message
- Improve commit description with more technical context
- Update patch headers to standard format--- ...ing-prototypes-for-getenv-and-getopt.patch | 70 +++++++++++++++++++ 1 file changed, 70 insertions(+)create mode 100644
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patchpackage/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch new file +6
-0@@ -0,0 +1,70 @@ +From b64b62d00cb64b62d00cb64b62d00cb64b62d00c Mon Sep 17 00:00:00:00 2001 +From: Shubham Chakraborty <[email protected]> +Date: Sat, 21 Feb 2026 12:00:00 +0000 +Subject: [PATCH] fix conflicting prototypes for getenv and getopt + +GCC 15 defaults to C23, which rejects old-style K&R empty parameter
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch line 16
Quoted 10 lines
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch new file +10
-0+list declarations that conflict with typed prototypes in system headers. + +Fix getenv() declarations in lib/fnmatch.c and src/getopt.c, and +fix getopt() declarations in src/getopt.h to match the prototypes +in <stdlib.h> and <unistd.h>. + +This fixes build errors like: +error: conflicting types for 'getenv'; have 'char *(void)' + +Upstream: https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html
You cannot use the upstream tag for a submission that's different from what was submitted upstream, including the authorship of the submission. At least not without any explanation of the differences.
If you adapted/expanded the upstream patch, the authorship of the original submission needs to be kept and reason for the changes explained. If this is your own patch, the authorship is correct but the upstream tag cannot be used. (You could still link to the submission in the commit message) As-is, it's really not clear what should happen if the upstream patch gets applied, could this patch be dropped or would the problem then not be fully fixed?
I cannot apply this as-is, even if it fixes the underlying problem. The patch origin authorship and upstream status need to be clear.
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch line 18
Quoted 2 lines
package/make/0001-fix-conflicting-prototypes-for-getenv-and-getopt.patch new file +2
-0+Signed-off-by: Shubham Chakraborty <[email protected]> +---
Best,
Marcus
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot