Enable C++11. Synch toolchains with Chrome.

* Consistently enable C++11 features on all platforms.
* Use the same ARM toolchain version as Chrome.
* Make clang the default on Mac OS X, just like Chrome.
* Use C99 on Mac OS X, again following Chrome.
* Small build fixes.

R=bmeurer@chromium.org

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

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22875 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent c503e741
......@@ -51,7 +51,7 @@ ifeq ($(ARCH), android_arm)
DEFINES += arm_neon=0 arm_version=7
TOOLCHAIN_ARCH = arm-linux-androideabi
TOOLCHAIN_PREFIX = $(TOOLCHAIN_ARCH)
TOOLCHAIN_VER = 4.6
TOOLCHAIN_VER = 4.8
else
ifeq ($(ARCH), android_arm64)
DEFINES = target_arch=arm64 v8_target_arch=arm64 android_target_arch=arm64 android_target_platform=L
......
......@@ -75,7 +75,12 @@
}, # Release
}, # configurations
'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter',
'-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions', ],
'-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions',
# Note: Using -std=c++0x will define __STRICT_ANSI__, which in
# turn will leave out some template stuff for 'long long'. What
# we want is -std=c++11, but this is not supported by GCC 4.6 or
# Xcode 4.2
'-std=gnu++0x' ],
'target_conditions': [
['_toolset=="target"', {
'cflags!': [
......
......@@ -33,7 +33,6 @@
'includes': ['toolchain.gypi'],
'variables': {
'component%': 'static_library',
'clang%': 0,
'asan%': 0,
'tsan%': 0,
'visibility%': 'hidden',
......@@ -117,6 +116,11 @@
}, {
'v8_enable_gdbjit%': 0,
}],
['OS=="mac"', {
'clang%': 1,
}, {
'clang%': 0,
}],
],
# Default ARM variable settings.
'arm_version%': 'default',
......@@ -214,12 +218,9 @@
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
'-Wno-long-long', '-pthread', '-fno-exceptions',
'-pedantic' ],
'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti' ],
'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
'ldflags': [ '-pthread', ],
'conditions': [
[ 'OS=="linux"', {
'cflags': [ '-ansi' ],
}],
[ 'visibility=="hidden" and v8_enable_backtrace==0', {
'cflags': [ '-fvisibility=hidden' ],
}],
......@@ -235,7 +236,7 @@
'target_defaults': {
'cflags': [ '-Wall', '<(werror)', '-W', '-Wno-unused-parameter',
'-fno-exceptions' ],
'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti' ],
'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
'conditions': [
[ 'visibility=="hidden"', {
'cflags': [ '-fvisibility=hidden' ],
......@@ -333,7 +334,7 @@
'target_defaults': {
'xcode_settings': {
'ALWAYS_SEARCH_USER_PATHS': 'NO',
'GCC_C_LANGUAGE_STANDARD': 'ansi', # -ansi
'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
# (Equivalent to -fPIC)
......@@ -369,7 +370,7 @@
['clang==1', {
'xcode_settings': {
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++11', # -std=gnu++11
'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x', # -std=gnu++0x
},
}],
],
......
......@@ -515,7 +515,7 @@ Thread::Thread(const Options& options)
: data_(new PlatformData),
stack_size_(options.stack_size()),
start_semaphore_(NULL) {
if (stack_size_ > 0 && stack_size_ < PTHREAD_STACK_MIN) {
if (stack_size_ > 0 && static_cast<size_t>(stack_size_) < PTHREAD_STACK_MIN) {
stack_size_ = PTHREAD_STACK_MIN;
}
set_name(options.name());
......
......@@ -719,7 +719,8 @@ Handle<String> JsonParser<seq_ascii>::ScanJsonString() {
} while (c0 != '"');
int length = position - position_;
uint32_t hash = (length <= String::kMaxHashCalcLength)
? StringHasher::GetHashCore(running_hash) : length;
? StringHasher::GetHashCore(running_hash)
: static_cast<uint32_t>(length);
Vector<const uint8_t> string_vector(
seq_source_->GetChars() + position_, length);
StringTable* string_table = isolate()->heap()->string_table();
......
......@@ -27,6 +27,8 @@
#include <stdlib.h>
#include <vector>
#include "src/v8.h"
#include "src/base/platform/platform.h"
......@@ -218,3 +220,40 @@ TEST(SequenceCollectorRegression) {
CHECK_EQ(0, strncmp("0123456789012345678901234567890123",
seq.start(), seq.length()));
}
// TODO(svenpanne) Unconditionally test this when our infrastructure is fixed.
#if !V8_CC_MSVC
TEST(CPlusPlus11Features) {
struct S {
bool x;
struct T {
double y;
int z[3];
} t;
};
S s{true, {3.1415, {1, 2, 3}}};
CHECK_EQ(2, s.t.z[1]);
// TODO(svenpanne) Remove the old-skool code when we ship the new C++ headers.
#if 0
std::vector<int> vec{11, 22, 33, 44};
#else
std::vector<int> vec;
vec.push_back(11);
vec.push_back(22);
vec.push_back(33);
vec.push_back(44);
#endif
vec.push_back(55);
vec.push_back(66);
for (auto& i : vec) {
++i;
}
int j = 12;
for (auto i : vec) {
CHECK_EQ(j, i);
j += 11;
}
}
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment