* [Buildroot] [PATCH] package/libmpeg2: fix build with GCC 15
@ 2026-02-21 8:14 Shubham Chakraborty
2026-05-31 12:10 ` Thomas Petazzoni via buildroot
2026-08-10 16:51 ` [Buildroot] [PATCH v2] " Shubham Chakraborty
0 siblings, 2 replies; 6+ messages in thread
From: Shubham Chakraborty @ 2026-02-21 8:14 UTC (permalink / raw)
To: buildroot; +Cc: Shubham Chakraborty
GCC 15 defaults to C23, which no longer allows K&R-style empty parameter
list declarations. Fix getopt(), getopt_long(), getopt_long_only(), and
_getopt_internal() in src/getopt.h and src/getopt.c to use explicit
typed prototypes. Also convert K&R-style function definitions to modern
prototype style and replace the bare getenv() declaration with a proper
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
.../libmpeg2/0005-fix-getopt-modern-c.patch | 108 ++++++++++++++++++
1 file changed, 108 insertions(+)
create mode 100644 package/libmpeg2/0005-fix-getopt-modern-c.patch
diff --git a/package/libmpeg2/0005-fix-getopt-modern-c.patch b/package/libmpeg2/0005-fix-getopt-modern-c.patch
new file mode 100644
index 0000000000..a95e443df2
--- /dev/null
+++ b/package/libmpeg2/0005-fix-getopt-modern-c.patch
@@ -0,0 +1,108 @@
+--- a/src/getopt.h
++++ b/src/getopt.h
+@@ -133,7 +133,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__ */
+
+ # ifndef __need_getopt
+@@ -150,12 +150,12 @@
+ int __long_only);
+ # endif
+ #else /* not __STDC__ */
+-extern int getopt ();
++extern int getopt (int __argc, char *const *__argv, const char *__shortopts);
+ # ifndef __need_getopt
+-extern int getopt_long ();
+-extern int getopt_long_only ();
++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, int *__longind);
+
+-extern int _getopt_internal ();
++extern int _getopt_internal (int __argc, char *const *__argv, const char *__shortopts, const struct option *__longopts, int *__longind, int __long_only);
+ # endif
+ #endif /* __STDC__ */
+
+--- a/src/getopt.c
++++ b/src/getopt.c
+@@ -207,24 +207,19 @@
+ /* Avoid depending on library functions or files
+ whose names are inconsistent. */
+
+-#ifndef getenv
+-extern char *getenv ();
+-#endif
++#include <stdlib.h>
+
+ static char *
+-my_index (str, chr)
+- const char *str;
+- int chr;
++my_index (const char *str, int chr)
+ {
+ while (*str)
+ {
+ if (*str == chr)
+- return (char *) str;
++ return (char *) str;
+ str++;
+ }
+ return 0;
+ }
+-
+ /* If using GCC, we can safely declare strlen this way.
+ If not using GCC, it is ok not to declare it. */
+ #ifdef __GNUC__
+@@ -302,8 +297,7 @@
+ #endif
+
+ static void
+-exchange (argv)
+- char **argv;
++exchange (char **argv)
+ {
+ int bottom = first_nonopt;
+ int middle = last_nonopt;
+@@ -387,10 +381,7 @@
+ static const char *_getopt_initialize (int, char *const *, const char *);
+ #endif
+ static const char *
+-_getopt_initialize (argc, argv, optstring)
+- int argc;
+- char *const *argv;
+- const char *optstring;
++_getopt_initialize (int argc, char *const *argv, const char *optstring)
+ {
+ /* Start processing options with ARGV-element 1 (since ARGV-element 0
+ is the program name); the sequence of previously skipped
+@@ -509,13 +500,8 @@
+ long-named options. */
+
+ int
+-_getopt_internal (argc, argv, optstring, longopts, longind, long_only)
+- int argc;
+- char *const *argv;
+- const char *optstring;
+- const struct option *longopts;
+- int *longind;
+- int long_only;
++_getopt_internal (int argc, char *const *argv, const char *optstring,
++ const struct option *longopts, int *longind, int long_only)
+ {
+ int print_errors = opterr;
+ if (optstring[0] == ':')
+@@ -969,10 +955,7 @@
+ }
+
+ int
+-getopt (argc, argv, optstring)
+- int argc;
+- char *const *argv;
+- const char *optstring;
++getopt (int argc, char *const *argv, const char *optstring)
+ {
+ return _getopt_internal (argc, argv, optstring,
+ (const struct option *) 0,
--
2.53.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH] package/libmpeg2: fix build with GCC 15
2026-02-21 8:14 [Buildroot] [PATCH] package/libmpeg2: fix build with GCC 15 Shubham Chakraborty
@ 2026-05-31 12:10 ` Thomas Petazzoni via buildroot
2026-08-10 16:51 ` [Buildroot] [PATCH v2] " Shubham Chakraborty
1 sibling, 0 replies; 6+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-05-31 12:10 UTC (permalink / raw)
To: Shubham Chakraborty; +Cc: buildroot
On Sat, Feb 21, 2026 at 01:44:58PM +0530, Shubham Chakraborty wrote:
> GCC 15 defaults to C23, which no longer allows K&R-style empty parameter
> list declarations. Fix getopt(), getopt_long(), getopt_long_only(), and
> _getopt_internal() in src/getopt.h and src/getopt.c to use explicit
> typed prototypes. Also convert K&R-style function definitions to modern
> prototype style and replace the bare getenv() declaration with a proper
>
> Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
When fixing build issues, please either a reference to an autobuilder
failure being fixed (for example in this case
https://autobuild.buildroot.net/results/53d/53daf0b4bd8b476252ca219e53a966405ece7e51/build-end.log)
or if none is available, a defconfig that exhibits the issue.
> diff --git a/package/libmpeg2/0005-fix-getopt-modern-c.patch b/package/libmpeg2/0005-fix-getopt-modern-c.patch
> new file mode 100644
> index 0000000000..a95e443df2
> --- /dev/null
> +++ b/package/libmpeg2/0005-fix-getopt-modern-c.patch
> @@ -0,0 +1,108 @@
> +--- a/src/getopt.h
> ++++ b/src/getopt.h
Patches must have a commit log, a Signed-off-by line, and an Upstream:
tag showing that they have been submitted upstream.
The Git repository is at https://code.videolan.org/videolan/libmpeg2.
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] 6+ messages in thread
* [Buildroot] [PATCH v2] package/libmpeg2: fix build with GCC 15
2026-02-21 8:14 [Buildroot] [PATCH] package/libmpeg2: fix build with GCC 15 Shubham Chakraborty
2026-05-31 12:10 ` Thomas Petazzoni via buildroot
@ 2026-08-10 16:51 ` Shubham Chakraborty
2026-09-18 22:09 ` Thomas Petazzoni via buildroot
` (2 more replies)
1 sibling, 3 replies; 6+ messages in thread
From: Shubham Chakraborty @ 2026-08-10 16:51 UTC (permalink / raw)
To: buildroot; +Cc: Shubham Chakraborty
GCC 15 defaults to C23, which no longer supports K&R-style empty
parameter list declarations used in libmpeg2. To avoid carrying intrusive
patches that rewrite legacy K&R-style declarations, pass -std=gnu89
to CFLAGS to restore the older compiler behavior.
Fixes: http://autobuild.buildroot.net/results/53d/53daf0b4bd8b476252ca219e53a966405ece7e51
Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
---
Changes v1 -> v2:
- Dropped C source patch (0005-fix-getopt-modern-c.patch) and instead
fixed the issue by appending -std=gnu89 to CFLAGS.
- Added Fixes tag pointing to the autobuilder failure.
package/libmpeg2/libmpeg2.mk | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/package/libmpeg2/libmpeg2.mk b/package/libmpeg2/libmpeg2.mk
index ec23dff57b..dd3008987e 100644
--- a/package/libmpeg2/libmpeg2.mk
+++ b/package/libmpeg2/libmpeg2.mk
@@ -16,6 +16,10 @@ LIBMPEG2_INSTALL_STAGING = YES
LIBMPEG2_AUTORECONF = YES
LIBMPEG2_CONF_OPTS = --without-x --disable-directx
+# GCC 15 defaults to C23 which no longer allows K&R style function
+# declarations, so force it to use gnu89 standard.
+LIBMPEG2_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -std=gnu89"
+
LIBMPEG2_CPE_ID_VENDOR = videolan
ifeq ($(BR2_PACKAGE_SDL),y)
--
2.55.0
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Buildroot] [PATCH v2] package/libmpeg2: fix build with GCC 15
2026-08-10 16:51 ` [Buildroot] [PATCH v2] " Shubham Chakraborty
@ 2026-09-18 22:09 ` Thomas Petazzoni via buildroot
2026-09-20 10:12 ` Thomas Petazzoni via buildroot
2026-09-25 14:43 ` Raphaël Mélotte via buildroot
2 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-09-18 22:09 UTC (permalink / raw)
To: Shubham Chakraborty; +Cc: buildroot
On Mon, Aug 10, 2026 at 10:21:05PM +0530, Shubham Chakraborty wrote:
> GCC 15 defaults to C23, which no longer supports K&R-style empty
> parameter list declarations used in libmpeg2. To avoid carrying intrusive
> patches that rewrite legacy K&R-style declarations, pass -std=gnu89
> to CFLAGS to restore the older compiler behavior.
>
> Fixes: http://autobuild.buildroot.net/results/53d/53daf0b4bd8b476252ca219e53a966405ece7e51
>
> Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
Thanks a lot, but I'm not able to reproduce the build issue in the
first place. The following defconfig uses gcc15 to build libmpeg2, and
it builds just fine:
BR2_aarch64=y
BR2_TOOLCHAIN_EXTERNAL=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM=y
BR2_TOOLCHAIN_EXTERNAL_DOWNLOAD=y
BR2_TOOLCHAIN_EXTERNAL_URL="https://toolchains.bootlin.com/downloads/releases/toolchains/aarch64/tarballs/aarch64--glibc--stable-2026.08-1.tar.xz"
BR2_TOOLCHAIN_EXTERNAL_GCC_15=y
BR2_TOOLCHAIN_EXTERNAL_HEADERS_5_10=y
BR2_TOOLCHAIN_EXTERNAL_CUSTOM_GLIBC=y
# BR2_TOOLCHAIN_EXTERNAL_INET_RPC is not set
BR2_TOOLCHAIN_EXTERNAL_CXX=y
BR2_TOOLCHAIN_EXTERNAL_OPENMP=y
BR2_PACKAGE_LIBMPEG2=y
So... are you sure the problem is simply gcc 15.x? Or are there other
conditions/reasons?
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] 6+ messages in thread
* Re: [Buildroot] [PATCH v2] package/libmpeg2: fix build with GCC 15
2026-08-10 16:51 ` [Buildroot] [PATCH v2] " Shubham Chakraborty
2026-09-18 22:09 ` Thomas Petazzoni via buildroot
@ 2026-09-20 10:12 ` Thomas Petazzoni via buildroot
2026-09-25 14:43 ` Raphaël Mélotte via buildroot
2 siblings, 0 replies; 6+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-09-20 10:12 UTC (permalink / raw)
To: Shubham Chakraborty; +Cc: buildroot
On Mon, Aug 10, 2026 at 10:21:05PM +0530, Shubham Chakraborty wrote:
> GCC 15 defaults to C23, which no longer supports K&R-style empty
> parameter list declarations used in libmpeg2. To avoid carrying intrusive
> patches that rewrite legacy K&R-style declarations, pass -std=gnu89
> to CFLAGS to restore the older compiler behavior.
>
> Fixes: http://autobuild.buildroot.net/results/53d/53daf0b4bd8b476252ca219e53a966405ece7e51
>
> Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
Thanks to the input from Bernd, I was able to reproduce the
issue. Except that the issue also occurred with GCC 14.x, which made
your commit log and comment in the code not quite accurate.
Turns out that GCC 15.x indeed defaults to C23, causing the problem.
But since the bump of autoconf to 2.73, when GCC 14.x is used,
autoconf injects -std=c23 in the CFLAGS... also causing the
problem. There are even autobuilder failures reported for this issue.
So I applied your patch, but after rewriting the commit log and
changing the comment in libmpeg2.mk.
Thanks!
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] 6+ messages in thread
* Re: [Buildroot] [PATCH v2] package/libmpeg2: fix build with GCC 15
2026-08-10 16:51 ` [Buildroot] [PATCH v2] " Shubham Chakraborty
2026-09-18 22:09 ` Thomas Petazzoni via buildroot
2026-09-20 10:12 ` Thomas Petazzoni via buildroot
@ 2026-09-25 14:43 ` Raphaël Mélotte via buildroot
2 siblings, 0 replies; 6+ messages in thread
From: Raphaël Mélotte via buildroot @ 2026-09-25 14:43 UTC (permalink / raw)
To: buildroot, Shubham Chakraborty; +Cc: Raphaël Mélotte
In reply of:
> GCC 15 defaults to C23, which no longer supports K&R-style empty
> parameter list declarations used in libmpeg2. To avoid carrying intrusive
> patches that rewrite legacy K&R-style declarations, pass -std=gnu89
> to CFLAGS to restore the older compiler behavior.
>
> Fixes: http://autobuild.buildroot.net/results/53d/53daf0b4bd8b476252ca219e53a966405ece7e51
>
> Signed-off-by: Shubham Chakraborty <chakrabortyshubham66@gmail.com>
Applied to 2025.02.x, 2026.08.x. Thanks
> ---
> Changes v1 -> v2:
> - Dropped C source patch (0005-fix-getopt-modern-c.patch) and instead
> fixed the issue by appending -std=gnu89 to CFLAGS.
> - Added Fixes tag pointing to the autobuilder failure.
>
> package/libmpeg2/libmpeg2.mk | 4 ++++
> 1 file changed, 4 insertions(+)
>
> diff --git a/package/libmpeg2/libmpeg2.mk b/package/libmpeg2/libmpeg2.mk
> index ec23dff57b..dd3008987e 100644
> --- a/package/libmpeg2/libmpeg2.mk
> +++ b/package/libmpeg2/libmpeg2.mk
> @@ -16,6 +16,10 @@ LIBMPEG2_INSTALL_STAGING = YES
> LIBMPEG2_AUTORECONF = YES
> LIBMPEG2_CONF_OPTS = --without-x --disable-directx
>
> +# GCC 15 defaults to C23 which no longer allows K&R style function
> +# declarations, so force it to use gnu89 standard.
> +LIBMPEG2_CONF_ENV += CFLAGS="$(TARGET_CFLAGS) -std=gnu89"
> +
> LIBMPEG2_CPE_ID_VENDOR = videolan
>
> ifeq ($(BR2_PACKAGE_SDL),y)
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2026-09-25 14:43 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-21 8:14 [Buildroot] [PATCH] package/libmpeg2: fix build with GCC 15 Shubham Chakraborty
2026-05-31 12:10 ` Thomas Petazzoni via buildroot
2026-08-10 16:51 ` [Buildroot] [PATCH v2] " Shubham Chakraborty
2026-09-18 22:09 ` Thomas Petazzoni via buildroot
2026-09-20 10:12 ` Thomas Petazzoni via buildroot
2026-09-25 14:43 ` Raphaël Mélotte via buildroot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.