* [Buildroot] [PATCH v4] package/which: fix getopt prototype for GCC 15
@ 2026-03-11 9:27 Shubham Chakraborty
2026-05-31 6:09 ` Thomas Petazzoni via buildroot
0 siblings, 1 reply; 3+ messages in thread
From: Shubham Chakraborty @ 2026-03-11 9:27 UTC (permalink / raw)
To: buildroot; +Cc: thomas.petazzoni, Shubham Chakraborty
Older C standards allowed empty parentheses in function declarations,
but GCC 15 enforces C23 semantics where extern int getopt() is
equivalent to extern int getopt(void), which conflicts with the
typed prototype provided by system headers (e.g. musl's unistd.h).
Fix by providing the full prototype in the non-GNU fallback branch,
matching the standard getopt() signature.
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
Changes v3 -> v4:
- Fixed patch submission: now correctly adds patch file as new file
instead of showing modifications to existing patch file
- Improved commit message clarity
Changes v2 -> v3:
- Added proper patch header with description and Signed-off-by
- Identified GCC 15 (not musl) as root cause
Changes v1 -> v2:
- Fixed commit message format
Apologies for the confusion in v3 - still learning the patch submission
process. This version should be correct.
---
...hich-fix-getopt-prototype-for-GCC-15.patch | 34 +++++++++++++++++++
1 file changed, 34 insertions(+)
create mode 100644 package/which/0001-package-which-fix-getopt-prototype-for-GCC-15.patch
diff --git a/package/which/0001-package-which-fix-getopt-prototype-for-GCC-15.patch b/package/which/0001-package-which-fix-getopt-prototype-for-GCC-15.patch
new file mode 100644
index 0000000000..afae321ce7
--- /dev/null
+++ b/package/which/0001-package-which-fix-getopt-prototype-for-GCC-15.patch
@@ -0,0 +1,34 @@
+From f1d07e5630628a7d218936b3ac3292daf6a7ba77 Mon Sep 17 00:00:00 2001
+From: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
+Date: Mon, 9 Mar 2026 21:43:58 +0530
+Subject: [PATCH] package/which: fix getopt prototype for GCC 15
+
+Older C standards allowed empty parentheses in function declarations,
+but GCC 15 enforces C23 semantics where extern int getopt() is
+equivalent to extern int getopt(void), which conflicts with the
+typed prototype provided by system headers (e.g. musl's unistd.h).
+
+Fix by providing the full prototype in the non-GNU fallback branch,
+matching the standard getopt() signature.
+
+Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
+---
+ getopt.h | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+
+diff --git a/getopt.h b/getopt.h
+index f080053..081334f 100644
+--- a/getopt.h
++++ b/getopt.h
+@@ -102,7 +102,7 @@ struct option {
+ 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);
+ extern int getopt_long_only(int argc, char *const *argv, const char *shortopts, const struct option *longopts,
+--
+2.53.0
+
--
2.53.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH v4] package/which: fix getopt prototype for GCC 15
2026-03-11 9:27 [Buildroot] [PATCH v4] package/which: fix getopt prototype for GCC 15 Shubham Chakraborty
@ 2026-05-31 6:09 ` Thomas Petazzoni via buildroot
[not found] ` <ahvu3dxZGAj2X-lO@fedora>
0 siblings, 1 reply; 3+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-05-31 6:09 UTC (permalink / raw)
To: Shubham Chakraborty; +Cc: buildroot
On Wed, Mar 11, 2026 at 02:57:13PM +0530, Shubham Chakraborty wrote:
> Older C standards allowed empty parentheses in function declarations,
> but GCC 15 enforces C23 semantics where extern int getopt() is
> equivalent to extern int getopt(void), which conflicts with the
> typed prototype provided by system headers (e.g. musl's unistd.h).
>
> Fix by providing the full prototype in the non-GNU fallback branch,
> matching the standard getopt() signature.
>
> Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
Which configuration fails to build? We have no failures in our
autobuilders, and I could not reproduce.
> ---
> ...hich-fix-getopt-prototype-for-GCC-15.patch | 34 +++++++++++++++++++
> 1 file changed, 34 insertions(+)
> create mode 100644 package/which/0001-package-which-fix-getopt-prototype-for-GCC-15.patch
>
> diff --git a/package/which/0001-package-which-fix-getopt-prototype-for-GCC-15.patch b/package/which/0001-package-which-fix-getopt-prototype-for-GCC-15.patch
> new file mode 100644
> index 0000000000..afae321ce7
> --- /dev/null
> +++ b/package/which/0001-package-which-fix-getopt-prototype-for-GCC-15.patch
> @@ -0,0 +1,34 @@
> +From f1d07e5630628a7d218936b3ac3292daf6a7ba77 Mon Sep 17 00:00:00 2001
> +From: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
> +Date: Mon, 9 Mar 2026 21:43:58 +0530
> +Subject: [PATCH] package/which: fix getopt prototype for GCC 15
> +
> +Older C standards allowed empty parentheses in function declarations,
> +but GCC 15 enforces C23 semantics where extern int getopt() is
> +equivalent to extern int getopt(void), which conflicts with the
> +typed prototype provided by system headers (e.g. musl's unistd.h).
> +
> +Fix by providing the full prototype in the non-GNU fallback branch,
> +matching the standard getopt() signature.
> +
> +Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
We only accept patches that are submitted upstream and therefore carry
and Upstream: tag pointing to the upstream submission.
Best regards,
Thomas
--
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Buildroot] [PATCH v4] package/which: fix getopt prototype for GCC 15
[not found] ` <ahvu3dxZGAj2X-lO@fedora>
@ 2026-06-01 15:41 ` Shubham Chakraborty
0 siblings, 0 replies; 3+ messages in thread
From: Shubham Chakraborty @ 2026-06-01 15:41 UTC (permalink / raw)
To: Thomas Petazzoni, Buildroot List
[-- Attachment #1.1: Type: text/plain, Size: 527 bytes --]
Hi Thomas,
Upon further investigation, I found out that patching the source c file is
not the only way to resolve this build error.
The issue can also be fixed by passing a compiler flag to set the C
standard version to gnu17:
WHICH_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -std=gnu17"
Could you please guide me on which approach would be preferred in Buildroot
context?
Should I proceed with the source code patch, or would it be better to
implement this configuration change in the .mk file instead?
Best regards,
Shubham
[-- Attachment #1.2: Type: text/html, Size: 835 bytes --]
[-- Attachment #2: Type: text/plain, Size: 150 bytes --]
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-06-01 15:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11 9:27 [Buildroot] [PATCH v4] package/which: fix getopt prototype for GCC 15 Shubham Chakraborty
2026-05-31 6:09 ` Thomas Petazzoni via buildroot
[not found] ` <ahvu3dxZGAj2X-lO@fedora>
2026-06-01 15:41 ` Shubham Chakraborty
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox