From 50d248aa3fe5132382676cc5c91e313b5aa1036b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lubo=C5=A1=20Lu=C5=88=C3=A1k?= Date: Thu, 13 Jun 2013 19:29:32 +0200 Subject: [PATCH] work around the C++11 __float128 problem with libstdc++ headers and clang Change-Id: Ia1b443d22b3b7f6f93f1ad8c5fa760b0f1da3b83 --- compilerplugins/Makefile-clang.mk | 2 +- configure.ac | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/compilerplugins/Makefile-clang.mk b/compilerplugins/Makefile-clang.mk index 34b9ac9d83ac..29ca356d3266 100644 --- a/compilerplugins/Makefile-clang.mk +++ b/compilerplugins/Makefile-clang.mk @@ -73,7 +73,7 @@ CLANGOBJS= define clangbuildsrc $(3): $(2) $(SRCDIR)/compilerplugins/Makefile-clang.mk $(CLANGOUTDIR)/clang-timestamp @echo [build CXX] $(subst $(SRCDIR)/,,$(2)) - $(QUIET)$(CXX) $(CLANGCXXFLAGS) $(CLANGWERROR) $(CLANGDEFS) $(CLANGINCLUDES) -I$(BUILDDIR)/config_host $(2) -fPIC -std=c++11 -c -o $(3) -MMD -MT $(3) -MP -MF $(CLANGOUTDIR)/$(1).d + $(QUIET)$(CXX) $(CLANGCXXFLAGS) $(CLANGWERROR) $(CLANGDEFS) $(CLANGINCLUDES) -I$(BUILDDIR)/config_host $(2) -fPIC $(CXXFLAGS_CXX11) -c -o $(3) -MMD -MT $(3) -MP -MF $(CLANGOUTDIR)/$(1).d -include $(CLANGOUTDIR)/$(1).d diff --git a/configure.ac b/configure.ac index 07885b508786..6a612f923493 100644 --- a/configure.ac +++ b/configure.ac @@ -5647,8 +5647,31 @@ return !(i != 0 && j != 0); // (__float128) ]]) ],[ AC_MSG_RESULT(yes) ], - [ AC_MSG_RESULT(no) - HAVE_CXX11= + [ + AC_MSG_RESULT(no) + # The only reason why libstdc++ headers fail with Clang in C++11 mode is because + # they use the __float128 type that Clang doesn't know (libstdc++ checks whether + # __float128 is available during its build, but it's usually built using GCC, + # and so c++config.h hardcodes __float128 being supported). As the only place + # where __float128 is actually used is in a template specialization, + # -D__float128=void will avoid the problem there while still causing a problem + # if somebody actually uses the type. + AC_MSG_CHECKING([whether -D__float128=void workaround helps]) + CXXFLAGS="$CXXFLAGS -D__float128=void" + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ +#include + // some Clang fail when compiling against GCC 4.7 headers with -std=gnu++0x + // (__float128) +]]) + ], + [ + AC_MSG_RESULT(yes) + CXXFLAGS_CXX11="$CXXFLAGS_CXX11 -D__float128=void" + ], + [ + AC_MSG_RESULT(no) + HAVE_CXX11= + ]) ]) AC_LANG_POP([C++])