[PPL-devel] [GIT] ppl/ppl(master): Detect when clang++ is used, and disable -frounding-math in that case.

Marco Poletti poletti.marco at gmail.com
Sun Dec 4 15:06:22 CET 2011


Module: ppl/ppl
Branch: master
Commit: fa6a077aa6dade2b1ab150fafc53ff0ceb68d829
URL:    http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=fa6a077aa6dade2b1ab150fafc53ff0ceb68d829

Author: Marco Poletti <poletti.marco at gmail.com>
Date:   Sun Dec  4 15:04:11 2011 +0100

Detect when clang++ is used, and disable -frounding-math in that case.

---

 configure.ac |   49 ++++++++++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 48 insertions(+), 1 deletions(-)

diff --git a/configure.ac b/configure.ac
index 912af57..db4f1d8 100644
--- a/configure.ac
+++ b/configure.ac
@@ -173,6 +173,25 @@ choke me
   AC_LANG_POP(C)
 fi
 
+# The clang compiler masquerades as gcc, but we want to know.
+if test x"$GCC" = xyes
+then
+  AC_MSG_CHECKING([whether we are actually using Clang])
+  AC_LANG_PUSH(C)
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#ifndef __clang__
+choke me
+#endif
+]])],
+  AC_MSG_RESULT(yes)
+  CLANG=yes,
+  AC_MSG_RESULT(no)
+  CLANG=no,
+  AC_MSG_RESULT(no)
+  CLANG=no)
+  AC_LANG_POP(C)
+fi
+
 save_CXXFLAGS="$CXXFLAGS"
 AC_PROG_CXX
 CXXFLAGS="$save_CXXFLAGS"
@@ -196,6 +215,25 @@ choke me
   AC_LANG_POP(C++)
 fi
 
+# The clang++ compiler masquerades as g++, but we want to know.
+if test x"$GXX" = xyes
+then
+  AC_MSG_CHECKING([whether we are actually using clang++])
+  AC_LANG_PUSH(C++)
+  AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
+#ifndef __clang__
+choke me
+#endif
+]])],
+  AC_MSG_RESULT(yes)
+  CLANGXX=yes,
+  AC_MSG_RESULT(no)
+  CLANGXX=no,
+  AC_MSG_RESULT(no)
+  CLANGXX=no)
+  AC_LANG_POP(C++)
+fi
+
 AC_PROG_FGREP
 AC_PROG_EGREP
 AC_PROG_SED
@@ -452,7 +490,16 @@ then
   then
     OPT_FLAGS="$OPT_FLAGS -fp-model strict -fp-speculation off"
   else
-    OPT_FLAGS="$OPT_FLAGS -frounding-math"
+    # -frounding-math is not yet supported in clang++, if we use it we get
+    # lots of warnings.
+    if test x"$CLANGXX" = xyes
+    then
+      AC_MSG_WARN([DISABLING -frounding-math:
+*** clang++ detected, disabling -frounding-math.
+*** NOTE THAT THIS CAN GIVE WRONG RESULTS!])
+    else
+      OPT_FLAGS="$OPT_FLAGS -frounding-math"
+    fi
   fi
 fi
 




More information about the PPL-devel mailing list