commit:     1d042be2d8cb16f0a2c8a74611433346d2950760
Author:     NHOrus <jy6x2b32pie9 <AT> yahoo <DOT> com>
AuthorDate: Mon Feb 10 14:43:11 2025 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Thu Feb 13 12:41:19 2025 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=1d042be2

dev-util/fuzz: fix compilation on musl

Missing include for string.h, glibc transitively included strcmp
Removed different getopt definition for non-glibc situation:
we are all living in POSIX-land (Somewhat. Hopefully. Mostly.) and
definitions for getopt are the same on musl and glibc.

Closes: https://bugs.gentoo.org/944111
Closes: https://bugs.gentoo.org/934059
Signed-off-by: NHOrus <jy6x2b32pie9 <AT> yahoo.com>
Closes: https://github.com/gentoo/gentoo/pull/40514
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-util/fuzz/files/fuzz-0.6-musl.patch            | 34 ++++++++++++++++++++++
 .../{fuzz-0.6-r3.ebuild => fuzz-0.6-r4.ebuild}     |  7 +++--
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/dev-util/fuzz/files/fuzz-0.6-musl.patch 
b/dev-util/fuzz/files/fuzz-0.6-musl.patch
new file mode 100644
index 000000000000..6783e008a8a6
--- /dev/null
+++ b/dev-util/fuzz/files/fuzz-0.6-musl.patch
@@ -0,0 +1,34 @@
+Fix missing include on musl, as strcmp is not transitively included
+Remove arg-less declaration for non-glibc case: we have POSIX here,
+getopt has same prototype in glibc and in musl
+https://bugs.gentoo.org/934059
+https://bugs.gentoo.org/944111
+--- a/getopt.c
++++ b/getopt.c
+@@ -43,6 +43,7 @@
+ #endif
+ 
+ #include <stdio.h>
++#include <string.h>
+ 
+ /* Comment out all this code if we are using the GNU C Library, and are not
+    actually compiling the library itself.  This code is part of the GNU C
+--- a/getopt.h
++++ b/getopt.h
+@@ -99,14 +99,12 @@
+ #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.  */
++/* But in Gentoo we have glibc and musl, and they have same POSIX
++   definition */
+ 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,

diff --git a/dev-util/fuzz/fuzz-0.6-r3.ebuild b/dev-util/fuzz/fuzz-0.6-r4.ebuild
similarity index 84%
rename from dev-util/fuzz/fuzz-0.6-r3.ebuild
rename to dev-util/fuzz/fuzz-0.6-r4.ebuild
index b5e826d55c10..152195a2ab69 100644
--- a/dev-util/fuzz/fuzz-0.6-r3.ebuild
+++ b/dev-util/fuzz/fuzz-0.6-r4.ebuild
@@ -1,4 +1,4 @@
-# Copyright 1999-2024 Gentoo Authors
+# Copyright 1999-2025 Gentoo Authors
 # Distributed under the terms of the GNU General Public License v2
 
 EAPI=8
@@ -21,7 +21,10 @@ KEYWORDS="~amd64 ~x86"
 DEPEND="sys-libs/readline:="
 RDEPEND="${DEPEND}"
 
-PATCHES=( "${WORKDIR}"/${DEB_P}-${DEB_PR}.diff )
+PATCHES=(
+       "${WORKDIR}"/"${DEB_P}-${DEB_PR}.diff"
+       "${FILESDIR}"/"${P}-musl.patch"
+)
 
 src_prepare() {
        default

Reply via email to