[libvirt] [PATCH] m4: workaround clang/glibc problem with isnan()

Daniel P. Berrange posted 1 patch 6 years, 8 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20170811162532.8679-1-berrange@redhat.com
m4/virt-compile-warnings.m4 | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
[libvirt] [PATCH] m4: workaround clang/glibc problem with isnan()
Posted by Daniel P. Berrange 6 years, 8 months ago
When building libvirt with clang we get bogus warnings about
'double' being promoted to 'long double' when calling isnan().

  https://bugzilla.redhat.com/show_bug.cgi?id=1472437

Detect this broken isnan() / compiler combination and disable
the -Wdouble-promotion flag.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
---
 m4/virt-compile-warnings.m4 | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index fa0940fc6..7b56115ce 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -134,6 +134,24 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
         [lv_cv_gcc_wlogical_op_equal_expr_broken=yes])
         CFLAGS="$save_CFLAGS"])
 
+    AC_CACHE_CHECK([whether clang gives bogus warnings for -Wdouble-promotion],
+      [lv_cv_clang_double_promotion_broken], [
+        save_CFLAGS="$CFLAGS"
+        CFLAGS="-O2 -Wdouble-promotion -Werror"
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+          #include <math.h>
+        ]], [[
+          float f = 0.0;
+	  return isnan(f);]])],
+        [lv_cv_clang_double_promotion_broken=no],
+        [lv_cv_clang_double_promotion_broken=yes])
+        CFLAGS="$save_CFLAGS"])
+
+    if test "$lv_cv_clang_double_promotion_broken" = "yes";
+    then
+      dontwarn="$dontwarn -Wdouble-promotion"
+    fi
+
     # We might fundamentally need some of these disabled forever, but
     # ideally we'd turn many of them on
     dontwarn="$dontwarn -Wfloat-equal"
-- 
2.13.3

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH] m4: workaround clang/glibc problem with isnan()
Posted by Pavel Hrdina 6 years, 8 months ago
On Fri, Aug 11, 2017 at 05:25:32PM +0100, Daniel P. Berrange wrote:
> When building libvirt with clang we get bogus warnings about
> 'double' being promoted to 'long double' when calling isnan().
> 
>   https://bugzilla.redhat.com/show_bug.cgi?id=1472437
> 
> Detect this broken isnan() / compiler combination and disable
> the -Wdouble-promotion flag.
> 
> Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
> ---
>  m4/virt-compile-warnings.m4 | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)

Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list