clang claim to be gcc 4.8.1 instead of 4.2.1

Yaron Keren yaron.keren at gmail.com
Wed Nov 12 14:55:25 PST 2014


gcc 4.2.1 is really old from 2008.  Some configuration headers such as
boost "libstdcpp3.hpp" behave differently for pre-gcc 4.3 or later.

gcc 4.8.1 is more recent, reasonable claim for clang.

I had tried going for 4.9.1 but encountered a problem with intrinsics in
mingw 4.9.1 intrin.h which are treated differently for gcc 4.9 or later:

 * On GCC 4.9 we may always include those headers. On older GCCs, we may do
it only if CPU
 * features used by them are enabled, so we need to check macros like
__SSE__ or __MMX__ first.
 */
#if __MINGW_GNUC_PREREQ(4, 9)
#define __MINGW_FORCE_SYS_INTRINS
#endif
...

this does not work correctly with clang since the headers try to use SSE3
instructions without __SSE3__ being defined and fail.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20141113/14d7a63e/attachment.html>
-------------- next part --------------
Index: tools/clang/lib/Frontend/InitPreprocessor.cpp
===================================================================
--- tools/clang/lib/Frontend/InitPreprocessor.cpp	(revision 221822)
+++ tools/clang/lib/Frontend/InitPreprocessor.cpp	(working copy)
@@ -475,9 +475,9 @@
 #undef TOSTR
 #undef TOSTR2
   if (!LangOpts.MSVCCompat) {
-    // Currently claim to be compatible with GCC 4.2.1-5621, but only if we're
+    // Currently claim to be compatible with GCC 4.8.1, but only if we're
     // not compiling for MSVC compatibility
-    Builder.defineMacro("__GNUC_MINOR__", "2");
+    Builder.defineMacro("__GNUC_MINOR__", "8");
     Builder.defineMacro("__GNUC_PATCHLEVEL__", "1");
     Builder.defineMacro("__GNUC__", "4");
     Builder.defineMacro("__GXX_ABI_VERSION", "1002");
@@ -495,9 +495,9 @@
   Builder.defineMacro("__PRAGMA_REDEFINE_EXTNAME", "1");
 
   // As sad as it is, enough software depends on the __VERSION__ for version
-  // checks that it is necessary to report 4.2.1 (the base GCC version we claim
+  // checks that it is necessary to report 4.8.1 (the base GCC version we claim
   // compatibility with) first.
-  Builder.defineMacro("__VERSION__", "\"4.2.1 Compatible " + 
+  Builder.defineMacro("__VERSION__", "\"4.8.1 Compatible " + 
                       Twine(getClangFullCPPVersion()) + "\"");
 
   // Initialize language-specific preprocessor defines.
Index: tools/clang/test/Preprocessor/init.c
===================================================================
--- tools/clang/test/Preprocessor/init.c	(revision 221822)
+++ tools/clang/test/Preprocessor/init.c	(working copy)
@@ -5860,7 +5860,7 @@
 // SPARC:#define __UINT_LEAST8_MAX__ 255
 // SPARC:#define __UINT_LEAST8_TYPE__ unsigned char
 // SPARC:#define __USER_LABEL_PREFIX__ _
-// SPARC:#define __VERSION__ "4.2.1 Compatible
+// SPARC:#define __VERSION__ "4.8.1 Compatible
 // SPARC:#define __WCHAR_MAX__ 2147483647
 // SPARC:#define __WCHAR_TYPE__ int
 // SPARC:#define __WCHAR_WIDTH__ 32


More information about the cfe-commits mailing list