gettext: fix cygwin build (#476288)

This commit is contained in:
John Ericson
2026-01-12 04:38:24 +00:00
committed by GitHub
4 changed files with 195 additions and 5 deletions
@@ -0,0 +1,67 @@
Based on https://gitweb.git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff_plain;h=c44fe03b72687c9e913727724c29bdb49c1f86e3
Backported to 5c5298c4f47bf1912f6317a938df501e680f2bcb for use in packages with older gnulibs
diff --git a/lib/string.in.h b/lib/string.in.h
index e764221168..db574ca576 100644
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -214,38 +214,58 @@ _GL_EXTERN_C void free (void *);
/* Declarations for ISO C N3322. */
#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
+# ifndef memcpy
_GL_EXTERN_C void *memcpy (void *__dest, const void *__src, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef memccpy
_GL_EXTERN_C void *memccpy (void *__dest, const void *__src, int __c, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 4)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 4);
+# endif
+# ifndef memmove
_GL_EXTERN_C void *memmove (void *__dest, const void *__src, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef strncpy
_GL_EXTERN_C char *strncpy (char *__dest, const char *__src, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef strndup
_GL_EXTERN_C char *strndup (const char *__s, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2);
+# endif
+# ifndef strncat
_GL_EXTERN_C char *strncat (char *__dest, const char *__src, size_t __n)
_GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef memcmp
_GL_EXTERN_C int memcmp (const void *__s1, const void *__s2, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef strncmp
_GL_EXTERN_C int strncmp (const char *__s1, const char *__s2, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
-# ifndef __cplusplus
+# endif
+# if !defined memchr && !defined __cplusplus
_GL_EXTERN_C void *memchr (const void *__s, int __c, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
_GL_EXTERN_C void *memrchr (const void *__s, int __c, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
# endif
+# ifndef memset
_GL_EXTERN_C void *memset (void *__s, int __c, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+# endif
+# ifndef memset_explicit
_GL_EXTERN_C void *memset_explicit (void *__s, int __c, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+# endif
#endif
+107
View File
@@ -0,0 +1,107 @@
Based on https://gitweb.git.savannah.gnu.org/gitweb/?p=gnulib.git;a=commitdiff_plain;h=c44fe03b72687c9e913727724c29bdb49c1f86e3
--- a/lib/string.in.h
+++ b/lib/string.in.h
@@ -214,63 +214,83 @@
/* Declarations for ISO C N3322. */
#if defined __GNUC__ && __GNUC__ >= 15 && !defined __clang__
+# ifndef memcpy
_GL_EXTERN_C void *memcpy (void *__dest, const void *__src, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_ATTRIBUTE_NOTHROW
-# endif
+# endif
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef memccpy
_GL_EXTERN_C void *memccpy (void *__dest, const void *__src, int __c, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_ATTRIBUTE_NOTHROW
-# endif
+# endif
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 4)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 4);
+# endif
+# ifndef memmove
_GL_EXTERN_C void *memmove (void *__dest, const void *__src, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_ATTRIBUTE_NOTHROW
-# endif
+# endif
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef strncpy
_GL_EXTERN_C char *strncpy (char *__dest, const char *__src, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_ATTRIBUTE_NOTHROW
-# endif
+# endif
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef strndup
_GL_EXTERN_C char *strndup (const char *__s, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_ATTRIBUTE_NOTHROW
-# endif
+# endif
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 2);
+# endif
+# ifndef strncat
_GL_EXTERN_C char *strncat (char *__dest, const char *__src, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_ATTRIBUTE_NOTHROW
-# endif
+# endif
_GL_ARG_NONNULL ((1)) _GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef memcmp
_GL_EXTERN_C int memcmp (const void *__s1, const void *__s2, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_ATTRIBUTE_NOTHROW
-# endif
+# endif
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
+# endif
+# ifndef strncmp
_GL_EXTERN_C int strncmp (const char *__s1, const char *__s2, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_ATTRIBUTE_NOTHROW
-# endif
+# endif
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (2, 3);
-# ifndef __cplusplus
+# endif
+# if !defined memchr && !defined __cplusplus
_GL_EXTERN_C void *memchr (const void *__s, int __c, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
_GL_EXTERN_C void *memrchr (const void *__s, int __c, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
# endif
+# ifndef memset
_GL_EXTERN_C void *memset (void *__s, int __c, size_t __n)
-# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
+# if __GLIBC__ + (__GLIBC_MINOR__ >= 2) > 2
_GL_ATTRIBUTE_NOTHROW
-# endif
+# endif
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+# endif
+# ifndef memset_explicit
_GL_EXTERN_C void *memset_explicit (void *__s, int __c, size_t __n)
_GL_ATTRIBUTE_NONNULL_IF_NONZERO (1, 3);
+# endif
#endif
+5
View File
@@ -34,6 +34,11 @@ stdenv.mkDerivation {
# do not change headers to not update all vendored build files
dontFixup = true;
passthru.patches = {
memcpy-fix = ./memcpy-fix.patch;
memcpy-fix-backport-250512 = ./memcpy-fix-backport-250512.patch;
};
meta = {
description = "Central location for code to be shared among GNU packages";
homepage = "https://www.gnu.org/software/gnulib/";
+16 -5
View File
@@ -5,6 +5,7 @@
libiconv,
bashNonInteractive,
updateAutotoolsGnuConfigScriptsHook,
gnulib,
}:
# Note: this package is used for bootstrapping fetchurl, and thus
@@ -69,12 +70,22 @@ stdenv.mkDerivation rec {
substituteInPlace gettext-tools/projects/GNOME/trigger --replace "/bin/pwd" pwd
substituteInPlace gettext-tools/src/project-id --replace "/bin/pwd" pwd
''
+ lib.optionalString stdenv.hostPlatform.isCygwin ''
sed -i -e "s/\(cldr_plurals_LDADD = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in
sed -i -e "s/\(libgettextsrc_la_LDFLAGS = \)/\\1..\/gnulib-lib\/libxml_rpl.la /" gettext-tools/src/Makefile.in
''
+ lib.optionalString stdenv.hostPlatform.isMinGW ''
sed -i "s/@GNULIB_CLOSE@/1/" */*/unistd.in.h
''
+ lib.optionalString stdenv.hostPlatform.isCygwin ''
for gnulib in \
./libtextstyle/lib \
./gettext-tools/libgettextpo \
./gettext-tools/gnulib-lib \
./gettext-runtime/libasprintf/gnulib-lib \
./gettext-runtime/intl/gnulib-lib \
./gettext-runtime/gnulib-lib
do
cd "$gnulib"
patch -p2 < ${gnulib.patches.memcpy-fix}
cd -
done
'';
strictDeps = true;
@@ -85,7 +96,7 @@ stdenv.mkDerivation rec {
lib.optionals (!stdenv.hostPlatform.isMinGW) [
bashNonInteractive
]
++ lib.optionals (!stdenv.hostPlatform.isLinux && !stdenv.hostPlatform.isCygwin) [
++ lib.optionals (!stdenv.hostPlatform.isLinux) [
# HACK, see #10874 (and 14664)
libiconv
];