all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#29406] [PATCH core-updates]: Add selected upstream fixes for glibc 2.26.
@ 2017-11-22 21:28 Marius Bakke
  2017-11-23 14:57 ` Leo Famulari
  2017-11-23 15:42 ` Ludovic Courtès
  0 siblings, 2 replies; 15+ messages in thread
From: Marius Bakke @ 2017-11-22 21:28 UTC (permalink / raw)
  To: 29406


[-- Attachment #1.1: Type: text/plain, Size: 1164 bytes --]

Hello!

I discovered that 'icu4c' failed to build for x86_64 on 'core-updates'.
After some investigation, it turns out to be a problem with <math.h> in
C++ mode, due to its usage of C-only builtins (in the 2.26 release).

Here are the relevant bug reports I've found so far by digging through
the "release/2.26/master" branch, aka "2.26 stable"[0]:

<https://sourceware.org/bugzilla/show_bug.cgi?id=21930>
<https://sourceware.org/bugzilla/show_bug.cgi?id=22235>
<https://sourceware.org/bugzilla/show_bug.cgi?id=22146>
<https://sourceware.org/bugzilla/show_bug.cgi?id=22296>

The attached patch includes the fixes from those bugs, as well as a
couple of others that looked important.  However it's still a very small
subset of the 2.26 post-release fixes.

I've read through _most_ of the commits and around half of them look
important enough to pick "unconditionally".  The other half I mainly
lack the context or skills to assess.

So I wonder if we should simply pick everything from this branch,
instead of only the few that fixes immediately visible problems.
Thoughts?

[0] https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/release/2.26/master


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1.2: 0001-gnu-glibc-Add-selected-fixes-from-upstream-stable-br.patch --]
[-- Type: text/x-patch, Size: 36722 bytes --]

From 7121dc7ed24e97080154794fb14ae4078a3451f7 Mon Sep 17 00:00:00 2001
From: Marius Bakke <mbakke@fastmail.com>
Date: Wed, 22 Nov 2017 22:26:31 +0100
Subject: [PATCH] gnu: glibc: Add selected fixes from upstream stable branch.

This backports a small subset of
<https://sourceware.org/git/?p=glibc.git;a=shortlog;h=refs/heads/release/2.26/master>.

* gnu/packages/patches/glibc-2.26-cpp-fixes.patch,
gnu/packages/patches/glibc-2.26-ifunc-resolver-longjmp.patch,
gnu/packages/patches/glibc-2.26-resolver-fixes.patch: New files.
* gnu/local.mk (dist_patch_DATA): Register them.
* gnu/packages/base.scm (glibc/linux)[source](patches): Use them.
---
 gnu/local.mk                                       |   3 +
 gnu/packages/base.scm                              |   3 +
 gnu/packages/patches/glibc-2.26-cpp-fixes.patch    | 716 +++++++++++++++++++++
 .../glibc-2.26-ifunc-resolver-longjmp.patch        | 109 ++++
 .../patches/glibc-2.26-resolver-fixes.patch        |  52 ++
 5 files changed, 883 insertions(+)
 create mode 100644 gnu/packages/patches/glibc-2.26-cpp-fixes.patch
 create mode 100644 gnu/packages/patches/glibc-2.26-ifunc-resolver-longjmp.patch
 create mode 100644 gnu/packages/patches/glibc-2.26-resolver-fixes.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index be093eccd..c6cb1aff7 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -665,6 +665,9 @@ dist_patch_DATA =						\
   %D%/packages/patches/glib-networking-ssl-cert-file.patch	\
   %D%/packages/patches/glib-respect-datadir.patch		\
   %D%/packages/patches/glib-tests-timer.patch			\
+  %D%/packages/patches/glibc-2.26-cpp-fixes.patch		\
+  %D%/packages/patches/glibc-2.26-resolver-fixes.patch		\
+  %D%/packages/patches/glibc-2.26-ifunc-resolver-longjmp.patch	\
   %D%/packages/patches/glibc-CVE-2015-5180.patch		\
   %D%/packages/patches/glibc-CVE-2015-7547.patch		\
   %D%/packages/patches/glibc-CVE-2016-3075.patch		\
diff --git a/gnu/packages/base.scm b/gnu/packages/base.scm
index a6663c5cf..49dc60642 100644
--- a/gnu/packages/base.scm
+++ b/gnu/packages/base.scm
@@ -533,6 +533,9 @@ store.")
             (modules '((guix build utils)))
             (patches (search-patches "glibc-ldd-x86_64.patch"
                                      "glibc-versioned-locpath.patch"
+                                     "glibc-2.26-cpp-fixes.patch"
+                                     "glibc-2.26-resolver-fixes.patch"
+                                     "glibc-2.26-ifunc-resolver-longjmp.patch"
                                      "glibc-CVE-2017-15670-15671.patch"
                                      "glibc-o-largefile.patch"))))
    (build-system gnu-build-system)
