gnulib: add gnulib-longdouble-redirect.patch

This patch adds gnulib-longdouble-redirect.patch, which is a subset of
gnulib commit 776af40e09b476a41073131a90022572f448c189.

This patch must be applied to the copy of gnulib which is vendored
within a few packages, when compiling for platforms that use
longdouble-redirection (a glibc-specific feature).  Without it,
compile failures mentioning "__LDBL_REDIR1_DECL" will occur.

Currently there are two packages which need this patch to their
vendored gnulib: gettext and gnused.  Both projects have merged a
fixed version of gnulib but have not yet made a release with the fix.
We can drop this patch as soon as both of those projects are
version-bumped.
This commit is contained in:
Adam Joseph 2022-07-25 21:33:04 -07:00
parent 9774560c4e
commit 9eafe4319c
2 changed files with 83 additions and 0 deletions

View file

@ -26,6 +26,17 @@ stdenv.mkDerivation {
# do not change headers to not update all vendored build files
dontFixup = true;
passthru = {
# This patch is used by multiple other packages (currently:
# gnused, gettext) which contain vendored copies of gnulib.
# Without it, compilation will fail with error messages about
# "__LDBL_REDIR1_DECL" or similar on platforms with longdouble
# redirects (currently powerpc64). Once all of those other
# packages make a release with a newer gnulib we can drop this
# patch.
longdouble-redirect-patch = ./gnulib-longdouble-redirect.patch;
};
meta = with lib; {
description = "Central location for code to be shared among GNU packages";
homepage = "https://www.gnu.org/software/gnulib/";

View file

@ -0,0 +1,72 @@
Below is the subset of gnulib commit
776af40e09b476a41073131a90022572f448c189 which deals with long double
redirects. The rest of that commit has been removed.
diff --git a/lib/cdefs.h b/lib/cdefs.h
index fd72b7b..4383e70 100644
--- a/lib/cdefs.h
+++ b/lib/cdefs.h
@@ -483,7 +493,37 @@
# include <bits/long-double.h>
#endif
-#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+#if __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 1
+# ifdef __REDIRECT
+
+/* Alias name defined automatically. */
+# define __LDBL_REDIR(name, proto) ... unused__ldbl_redir
+# define __LDBL_REDIR_DECL(name) \
+ extern __typeof (name) name __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined automatically, with leading underscores. */
+# define __LDBL_REDIR2_DECL(name) \
+ extern __typeof (__##name) __##name \
+ __asm (__ASMNAME ("__" #name "ieee128"));
+
+/* Alias name defined manually. */
+# define __LDBL_REDIR1(name, proto, alias) ... unused__ldbl_redir1
+# define __LDBL_REDIR1_DECL(name, alias) \
+ extern __typeof (name) name __asm (__ASMNAME (#alias));
+
+# define __LDBL_REDIR1_NTH(name, proto, alias) \
+ __REDIRECT_NTH (name, proto, alias)
+# define __REDIRECT_NTH_LDBL(name, proto, alias) \
+ __LDBL_REDIR1_NTH (name, proto, __##alias##ieee128)
+
+/* Unused. */
+# define __REDIRECT_LDBL(name, proto, alias) ... unused__redirect_ldbl
+# define __LDBL_REDIR_NTH(name, proto) ... unused__ldbl_redir_nth
+
+# else
+_Static_assert (0, "IEEE 128-bits long double requires redirection on this platform");
+# endif
+#elif defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
# define __LDBL_COMPAT 1
# ifdef __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
@@ -492,6 +532,8 @@
# define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
# define __LDBL_REDIR_NTH(name, proto) \
__LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+# define __LDBL_REDIR2_DECL(name) \
+ extern __typeof (__##name) __##name __asm (__ASMNAME ("__nldbl___" #name));
# define __LDBL_REDIR1_DECL(name, alias) \
extern __typeof (name) name __asm (__ASMNAME (#alias));
# define __LDBL_REDIR_DECL(name) \
@@ -502,11 +544,13 @@
__LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
# endif
#endif
-#if !defined __LDBL_COMPAT || !defined __REDIRECT
+#if (!defined __LDBL_COMPAT && __LDOUBLE_REDIRECTS_TO_FLOAT128_ABI == 0) \
+ || !defined __REDIRECT
# define __LDBL_REDIR1(name, proto, alias) name proto
# define __LDBL_REDIR(name, proto) name proto
# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
+# define __LDBL_REDIR2_DECL(name)
# define __LDBL_REDIR_DECL(name)
# ifdef __REDIRECT
# define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)