Skip to contentSkip to conversation

package/make: fix build with musl and gcc-15.x

PATCH Applied Daniel Houck 2 participants 7 messages May 3 – May 15

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 package/make: fix build with musl and gcc-15.x

It builds fine with glibc and gcc-15.x but conditionally includes code with musl that fails. See eg. commit 999fb19d4b.

Fixes #176. See also https://savannah.gnu.org/bugs/index.php?68302

---
 package/make/make.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/make/make.mk +8 -0
index 1d1a976eb4..7120548bcc 100644
@@ -14,6 +14,14 @@ MAKE_CPE_ID_VENDOR = gnu
 
 MAKE_CONF_OPTS = --without-guile
 
+# Make doesn't build with C23 in some configurations; see upstream #68302
+# gcc-15 defaults to -std=gnu23, so we force "-std=gnu17" for gcc version
+# supporting it. Earlier gcc versions will work, since they are using the
+# older standard.
+ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_8),y)
+MAKE_CONF_ENV = CFLAGS="$(TARGET_CFLAGS) -std=gnu17"
+endif
+
 # Disable the 'load' operation for static builds since it needs dlopen
 ifeq ($(BR2_STATIC_LIBS),y)
 MAKE_CONF_OPTS += --disable-load
Signature · 6 lines
2.54.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#1 lore raw

Hi Daniel,
thanks for the patch.

Quoted 2 lines · Daniel Houck

It builds fine with glibc and gcc-15.x but conditionally includes code with musl that fails. See eg. commit 999fb19d4b.