diff --git a/gnu/packages/patches/glibc-2.26-cpp-fixes.patch b/gnu/packages/patches/glibc-2.26-cpp-fixes.patch
new file mode 100644
index 000000000..7564d3aac
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.26-cpp-fixes.patch
@@ -0,0 +1,716 @@
+Glibc 2.26 pulls in C-only builtins in <math.h> on some platforms.  This in turn
+causes GCC to fail to override these in <cmath> when testing their existence.
+
+This is an amalgamation of patches from a variety of upstream bug reports:
+
+From <https://sourceware.org/bugzilla/show_bug.cgi?id=21930>:
+https://sourceware.org/git/?p=glibc.git;a=commit;h=c2921b17a37e887b8a5ca9d84b875b9ba702b79c
+https://sourceware.org/git/?p=glibc.git;a=commit;h=5e989c36934d0f0cf13b7a53ef2fa440bce39210
+https://sourceware.org/git/?p=glibc.git;a=commit;h=ef8566d72af5e03c1b82cf02efb794268a347f8c
+https://sourceware.org/git/?p=glibc.git;a=commit;h=35dded99a89db873b06270ca7f21245a0faf712a
+https://sourceware.org/git/?p=glibc.git;a=commit;h=58270c0049404ef2f878fdd45df55f17f0b8c1f7
+
+From <https://sourceware.org/bugzilla/show_bug.cgi?id=22235>:
+https://sourceware.org/git/?p=glibc.git;a=commit;h=3b10c5d2abb0392d5ecfd865e2eb911ac109e36f
+https://sourceware.org/git/?p=glibc.git;a=commit;h=dd3a7239fddff81ac31373d69978d7aa1902c65f
+
+From <https://sourceware.org/bugzilla/show_bug.cgi?id=22146>:
+https://sourceware.org/git/?p=glibc.git;a=commit;h=d37c951fde57e8acb320a9a7d437ba50a1fc3c8a
+
+From <https://sourceware.org/bugzilla/show_bug.cgi?id=22296>:
+https://sourceware.org/git/?p=glibc.git;a=commit;h=f8279a4b3cc66d3ec8bfb8519e9987b8f7727f53 
+
+...with ChangeLog and NEWS entries removed.
+
+From c2921b17a37e887b8a5ca9d84b875b9ba702b79c Mon Sep 17 00:00:00 2001
+From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
+Date: Mon, 21 Aug 2017 14:23:27 +0200
+Subject: [PATCH] Do not use __builtin_types_compatible_p in C++ mode (bug
+ 21930)
+diff --git a/math/math.h b/math/math.h
+index e217080..dea8dbe 100644
+--- a/math/math.h
++++ b/math/math.h
+@@ -442,8 +442,12 @@ enum
+ 
+ /* Return nonzero value if X is positive or negative infinity.  */
+ # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \
+-     && !defined __SUPPORT_SNAN__
+-   /* __builtin_isinf_sign is broken for float128 only before GCC 7.0.  */
++     && !defined __SUPPORT_SNAN__ && !defined __cplusplus
++   /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,
++      use the helper function, __isinff128, with older compilers.  This is
++      only provided for C mode, because in C++ mode, GCC has no support
++      for __builtin_types_compatible_p (and when in C++ mode, this macro is
++      not used anyway, because libstdc++ headers undefine it).  */
+ #  define isinf(x) \
+     (__builtin_types_compatible_p (__typeof (x), _Float128) \
+      ? __isinff128 (x) : __builtin_isinf_sign (x))
+
+From 5e989c36934d0f0cf13b7a53ef2fa440bce39210 Mon Sep 17 00:00:00 2001
+From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
+Date: Mon, 14 Aug 2017 17:51:51 -0300
+Subject: [PATCH] Do not use generic selection in C++ mode
+diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
+index 06523bf..0c80821 100644
+--- a/misc/sys/cdefs.h
++++ b/misc/sys/cdefs.h
+@@ -464,17 +464,18 @@
+ # define __glibc_macro_warning(msg)
+ #endif
+ 
+-/* Support for generic selection (ISO C11) is available in GCC since
+-   version 4.9.  Previous versions do not provide generic selection,
+-   even though they might set __STDC_VERSION__ to 201112L, when in
+-   -std=c11 mode.  Thus, we must check for !defined __GNUC__ when
+-   testing __STDC_VERSION__ for generic selection support.
++/* Generic selection (ISO C11) is a C-only feature, available in GCC
++   since version 4.9.  Previous versions do not provide generic
++   selection, even though they might set __STDC_VERSION__ to 201112L,
++   when in -std=c11 mode.  Thus, we must check for !defined __GNUC__
++   when testing __STDC_VERSION__ for generic selection support.
+    On the other hand, Clang also defines __GNUC__, so a clang-specific
+    check is required to enable the use of generic selection.  */
+-#if __GNUC_PREREQ (4, 9) \
+-    || __glibc_clang_has_extension (c_generic_selections) \
+-    || (!defined __GNUC__ && defined __STDC_VERSION__ \
+-	&& __STDC_VERSION__ >= 201112L)
++#if !defined __cplusplus \
++    && (__GNUC_PREREQ (4, 9) \
++	|| __glibc_clang_has_extension (c_generic_selections) \
++	|| (!defined __GNUC__ && defined __STDC_VERSION__ \
++	    && __STDC_VERSION__ >= 201112L))
+ # define __HAVE_GENERIC_SELECTION 1
+ #else
+ # define __HAVE_GENERIC_SELECTION 0
+
+
+From ef8566d72af5e03c1b82cf02efb794268a347f8c Mon Sep 17 00:00:00 2001
+From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
+Date: Mon, 14 Aug 2017 13:46:15 -0300
+Subject: [PATCH] Provide a C++ version of issignaling that does not use
+ __MATH_TG
+
+diff --git a/math/Makefile b/math/Makefile
+index e09b0c0..0130fcf 100644
+--- a/math/Makefile
++++ b/math/Makefile
+@@ -203,7 +203,7 @@ tests-static = test-fpucw-static test-fpucw-ieee-static \
+ 	       test-signgam-ullong-static test-signgam-ullong-init-static
+ 
+ ifneq (,$(CXX))
+-tests += test-math-isinff test-math-iszero
++tests += test-math-isinff test-math-iszero test-math-issignaling
+ endif
+ 
+ ifneq (no,$(PERL))
+@@ -350,6 +350,7 @@ CFLAGS-test-signgam-ullong-init-static.c = -std=c99
+ 
+ CFLAGS-test-math-isinff.cc = -std=gnu++11
+ CFLAGS-test-math-iszero.cc = -std=gnu++11
++CFLAGS-test-math-issignaling.cc = -std=gnu++11
+ 
+ CFLAGS-test-iszero-excess-precision.c = -fexcess-precision=standard
+ CFLAGS-test-iseqsig-excess-precision.c = -fexcess-precision=standard
+diff --git a/math/math.h b/math/math.h
+index dea8dbe..add86af 100644
+--- a/math/math.h
++++ b/math/math.h
+@@ -474,7 +474,24 @@ enum
+ # include <bits/iscanonical.h>
+ 
+ /* Return nonzero value if X is a signaling NaN.  */
+-# define issignaling(x) __MATH_TG ((x), __issignaling, (x))
++# ifndef __cplusplus
++#  define issignaling(x) __MATH_TG ((x), __issignaling, (x))
++# else
++   /* In C++ mode, __MATH_TG cannot be used, because it relies on
++      __builtin_types_compatible_p, which is a C-only builtin.  On the
++      other hand, overloading provides the means to distinguish between
++      the floating-point types.  The overloading resolution will match
++      the correct parameter (regardless of type qualifiers (i.e.: const
++      and volatile).  */
++extern "C++" {
++inline int issignaling (float __val) { return __issignalingf (__val); }
++inline int issignaling (double __val) { return __issignaling (__val); }
++inline int issignaling (long double __val) { return __issignalingl (__val); }
++#  if __HAVE_DISTINCT_FLOAT128
++inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
++#  endif
++} /* extern C++ */
++# endif
+ 
+ /* Return nonzero value if X is subnormal.  */
+ # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL)
+diff --git a/math/test-math-issignaling.cc b/math/test-math-issignaling.cc
+new file mode 100644
+index 0000000..22ae9e1
+--- /dev/null
++++ b/math/test-math-issignaling.cc
+@@ -0,0 +1,113 @@
++/* Test for the C++ implementation of issignaling.
++   Copyright (C) 2017 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library is distributed in the hope that it will be useful,
++   but WITHOUT ANY WARRANTY; without even the implied warranty of
++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#define _GNU_SOURCE 1
++#include <math.h>
++#include <stdio.h>
++
++#include <limits>
++
++/* There is no signaling_NaN for _Float128 in std::numeric_limits.
++   Include ieee754_float128.h and use the bitfields in the union
++   ieee854_float128.ieee_nan to build a signaling NaN.  */
++#if __HAVE_DISTINCT_FLOAT128
++# include <ieee754_float128.h>
++#endif
++
++static bool errors;
++
++static void
++check (int actual, int expected, const char *actual_expr, int line)
++{
++  if (actual != expected)
++    {
++      errors = true;
++      printf ("%s:%d: error: %s\n", __FILE__, line, actual_expr);
++      printf ("%s:%d:   expected: %d\n", __FILE__, line, expected);
++      printf ("%s:%d:   actual: %d\n", __FILE__, line, actual);
++    }
++}
++
++#define CHECK(actual, expected) \
++  check ((actual), (expected), #actual, __LINE__)
++
++template <class T>
++static void
++check_type ()
++{
++  typedef std::numeric_limits<T> limits;
++  CHECK (issignaling (T{0}), 0);
++  if (limits::has_infinity)
++    {
++      CHECK (issignaling (limits::infinity ()), 0);
++      CHECK (issignaling (-limits::infinity ()), 0);
++    }
++  if (limits::has_quiet_NaN)
++    CHECK (issignaling (limits::quiet_NaN ()), 0);
++  if (limits::has_signaling_NaN)
++    CHECK (issignaling (limits::signaling_NaN ()), 1);
++}
++
++#if __HAVE_DISTINCT_FLOAT128
++static void
++check_float128 ()
++{
++  ieee854_float128 q;
++
++  q.d = 0;
++  CHECK (issignaling (q.d), 0);
++
++  /* Infinity.  */
++  q.ieee.negative = 0;
++  q.ieee.exponent = 0x7FFF;
++  q.ieee.mantissa0 = 0x0000;
++  q.ieee.mantissa1 = 0x00000000;
++  q.ieee.mantissa2 = 0x00000000;
++  q.ieee.mantissa3 = 0x00000000;
++  CHECK (issignaling (q.d), 0);
++
++  /* Quiet NaN.  */
++  q.ieee_nan.quiet_nan = 1;
++  q.ieee_nan.mantissa0 = 0x0000;
++  CHECK (issignaling (q.d), 0);
++
++  /* Still a quiet NaN.  */
++  q.ieee_nan.quiet_nan = 1;
++  q.ieee_nan.mantissa0 = 0x4000;
++  CHECK (issignaling (q.d), 0);
++
++  /* Signaling NaN.  */
++  q.ieee_nan.quiet_nan = 0;
++  q.ieee_nan.mantissa0 = 0x4000;
++  CHECK (issignaling (q.d), 1);
++}
++#endif
++
++static int
++do_test (void)
++{
++  check_type<float> ();
++  check_type<double> ();
++  check_type<long double> ();
++#if __HAVE_DISTINCT_FLOAT128
++  check_float128 ();
++#endif
++  return errors;
++}
++
++#include <support/test-driver.c>
+diff --git a/sysdeps/powerpc/powerpc64le/Makefile b/sysdeps/powerpc/powerpc64le/Makefile
+index 77617b6..19adbfa 100644
+--- a/sysdeps/powerpc/powerpc64le/Makefile
++++ b/sysdeps/powerpc/powerpc64le/Makefile
+@@ -16,6 +16,7 @@ $(foreach suf,$(all-object-suffixes),%f128_r$(suf)): CFLAGS += -mfloat128
+ $(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += -mfloat128
+ $(foreach suf,$(all-object-suffixes),$(objpfx)test-ifloat128%$(suf)): CFLAGS += -mfloat128
+ CFLAGS-libm-test-support-float128.c += -mfloat128
++CFLAGS-test-math-issignaling.cc += -mfloat128
+ $(objpfx)test-float128% $(objpfx)test-ifloat128%: \
+   gnulib-tests += $(f128-loader-link)
+ endif
+
+From 35dded99a89db873b06270ca7f21245a0faf712a Mon Sep 17 00:00:00 2001
+From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
+Date: Wed, 23 Aug 2017 10:16:54 -0300
+Subject: [PATCH] Fix the C++ version of issignaling when __NO_LONG_DOUBLE_MATH
+ is defined
+
+diff --git a/math/math.h b/math/math.h
+index add86af..60dfa31 100644
+--- a/math/math.h
++++ b/math/math.h
+@@ -486,7 +486,15 @@ enum
+ extern "C++" {
+ inline int issignaling (float __val) { return __issignalingf (__val); }
+ inline int issignaling (double __val) { return __issignaling (__val); }
+-inline int issignaling (long double __val) { return __issignalingl (__val); }
++inline int
++issignaling (long double __val)
++{
++#  ifdef __NO_LONG_DOUBLE_MATH
++  return __issignaling (__val);
++#  else
++  return __issignalingl (__val);
++#  endif
++}
+ #  if __HAVE_DISTINCT_FLOAT128
+ inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
+ #  endif
+
+From 58270c0049404ef2f878fdd45df55f17f0b8c1f7 Mon Sep 17 00:00:00 2001
+From: "Gabriel F. T. Gomes" <gftg@linux.vnet.ibm.com>
+Date: Tue, 22 Aug 2017 16:34:42 -0300
+Subject: [PATCH] Provide a C++ version of iszero that does not use __MATH_TG
+ (bug 21930)
+diff --git a/math/math.h b/math/math.h
+index 60dfa31..7c0fc6d 100644
+--- a/math/math.h
++++ b/math/math.h
+@@ -513,15 +513,40 @@ inline int issignaling (_Float128 __val) { return __issignalingf128 (__val); }
+ #  endif
+ # else	/* __cplusplus */
+ extern "C++" {
++#  ifdef __SUPPORT_SNAN__
++inline int
++iszero (float __val)
++{
++  return __fpclassifyf (__val) == FP_ZERO;
++}
++inline int
++iszero (double __val)
++{
++  return __fpclassify (__val) == FP_ZERO;
++}
++inline int
++iszero (long double __val)
++{
++#   ifdef __NO_LONG_DOUBLE_MATH
++  return __fpclassify (__val) == FP_ZERO;
++#   else
++  return __fpclassifyl (__val) == FP_ZERO;
++#   endif
++}
++#   if __HAVE_DISTINCT_FLOAT128
++inline int
++iszero (_Float128 __val)
++{
++  return __fpclassifyf128 (__val) == FP_ZERO;
++}
++#   endif
++#  else
+ template <class __T> inline bool
+ iszero (__T __val)
+ {
+-#  ifdef __SUPPORT_SNAN__
+-  return fpclassify (__val) == FP_ZERO;
+-#  else
+   return __val == 0;
+-#  endif
+ }
++#  endif
+ } /* extern C++ */
+ # endif	/* __cplusplus */
+ #endif /* Use IEC_60559_BFP_EXT.  */
+diff --git a/math/test-math-iszero.cc b/math/test-math-iszero.cc
+index 027e972..5c07261 100644
+--- a/math/test-math-iszero.cc
++++ b/math/test-math-iszero.cc
+@@ -22,6 +22,13 @@
+ 
+ #include <limits>
+ 
++/* Support for _Float128 in std::numeric_limits is limited.
++   Include ieee754_float128.h and use the bitfields in the union
++   ieee854_float128.ieee_nan to build corner-case inputs.  */
++#if __HAVE_DISTINCT_FLOAT128
++# include <ieee754_float128.h>
++#endif
++
+ static bool errors;
+ 
+ static void
+@@ -72,12 +79,84 @@ check_type ()
+          std::numeric_limits<T>::has_denorm == std::denorm_absent);
+ }
+ 
++#if __HAVE_DISTINCT_FLOAT128
++static void
++check_float128 ()
++{
++  ieee854_float128 q;
++
++  q.d = 0.0Q;
++  CHECK (iszero (q.d), 1);
++  q.d = -0.0Q;
++  CHECK (iszero (q.d), 1);
++  q.d = 1.0Q;
++  CHECK (iszero (q.d), 0);
++  q.d = -1.0Q;
++  CHECK (iszero (q.d), 0);
++
++  /* Normal min.  */
++  q.ieee.negative = 0;
++  q.ieee.exponent = 0x0001;
++  q.ieee.mantissa0 = 0x0000;
++  q.ieee.mantissa1 = 0x00000000;
++  q.ieee.mantissa2 = 0x00000000;
++  q.ieee.mantissa3 = 0x00000000;
++  CHECK (iszero (q.d), 0);
++  q.ieee.negative = 1;
++  CHECK (iszero (q.d), 0);
++
++  /* Normal max.  */
++  q.ieee.negative = 0;
++  q.ieee.exponent = 0x7FFE;
++  q.ieee.mantissa0 = 0xFFFF;
++  q.ieee.mantissa1 = 0xFFFFFFFF;
++  q.ieee.mantissa2 = 0xFFFFFFFF;
++  q.ieee.mantissa3 = 0xFFFFFFFF;
++  CHECK (iszero (q.d), 0);
++  q.ieee.negative = 1;
++  CHECK (iszero (q.d), 0);
++
++  /* Infinity.  */
++  q.ieee.negative = 0;
++  q.ieee.exponent = 0x7FFF;
++  q.ieee.mantissa0 = 0x0000;
++  q.ieee.mantissa1 = 0x00000000;
++  q.ieee.mantissa2 = 0x00000000;
++  q.ieee.mantissa3 = 0x00000000;
++  CHECK (iszero (q.d), 0);
++
++  /* Quiet NaN.  */
++  q.ieee_nan.quiet_nan = 1;
++  q.ieee_nan.mantissa0 = 0x0000;
++  CHECK (iszero (q.d), 0);
++
++  /* Signaling NaN.  */
++  q.ieee_nan.quiet_nan = 0;
++  q.ieee_nan.mantissa0 = 0x4000;
++  CHECK (iszero (q.d), 0);
++
++  /* Denormal min.  */
++  q.ieee.negative = 0;
++  q.ieee.exponent = 0x0000;
++  q.ieee.mantissa0 = 0x0000;
++  q.ieee.mantissa1 = 0x00000000;
++  q.ieee.mantissa2 = 0x00000000;
++  q.ieee.mantissa3 = 0x00000001;
++  CHECK (iszero (q.d), 0);
++  q.ieee.negative = 1;
++  CHECK (iszero (q.d), 0);
++}
++#endif
++
+ static int
+ do_test (void)
+ {
+   check_type<float> ();
+   check_type<double> ();
+   check_type<long double> ();
++#if __HAVE_DISTINCT_FLOAT128
++  check_float128 ();
++#endif
+   return errors;
+ }
+ 
+diff --git a/sysdeps/powerpc/powerpc64le/Makefile b/sysdeps/powerpc/powerpc64le/Makefile
+index 19adbfa..dea2290 100644
+--- a/sysdeps/powerpc/powerpc64le/Makefile
++++ b/sysdeps/powerpc/powerpc64le/Makefile
+@@ -17,7 +17,8 @@ $(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += -
+ $(foreach suf,$(all-object-suffixes),$(objpfx)test-ifloat128%$(suf)): CFLAGS += -mfloat128
+ CFLAGS-libm-test-support-float128.c += -mfloat128
+ CFLAGS-test-math-issignaling.cc += -mfloat128
+-$(objpfx)test-float128% $(objpfx)test-ifloat128%: \
++CFLAGS-test-math-iszero.cc += -mfloat128
++$(objpfx)test-float128% $(objpfx)test-ifloat128% $(objpfx)test-math-iszero: \
+   gnulib-tests += $(f128-loader-link)
+ endif
+
+From d37c951fde57e8acb320a9a7d437ba50a1fc3c8a Mon Sep 17 00:00:00 2001
+From: "Gabriel F. T. Gomes" <gabriel@inconstante.eti.br>
+Date: Wed, 20 Sep 2017 15:10:26 -0300
+Subject: [PATCH] Let fpclassify use the builtin when optimizing for size in
+ C++ mode (bug 22146)
+diff --git a/math/math.h b/math/math.h
+index 7c0fc6d..f9348ec 100644
+--- a/math/math.h
++++ b/math/math.h
+@@ -402,7 +402,13 @@ enum
+ 
+ /* Return number of classification appropriate for X.  */
+ # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__			      \
+-     && !defined __OPTIMIZE_SIZE__
++     && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)
++     /* The check for __cplusplus allows the use of the builtin, even
++	when optimization for size is on.  This is provided for
++	libstdc++, only to let its configure test work when it is built
++	with -Os.  No further use of this definition of fpclassify is
++	expected in C++ mode, since libstdc++ provides its own version
++	of fpclassify in cmath (which undefines fpclassify).  */
+ #  define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE,	      \
+      FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
+ # else
+
+From 3b10c5d2abb0392d5ecfd865e2eb911ac109e36f Mon Sep 17 00:00:00 2001
+From: "Gabriel F. T. Gomes" <gabriel@inconstante.eti.br>
+Date: Mon, 2 Oct 2017 14:46:35 -0300
+Subject: [PATCH] Add C++ versions of iscanonical for ldbl-96 and ldbl-128ibm
+ (bug 22235)
+diff --git a/math/Makefile b/math/Makefile
+index 0130fcf..2c17c68 100644
+--- a/math/Makefile
++++ b/math/Makefile
+@@ -203,7 +203,8 @@ tests-static = test-fpucw-static test-fpucw-ieee-static \
+ 	       test-signgam-ullong-static test-signgam-ullong-init-static
+ 
+ ifneq (,$(CXX))
+-tests += test-math-isinff test-math-iszero test-math-issignaling
++tests += test-math-isinff test-math-iszero test-math-issignaling \
++	 test-math-iscanonical
+ endif
+ 
+ ifneq (no,$(PERL))
+@@ -351,6 +352,7 @@ CFLAGS-test-signgam-ullong-init-static.c = -std=c99
+ CFLAGS-test-math-isinff.cc = -std=gnu++11
+ CFLAGS-test-math-iszero.cc = -std=gnu++11
+ CFLAGS-test-math-issignaling.cc = -std=gnu++11
++CFLAGS-test-math-iscanonical.cc = -std=gnu++11
+ 
+ CFLAGS-test-iszero-excess-precision.c = -fexcess-precision=standard
+ CFLAGS-test-iseqsig-excess-precision.c = -fexcess-precision=standard
+diff --git a/math/math.h b/math/math.h
+index f9348ec..2b216c6 100644
+--- a/math/math.h
++++ b/math/math.h
+@@ -488,7 +488,7 @@ enum
+       other hand, overloading provides the means to distinguish between
+       the floating-point types.  The overloading resolution will match
+       the correct parameter (regardless of type qualifiers (i.e.: const
+-      and volatile).  */
++      and volatile)).  */
+ extern "C++" {
+ inline int issignaling (float __val) { return __issignalingf (__val); }
+ inline int issignaling (double __val) { return __issignaling (__val); }
+diff --git a/math/test-math-iscanonical.cc b/math/test-math-iscanonical.cc
+new file mode 100644
+index 0000000..aba68ac
+--- /dev/null
++++ b/math/test-math-iscanonical.cc
+@@ -0,0 +1,48 @@
++/* Test for the C++ implementation of iscanonical.
++   Copyright (C) 2017 Free Software Foundation, Inc.
++   This file is part of the GNU C Library.
++
++   The GNU C Library is free software; you can redistribute it and/or
++   modify it under the terms of the GNU Lesser General Public
++   License as published by the Free Software Foundation; either
++   version 2.1 of the License, or (at your option) any later version.
++
++   The GNU C Library is distributed in the hope that it will be useful,
++   but WITHOUT ANY WARRANTY; without even the implied warranty of
++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
++   Lesser General Public License for more details.
++
++   You should have received a copy of the GNU Lesser General Public
++   License along with the GNU C Library; if not, see
++   <http://www.gnu.org/licenses/>.  */
++
++#define _GNU_SOURCE 1
++#include <math.h>
++#include <stdio.h>
++
++static bool errors;
++
++template <class T>
++static void
++check_type ()
++{
++  T val = 0;
++
++  /* Check if iscanonical is available in C++ mode (bug 22235).  */
++  if (iscanonical (val) == 0)
++    errors++;
++}
++
++static int
++do_test (void)
++{
++  check_type<float> ();
++  check_type<double> ();
++  check_type<long double> ();
++#if __HAVE_DISTINCT_FLOAT128
++  check_type<_Float128> ();
++#endif
++  return errors;
++}
++
++#include <support/test-driver.c>
+diff --git a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
+index 7ddb368..f756857 100644
+--- a/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
++++ b/sysdeps/ieee754/ldbl-128ibm/bits/iscanonical.h
+@@ -37,5 +37,22 @@ extern int __iscanonicall (long double __x)
+    conversion, before being discarded; in IBM long double, there are
+    encodings that are not consistently handled as corresponding to any
+    particular value of the type, and we return 0 for those.  */
+-# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x))
+-#endif
++# ifndef __cplusplus
++#  define iscanonical(x) __MATH_TG ((x), __iscanonical, (x))
++# else
++/* In C++ mode, __MATH_TG cannot be used, because it relies on
++   __builtin_types_compatible_p, which is a C-only builtin.  On the
++   other hand, overloading provides the means to distinguish between
++   the floating-point types.  The overloading resolution will match
++   the correct parameter (regardless of type qualifiers (i.e.: const
++   and volatile)).  */
++extern "C++" {
++inline int iscanonical (float __val) { return __iscanonicalf (__val); }
++inline int iscanonical (double __val) { return __iscanonical (__val); }
++inline int iscanonical (long double __val) { return __iscanonicall (__val); }
++#  if __HAVE_DISTINCT_FLOAT128
++inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); }
++#  endif
++}
++# endif /* __cplusplus */
++#endif /* __NO_LONG_DOUBLE_MATH */
+diff --git a/sysdeps/ieee754/ldbl-96/bits/iscanonical.h b/sysdeps/ieee754/ldbl-96/bits/iscanonical.h
+index 4a4f4ad..cfa36a0 100644
+--- a/sysdeps/ieee754/ldbl-96/bits/iscanonical.h
++++ b/sysdeps/ieee754/ldbl-96/bits/iscanonical.h
+@@ -34,4 +34,21 @@ extern int __iscanonicall (long double __x)
+    conversion, before being discarded; in extended precision, there
+    are encodings that are not consistently handled as corresponding to
+    any particular value of the type, and we return 0 for those.  */
+-#define iscanonical(x) __MATH_TG ((x), __iscanonical, (x))
++#ifndef __cplusplus
++# define iscanonical(x) __MATH_TG ((x), __iscanonical, (x))
++#else
++/* In C++ mode, __MATH_TG cannot be used, because it relies on
++   __builtin_types_compatible_p, which is a C-only builtin.  On the
++   other hand, overloading provides the means to distinguish between
++   the floating-point types.  The overloading resolution will match
++   the correct parameter (regardless of type qualifiers (i.e.: const
++   and volatile)).  */
++extern "C++" {
++inline int iscanonical (float __val) { return __iscanonicalf (__val); }
++inline int iscanonical (double __val) { return __iscanonical (__val); }
++inline int iscanonical (long double __val) { return __iscanonicall (__val); }
++# if __HAVE_DISTINCT_FLOAT128
++inline int iscanonical (_Float128 __val) { return __iscanonicalf128 (__val); }
++# endif
++}
++#endif /* __cplusplus */
+diff --git a/sysdeps/powerpc/powerpc64le/Makefile b/sysdeps/powerpc/powerpc64le/Makefile
+index dea2290..cf2dbfb 100644
+--- a/sysdeps/powerpc/powerpc64le/Makefile
++++ b/sysdeps/powerpc/powerpc64le/Makefile
+@@ -16,6 +16,7 @@ $(foreach suf,$(all-object-suffixes),%f128_r$(suf)): CFLAGS += -mfloat128
+ $(foreach suf,$(all-object-suffixes),$(objpfx)test-float128%$(suf)): CFLAGS += -mfloat128
+ $(foreach suf,$(all-object-suffixes),$(objpfx)test-ifloat128%$(suf)): CFLAGS += -mfloat128
+ CFLAGS-libm-test-support-float128.c += -mfloat128
++CFLAGS-test-math-iscanonical.cc += -mfloat128
+ CFLAGS-test-math-issignaling.cc += -mfloat128
+ CFLAGS-test-math-iszero.cc += -mfloat128
+ $(objpfx)test-float128% $(objpfx)test-ifloat128% $(objpfx)test-math-iszero: \
+
+From dd3a7239fddff81ac31373d69978d7aa1902c65f Mon Sep 17 00:00:00 2001
+From: "H.J. Lu" <hjl.tools@gmail.com>
+Date: Tue, 3 Oct 2017 17:41:32 -0700
+Subject: [PATCH] test-math-iscanonical.cc: Replace bool with int
+diff --git a/math/test-math-iscanonical.cc b/math/test-math-iscanonical.cc
+index aba68ac..4cfb1c5 100644
+--- a/math/test-math-iscanonical.cc
++++ b/math/test-math-iscanonical.cc
+@@ -20,7 +20,7 @@
+ #include <math.h>
+ #include <stdio.h>
+ 
+-static bool errors;
++static int errors;
+ 
+ template <class T>
+ static void
+@@ -42,7 +42,7 @@ do_test (void)
+ #if __HAVE_DISTINCT_FLOAT128
+   check_type<_Float128> ();
+ #endif
+-  return errors;
++  return errors != 0;
+ }
+ 
+ #include <support/test-driver.c>
+ 
+From f8279a4b3cc66d3ec8bfb8519e9987b8f7727f53 Mon Sep 17 00:00:00 2001
+From: Romain Naour <romain.naour@gmail.com>
+Date: Mon, 16 Oct 2017 23:21:56 +0200
+Subject: [PATCH] Let signbit use the builtin in C++ mode with gcc < 6.x (bug
+ 22296)
+diff --git a/math/math.h b/math/math.h
+index 2b216c6..ba26624 100644
+--- a/math/math.h
++++ b/math/math.h
+@@ -418,6 +418,15 @@ enum
+ /* Return nonzero value if sign of X is negative.  */
+ # if __GNUC_PREREQ (6,0)
+ #  define signbit(x) __builtin_signbit (x)
++# elif defined __cplusplus
++  /* In C++ mode, __MATH_TG cannot be used, because it relies on
++     __builtin_types_compatible_p, which is a C-only builtin.
++     The check for __cplusplus allows the use of the builtin instead of
++     __MATH_TG. This is provided for libstdc++, only to let its configure
++     test work. No further use of this definition of signbit is expected
++     in C++ mode, since libstdc++ provides its own version of signbit
++     in cmath (which undefines signbit). */
++#  define signbit(x) __builtin_signbitl (x)
+ # elif __GNUC_PREREQ (4,0)
+ #  define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))
+ # else
+
diff --git a/gnu/packages/patches/glibc-2.26-ifunc-resolver-longjmp.patch b/gnu/packages/patches/glibc-2.26-ifunc-resolver-longjmp.patch
new file mode 100644
index 000000000..8f8bad5b1
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.26-ifunc-resolver-longjmp.patch
@@ -0,0 +1,109 @@
+Fix a linker warning when a shared library that calls longjmp without using
+libthread is linked into a program that links -lphtread.
+
+This should address <https://bugs.gnu.org/29133>.
+
+Upstream bug report:
+https://sourceware.org/bugzilla/show_bug.cgi?id=21041
+
+Copied from upstream git:
+https://sourceware.org/git/?p=glibc.git;a=commit;h=88758c4ad3f046d050bc2c3ae0f172b6524ca6c2
+
+From 88758c4ad3f046d050bc2c3ae0f172b6524ca6c2 Mon Sep 17 00:00:00 2001
+From: Andreas Schwab <schwab@suse.de>
+Date: Tue, 8 Aug 2017 16:21:58 +0200
+Subject: [PATCH] Don't use IFUNC resolver for longjmp or system in libpthread
+ (bug 21041)
+diff --git a/nptl/pt-longjmp.c b/nptl/pt-longjmp.c
+index 2ef757e..8f3c6b3 100644
+--- a/nptl/pt-longjmp.c
++++ b/nptl/pt-longjmp.c
+@@ -25,21 +25,14 @@
+    symbol in libpthread, but the historical ABI requires it.  For static
+    linking, there is no need to provide anything here--the libc version
+    will be linked in.  For shared library ABI compatibility, there must be
+-   longjmp and siglongjmp symbols in libpthread.so; so we define them using
+-   IFUNC to redirect to the libc function.  */
++   longjmp and siglongjmp symbols in libpthread.so.
+ 
+-#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)
+-
+-# if HAVE_IFUNC
+-
+-#  undef INIT_ARCH
+-#  define INIT_ARCH()
+-#  define DEFINE_LONGJMP(name) libc_ifunc (name, &__libc_longjmp)
+-
+-extern __typeof(longjmp) longjmp_ifunc;
+-extern __typeof(siglongjmp) siglongjmp_ifunc;
++   With an IFUNC resolver, it would be possible to avoid the indirection,
++   but the IFUNC resolver might run before the __libc_longjmp symbol has
++   been relocated, in which case the IFUNC resolver would not be able to
++   provide the correct address.  */
+ 
+-# else  /* !HAVE_IFUNC */
++#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)
+ 
+ static void __attribute__ ((noreturn, used))
+ longjmp_compat (jmp_buf env, int val)
+@@ -47,14 +40,10 @@ longjmp_compat (jmp_buf env, int val)
+   __libc_longjmp (env, val);
+ }
+ 
+-# define DEFINE_LONGJMP(name) strong_alias (longjmp_compat, name)
+-
+-# endif  /* HAVE_IFUNC */
+-
+-DEFINE_LONGJMP (longjmp_ifunc)
+-compat_symbol (libpthread, longjmp_ifunc, longjmp, GLIBC_2_0);
++strong_alias (longjmp_compat, longjmp_alias)
++compat_symbol (libpthread, longjmp_alias, longjmp, GLIBC_2_0);
+ 
+-strong_alias (longjmp_ifunc, siglongjmp_ifunc)
+-compat_symbol (libpthread, siglongjmp_ifunc, siglongjmp, GLIBC_2_0);
++strong_alias (longjmp_alias, siglongjmp_alias)
++compat_symbol (libpthread, siglongjmp_alias, siglongjmp, GLIBC_2_0);
+ 
+ #endif
+diff --git a/nptl/pt-system.c b/nptl/pt-system.c
+index f8ca6ba..b30ddf2 100644
+--- a/nptl/pt-system.c
++++ b/nptl/pt-system.c
+@@ -25,29 +25,21 @@
+    libpthread, but the historical ABI requires it.  For static linking,
+    there is no need to provide anything here--the libc version will be
+    linked in.  For shared library ABI compatibility, there must be a
+-   'system' symbol in libpthread.so; so we define it using IFUNC to
+-   redirect to the libc function.  */
++   'system' symbol in libpthread.so.
+ 
+-#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)
+-
+-# if HAVE_IFUNC
+-
+-extern __typeof(system) system_ifunc;
+-#  undef INIT_ARCH
+-#  define INIT_ARCH()
+-libc_ifunc (system_ifunc, &__libc_system)
++   With an IFUNC resolver, it would be possible to avoid the indirection,
++   but the IFUNC resolver might run before the __libc_system symbol has
++   been relocated, in which case the IFUNC resolver would not be able to
++   provide the correct address.  */
+ 
+-# else  /* !HAVE_IFUNC */
++#if SHLIB_COMPAT (libpthread, GLIBC_2_0, GLIBC_2_22)
+ 
+ static int __attribute__ ((used))
+ system_compat (const char *line)
+ {
+   return __libc_system (line);
+ }
+-strong_alias (system_compat, system_ifunc)
+-
+-# endif  /* HAVE_IFUNC */
+-
+-compat_symbol (libpthread, system_ifunc, system, GLIBC_2_0);
++strong_alias (system_compat, system_alias)
++compat_symbol (libpthread, system_alias, system, GLIBC_2_0);
+ 
+ #endif
diff --git a/gnu/packages/patches/glibc-2.26-resolver-fixes.patch b/gnu/packages/patches/glibc-2.26-resolver-fixes.patch
new file mode 100644
index 000000000..5ddf76753
--- /dev/null
+++ b/gnu/packages/patches/glibc-2.26-resolver-fixes.patch
@@ -0,0 +1,52 @@
+This patch fixes some problems in the glibc 2.26 resolver.
+
+https://sourceware.org/bugzilla/show_bug.cgi?id=22095
+https://sourceware.org/bugzilla/show_bug.cgi?id=22096
+
+Picked from these commits:
+https://sourceware.org/git/?p=glibc.git;a=commit;h=905a6129147e7ee80e8918e23efe212433b8cce7
+https://sourceware.org/git/?p=glibc.git;a=commit;h=27233446a62ca35ce0b54566279a99a6774d4210
+
+From 905a6129147e7ee80e8918e23efe212433b8cce7 Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer@redhat.com>
+Date: Wed, 6 Sep 2017 15:46:54 +0200
+Subject: [PATCH] resolv: Fix memory leak with OOM during resolv.conf parsing
+ [BZ #22095]
+diff --git a/resolv/res_init.c b/resolv/res_init.c
+index fa46ce7..4e1f9fe 100644
+--- a/resolv/res_init.c
++++ b/resolv/res_init.c
+@@ -446,6 +446,11 @@ res_vinit_1 (FILE *fp, struct resolv_conf_parser *parser)
+                     (&parser->nameserver_list);
+                   if (p != NULL)
+                     *p = sa;
++                  else
++                    {
++                      free (sa);
++                      return false;
++                    }
+                 }
+               continue;
+             }
+
+From 27233446a62ca35ce0b54566279a99a6774d4210 Mon Sep 17 00:00:00 2001
+From: Florian Weimer <fweimer@redhat.com>
+Date: Wed, 6 Sep 2017 15:47:27 +0200
+Subject: [PATCH] resolv: __resolv_conf_attach must not free passed conf object
+ [BZ #22096]
+diff --git a/resolv/resolv_conf.c b/resolv/resolv_conf.c
+index f391d30c2..e0f296d 100644
+--- a/resolv/resolv_conf.c
++++ b/resolv/resolv_conf.c
+@@ -600,10 +600,7 @@ __resolv_conf_attach (struct __res_state *resp, struct resolv_conf *conf)
+ 
+   struct resolv_conf_global *global_copy = get_locked_global ();
+   if (global_copy == NULL)
+-    {
+-      free (conf);
+-      return false;
+-    }
++    return false;
+ 
+   /* Try to find an unused index in the array.  */
+   size_t index;
-- 
2.15.0


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 487 bytes --]

^ permalink raw reply related	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2017-11-29 16:41 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-11-22 21:28 [bug#29406] [PATCH core-updates]: Add selected upstream fixes for glibc 2.26 Marius Bakke
2017-11-23 14:57 ` Leo Famulari
2017-11-24  1:12   ` Marius Bakke
2017-11-24  3:08     ` Marius Bakke
2017-11-27 21:30   ` Leo Famulari
2017-11-28  1:42     ` Marius Bakke
2017-11-28 10:45       ` Ludovic Courtès
2017-11-28 12:54         ` Marius Bakke
2017-11-28 16:03           ` bug#29406: " Ludovic Courtès
2017-11-28 17:16             ` [bug#29406] " Marius Bakke
2017-11-28 21:02               ` Ludovic Courtès
2017-11-28 21:42                 ` Leo Famulari
2017-11-29 16:40                   ` Ludovic Courtès
2017-11-28 18:26           ` Leo Famulari
2017-11-23 15:42 ` Ludovic Courtès

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.