From cc060436285ded4b51b99f653ef1769c58021f10 Mon Sep 17 00:00:00 2001 From: Yureka Date: Mon, 22 Dec 2025 20:50:58 +0100 Subject: [PATCH] gnumake: fix build with musl The patch for getopt.{c,h} was sent to the mailing list in March and did not get any replies: https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html I added the second patch fixing the same issue in lib/fnmatch.c. --- .../patches/0001-No-impure-bin-sh.patch | 2 +- .../patches/0002-Remove-impure-dirs.patch | 6 +-- ...ch-for-a-C-compiler-and-set-MAKE_CXX.patch | 6 +-- ...004-Fix-signatures-for-getenv-getopt.patch | 50 +++++++++++++++++++ ...005-Fix-signatures-for-getenv-getopt.patch | 34 +++++++++++++ 5 files changed, 91 insertions(+), 7 deletions(-) create mode 100644 pkgs/development/tools/build-managers/gnumake/patches/0004-Fix-signatures-for-getenv-getopt.patch create mode 100644 pkgs/development/tools/build-managers/gnumake/patches/0005-Fix-signatures-for-getenv-getopt.patch diff --git a/pkgs/development/tools/build-managers/gnumake/patches/0001-No-impure-bin-sh.patch b/pkgs/development/tools/build-managers/gnumake/patches/0001-No-impure-bin-sh.patch index b553b31d997d..cd30fd38be02 100644 --- a/pkgs/development/tools/build-managers/gnumake/patches/0001-No-impure-bin-sh.patch +++ b/pkgs/development/tools/build-managers/gnumake/patches/0001-No-impure-bin-sh.patch @@ -1,7 +1,7 @@ From 532276a537fbfc08c946c9f808f1b0bb54e16523 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 24 Apr 2021 10:11:40 +0200 -Subject: [PATCH 1/3] No impure bin sh +Subject: [PATCH 1/5] No impure bin sh default_shell is used to populuate default shell used to execute jobs. Unless SHELL is set to a different value this would be /bin/sh. diff --git a/pkgs/development/tools/build-managers/gnumake/patches/0002-Remove-impure-dirs.patch b/pkgs/development/tools/build-managers/gnumake/patches/0002-Remove-impure-dirs.patch index 8ba6b743176f..49f6e3543e7a 100644 --- a/pkgs/development/tools/build-managers/gnumake/patches/0002-Remove-impure-dirs.patch +++ b/pkgs/development/tools/build-managers/gnumake/patches/0002-Remove-impure-dirs.patch @@ -1,7 +1,7 @@ -From 2db52008be2e2d504889f4f19318c2ba5a2a4797 Mon Sep 17 00:00:00 2001 +From 99dcf18f8c66c25e17e0b84c005b03000312eb8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Sat, 24 Apr 2021 10:20:16 +0200 -Subject: [PATCH 2/3] Remove impure dirs +Subject: [PATCH 2/5] Remove impure dirs Purity: don't look for library dependencies (of the form `-lfoo') in /lib and /usr/lib. It's a stupid feature anyway. Likewise, when @@ -40,5 +40,5 @@ index fe67ab28..1b76560c 100644 #if defined(WINDOWS32) && !defined(LIBDIR) /* -- -2.44.1 +2.51.2 diff --git a/pkgs/development/tools/build-managers/gnumake/patches/0003-Do-not-search-for-a-C-compiler-and-set-MAKE_CXX.patch b/pkgs/development/tools/build-managers/gnumake/patches/0003-Do-not-search-for-a-C-compiler-and-set-MAKE_CXX.patch index cb0ce4defb45..a48b6192d2b1 100644 --- a/pkgs/development/tools/build-managers/gnumake/patches/0003-Do-not-search-for-a-C-compiler-and-set-MAKE_CXX.patch +++ b/pkgs/development/tools/build-managers/gnumake/patches/0003-Do-not-search-for-a-C-compiler-and-set-MAKE_CXX.patch @@ -1,7 +1,7 @@ -From 3317b3a78666e6073c63f62a322176e3dc680461 Mon Sep 17 00:00:00 2001 +From e63470a43889be3f61c71ca31e57b4e3c3da5961 Mon Sep 17 00:00:00 2001 From: Ivan Trubach Date: Sat, 17 Aug 2024 22:35:03 +0300 -Subject: [PATCH 3/3] Do not search for a C++ compiler and set MAKE_CXX +Subject: [PATCH 3/5] Do not search for a C++ compiler and set MAKE_CXX MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit @@ -79,5 +79,5 @@ index e396269b..78ba402f 100644 /* This expands to $(CO) $(COFLAGS) $< $@ if $@ does not exist, and to the empty string if $@ does exist. */ -- -2.44.1 +2.51.2 diff --git a/pkgs/development/tools/build-managers/gnumake/patches/0004-Fix-signatures-for-getenv-getopt.patch b/pkgs/development/tools/build-managers/gnumake/patches/0004-Fix-signatures-for-getenv-getopt.patch new file mode 100644 index 000000000000..f37b7a49e341 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/patches/0004-Fix-signatures-for-getenv-getopt.patch @@ -0,0 +1,50 @@ +From 776f707b5bb67d4c0c15f981b5a1b6d7f3a9cebc Mon Sep 17 00:00:00 2001 +From: Khem Raj +Date: Sat, 22 Mar 2025 14:24:57 -0700 +Subject: [PATCH 4/5] Fix signatures for getenv/getopt + +GCC-15 complains about missing parameters, this gets found +out when using non-glibc ( e.g. musl ) C library + +Fixes +lib/fnmatch.c:124:14: error: conflicting types for 'getenv'; have 'char *(void)' +| 124 | extern char *getenv (); +| | ^~~~~~ + +src/getopt.c: Define parameters of getenv() and getopt(). +src/getopt.h: Ditto. +--- +Link: https://lists.gnu.org/archive/html/bug-make/2025-03/msg00032.html + src/getopt.c | 2 +- + src/getopt.h | 2 +- + 2 files changed, 2 insertions(+), 2 deletions(-) + +diff --git a/src/getopt.c b/src/getopt.c +index 7a792de8..76251ccb 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 df18ceeb..d8bb2263 100644 +--- a/src/getopt.h ++++ b/src/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, char * const*, const char *); + #endif /* __GNU_LIBRARY__ */ + extern int getopt_long (int argc, char *const *argv, const char *shortopts, + const struct option *longopts, int *longind); +-- +2.51.2 + diff --git a/pkgs/development/tools/build-managers/gnumake/patches/0005-Fix-signatures-for-getenv-getopt.patch b/pkgs/development/tools/build-managers/gnumake/patches/0005-Fix-signatures-for-getenv-getopt.patch new file mode 100644 index 000000000000..c594ba27c2a9 --- /dev/null +++ b/pkgs/development/tools/build-managers/gnumake/patches/0005-Fix-signatures-for-getenv-getopt.patch @@ -0,0 +1,34 @@ +From a4169ae60a7cb2c2bc788daa2c91441cc807acbc Mon Sep 17 00:00:00 2001 +From: Yureka +Date: Mon, 22 Dec 2025 20:53:31 +0100 +Subject: [PATCH 5/5] Fix signatures for getenv/getopt + +As the previous commit, this fixes GCC-15 complaining about mismatching +definitions with non-glibc (musl) C library. + +Fixes +lib/fnmatch.c:124:14: error: conflicting types for 'getenv'; have 'char *(void)' +| 124 | extern char *getenv (); +| | ^~~~~~ + +lib/fnmatch.c: Define parameters of getenv() +--- + lib/fnmatch.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/lib/fnmatch.c b/lib/fnmatch.c +index 01da376b..cb1c856b 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 +-- +2.51.2 +