Alpine[1] and Gentoo[2][3] have a "proper" fix for this (meaning the fix the offending code instead of changing the std level.

There's also been a submission to the make mailing list[4], but without any reaction and only containing two of the three fixes the other patches have.

I think this is the better solution, even though it means carrying a patch until make eventually might fix this upstream.

I think we can just use the gentoo patch as-is I think? What do you think?

Quoted 5 lines

Fixes #176. See also https://savannah.gnu.org/bugs/index.php?68302

---

Best,
Marcus

[1] https://github.com/alpinelinux/aports/blob/master/main/make/getopt-gcc15.patch
[2] https://bugs.gentoo.org/945968
[3] https://codeberg.org/gentoo/gentoo/src/branch/master/dev-build/make/files/make-4.4.1-c23.patch
[4] https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#2 lore raw

Hi Marcus,

Quoted 3 lines · Marcus Hoffmann

Alpine[1] and Gentoo[2][3] have a "proper" fix for this (meaning the fix the offending code instead of changing the std level.

There's also been a submission to the make mailing list[4], but without any reaction and only containing two of the three fixes the other patches have.

Ah, I couldn't find any prior art, thanks for the links. I'm kind of surprised it's only three places, but a few days ago I was surprised anyone still wrote C without prototypes like that, so what do I know?

Quoted 3 lines

I think this is the better solution, even though it means carrying a patch until make eventually might fix this upstream.

I think we can just use the gentoo patch as-is I think? What do you think?Yeah that sounds good. I'll do a couple tests to make sure everything

works as expected and then send that instead.

Thanks,
Daniel

PS. This is my first time sending to a list like this that doesn't like HTML emails; everyone else I talk to is fine with them. I'm 95% sure I set up my mail client correctly, but if not, I apologize and I'll fix it for next time.
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#3 lore raw

PATCH v2 1/1 package/make: fix build with musl and gcc-15.x

In reply to Daniel Houck

Patch the parts of Make that use code invalid in C23. It wasn't included when compiling with glibc but failed to build with musl.

Fixes #176. See also https://savannah.gnu.org/bugs/index.php?68302

---
Changes v1 -> v2:
- patch make instead of using CFLAGS (suggested by Marcus)

 ...1-fix-compilation-on-musl-with-gcc15.patch | 61 +++++++++++++++++++
 1 file changed, 61 insertions(+)
 create mode 100644 package/make/0001-fix-compilation-on-musl-with-gcc15.patch
package/make/0001-fix-compilation-on-musl-with-gcc15.patch new file +61 -0
new file mode 100644
index 0000000000..aa2598df9a
@@ -0,0 +1,61 @@
+From 31bc8976fb7bfdde8b9293e6a4eb2becb29a73bc Mon Sep 17 00:00:00 2001
+From: Bobby Bingham <[email protected]>
+Date: Wed, 2 Jul 2025 18:09:28 -0500
+Subject: [PATCH] fix compilation on musl with gcc15
+
+---
+
+Patch originally from https://codeberg.org/gentoo/gentoo/raw/branch/master/dev-build/make/files/make-4.4.1-c23.patch
+
+ lib/fnmatch.c | 2 +-
+ src/getopt.c  | 2 +-
+ src/getopt.h  | 7 -------
+ 3 files changed, 2 insertions(+), 9 deletions(-)
+
+diff --git a/lib/fnmatch.c b/lib/fnmatch.c
+index 01da376..9b54022 100644
+--- a/lib/fnmatch.c
++++ b/lib/fnmatch.c
+@@ -121,7 +121,7 @@ USA.  */
+    whose names are inconsistent.  */
+ 
+ # if !defined _LIBC && !defined getenv
+-extern char *getenv ();
++extern char *getenv (const char*);
+ # endif
+ 
+ # ifndef errno
+diff --git a/src/getopt.c b/src/getopt.c
+index 7a792de..9b56abe 100644
+--- a/src/getopt.c
++++ b/src/getopt.c
+@@ -202,7 +202,7 @@ static char *posixly_correct;
+    whose names are inconsistent.  */
+ 
+ #ifndef getenv
+-extern char *getenv ();
++extern char *getenv (const char*);
+ #endif
+ 
+ static char *
+diff --git a/src/getopt.h b/src/getopt.h
+index df18cee..a6cc621 100644
+--- a/src/getopt.h
++++ b/src/getopt.h
+@@ -96,14 +96,7 @@ struct option
+ #define optional_argument	2
+ 
+ #if defined (__STDC__) && __STDC__
+-#ifdef __GNU_LIBRARY__
+-/* Many other libraries have conflicting prototypes for getopt, with
+-   differences in the consts, in stdlib.h.  To avoid compilation
+-   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 ();
+-#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,
+-- 
+2.50.0
Signature · 6 lines
2.54.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#4 lore raw

PATCH v3 1/1 package/make: fix build with musl and gcc-15.x

Patch the parts of Make that use code invalid in C23. It wasn't included when compiling with glibc but failed to build with musl.

Fixes #176. See also https://savannah.gnu.org/bugs/index.php?68302

---
Changes v3 -> v2:
- Format the patch as specified in Buildroot manual. I thought I'd done that for v2 but forgot to actually commit that change, oops.

Changes v1 -> v2:
- patch make instead of using CFLAGS (suggested by Marcus)

 ...1-fix-compilation-on-musl-with-gcc15.patch | 66 +++++++++++++++++++
 1 file changed, 66 insertions(+)
 create mode 100644 package/make/0001-fix-compilation-on-musl-with-gcc15.patch
package/make/0001-fix-compilation-on-musl-with-gcc15.patch new file +66 -0
new file mode 100644
index 0000000000..990aee0abf
@@ -0,0 +1,66 @@
+From 31bc8976fb7bfdde8b9293e6a4eb2becb29a73bc Mon Sep 17 00:00:00 2001
+From: Bobby Bingham <[email protected]>
+Date: Wed, 2 Jul 2025 18:09:28 -0500
+Subject: [PATCH] fix compilation on musl with gcc15
+
+Patch originally from https://codeberg.org/gentoo/gentoo/raw/branch/master/dev-build/make/files/make-4.4.1-c23.patch
+
+This addresses the same issues as, but is not quite identical to, the
+patch linked to as upstream.  Upstream has not acknowledged its patch in
+any way.
+
+Signed-off-by: Daniel Houck <[email protected]>
+Upstream: https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html
+---
+ lib/fnmatch.c | 2 +-
+ src/getopt.c  | 2 +-
+ src/getopt.h  | 7 -------
+ 3 files changed, 2 insertions(+), 9 deletions(-)
+
+diff --git a/lib/fnmatch.c b/lib/fnmatch.c
+index 01da376..9b54022 100644
+--- a/lib/fnmatch.c
++++ b/lib/fnmatch.c
+@@ -121,7 +121,7 @@ USA.  */
+    whose names are inconsistent.  */
+ 
+ # if !defined _LIBC && !defined getenv
+-extern char *getenv ();
++extern char *getenv (const char*);
+ # endif
+ 
+ # ifndef errno
+diff --git a/src/getopt.c b/src/getopt.c
+index 7a792de..9b56abe 100644
+--- a/src/getopt.c
++++ b/src/getopt.c
+@@ -202,7 +202,7 @@ static char *posixly_correct;
+    whose names are inconsistent.  */
+ 
+ #ifndef getenv
+-extern char *getenv ();
++extern char *getenv (const char*);
+ #endif
+ 
+ static char *
+diff --git a/src/getopt.h b/src/getopt.h
+index df18cee..a6cc621 100644
+--- a/src/getopt.h
++++ b/src/getopt.h
+@@ -96,14 +96,7 @@ struct option
+ #define optional_argument	2
+ 
+ #if defined (__STDC__) && __STDC__
+-#ifdef __GNU_LIBRARY__
+-/* Many other libraries have conflicting prototypes for getopt, with
+-   differences in the consts, in stdlib.h.  To avoid compilation
+-   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 ();
+-#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,
+-- 
+2.50.0
Signature · 6 lines
2.54.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot
#5 lore raw
Quoted 7 lines · Daniel Houck

Patch the parts of Make that use code invalid in C23. It wasn't included when compiling with glibc but failed to build with musl.

Fixes #176. See also https://savannah.gnu.org/bugs/index.php?68302

---

Applied to master, thanks!

Marcus
_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

#6 lore raw
In reply to Daniel Houck

In reply of:

Quoted 6 lines

It builds fine with glibc and gcc-15.x but conditionally includes code with musl that fails. See eg. commit 999fb19d4b.

Fixes #176. See also https://savannah.gnu.org/bugs/index.php?68302

Applied to 2026.02.x. Thanks

Quoted 30 lines
---
 package/make/make.mk | 8 ++++++++
 1 file changed, 8 insertions(+)
package/make/make.mk +8 -0
index 1d1a976eb4..7120548bcc 100644
@@ -14,6 +14,14 @@ MAKE_CPE_ID_VENDOR = gnu
 
 MAKE_CONF_OPTS = --without-guile
 
+# Make doesn't build with C23 in some configurations; see upstream #68302
+# gcc-15 defaults to -std=gnu23, so we force "-std=gnu17" for gcc version
+# supporting it. Earlier gcc versions will work, since they are using the
+# older standard.
+ifeq ($(BR2_TOOLCHAIN_GCC_AT_LEAST_8),y)
+MAKE_CONF_ENV = CFLAGS="$(TARGET_CFLAGS) -std=gnu17"
+endif
+
 # Disable the 'load' operation for static builds since it needs dlopen
 ifeq ($(BR2_STATIC_LIBS),y)
 MAKE_CONF_OPTS += --disable-load
Signature · 6 lines
2.54.0

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot

_______________________________________________
buildroot mailing list
[email protected]
https://lists.buildroot.org/mailman/listinfo/buildroot