wok-next rev 20505

Patch glibc for C++ math - if all will be OK, no more 'std.patch'es will be required.
And, I hope, it will fix qt5 where std.patch not helps.
author Aleksej Bobylev <al.bobylev@gmail.com>
date Fri Mar 16 12:33:33 2018 +0200 (2018-03-16)
parents cc34674845c1
children e1076259a437 d24a2d3884ee
files glibc/stuff/patches/glibc-2.26-math-1.patch glibc/stuff/patches/glibc-2.26-math-2.patch glibc/stuff/patches/glibc-2.26-math-3.patch glibc/stuff/patches/series
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/glibc/stuff/patches/glibc-2.26-math-1.patch	Fri Mar 16 12:33:33 2018 +0200
     1.3 @@ -0,0 +1,46 @@
     1.4 +    From: "Gabriel F. T. Gomes" <gftg at linux dot vnet dot ibm dot com>
     1.5 +    To: libc-alpha at sourceware dot org
     1.6 +    Date: Tue, 15 Aug 2017 14:44:59 -0300
     1.7 +    Subject: [PATCH 1/3] Do not use __builtin_types_compatible_p in C++ mode (bug 21930)
     1.8 +    Authentication-results: sourceware.org; auth=none
     1.9 +    References: <20170815174501.4143-1-gftg@linux.vnet.ibm.com>
    1.10 +
    1.11 +The logic to define isinf for float128 depends on the availability of
    1.12 +__builtin_types_compatible_p, which is only available in C mode,
    1.13 +however, the conditionals do not check for C or C++ mode.  This lead to
    1.14 +an error in libstdc++ configure, as reported by bug 21930.
    1.15 +
    1.16 +This patch adds a conditional for C mode in the definition of isinf for
    1.17 +float128.  No definition is provided in C++ mode, since libstdc++
    1.18 +headers undefine isinf.
    1.19 +
    1.20 +Tested for powerpc64le (glibc test suite and libstdc++-v3 configure).
    1.21 +
    1.22 +	[BZ #21930]
    1.23 +	* math/math.h (isinf): Check if in C or C++ mode before using
    1.24 +	__builtin_types_compatible_p, since this is a C mode feature.
    1.25 +---
    1.26 + math/math.h | 8 ++++++--
    1.27 + 1 file changed, 6 insertions(+), 2 deletions(-)
    1.28 +
    1.29 +diff --git a/math/math.h b/math/math.h
    1.30 +index e21708045a..dea8dbe1ae 100644
    1.31 +--- a/math/math.h
    1.32 ++++ b/math/math.h
    1.33 +@@ -442,8 +442,12 @@ enum
    1.34 + 
    1.35 + /* Return nonzero value if X is positive or negative infinity.  */
    1.36 + # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \
    1.37 +-     && !defined __SUPPORT_SNAN__
    1.38 +-   /* __builtin_isinf_sign is broken for float128 only before GCC 7.0.  */
    1.39 ++     && !defined __SUPPORT_SNAN__ && !defined __cplusplus
    1.40 ++   /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,
    1.41 ++      use the helper function, __isinff128, with older compilers.  This is
    1.42 ++      only provided for C mode, because in C++ mode, GCC has no support
    1.43 ++      for __builtin_types_compatible_p (and when in C++ mode, this macro is
    1.44 ++      not used anyway, because libstdc++ headers undefine it).  */
    1.45 + #  define isinf(x) \
    1.46 +     (__builtin_types_compatible_p (__typeof (x), _Float128) \
    1.47 +      ? __isinff128 (x) : __builtin_isinf_sign (x))
    1.48 +-- 
    1.49 +2.13.5
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/glibc/stuff/patches/glibc-2.26-math-2.patch	Fri Mar 16 12:33:33 2018 +0200
     2.3 @@ -0,0 +1,58 @@
     2.4 +    From: "Gabriel F. T. Gomes" <gftg at linux dot vnet dot ibm dot com>
     2.5 +    To: libc-alpha at sourceware dot org
     2.6 +    Date: Tue, 15 Aug 2017 14:45:00 -0300
     2.7 +    Subject: [PATCH 2/3] Provide a C++ version of issignaling that does not use __MATH_TG
     2.8 +    Authentication-results: sourceware.org; auth=none
     2.9 +    References: <20170815174501.4143-1-gftg@linux.vnet.ibm.com>
    2.10 +
    2.11 +The macro __MATH_TG contains the logic to select between long double and
    2.12 +_Float128, when these types are ABI-distinct.  This logic relies on
    2.13 +__builtin_types_compatible_p, which is not available in C++ mode.
    2.14 +
    2.15 +On the other hand, C++ function overloading provides the means to
    2.16 +distinguish between the floating-point types.  The overloading
    2.17 +resolution will match the correct parameter regardless of type
    2.18 +qualifiers, i.e.: const and volatile.
    2.19 +
    2.20 +Tested for powerpc64le.
    2.21 +
    2.22 +	* math/math.h [defined __cplusplus] (issignaling): Provide a C++
    2.23 +	definition for issignaling that does not rely on __MATH_TG,
    2.24 +	since __MATH_TG uses __builtin_types_compatible_p, which is only
    2.25 +	available in C mode.
    2.26 +---
    2.27 + math/math.h | 19 ++++++++++++++++++-
    2.28 + 1 file changed, 18 insertions(+), 1 deletion(-)
    2.29 +
    2.30 +diff --git a/math/math.h b/math/math.h
    2.31 +index dea8dbe1ae..1d6cdb0685 100644
    2.32 +--- a/math/math.h
    2.33 ++++ b/math/math.h
    2.34 +@@ -474,7 +474,24 @@ enum
    2.35 + # include <bits/iscanonical.h>
    2.36 + 
    2.37 + /* Return nonzero value if X is a signaling NaN.  */
    2.38 +-# define issignaling(x) __MATH_TG ((x), __issignaling, (x))
    2.39 ++# ifndef __cplusplus
    2.40 ++#  define issignaling(x) __MATH_TG ((x), __issignaling, (x))
    2.41 ++# else
    2.42 ++   /* In C++ mode, __MATH_TG cannot be used, because it relies on
    2.43 ++      __builtin_types_compatible_p, which is a C-only builtin.  On the
    2.44 ++      other hand, overloading provides the means to distinguish between
    2.45 ++      the floating-point types.  The overloading resolution will match
    2.46 ++      the correct parameter (regardless of type qualifiers (i.e.: const
    2.47 ++      and volatile).  */
    2.48 ++extern "C++" {
    2.49 ++int issignaling (float __val) { return __issignalingf (__val); }
    2.50 ++int issignaling (double __val) { return __issignaling (__val); }
    2.51 ++int issignaling (long double __val) { return __issignalingl (__val); }
    2.52 ++#if __HAVE_DISTINCT_FLOAT128
    2.53 ++int issignaling (_Float128  __val) { return __issignalingf128 (__val); }
    2.54 ++#endif
    2.55 ++} /* extern C++ */
    2.56 ++# endif
    2.57 + 
    2.58 + /* Return nonzero value if X is subnormal.  */
    2.59 + # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL)
    2.60 +-- 
    2.61 +2.13.5
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/glibc/stuff/patches/glibc-2.26-math-3.patch	Fri Mar 16 12:33:33 2018 +0200
     3.3 @@ -0,0 +1,53 @@
     3.4 +    From: "Gabriel F. T. Gomes" <gftg at linux dot vnet dot ibm dot com>
     3.5 +    To: libc-alpha at sourceware dot org
     3.6 +    Date: Tue, 15 Aug 2017 14:45:01 -0300
     3.7 +    Subject: [PATCH 3/3] Do not use generic selection in C++ mode
     3.8 +    Authentication-results: sourceware.org; auth=none
     3.9 +    References: <20170815174501.4143-1-gftg@linux.vnet.ibm.com>
    3.10 +
    3.11 +The logic to protect the use of generic selection (_Generic) does not
    3.12 +check for C or C++ mode, however, generic selection is a C-only
    3.13 +feature.
    3.14 +
    3.15 +Tested for powerpc64le.
    3.16 +
    3.17 +	* misc/sys/cdefs.h (__HAVE_GENERIC_SELECTION): Define to 0, if
    3.18 +	in C++ mode.
    3.19 +---
    3.20 + misc/sys/cdefs.h | 19 ++++++++++---------
    3.21 + 1 file changed, 10 insertions(+), 9 deletions(-)
    3.22 +
    3.23 +diff --git a/misc/sys/cdefs.h b/misc/sys/cdefs.h
    3.24 +index b3e7f3be96..cfd39d5302 100644
    3.25 +--- a/misc/sys/cdefs.h
    3.26 ++++ b/misc/sys/cdefs.h
    3.27 +@@ -463,17 +463,18 @@
    3.28 + # define __glibc_macro_warning(msg)
    3.29 + #endif
    3.30 + 
    3.31 +-/* Support for generic selection (ISO C11) is available in GCC since
    3.32 +-   version 4.9.  Previous versions do not provide generic selection,
    3.33 +-   even though they might set __STDC_VERSION__ to 201112L, when in
    3.34 +-   -std=c11 mode.  Thus, we must check for !defined __GNUC__ when
    3.35 +-   testing __STDC_VERSION__ for generic selection support.
    3.36 ++/* Generic selection (ISO C11) is a C-only feature, available in GCC
    3.37 ++   since version 4.9.  Previous versions do not provide generic
    3.38 ++   selection, even though they might set __STDC_VERSION__ to 201112L,
    3.39 ++   when in -std=c11 mode.  Thus, we must check for !defined __GNUC__
    3.40 ++   when testing __STDC_VERSION__ for generic selection support.
    3.41 +    On the other hand, Clang also defines __GNUC__, so a clang-specific
    3.42 +    check is required to enable the use of generic selection.  */
    3.43 +-#if __GNUC_PREREQ (4, 9) \
    3.44 +-    || __glibc_clang_has_extension (c_generic_selections) \
    3.45 +-    || (!defined __GNUC__ && defined __STDC_VERSION__ \
    3.46 +-	&& __STDC_VERSION__ >= 201112L)
    3.47 ++#if !defined __cplusplus \
    3.48 ++    && (__GNUC_PREREQ (4, 9) \
    3.49 ++	|| __glibc_clang_has_extension (c_generic_selections) \
    3.50 ++	|| (!defined __GNUC__ && defined __STDC_VERSION__ \
    3.51 ++	    && __STDC_VERSION__ >= 201112L))
    3.52 + # define __HAVE_GENERIC_SELECTION 1
    3.53 + #else
    3.54 + # define __HAVE_GENERIC_SELECTION 0
    3.55 +-- 
    3.56 +2.13.5
     4.1 --- a/glibc/stuff/patches/series	Fri Mar 16 12:14:10 2018 +0200
     4.2 +++ b/glibc/stuff/patches/series	Fri Mar 16 12:33:33 2018 +0200
     4.3 @@ -1,1 +1,8 @@
     4.4 +# LFS
     4.5  glibc-2.26-fhs-1.patch
     4.6 +
     4.7 +# https://sourceware.org/ml/libc-alpha/2017-08/msg00586.html
     4.8 +glibc-2.26-math-1.patch
     4.9 +glibc-2.26-math-2.patch
    4.10 +glibc-2.26-math-3.patch
    4.11 +# also see: https://github.com/voidlinux/void-packages/issues/7307