From: Daniel P. Berrange Date: Fri, 11 Aug 2017 16:23:56 +0000 (+0100) Subject: m4: workaround clang/glibc problem with isnan() X-Git-Tag: v3.7.0-rc1~174 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c21dd711c7f31222aae8cc5f510dc193872a50c;p=thirdparty%2Flibvirt.git m4: workaround clang/glibc problem with isnan() 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. Reviewed-by: Pavel Hrdina Signed-off-by: Daniel P. Berrange --- diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index fa0940fc68..7b56115ce6 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 + ]], [[ + 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"