From: Romain Naour <romain.naour@gmail.com>
To: buildroot@busybox.net
Subject: [Buildroot] [PATCH] package/glibc: fix signbit build issue with gcc < 6.x
Date: Mon, 16 Oct 2017 21:34:14 +0200 [thread overview]
Message-ID: <63d5542e-b72b-e7fe-7e90-39f0cda4a630@gmail.com> (raw)
In-Reply-To: <20171015215736.3573-2-romain.naour@gmail.com>
Hi All,
Le 15/10/2017 ? 23:57, Romain Naour a ?crit?:
> As reported in [1], mesa3d package fail to build with a x86_64 toolchain
> using gcc 5.5.0 and glibc 2.26.
>
> Add a new patch providing signbit() functions for C++ that does not use
> __MATH_TG macro.
>
> [1] https://sourceware.org/bugzilla/show_bug.cgi?id=22296
I withdraw this patch since it's not the correct fix [1]
[1] https://sourceware.org/ml/libc-alpha/2017-10/msg00703.html
Best regards,
Romain
>
> Signed-off-by: Romain Naour <romain.naour@gmail.com>
> ---
> ...-version-of-signbit-that-does-not-use-__M.patch | 65 ++++++++++++++++++++++
> 1 file changed, 65 insertions(+)
> create mode 100644 package/glibc/0007-Provide-a-C-version-of-signbit-that-does-not-use-__M.patch
>
> diff --git a/package/glibc/0007-Provide-a-C-version-of-signbit-that-does-not-use-__M.patch b/package/glibc/0007-Provide-a-C-version-of-signbit-that-does-not-use-__M.patch
> new file mode 100644
> index 0000000..ea7a4e7
> --- /dev/null
> +++ b/package/glibc/0007-Provide-a-C-version-of-signbit-that-does-not-use-__M.patch
> @@ -0,0 +1,65 @@
> +From 2a735f52ec321f06b2af4b4265160d54260e5c44 Mon Sep 17 00:00:00 2001
> +From: Romain Naour <romain.naour@gmail.com>
> +Date: Sun, 15 Oct 2017 20:04:24 +0200
> +Subject: [PATCH] Provide a C++ version of signbit that does not use __MATH_TG
> + (bug 22296)
> +
> +The macro __MATH_TG contains the logic to select between long double and
> +_Float128, when these types are ABI-distinct. This logic relies on
> +__builtin_types_compatible_p, which is not available in C++ mode.
> +
> +On the other hand, C++ function 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.
> +
> +This is the same fix as for issignaling [1] but the issue appear
> +only with gcc < 6.x. Since GCC 6.0, __builtin_signbit is type-generic,
> +so signbit() is defined without __MATH_TG.
> +
> +Tested for x86_64.
> +
> + * math/math.h [defined __cplusplus] (signbit): Provide a C++
> + definition for signbit that does not rely on __MATH_TG,
> + since __MATH_TG uses __builtin_types_compatible_p, which is only
> + available in C mode.
> +
> +[1] a16e8bc08edca84d507715c66d6cddbbc7ed3b62
> +
> +Signed-off-by: Romain Naour <romain.naour@gmail.com>
> +---
> +patch status: submited upstream
> +https://sourceware.org/ml/libc-alpha/2017-10/msg00654.html
> +---
> + math/math.h | 15 +++++++++++++++
> + 1 file changed, 15 insertions(+)
> +
> +diff --git a/math/math.h b/math/math.h
> +index 2b216c6..0013ad9 100644
> +--- a/math/math.h
> ++++ b/math/math.h
> +@@ -418,6 +418,21 @@ 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. 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 signbit (float __val) { return __signbitf (__val); }
> ++inline int signbit (double __val) { return __signbit (__val); }
> ++inline int signbit (long double __val) { return __signbitl (__val); }
> ++# if __HAVE_DISTINCT_FLOAT128
> ++inline int signbit (_Float128 __val) { return __signbitf128 (__val); }
> ++# endif
> ++} /* extern C++ */
> + # elif __GNUC_PREREQ (4,0)
> + # define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))
> + # else
> +--
> +2.9.5
> +
>
next prev parent reply other threads:[~2017-10-16 19:34 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-15 21:57 [Buildroot] [PATCH] package/gcc: bump to 5.5.0 Romain Naour
2017-10-15 21:57 ` [Buildroot] [PATCH] package/glibc: fix signbit build issue with gcc < 6.x Romain Naour
2017-10-16 19:34 ` Romain Naour [this message]
2017-10-17 20:41 ` [Buildroot] [PATCH] package/gcc: bump to 5.5.0 Peter Korsgaard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=63d5542e-b72b-e7fe-7e90-39f0cda4a630@gmail.com \
--to=romain.naour@gmail.com \
--cc=buildroot@busybox.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox