Set V8_CC_GNU or V8_CC_MSVC for clang in gcc / cl mode.
authorthakis <thakis@chromium.org>
Tue, 2 Dec 2014 05:23:09 +0000 (21:23 -0800)
committerCommit bot <commit-bot@chromium.org>
Tue, 2 Dec 2014 05:23:21 +0000 (05:23 +0000)
Also, remove V8_CC_CLANG since it's not read anywhere (and ideally shouldn't
be).

Clang tries to be compatible with gcc in clang mode, and with msvc in clang-cl
mode. It wants to go down the same code paths that these compilers want to go
down in most cases.

For example, V8PRIxPTR was set incorrectly on Windows 64-bit before this change
since macros.h assumed that checking for V8_CC_MSVC is enough to find LLP64
systems, but V8_CC_MSVC wasn't set for clang.  Most other existing checks for
V8_CC_MSVC should be taken for clang-cl too (and for the remaining ones,
clang-cl is happy with either code path).

Likewise, V8_IMMEDIATE_CRASH is currently set to a suboptimal value with clang
since __builtin_trap() is only used if V8_CC_GNU is set.

Including clang in the gcc and cl macros is also what chromium does.

BUG=chromium:82385
LOG=y

Review URL: https://codereview.chromium.org/757553004

Cr-Commit-Position: refs/heads/master@{#25592}

include/v8config.h

index 721ef37..d1ca22c 100644 (file)
 // -----------------------------------------------------------------------------
 // Compiler detection
 //
-//  V8_CC_CLANG   - Clang
-//  V8_CC_GNU     - GNU C++
+//  V8_CC_GNU     - GCC, or clang in gcc mode
 //  V8_CC_INTEL   - Intel C++
 //  V8_CC_MINGW   - Minimalist GNU for Windows
 //  V8_CC_MINGW32 - Minimalist GNU for Windows (mingw32)
 //  V8_CC_MINGW64 - Minimalist GNU for Windows (mingw-w64)
-//  V8_CC_MSVC    - Microsoft Visual C/C++
+//  V8_CC_MSVC    - Microsoft Visual C/C++, or clang in cl.exe mode
 //
 // C++11 feature detection
 //
 
 #if defined(__clang__)
 
-# define V8_CC_CLANG 1
+#if defined(__GNUC__)  // Clang in gcc mode.
+# define V8_CC_GNU 1
+#elif defined(_MSC_VER)  // Clang in cl mode.
+# define V8_CC_MSVC 1
+#endif
 
 // Clang defines __alignof__ as alias for __alignof
 # define V8_HAS___ALIGNOF 1