summaryrefslogtreecommitdiffstats
path: root/build/pkgs/mpfr/patches/clang_workaround.patch
diff options
context:
space:
mode:
Diffstat (limited to 'build/pkgs/mpfr/patches/clang_workaround.patch')
-rw-r--r--build/pkgs/mpfr/patches/clang_workaround.patch20
1 files changed, 20 insertions, 0 deletions
diff --git a/build/pkgs/mpfr/patches/clang_workaround.patch b/build/pkgs/mpfr/patches/clang_workaround.patch
new file mode 100644
index 00000000..845ee1a
--- /dev/null
+++ b/build/pkgs/mpfr/patches/clang_workaround.patch
@@ -0,0 +1,20 @@
+diff --git a/src/set_d.c b/src/set_d.c
+index c076ccf..5fc9548 100644
+--- a/src/set_d.c
++++ b/src/set_d.c
+@@ -118,8 +118,15 @@ __gmpfr_extract_double (mpfr_limb_ptr rp, double d)
+
+ d *= MP_BASE_AS_DOUBLE;
+ #if GMP_NUMB_BITS >= 64
++#ifndef __clang__
+ manl = d;
+ #else
++ /* clang produces an invalid exception when d >= 2^63,
++ see https://bugs.llvm.org//show_bug.cgi?id=17686.
++ Since this is always the case, here, we use the following patch. */
++ manl = 0x8000000000000000 + (mp_limb_t) (d - 0x8000000000000000);
++#endif /* __clang__ */
++#else
+ manh = (mp_limb_t) d;
+ manl = (mp_limb_t) ((d - manh) * MP_BASE_AS_DOUBLE);
+ #endif