diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2013-08-09 18:09:38 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2013-08-09 18:28:32 +0200 |
commit | 63a1212a42bb0c5fa8f1d3d847a5e0fb6126d1c4 (patch) | |
tree | ab66d043ee65aca03197a4589350670071e82016 | |
parent | c3140e23ff7a22e3b4126a2d12ee90dfdcd19ce2 (diff) |
try to ensure not testing GCC version when using Clang
Clang reports itself as GCC 4.2.1 when asked the GCC way, which is about
as good an answer as any, since there's no good mapping between them.
So when testing GCC version, Clang would be usually considered too old,
and therefore the proper way is to do a configure check if possible.
GCC version should be only used for GCC-specific things such as avoiding
a bug in a specific GCC version, and such testing should first check
the compiler is not Clang.
Rename GCCVER to GCC_VERSION and use it throughout the build system
where needed. As it's empty for anything that's not GCC, this should
lead to errors when used incorrectly.
Change-Id: Iea96bbaf5d8ceabefa25be88576eeb4115384937
-rw-r--r-- | config_host.mk.in | 1 | ||||
-rw-r--r-- | configure.ac | 41 | ||||
-rw-r--r-- | solenv/gbuild/platform/WNT_INTEL_GCC.mk | 6 | ||||
-rw-r--r-- | solenv/gbuild/platform/com_GCC_defs.mk | 2 | ||||
-rw-r--r-- | solenv/gbuild/platform/solaris.mk | 5 | ||||
-rw-r--r-- | solenv/gbuild/platform/unxgcc.mk | 29 |
6 files changed, 46 insertions, 38 deletions
diff --git a/config_host.mk.in b/config_host.mk.in index e72648018411..4524b3b1933e 100644 --- a/config_host.mk.in +++ b/config_host.mk.in @@ -176,6 +176,7 @@ export FONTCONFIG_CFLAGS=$(gb_SPACE)@FONTCONFIG_CFLAGS@ export FONTCONFIG_LIBS=$(gb_SPACE)@FONTCONFIG_LIBS@ export FREETYPE_CFLAGS=$(gb_SPACE)@FREETYPE_CFLAGS@ export FREETYPE_LIBS=$(gb_SPACE)@FREETYPE_LIBS@ +export GCC_VERSION=@GCC_VERSION@ export GCONF_CFLAGS=$(gb_SPACE)@GCONF_CFLAGS@ export GCONF_LIBS=$(gb_SPACE)@GCONF_LIBS@ export GIO_CFLAGS=$(gb_SPACE)@GIO_CFLAGS@ diff --git a/configure.ac b/configure.ac index 8fc59dc5fb9c..199456b77934 100644 --- a/configure.ac +++ b/configure.ac @@ -2925,20 +2925,6 @@ fi AC_SUBST(CROSS_COMPILING) dnl =================================================================== -dnl Test the gcc version -dnl =================================================================== -if test "$GCC" = "yes"; then - AC_MSG_CHECKING([the GCC version]) - _gcc_version=`$CC -dumpversion` - GCCVER=`echo $_gcc_version | $AWK -F. '{ print \$1*100+\$2 }'` - - AC_MSG_RESULT([gcc $_gcc_version]) - if test "$GCCVER" -lt 0400; then - AC_MSG_ERROR([GCC $_gcc_version is too old, must be at least GCC 4.0.0]) - fi -fi - -dnl =================================================================== dnl Is GCC actually Clang? dnl =================================================================== @@ -2973,6 +2959,27 @@ if test "$CCACHE" != "" -a "$COM_GCC_IS_CLANG" = TRUE; then fi fi +dnl =================================================================== +dnl Test the gcc version +dnl =================================================================== +if test "$GCC" = "yes" -a -z "$COM_GCC_IS_CLANG"; then + AC_MSG_CHECKING([the GCC version]) + _gcc_version=`$CC -dumpversion` + GCC_VERSION=`echo $_gcc_version | $AWK -F. '{ print \$1*100+\$2 }'` + + AC_MSG_RESULT([gcc $_gcc_version]) + if test "$GCC_VERSION" -lt 0400; then + AC_MSG_ERROR([GCC $_gcc_version is too old, must be at least GCC 4.0.0]) + fi +else + # Explicitly force GCC_VERSION to be empty, even for Clang, to check incorrect uses. + # GCC version should generally be checked only when handling GCC-specific bugs, for testing + # things like features configure checks should be used, otherwise they may e.g. fail with Clang + # (which reports itself as GCC 4.2.1). + GCC_VERSION= +fi +AC_SUBST(GCC_VERSION) + # =================================================================== # check various GCC options that Clang does not support now but maybe # will somewhen in the future, check them even for GCC, so that the @@ -5596,10 +5603,10 @@ if test "$GCC" = "yes"; then dnl libstdc++-v3/libsupc++/guard.cc for what #ifdefs actually make a dnl difference there. Conservative advice from Jakub Jelinek is to assume dnl it working in GCC >= 4.3, so conservative way to check here is to use - dnl GCCVER for GCC but resort to __GLIBCXX__ corresponding to libstdc++ + dnl GCC_VERSION for GCC but resort to __GLIBCXX__ corresponding to libstdc++ dnl shipped with GCC 4.3.0 (cf. <http://gcc.gnu.org/onlinedocs/libstdc++/ dnl manual/abi.html#abi.versioning.history>; 4.3.0 is 20080306, 4.2.4 is - dnl 20080519, 4.3.1 is 20080606) for Clang (for which GCCVER is notoriously + dnl 20080519, 4.3.1 is 20080606) for Clang (for which GCC_VERSION is notoriously dnl "too old"): if test "$_os" != Darwin -a "$_os" != Android; then if test "$COM_GCC_IS_CLANG" = TRUE; then @@ -5611,7 +5618,7 @@ if test "$GCC" = "yes"; then #endif ]])],[HAVE_THREADSAFE_STATICS=TRUE],[]) AC_LANG_POP([C++]) - elif test "${GCCVER?}" -ge 0403; then + elif test "${GCC_VERSION?}" -ge 0403; then HAVE_THREADSAFE_STATICS=TRUE fi fi diff --git a/solenv/gbuild/platform/WNT_INTEL_GCC.mk b/solenv/gbuild/platform/WNT_INTEL_GCC.mk index 49b0103b1562..728e0426322f 100644 --- a/solenv/gbuild/platform/WNT_INTEL_GCC.mk +++ b/solenv/gbuild/platform/WNT_INTEL_GCC.mk @@ -25,12 +25,11 @@ gb_TMPDIR:=$(if $(TMPDIR),$(TMPDIR),/tmp) include $(GBUILDDIR)/platform/com_GCC_defs.mk include $(GBUILDDIR)/platform/windows.mk +ifeq ($(COM_GCC_IS_CLANG),) # This has to do something with calling conventions, which are different # for x86 and x64. Don't put it in the common part since it is breaking # and conde that uses boost::bind -gb_CCVER := $(shell $(gb_CC) -dumpversion | $(gb_AWK) -F. -- \ - '{ print $$1*10000+$$2*100+$$3 }') -gb_GccLess470 := $(shell expr $(gb_CCVER) \< 40700) +gb_GccLess470 := $(shell expr $(GCC_VERSION) \< 407) # Until GCC 4.6, MinGW used __cdecl by default, and BOOST_MEM_FN_ENABLE_CDECL # would result in ambiguous calls to overloaded boost::bind; since GCC 4.7, @@ -39,6 +38,7 @@ gb_GccLess470 := $(shell expr $(gb_CCVER) \< 40700) ifeq ($(gb_GccLess470),0) gb_COMPILERDEFS += -DBOOST_MEM_FN_ENABLE_CDECL endif +endif include $(GBUILDDIR)/platform/mingw.mk diff --git a/solenv/gbuild/platform/com_GCC_defs.mk b/solenv/gbuild/platform/com_GCC_defs.mk index b229258e0375..566d87116ea7 100644 --- a/solenv/gbuild/platform/com_GCC_defs.mk +++ b/solenv/gbuild/platform/com_GCC_defs.mk @@ -37,8 +37,6 @@ ifeq ($(strip $(gb_COMPILERDEFAULTOPTFLAGS)),) gb_COMPILERDEFAULTOPTFLAGS := -O2 endif -gb_CCVER := $(shell $(gb_CC) -dumpversion | $(gb_AWK) -F. -- '{ print $$1*10000+$$2*100+$$3 }') - gb_SHORTSTDC3 := 1 gb_SHORTSTDCPP3 := 6 diff --git a/solenv/gbuild/platform/solaris.mk b/solenv/gbuild/platform/solaris.mk index 58c9b6835b9d..f9d236b1c466 100644 --- a/solenv/gbuild/platform/solaris.mk +++ b/solenv/gbuild/platform/solaris.mk @@ -74,8 +74,8 @@ gb_COMPILERDEFS += \ endif -gb_CCVER := $(shell $(gb_CC) -dumpversion | $(gb_AWK) -F. -- '{ print $$1*10000+$$2*100+$$3 }') -gb_GccLess460 := $(shell expr $(gb_CCVER) \< 40600) +ifeq ($(COM_GCC_IS_CLANG),) +gb_GccLess460 := $(shell expr $(GCC_VERSION) \< 406) #At least SLED 10.2 gcc 4.3 overly agressively optimizes uno::Sequence into #junk, so only strict-alias on >= 4.6.0 @@ -85,6 +85,7 @@ ifeq ($(gb_StrictAliasingUnsafe),1) gb_CFLAGS += -fno-strict-aliasing gb_CXXFLAGS += -fno-strict-aliasing endif +endif ifeq ($(HAVE_CXX11),TRUE) #Currently, as well as for its own merits, c++11/c++0x mode allows use to use diff --git a/solenv/gbuild/platform/unxgcc.mk b/solenv/gbuild/platform/unxgcc.mk index 17b9eb2c413c..9eb79fd9e2c0 100644 --- a/solenv/gbuild/platform/unxgcc.mk +++ b/solenv/gbuild/platform/unxgcc.mk @@ -23,9 +23,6 @@ gb_PROGRAMDIRNAME := program include $(GBUILDDIR)/platform/com_GCC_defs.mk -gb_CCVER := $(shell $(gb_CC) -dumpversion | $(gb_AWK) -F. -- '{ print $$1*10000+$$2*100+$$3 }') -gb_GccLess460 := $(shell expr $(gb_CCVER) \< 40600) - gb_MKTEMP := mktemp -t gbuild.XXXXXX ifneq ($(origin AR),default) @@ -51,7 +48,9 @@ gb_CXXFLAGS := \ -Wshadow \ -Woverloaded-virtual \ -ifneq ($(COM_GCC_IS_CLANG),TRUE) +ifeq ($(COM_GCC_IS_CLANG),) +gb_GccLess460 := $(shell expr $(GCC_VERSION) \< 406) + # Only GCC 4.6 has a fix for <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=7302> # "-Wnon-virtual-dtor should't complain of protected dtor" and supports #pragma # GCC diagnostic push/pop required e.g. in cppuhelper/propertysetmixin.hxx to @@ -62,16 +61,6 @@ gb_CXXFLAGS += -Wno-non-virtual-dtor else gb_CXXFLAGS += -Wnon-virtual-dtor endif -else -gb_CXXFLAGS += -Wnon-virtual-dtor -endif - -# enable debug STL -ifeq ($(gb_ENABLE_DBGUTIL),$(true)) -gb_COMPILERDEFS += \ - -D_GLIBCXX_DEBUG \ - -endif #At least SLED 10.2 gcc 4.3 overly agressively optimizes uno::Sequence into #junk, so only strict-alias on >= 4.6.0 @@ -82,6 +71,18 @@ gb_CFLAGS += -fno-strict-aliasing gb_CXXFLAGS += -fno-strict-aliasing endif +else # Clang +gb_CXXFLAGS += -Wnon-virtual-dtor +endif + + +# enable debug STL +ifeq ($(gb_ENABLE_DBGUTIL),$(true)) +gb_COMPILERDEFS += \ + -D_GLIBCXX_DEBUG \ + +endif + ifeq ($(HAVE_CXX11),TRUE) #Currently, as well as for its own merits, c++11/c++0x mode allows use to use #a template for SAL_N_ELEMENTS to detect at compiler time its misuse |