Upgrade V8 to version 4.9.385.28
https://chromium.googlesource.com/v8/v8/+/4.9.385.28
FPIIM-449
Change-Id: I4b2e74289d4bf3667f2f3dc8aa2e541f63e26eb4
diff --git a/build/OWNERS b/build/OWNERS
new file mode 100644
index 0000000..0e56af3
--- /dev/null
+++ b/build/OWNERS
@@ -0,0 +1 @@
+machenbach@chromium.org
diff --git a/build/all.gyp b/build/all.gyp
index 4aeb507..0a05a2f 100644
--- a/build/all.gyp
+++ b/build/all.gyp
@@ -19,6 +19,24 @@
'../tools/parser-shell.gyp:parser-shell',
],
}],
+ ['test_isolation_mode != "noop"', {
+ 'dependencies': [
+ '../test/bot_default.gyp:*',
+ '../test/benchmarks/benchmarks.gyp:*',
+ '../test/default.gyp:*',
+ '../test/ignition.gyp:*',
+ '../test/intl/intl.gyp:*',
+ '../test/message/message.gyp:*',
+ '../test/mjsunit/mjsunit.gyp:*',
+ '../test/mozilla/mozilla.gyp:*',
+ '../test/optimize_for_size.gyp:*',
+ '../test/preparser/preparser.gyp:*',
+ '../test/simdjs/simdjs.gyp:*',
+ '../test/test262/test262.gyp:*',
+ '../test/webkit/webkit.gyp:*',
+ '../tools/check-static-initializers.gyp:*',
+ ],
+ }],
]
}
]
diff --git a/build/android.gypi b/build/android.gypi
deleted file mode 100644
index 5d3b25a..0000000
--- a/build/android.gypi
+++ /dev/null
@@ -1,279 +0,0 @@
-# Copyright 2012 the V8 project authors. All rights reserved.
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following
-# disclaimer in the documentation and/or other materials provided
-# with the distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived
-# from this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-# Definitions for building standalone V8 binaries to run on Android.
-# This is mostly excerpted from:
-# http://src.chromium.org/viewvc/chrome/trunk/src/build/common.gypi
-
-{
- 'variables': {
- # Location of Android NDK.
- 'variables': {
- 'android_ndk_root%': '<!(/bin/echo -n $ANDROID_NDK_ROOT)',
- 'android_toolchain%': '<!(/bin/echo -n $ANDROID_TOOLCHAIN)',
- },
- 'conditions': [
- ['android_ndk_root==""', {
- 'variables': {
- 'android_sysroot': '<(android_toolchain)/sysroot/',
- 'android_stlport': '<(android_toolchain)/sources/cxx-stl/stlport/',
- },
- 'android_include': '<(android_sysroot)/usr/include',
- 'android_lib': '<(android_sysroot)/usr/lib',
- 'android_stlport_include': '<(android_stlport)/stlport',
- 'android_stlport_libs': '<(android_stlport)/libs',
- }, {
- 'variables': {
- 'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)',
- 'android_stlport': '<(android_ndk_root)/sources/cxx-stl/stlport/',
- },
- 'android_include': '<(android_sysroot)/usr/include',
- 'android_lib': '<(android_sysroot)/usr/lib',
- 'android_stlport_include': '<(android_stlport)/stlport',
- 'android_stlport_libs': '<(android_stlport)/libs',
- }],
- ],
- # Enable to use the system stlport, otherwise statically
- # link the NDK one?
- 'use_system_stlport%': '<(android_webview_build)',
- 'android_stlport_library': 'stlport_static',
- }, # variables
- 'target_defaults': {
- 'defines': [
- 'ANDROID',
- 'V8_ANDROID_LOG_STDOUT',
- ],
- 'configurations': {
- 'Release': {
- 'cflags': [
- '-fomit-frame-pointer',
- ],
- }, # Release
- }, # configurations
- 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'],
- 'cflags_cc': [ '-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!': [
- '-pthread', # Not supported by Android toolchain.
- ],
- 'cflags': [
- '-ffunction-sections',
- '-funwind-tables',
- '-fstack-protector',
- '-fno-short-enums',
- '-finline-limit=64',
- '-Wa,--noexecstack',
- # Note: This include is in cflags to ensure that it comes after
- # all of the includes.
- '-I<(android_include)',
- ],
- 'cflags_cc': [
- '-Wno-error=non-virtual-dtor', # TODO(michaelbai): Fix warnings.
- ],
- 'defines': [
- 'ANDROID',
- #'__GNU_SOURCE=1', # Necessary for clone()
- 'USE_STLPORT=1',
- '_STLP_USE_PTR_SPECIALIZATIONS=1',
- 'HAVE_OFF64_T',
- 'HAVE_SYS_UIO_H',
- 'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
- ],
- 'ldflags!': [
- '-pthread', # Not supported by Android toolchain.
- ],
- 'ldflags': [
- '-nostdlib',
- '-Wl,--no-undefined',
- ],
- 'libraries!': [
- '-lrt', # librt is built into Bionic.
- # Not supported by Android toolchain.
- # Where do these come from? Can't find references in
- # any Chromium gyp or gypi file. Maybe they come from
- # gyp itself?
- '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4',
- ],
- 'libraries': [
- '-l<(android_stlport_library)',
- # Manually link the libgcc.a that the cross compiler uses.
- '<!($CC -print-libgcc-file-name)',
- '-lc',
- '-ldl',
- '-lstdc++',
- '-lm',
- ],
- 'conditions': [
- ['android_webview_build==0', {
- 'ldflags': [
- '-Wl,-rpath-link=<(android_lib)',
- '-L<(android_lib)',
- ],
- }],
- ['target_arch == "arm"', {
- 'ldflags': [
- # Enable identical code folding to reduce size.
- '-Wl,--icf=safe',
- ],
- }],
- ['target_arch=="arm" and arm_version==7', {
- 'cflags': [
- '-march=armv7-a',
- '-mtune=cortex-a8',
- '-mfpu=vfp3',
- ],
- }],
- # NOTE: The stlport header include paths below are specified in
- # cflags rather than include_dirs because they need to come
- # after include_dirs. Think of them like system headers, but
- # don't use '-isystem' because the arm-linux-androideabi-4.4.3
- # toolchain (circa Gingerbread) will exhibit strange errors.
- # The include ordering here is important; change with caution.
- ['use_system_stlport==0', {
- 'cflags': [
- '-I<(android_stlport_include)',
- ],
- 'conditions': [
- ['target_arch=="arm" and arm_version==7', {
- 'ldflags': [
- '-L<(android_stlport_libs)/armeabi-v7a',
- ],
- }],
- ['target_arch=="arm" and arm_version < 7', {
- 'ldflags': [
- '-L<(android_stlport_libs)/armeabi',
- ],
- }],
- ['target_arch=="mipsel"', {
- 'ldflags': [
- '-L<(android_stlport_libs)/mips',
- ],
- }],
- ['target_arch=="ia32" or target_arch=="x87"', {
- 'ldflags': [
- '-L<(android_stlport_libs)/x86',
- ],
- }],
- ['target_arch=="x64"', {
- 'ldflags': [
- '-L<(android_stlport_libs)/x86_64',
- ],
- }],
- ['target_arch=="arm64"', {
- 'ldflags': [
- '-L<(android_stlport_libs)/arm64-v8a',
- ],
- }],
- ],
- }],
- ['target_arch=="ia32" or target_arch=="x87"', {
- # The x86 toolchain currently has problems with stack-protector.
- 'cflags!': [
- '-fstack-protector',
- ],
- 'cflags': [
- '-fno-stack-protector',
- ],
- }],
- ['target_arch=="mipsel"', {
- # The mips toolchain currently has problems with stack-protector.
- 'cflags!': [
- '-fstack-protector',
- '-U__linux__'
- ],
- 'cflags': [
- '-fno-stack-protector',
- ],
- }],
- ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64") and component!="shared_library"', {
- 'cflags': [
- '-fPIE',
- ],
- 'ldflags': [
- '-pie',
- ],
- }],
- ],
- 'target_conditions': [
- ['_type=="executable"', {
- 'conditions': [
- ['target_arch=="arm64"', {
- 'ldflags': [
- '-Wl,-dynamic-linker,/system/bin/linker64',
- ],
- }, {
- 'ldflags': [
- '-Wl,-dynamic-linker,/system/bin/linker',
- ],
- }]
- ],
- 'ldflags': [
- '-Bdynamic',
- '-Wl,-z,nocopyreloc',
- # crtbegin_dynamic.o should be the last item in ldflags.
- '<(android_lib)/crtbegin_dynamic.o',
- ],
- 'libraries': [
- # crtend_android.o needs to be the last item in libraries.
- # Do not add any libraries after this!
- '<(android_lib)/crtend_android.o',
- ],
- }],
- ['_type=="shared_library"', {
- 'ldflags': [
- '-Wl,-shared,-Bsymbolic',
- '<(android_lib)/crtbegin_so.o',
- ],
- }],
- ['_type=="static_library"', {
- 'ldflags': [
- # Don't export symbols from statically linked libraries.
- '-Wl,--exclude-libs=ALL',
- ],
- }],
- ],
- }], # _toolset=="target"
- # Settings for building host targets using the system toolchain.
- ['_toolset=="host"', {
- 'cflags': [ '-pthread' ],
- 'ldflags': [ '-pthread' ],
- 'ldflags!': [
- '-Wl,-z,noexecstack',
- '-Wl,--gc-sections',
- '-Wl,-O1',
- '-Wl,--as-needed',
- ],
- }],
- ], # target_conditions
- }, # target_defaults
-}
diff --git a/build/config/win/msvs_dependencies.isolate b/build/config/win/msvs_dependencies.isolate
new file mode 100644
index 0000000..ff92227
--- /dev/null
+++ b/build/config/win/msvs_dependencies.isolate
@@ -0,0 +1,77 @@
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+{
+ 'conditions': [
+ # Copy the VS runtime DLLs into the isolate so that they
+ # don't have to be preinstalled on the target machine.
+ #
+ # VS2013 runtimes
+ ['OS=="win" and msvs_version==2013 and component=="shared_library" and CONFIGURATION_NAME=="Debug"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/x64/msvcp120d.dll',
+ '<(PRODUCT_DIR)/x64/msvcr120d.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2013 and component=="shared_library" and CONFIGURATION_NAME=="Release"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/x64/msvcp120.dll',
+ '<(PRODUCT_DIR)/x64/msvcr120.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2013 and component=="shared_library" and (CONFIGURATION_NAME=="Debug" or CONFIGURATION_NAME=="Debug_x64")', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/msvcp120d.dll',
+ '<(PRODUCT_DIR)/msvcr120d.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2013 and component=="shared_library" and (CONFIGURATION_NAME=="Release" or CONFIGURATION_NAME=="Release_x64")', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/msvcp120.dll',
+ '<(PRODUCT_DIR)/msvcr120.dll',
+ ],
+ },
+ }],
+ # VS2015 runtimes
+ ['OS=="win" and msvs_version==2015 and component=="shared_library" and CONFIGURATION_NAME=="Debug"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/x64/msvcp140d.dll',
+ '<(PRODUCT_DIR)/x64/vccorlib140d.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2015 and component=="shared_library" and CONFIGURATION_NAME=="Release"', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/x64/msvcp140.dll',
+ '<(PRODUCT_DIR)/x64/vccorlib140.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2015 and component=="shared_library" and (CONFIGURATION_NAME=="Debug" or CONFIGURATION_NAME=="Debug_x64")', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/msvcp140d.dll',
+ '<(PRODUCT_DIR)/vccorlib140d.dll',
+ ],
+ },
+ }],
+ ['OS=="win" and msvs_version==2015 and component=="shared_library" and (CONFIGURATION_NAME=="Release" or CONFIGURATION_NAME=="Release_x64")', {
+ 'variables': {
+ 'files': [
+ '<(PRODUCT_DIR)/msvcp140.dll',
+ '<(PRODUCT_DIR)/vccorlib140.dll',
+ ],
+ },
+ }],
+ ],
+}
\ No newline at end of file
diff --git a/build/detect_v8_host_arch.py b/build/detect_v8_host_arch.py
index 3460a9a..89e8286 100644
--- a/build/detect_v8_host_arch.py
+++ b/build/detect_v8_host_arch.py
@@ -41,6 +41,7 @@
"""Hook to be called from gyp without starting a separate python
interpreter."""
host_arch = platform.machine()
+ host_system = platform.system();
# Convert machine type to format recognized by gyp.
if re.match(r'i.86', host_arch) or host_arch == 'i86pc':
@@ -56,6 +57,13 @@
elif host_arch.startswith('mips'):
host_arch = 'mipsel'
+ # Under AIX the value returned by platform.machine is not
+ # the best indicator of the host architecture
+ # AIX 6.1 which is the lowest level supported only provides
+ # a 64 bit kernel
+ if host_system == 'AIX':
+ host_arch = 'ppc64'
+
# platform.machine is based on running kernel. It's possible to use 64-bit
# kernel with 32-bit userland, e.g. to give linker slightly more memory.
# Distinguish between different userland bitness by querying
diff --git a/build/download_gold_plugin.py b/build/download_gold_plugin.py
new file mode 100755
index 0000000..b8131fd
--- /dev/null
+++ b/build/download_gold_plugin.py
@@ -0,0 +1,81 @@
+#!/usr/bin/env python
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Copyright 2015 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""Script to download LLVM gold plugin from google storage."""
+
+import json
+import os
+import re
+import platform
+import shutil
+import subprocess
+import sys
+import zipfile
+
+# Bail out on windows and cygwin.
+if "win" in platform.system().lower():
+ # Python 2.7.6 hangs at the second path.insert command on windows. Works
+ # with python 2.7.8.
+ print "Gold plugin download not supported on windows."
+ sys.exit(0)
+
+SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
+CHROME_SRC = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
+sys.path.insert(0, os.path.join(CHROME_SRC, 'tools'))
+
+import find_depot_tools
+
+DEPOT_PATH = find_depot_tools.add_depot_tools_to_path()
+GSUTIL_PATH = os.path.join(DEPOT_PATH, 'gsutil.py')
+
+LLVM_BUILD_PATH = os.path.join(CHROME_SRC, 'third_party', 'llvm-build',
+ 'Release+Asserts')
+CLANG_UPDATE_PY = os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts',
+ 'update.py')
+CLANG_REVISION = os.popen(CLANG_UPDATE_PY + ' --print-revision').read().rstrip()
+
+CLANG_BUCKET = 'gs://chromium-browser-clang/Linux_x64'
+
+GOLD_PLUGIN_PATH = os.path.join(LLVM_BUILD_PATH, 'lib', 'LLVMgold.so')
+
+sys.path.insert(0, os.path.join(CHROME_SRC, 'tools', 'clang', 'scripts'))
+
+import update
+
+def main():
+ if not re.search(r'cfi_vptr=1', os.environ.get('GYP_DEFINES', '')):
+ # Bailout if this is not a cfi build.
+ print 'Skipping gold plugin download for non-cfi build.'
+ return 0
+ if (os.path.exists(GOLD_PLUGIN_PATH) and
+ update.ReadStampFile().strip() == update.PACKAGE_VERSION):
+ # Bailout if clang is up-to-date. This requires the script to be run before
+ # the clang update step! I.e. afterwards clang would always be up-to-date.
+ print 'Skipping gold plugin download. File present and clang up to date.'
+ return 0
+
+ # Make sure this works on empty checkouts (i.e. clang not downloaded yet).
+ if not os.path.exists(LLVM_BUILD_PATH):
+ os.makedirs(LLVM_BUILD_PATH)
+
+ targz_name = 'llvmgold-%s.tgz' % CLANG_REVISION
+ remote_path = '%s/%s' % (CLANG_BUCKET, targz_name)
+
+ os.chdir(LLVM_BUILD_PATH)
+
+ # TODO(pcc): Fix gsutil.py cp url file < /dev/null 2>&0
+ # (currently aborts with exit code 1,
+ # https://github.com/GoogleCloudPlatform/gsutil/issues/289) or change the
+ # stdin->stderr redirect in update.py to do something else (crbug.com/494442).
+ subprocess.check_call(['python', GSUTIL_PATH,
+ 'cp', remote_path, targz_name],
+ stderr=open('/dev/null', 'w'))
+ subprocess.check_call(['tar', 'xzf', targz_name])
+ os.remove(targz_name)
+ return 0
+
+if __name__ == '__main__':
+ sys.exit(main())
diff --git a/build/features.gypi b/build/features.gypi
index 465eba9..5a21a63 100644
--- a/build/features.gypi
+++ b/build/features.gypi
@@ -39,6 +39,8 @@
'v8_trace_maps%': 0,
+ # Enable the snapshot feature, for fast context creation.
+ # http://v8project.blogspot.com/2015/09/custom-startup-snapshots.html
'v8_use_snapshot%': 'true',
'v8_enable_verify_predictable%': 0,
@@ -59,8 +61,14 @@
# Enable compiler warnings when using V8_DEPRECATED apis.
'v8_deprecation_warnings%': 0,
+ # Enable compiler warnings when using V8_DEPRECATE_SOON apis.
+ 'v8_imminent_deprecation_warnings%': 0,
+
# Set to 1 to enable DCHECKs in release builds.
'dcheck_always_on%': 0,
+
+ # Enable/disable JavaScript API accessors.
+ 'v8_js_accessors%': 0,
},
'target_defaults': {
'conditions': [
@@ -88,10 +96,13 @@
['v8_deprecation_warnings==1', {
'defines': ['V8_DEPRECATION_WARNINGS',],
}],
+ ['v8_imminent_deprecation_warnings==1', {
+ 'defines': ['V8_IMMINENT_DEPRECATION_WARNINGS',],
+ }],
['v8_enable_i18n_support==1', {
'defines': ['V8_I18N_SUPPORT',],
}],
- ['v8_use_external_startup_data==1', {
+ ['v8_use_snapshot=="true" and v8_use_external_startup_data==1', {
'defines': ['V8_USE_EXTERNAL_STARTUP_DATA',],
}],
['dcheck_always_on!=0', {
@@ -102,13 +113,9 @@
'DebugBaseCommon': {
'abstract': 1,
'variables': {
- 'v8_enable_extra_checks%': 1,
'v8_enable_handle_zapping%': 1,
},
'conditions': [
- ['v8_enable_extra_checks==1', {
- 'defines': ['ENABLE_EXTRA_CHECKS',],
- }],
['v8_enable_handle_zapping==1', {
'defines': ['ENABLE_HANDLE_ZAPPING',],
}],
@@ -116,13 +123,9 @@
}, # Debug
'Release': {
'variables': {
- 'v8_enable_extra_checks%': 0,
'v8_enable_handle_zapping%': 0,
},
'conditions': [
- ['v8_enable_extra_checks==1', {
- 'defines': ['ENABLE_EXTRA_CHECKS',],
- }],
['v8_enable_handle_zapping==1', {
'defines': ['ENABLE_HANDLE_ZAPPING',],
}],
diff --git a/build/get_landmines.py b/build/get_landmines.py
index 66a86cb..ea0ae0d 100755
--- a/build/get_landmines.py
+++ b/build/get_landmines.py
@@ -20,6 +20,12 @@
print 'Activating MSVS 2013.'
print 'Revert activation of MSVS 2013.'
print 'Activating MSVS 2013 again.'
+ print 'Clobber after ICU roll.'
+ print 'Moar clobbering...'
+ print 'Remove build/android.gypi'
+ print 'Cleanup after windows ninja switch attempt.'
+ print 'Switching to pinned msvs toolchain.'
+ print 'Clobbering to hopefully resolve problem with mksnapshot'
return 0
diff --git a/build/gyp_environment.py b/build/gyp_environment.py
new file mode 100644
index 0000000..7a4e622
--- /dev/null
+++ b/build/gyp_environment.py
@@ -0,0 +1,54 @@
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+"""
+Sets up various automatic gyp environment variables. These are used by
+gyp_v8 and landmines.py which run at different stages of runhooks. To
+make sure settings are consistent between them, all setup should happen here.
+"""
+
+import os
+import sys
+import vs_toolchain
+
+SCRIPT_DIR = os.path.dirname(os.path.realpath(__file__))
+V8_ROOT = os.path.abspath(os.path.join(SCRIPT_DIR, os.pardir))
+
+
+def apply_gyp_environment(file_path=None):
+ """
+ Reads in a *.gyp_env file and applies the valid keys to os.environ.
+ """
+ if not file_path or not os.path.exists(file_path):
+ return
+ file_contents = open(file_path).read()
+ try:
+ file_data = eval(file_contents, {'__builtins__': None}, None)
+ except SyntaxError, e:
+ e.filename = os.path.abspath(file_path)
+ raise
+ supported_vars = ( 'V8_GYP_FILE',
+ 'V8_GYP_SYNTAX_CHECK',
+ 'GYP_DEFINES',
+ 'GYP_GENERATOR_FLAGS',
+ 'GYP_GENERATOR_OUTPUT', )
+ for var in supported_vars:
+ val = file_data.get(var)
+ if val:
+ if var in os.environ:
+ print 'INFO: Environment value for "%s" overrides value in %s.' % (
+ var, os.path.abspath(file_path)
+ )
+ else:
+ os.environ[var] = val
+
+
+def set_environment():
+ """Sets defaults for GYP_* variables."""
+
+ if 'SKIP_V8_GYP_ENV' not in os.environ:
+ # Update the environment based on v8.gyp_env
+ gyp_env_path = os.path.join(os.path.dirname(V8_ROOT), 'v8.gyp_env')
+ apply_gyp_environment(gyp_env_path)
+ vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
diff --git a/build/gyp_v8 b/build/gyp_v8
index 14467ec..8813f2c 100755
--- a/build/gyp_v8
+++ b/build/gyp_v8
@@ -30,12 +30,15 @@
# This script is wrapper for V8 that adds some support for how GYP
# is invoked by V8 beyond what can be done in the gclient hooks.
+import argparse
import glob
+import gyp_environment
import os
import platform
import shlex
import subprocess
import sys
+import vs_toolchain
script_dir = os.path.dirname(os.path.realpath(__file__))
v8_root = os.path.abspath(os.path.join(script_dir, os.pardir))
@@ -48,32 +51,23 @@
1, os.path.abspath(os.path.join(v8_root, 'tools', 'generate_shim_headers')))
-def apply_gyp_environment(file_path=None):
- """
- Reads in a *.gyp_env file and applies the valid keys to os.environ.
- """
- if not file_path or not os.path.exists(file_path):
- return
- file_contents = open(file_path).read()
- try:
- file_data = eval(file_contents, {'__builtins__': None}, None)
- except SyntaxError, e:
- e.filename = os.path.abspath(file_path)
- raise
- supported_vars = ( 'V8_GYP_FILE',
- 'V8_GYP_SYNTAX_CHECK',
- 'GYP_DEFINES',
- 'GYP_GENERATOR_FLAGS',
- 'GYP_GENERATOR_OUTPUT', )
- for var in supported_vars:
- val = file_data.get(var)
- if val:
- if var in os.environ:
- print 'INFO: Environment value for "%s" overrides value in %s.' % (
- var, os.path.abspath(file_path)
- )
- else:
- os.environ[var] = val
+def GetOutputDirectory():
+ """Returns the output directory that GYP will use."""
+
+ # Handle command line generator flags.
+ parser = argparse.ArgumentParser()
+ parser.add_argument('-G', dest='genflags', default=[], action='append')
+ genflags = parser.parse_known_args()[0].genflags
+
+ # Handle generator flags from the environment.
+ genflags += shlex.split(os.environ.get('GYP_GENERATOR_FLAGS', ''))
+
+ needle = 'output_dir='
+ for item in genflags:
+ if item.startswith(needle):
+ return item[len(needle):]
+
+ return 'out'
def additional_include_files(args=[]):
@@ -109,12 +103,12 @@
def run_gyp(args):
rc = gyp.main(args)
- # Check for landmines (reasons to clobber the build). This must be run here,
- # rather than a separate runhooks step so that any environment modifications
- # from above are picked up.
- print 'Running build/landmines.py...'
- subprocess.check_call(
- [sys.executable, os.path.join(script_dir, 'landmines.py')])
+ vs2013_runtime_dll_dirs = vs_toolchain.SetEnvironmentAndGetRuntimeDllDirs()
+ if vs2013_runtime_dll_dirs:
+ x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
+ vs_toolchain.CopyVsRuntimeDlls(
+ os.path.join(v8_root, GetOutputDirectory()),
+ (x86_runtime, x64_runtime))
if rc != 0:
print 'Error running GYP'
@@ -124,10 +118,7 @@
if __name__ == '__main__':
args = sys.argv[1:]
- if 'SKIP_V8_GYP_ENV' not in os.environ:
- # Update the environment based on v8.gyp_env
- gyp_env_path = os.path.join(os.path.dirname(v8_root), 'v8.gyp_env')
- apply_gyp_environment(gyp_env_path)
+ gyp_environment.set_environment()
# This could give false positives since it doesn't actually do real option
# parsing. Oh well.
@@ -167,7 +158,8 @@
# Generate for the architectures supported on the given platform.
gyp_args = list(args)
- gyp_generators = os.environ.get('GYP_GENERATORS')
+ gyp_args.extend(['-D', 'gyp_output_dir=' + GetOutputDirectory()])
+ gyp_generators = os.environ.get('GYP_GENERATORS', '')
if platform.system() == 'Linux' and gyp_generators != 'ninja':
# Work around for crbug.com/331475.
for f in glob.glob(os.path.join(v8_root, 'out', 'Makefile.*')):
@@ -177,4 +169,13 @@
# -Goutput_dir defines where the build output goes, relative to the
# Makefile. Set it to . so that the build output doesn't end up in out/out.
gyp_args.append('-Goutput_dir=.')
+
+ gyp_defines = os.environ.get('GYP_DEFINES', '')
+
+ # Automatically turn on crosscompile support for platforms that need it.
+ if all(('ninja' in gyp_generators,
+ 'OS=android' in gyp_defines,
+ 'GYP_CROSSCOMPILE' not in os.environ)):
+ os.environ['GYP_CROSSCOMPILE'] = '1'
+
run_gyp(gyp_args)
diff --git a/build/isolate.gypi b/build/isolate.gypi
new file mode 100644
index 0000000..5d30005
--- /dev/null
+++ b/build/isolate.gypi
@@ -0,0 +1,96 @@
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Copyright (c) 2012 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+# This file is meant to be included into a target to provide a rule
+# to "build" .isolate files into a .isolated file.
+#
+# To use this, create a gyp target with the following form:
+# 'conditions': [
+# ['test_isolation_mode != "noop"', {
+# 'targets': [
+# {
+# 'target_name': 'foo_test_run',
+# 'type': 'none',
+# 'dependencies': [
+# 'foo_test',
+# ],
+# 'includes': [
+# '../build/isolate.gypi',
+# ],
+# 'sources': [
+# 'foo_test.isolate',
+# ],
+# },
+# ],
+# }],
+# ],
+#
+# Note: foo_test.isolate is included and a source file. It is an inherent
+# property of the .isolate format. This permits to define GYP variables but is
+# a stricter format than GYP so isolate.py can read it.
+#
+# The generated .isolated file will be:
+# <(PRODUCT_DIR)/foo_test.isolated
+#
+# See http://dev.chromium.org/developers/testing/isolated-testing/for-swes
+# for more information.
+
+{
+ 'rules': [
+ {
+ 'rule_name': 'isolate',
+ 'extension': 'isolate',
+ 'inputs': [
+ # Files that are known to be involved in this step.
+ '<(DEPTH)/tools/isolate_driver.py',
+ '<(DEPTH)/tools/swarming_client/isolate.py',
+ '<(DEPTH)/tools/swarming_client/run_isolated.py',
+ ],
+ 'outputs': [
+ '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated',
+ ],
+ 'action': [
+ 'python',
+ '<(DEPTH)/tools/isolate_driver.py',
+ '<(test_isolation_mode)',
+ '--isolated', '<(PRODUCT_DIR)/<(RULE_INPUT_ROOT).isolated',
+ '--isolate', '<(RULE_INPUT_PATH)',
+
+ # Variables should use the -V FOO=<(FOO) form so frequent values,
+ # like '0' or '1', aren't stripped out by GYP. Run 'isolate.py help'
+ # for more details.
+
+ # Path variables are used to replace file paths when loading a .isolate
+ # file
+ '--path-variable', 'DEPTH', '<(DEPTH)',
+ '--path-variable', 'PRODUCT_DIR', '<(PRODUCT_DIR)',
+
+ '--config-variable', 'CONFIGURATION_NAME=<(CONFIGURATION_NAME)',
+ '--config-variable', 'OS=<(OS)',
+ '--config-variable', 'asan=<(asan)',
+ '--config-variable', 'cfi_vptr=<(cfi_vptr)',
+ '--config-variable', 'icu_use_data_file_flag=0',
+ '--config-variable', 'msan=<(msan)',
+ '--config-variable', 'tsan=<(tsan)',
+ '--config-variable', 'component=<(component)',
+ '--config-variable', 'target_arch=<(target_arch)',
+ '--config-variable', 'use_custom_libcxx=<(use_custom_libcxx)',
+ '--config-variable', 'v8_use_external_startup_data=<(v8_use_external_startup_data)',
+ '--config-variable', 'v8_use_snapshot=<(v8_use_snapshot)',
+ ],
+ 'conditions': [
+ ['OS=="win"', {
+ 'action': [
+ '--config-variable', 'msvs_version=2013',
+ ],
+ }, {
+ 'action': [
+ '--config-variable', 'msvs_version=0',
+ ],
+ }],
+ ],
+ },
+ ],
+}
diff --git a/build/landmine_utils.py b/build/landmine_utils.py
index e8b7c98..cb34991 100644
--- a/build/landmine_utils.py
+++ b/build/landmine_utils.py
@@ -47,10 +47,19 @@
return dict(arg.split('=', 1)
for arg in shlex.split(os.environ.get('GYP_DEFINES', '')))
+
+@memoize()
+def gyp_generator_flags():
+ """Parses and returns GYP_GENERATOR_FLAGS env var as a dictionary."""
+ return dict(arg.split('=', 1)
+ for arg in shlex.split(os.environ.get('GYP_GENERATOR_FLAGS', '')))
+
+
@memoize()
def gyp_msvs_version():
return os.environ.get('GYP_MSVS_VERSION', '')
+
@memoize()
def distributor():
"""
diff --git a/build/landmines.py b/build/landmines.py
index bd1fb28..97c6390 100755
--- a/build/landmines.py
+++ b/build/landmines.py
@@ -4,10 +4,9 @@
# found in the LICENSE file.
"""
-This script runs every build as a hook. If it detects that the build should
-be clobbered, it will touch the file <build_dir>/.landmine_triggered. The
-various build scripts will then check for the presence of this file and clobber
-accordingly. The script will also emit the reasons for the clobber to stdout.
+This script runs every build as the first hook (See DEPS). If it detects that
+the build should be clobbered, it will delete the contents of the build
+directory.
A landmine is tripped when a builder checks out a different revision, and the
diff between the new landmines and the old ones is non-null. At this point, the
@@ -15,9 +14,13 @@
"""
import difflib
+import errno
+import gyp_environment
import logging
import optparse
import os
+import re
+import shutil
import sys
import subprocess
import time
@@ -28,46 +31,109 @@
SRC_DIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
-def get_target_build_dir(build_tool, target):
+def get_build_dir(build_tool, is_iphone=False):
"""
Returns output directory absolute path dependent on build and targets.
Examples:
- r'c:\b\build\slave\win\build\src\out\Release'
- '/mnt/data/b/build/slave/linux/build/src/out/Debug'
- '/b/build/slave/ios_rel_device/build/src/xcodebuild/Release-iphoneos'
+ r'c:\b\build\slave\win\build\src\out'
+ '/mnt/data/b/build/slave/linux/build/src/out'
+ '/b/build/slave/ios_rel_device/build/src/xcodebuild'
Keep this function in sync with tools/build/scripts/slave/compile.py
"""
ret = None
if build_tool == 'xcode':
- ret = os.path.join(SRC_DIR, 'xcodebuild', target)
+ ret = os.path.join(SRC_DIR, 'xcodebuild')
elif build_tool in ['make', 'ninja', 'ninja-ios']: # TODO: Remove ninja-ios.
- ret = os.path.join(SRC_DIR, 'out', target)
+ if 'CHROMIUM_OUT_DIR' in os.environ:
+ output_dir = os.environ.get('CHROMIUM_OUT_DIR').strip()
+ if not output_dir:
+ raise Error('CHROMIUM_OUT_DIR environment variable is set but blank!')
+ else:
+ output_dir = landmine_utils.gyp_generator_flags().get('output_dir', 'out')
+ ret = os.path.join(SRC_DIR, output_dir)
elif build_tool in ['msvs', 'vs', 'ib']:
- ret = os.path.join(SRC_DIR, 'build', target)
+ ret = os.path.join(SRC_DIR, 'build')
else:
raise NotImplementedError('Unexpected GYP_GENERATORS (%s)' % build_tool)
return os.path.abspath(ret)
-def set_up_landmines(target, new_landmines):
- """Does the work of setting, planting, and triggering landmines."""
- out_dir = get_target_build_dir(landmine_utils.builder(), target)
+def extract_gn_build_commands(build_ninja_file):
+ """Extracts from a build.ninja the commands to run GN.
- landmines_path = os.path.join(out_dir, '.landmines')
- if not os.path.exists(out_dir):
+ The commands to run GN are the gn rule and build.ninja build step at the
+ top of the build.ninja file. We want to keep these when deleting GN builds
+ since we want to preserve the command-line flags to GN.
+
+ On error, returns the empty string."""
+ result = ""
+ with open(build_ninja_file, 'r') as f:
+ # Read until the second blank line. The first thing GN writes to the file
+ # is the "rule gn" and the second is the section for "build build.ninja",
+ # separated by blank lines.
+ num_blank_lines = 0
+ while num_blank_lines < 2:
+ line = f.readline()
+ if len(line) == 0:
+ return '' # Unexpected EOF.
+ result += line
+ if line[0] == '\n':
+ num_blank_lines = num_blank_lines + 1
+ return result
+
+def delete_build_dir(build_dir):
+ # GN writes a build.ninja.d file. Note that not all GN builds have args.gn.
+ build_ninja_d_file = os.path.join(build_dir, 'build.ninja.d')
+ if not os.path.exists(build_ninja_d_file):
+ shutil.rmtree(build_dir)
return
- if not os.path.exists(landmines_path):
- print "Landmines tracker didn't exists."
+ # GN builds aren't automatically regenerated when you sync. To avoid
+ # messing with the GN workflow, erase everything but the args file, and
+ # write a dummy build.ninja file that will automatically rerun GN the next
+ # time Ninja is run.
+ build_ninja_file = os.path.join(build_dir, 'build.ninja')
+ build_commands = extract_gn_build_commands(build_ninja_file)
- # FIXME(machenbach): Clobber deletes the .landmines tracker. Difficult
- # to know if we are right after a clobber or if it is first-time landmines
- # deployment. Also, a landmine-triggered clobber right after a clobber is
- # not possible. Different clobber methods for msvs, xcode and make all
- # have different blacklists of files that are not deleted.
+ try:
+ gn_args_file = os.path.join(build_dir, 'args.gn')
+ with open(gn_args_file, 'r') as f:
+ args_contents = f.read()
+ except IOError:
+ args_contents = ''
+
+ shutil.rmtree(build_dir)
+
+ # Put back the args file (if any).
+ os.mkdir(build_dir)
+ if args_contents != '':
+ with open(gn_args_file, 'w') as f:
+ f.write(args_contents)
+
+ # Write the build.ninja file sufficiently to regenerate itself.
+ with open(os.path.join(build_dir, 'build.ninja'), 'w') as f:
+ if build_commands != '':
+ f.write(build_commands)
+ else:
+ # Couldn't parse the build.ninja file, write a default thing.
+ f.write('''rule gn
+command = gn -q gen //out/%s/
+description = Regenerating ninja files
+
+build build.ninja: gn
+generator = 1
+depfile = build.ninja.d
+''' % (os.path.split(build_dir)[1]))
+
+ # Write a .d file for the build which references a nonexistant file. This
+ # will make Ninja always mark the build as dirty.
+ with open(build_ninja_d_file, 'w') as f:
+ f.write('build.ninja: nonexistant_file.gn\n')
+
+
+def needs_clobber(landmines_path, new_landmines):
if os.path.exists(landmines_path):
- triggered = os.path.join(out_dir, '.landmines_triggered')
with open(landmines_path, 'r') as f:
old_landmines = f.readlines()
if old_landmines != new_landmines:
@@ -75,14 +141,54 @@
diff = difflib.unified_diff(old_landmines, new_landmines,
fromfile='old_landmines', tofile='new_landmines',
fromfiledate=old_date, tofiledate=time.ctime(), n=0)
+ sys.stdout.write('Clobbering due to:\n')
+ sys.stdout.writelines(diff)
+ return True
+ else:
+ sys.stdout.write('Clobbering due to missing landmines file.\n')
+ return True
+ return False
- with open(triggered, 'w') as f:
- f.writelines(diff)
- print "Setting landmine: %s" % triggered
- elif os.path.exists(triggered):
- # Remove false triggered landmines.
- os.remove(triggered)
- print "Removing landmine: %s" % triggered
+
+def clobber_if_necessary(new_landmines):
+ """Does the work of setting, planting, and triggering landmines."""
+ out_dir = get_build_dir(landmine_utils.builder())
+ landmines_path = os.path.normpath(os.path.join(out_dir, '..', '.landmines'))
+ try:
+ os.makedirs(out_dir)
+ except OSError as e:
+ if e.errno == errno.EEXIST:
+ pass
+
+ if needs_clobber(landmines_path, new_landmines):
+ # Clobber contents of build directory but not directory itself: some
+ # checkouts have the build directory mounted.
+ for f in os.listdir(out_dir):
+ path = os.path.join(out_dir, f)
+ if os.path.basename(out_dir) == 'build':
+ # Only delete build directories and files for MSVS builds as the folder
+ # shares some checked out files and directories.
+ if (os.path.isdir(path) and
+ re.search(r'(?:[Rr]elease)|(?:[Dd]ebug)', f)):
+ delete_build_dir(path)
+ elif (os.path.isfile(path) and
+ (path.endswith('.sln') or
+ path.endswith('.vcxproj') or
+ path.endswith('.vcxproj.user'))):
+ os.unlink(path)
+ else:
+ if os.path.isfile(path):
+ os.unlink(path)
+ elif os.path.isdir(path):
+ delete_build_dir(path)
+ if os.path.basename(out_dir) == 'xcodebuild':
+ # Xcodebuild puts an additional project file structure into build,
+ # while the output folder is xcodebuild.
+ project_dir = os.path.join(SRC_DIR, 'build', 'all.xcodeproj')
+ if os.path.exists(project_dir) and os.path.isdir(project_dir):
+ delete_build_dir(project_dir)
+
+ # Save current set of landmines for next time.
with open(landmines_path, 'w') as f:
f.writelines(new_landmines)
@@ -123,14 +229,14 @@
if landmine_utils.builder() in ('dump_dependency_json', 'eclipse'):
return 0
+ gyp_environment.set_environment()
+
landmines = []
for s in landmine_scripts:
proc = subprocess.Popen([sys.executable, s], stdout=subprocess.PIPE)
output, _ = proc.communicate()
landmines.extend([('%s\n' % l.strip()) for l in output.splitlines()])
-
- for target in ('Debug', 'Release'):
- set_up_landmines(target, landmines)
+ clobber_if_necessary(landmines)
return 0
diff --git a/build/mac/asan.gyp b/build/mac/asan.gyp
new file mode 100644
index 0000000..3fc7f58
--- /dev/null
+++ b/build/mac/asan.gyp
@@ -0,0 +1,31 @@
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+{
+ 'targets': [
+ {
+ 'target_name': 'asan_dynamic_runtime',
+ 'toolsets': ['target', 'host'],
+ 'type': 'none',
+ 'variables': {
+ # Every target is going to depend on asan_dynamic_runtime, so allow
+ # this one to depend on itself.
+ 'prune_self_dependency': 1,
+ # Path is relative to this GYP file.
+ 'asan_rtl_mask_path':
+ '../../third_party/llvm-build/Release+Asserts/lib/clang/*/lib/darwin',
+ 'asan_osx_dynamic':
+ '<(asan_rtl_mask_path)/libclang_rt.asan_osx_dynamic.dylib',
+ },
+ 'copies': [
+ {
+ 'destination': '<(PRODUCT_DIR)',
+ 'files': [
+ '<!(/bin/ls <(asan_osx_dynamic))',
+ ],
+ },
+ ],
+ },
+ ],
+}
diff --git a/build/standalone.gypi b/build/standalone.gypi
index ee91e78..273d72b 100644
--- a/build/standalone.gypi
+++ b/build/standalone.gypi
@@ -33,22 +33,25 @@
'includes': ['toolchain.gypi'],
'variables': {
'component%': 'static_library',
- 'make_clang_dir%': '../third_party/llvm-build/Release+Asserts',
'clang_xcode%': 0,
- 'asan%': 0,
- 'tsan%': 0,
+ # Track where uninitialized memory originates from. From fastest to
+ # slowest: 0 - no tracking, 1 - track only the initial allocation site, 2
+ # - track the chain of stores leading from allocation site to use site.
+ 'msan_track_origins%': 2,
'visibility%': 'hidden',
'v8_enable_backtrace%': 0,
'v8_enable_i18n_support%': 1,
'v8_deprecation_warnings': 1,
+ 'v8_imminent_deprecation_warnings': 1,
'msvs_multi_core_compile%': '1',
'mac_deployment_target%': '10.5',
+ 'release_extra_cflags%': '',
'variables': {
'variables': {
'variables': {
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
- OS=="netbsd" or OS=="mac" or OS=="qnx"', {
+ OS=="netbsd" or OS=="mac" or OS=="qnx" or OS=="aix"', {
# This handles the Unix platforms we generally deal with.
# Anything else gets passed through, which probably won't work
# very well; such hosts should pass an explicit target_arch
@@ -56,22 +59,117 @@
'host_arch%': '<!pymod_do_main(detect_v8_host_arch)',
}, {
# OS!="linux" and OS!="freebsd" and OS!="openbsd" and
- # OS!="netbsd" and OS!="mac"
+ # OS!="netbsd" and OS!="mac" and OS!="aix"
'host_arch%': 'ia32',
}],
],
},
'host_arch%': '<(host_arch)',
'target_arch%': '<(host_arch)',
+ 'base_dir%': '<!(cd <(DEPTH) && python -c "import os; print os.getcwd()")',
+
+ # Instrument for code coverage with gcov.
+ 'coverage%': 0,
},
+ 'base_dir%': '<(base_dir)',
'host_arch%': '<(host_arch)',
'target_arch%': '<(target_arch)',
'v8_target_arch%': '<(target_arch)',
+ 'coverage%': '<(coverage)',
+ 'asan%': 0,
+ 'lsan%': 0,
+ 'msan%': 0,
+ 'tsan%': 0,
+ # Enable coverage gathering instrumentation in sanitizer tools. This flag
+ # also controls coverage granularity (1 for function-level, 2 for
+ # block-level, 3 for edge-level).
+ 'sanitizer_coverage%': 0,
+ # Use libc++ (buildtools/third_party/libc++ and
+ # buildtools/third_party/libc++abi) instead of stdlibc++ as standard
+ # library. This is intended to be used for instrumented builds.
+ 'use_custom_libcxx%': 0,
+
+ 'clang_dir%': '<(base_dir)/third_party/llvm-build/Release+Asserts',
+
+ 'use_lto%': 0,
+
+ # Control Flow Integrity for virtual calls and casts.
+ # See http://clang.llvm.org/docs/ControlFlowIntegrity.html
+ 'cfi_vptr%': 0,
+ 'cfi_diag%': 0,
+
+ 'cfi_blacklist%': '<(base_dir)/tools/cfi/blacklist.txt',
+
+ # Set to 1 to enable fast builds.
+ # TODO(machenbach): Only configured for windows.
+ 'fastbuild%': 0,
+
+ # goma settings.
+ # 1 to use goma.
+ # If no gomadir is set, it uses the default gomadir.
+ 'use_goma%': 0,
+ 'gomadir%': '',
+
+ 'conditions': [
+ # Set default gomadir.
+ ['OS=="win"', {
+ 'gomadir': 'c:\\goma\\goma-win',
+ }, {
+ 'gomadir': '<!(/bin/echo -n ${HOME}/goma)',
+ }],
+ ['host_arch!="ppc" and host_arch!="ppc64" and host_arch!="ppc64le" and host_arch!="s390" and host_arch!="s390x" and \
+ coverage==0', {
+ 'host_clang%': 1,
+ }, {
+ 'host_clang%': 0,
+ }],
+ # linux_use_bundled_gold: whether to use the gold linker binary checked
+ # into third_party/binutils. Force this off via GYP_DEFINES when you
+ # are using a custom toolchain and need to control -B in ldflags.
+ # Do not use 32-bit gold on 32-bit hosts as it runs out address space
+ # for component=static_library builds.
+ ['(OS=="linux" or OS=="android") and (target_arch=="x64" or target_arch=="arm" or (target_arch=="ia32" and host_arch=="x64"))', {
+ 'linux_use_bundled_gold%': 1,
+ }, {
+ 'linux_use_bundled_gold%': 0,
+ }],
+
+ # TODO(machenbach): Remove the conditions as more configurations are
+ # supported.
+ ['OS=="linux" or OS=="win"', {
+ 'test_isolation_mode%': 'check',
+ }, {
+ 'test_isolation_mode%': 'noop',
+ }],
+ ],
},
+ 'base_dir%': '<(base_dir)',
+ 'clang_dir%': '<(clang_dir)',
'host_arch%': '<(host_arch)',
+ 'host_clang%': '<(host_clang)',
'target_arch%': '<(target_arch)',
'v8_target_arch%': '<(v8_target_arch)',
'werror%': '-Werror',
+ 'use_goma%': '<(use_goma)',
+ 'gomadir%': '<(gomadir)',
+ 'asan%': '<(asan)',
+ 'lsan%': '<(lsan)',
+ 'msan%': '<(msan)',
+ 'tsan%': '<(tsan)',
+ 'sanitizer_coverage%': '<(sanitizer_coverage)',
+ 'use_custom_libcxx%': '<(use_custom_libcxx)',
+ 'linux_use_bundled_gold%': '<(linux_use_bundled_gold)',
+ 'use_lto%': '<(use_lto)',
+ 'cfi_vptr%': '<(cfi_vptr)',
+ 'cfi_diag%': '<(cfi_diag)',
+ 'cfi_blacklist%': '<(cfi_blacklist)',
+ 'test_isolation_mode%': '<(test_isolation_mode)',
+ 'fastbuild%': '<(fastbuild)',
+ 'coverage%': '<(coverage)',
+
+ # Add a simple extras solely for the purpose of the cctests
+ 'v8_extra_library_files': ['../test/cctest/test-extra.js'],
+ 'v8_experimental_extra_library_files': ['../test/cctest/test-experimental-extra.js'],
# .gyp files or targets should set v8_code to 1 if they build V8 specific
# code, as opposed to external code. This variable is used to control such
@@ -82,22 +180,20 @@
# Speeds up Debug builds:
# 0 - Compiler optimizations off (debuggable) (default). This may
# be 5x slower than Release (or worse).
- # 1 - Turn on compiler optimizations. This may be hard or impossible to
- # debug. This may still be 2x slower than Release (or worse).
- # 2 - Turn on optimizations, and also #undef DEBUG / #define NDEBUG
- # (but leave V8_ENABLE_CHECKS and most other assertions enabled.
- # This may cause some v8 tests to fail in the Debug configuration.
- # This roughly matches the performance of a Release build and can
- # be used by embedders that need to build their own code as debug
- # but don't want or need a debug version of V8. This should produce
- # near-release speeds.
+ # 1 - Turn on optimizations and disable slow DCHECKs, but leave
+ # V8_ENABLE_CHECKS and most other assertions enabled. This may cause
+ # some v8 tests to fail in the Debug configuration. This roughly
+ # matches the performance of a Release build and can be used by
+ # embedders that need to build their own code as debug but don't want
+ # or need a debug version of V8. This should produce near-release
+ # speeds.
'v8_optimized_debug%': 0,
# Use external files for startup data blobs:
# the JS builtins sources and the start snapshot.
# Embedders that don't use standalone.gypi will need to add
# their own default value.
- 'v8_use_external_startup_data%': 0,
+ 'v8_use_external_startup_data%': 1,
# Relative path to icu.gyp from this file.
'icu_gyp_path': '../third_party/icu/icu.gyp',
@@ -118,17 +214,143 @@
}, {
'os_posix%': 1,
}],
- ['(v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
- (OS=="linux" or OS=="mac")', {
+ ['OS=="win" and use_goma==1', {
+ # goma doesn't support pch yet.
+ 'chromium_win_pch': 0,
+ # goma doesn't support PDB yet.
+ 'fastbuild%': 1,
+ }],
+ ['((v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
+ (OS=="linux" or OS=="mac")) or (v8_target_arch=="ppc64" and OS=="linux")', {
'v8_enable_gdbjit%': 1,
}, {
'v8_enable_gdbjit%': 0,
}],
- ['OS=="mac"', {
+ ['(OS=="linux" or OS=="mac") and (target_arch=="ia32" or target_arch=="x64") and \
+ (v8_target_arch!="x87" and v8_target_arch!="x32") and coverage==0', {
'clang%': 1,
}, {
'clang%': 0,
}],
+ ['asan==1 or lsan==1 or msan==1 or tsan==1', {
+ 'clang%': 1,
+ 'use_allocator%': 'none',
+ }],
+ ['asan==1 and OS=="linux"', {
+ 'use_custom_libcxx%': 1,
+ }],
+ ['tsan==1', {
+ 'use_custom_libcxx%': 1,
+ }],
+ ['msan==1', {
+ # Use a just-built, MSan-instrumented libc++ instead of the system-wide
+ # libstdc++. This is required to avoid false positive reports whenever
+ # the C++ standard library is used.
+ 'use_custom_libcxx%': 1,
+ }],
+ ['cfi_vptr==1', {
+ 'use_lto%': 1,
+ }],
+ ['OS=="android"', {
+ # Location of Android NDK.
+ 'variables': {
+ 'variables': {
+ # The Android toolchain needs to use the absolute path to the NDK
+ # because it is used at different levels in the GYP files.
+ 'android_ndk_root%': '<(base_dir)/third_party/android_tools/ndk/',
+ 'android_host_arch%': "<!(uname -m | sed -e 's/i[3456]86/x86/')",
+ 'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
+ },
+
+ # Copy conditionally-set variables out one scope.
+ 'android_ndk_root%': '<(android_ndk_root)',
+ 'host_os%': '<(host_os)',
+
+ 'conditions': [
+ ['target_arch == "ia32"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'x86',
+ 'android_target_platform%': '16',
+ }],
+ ['target_arch == "x64"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/x86_64-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'x86_64',
+ 'android_target_platform%': '21',
+ }],
+ ['target_arch=="arm"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'arm',
+ 'android_target_platform%': '16',
+ 'arm_version%': 7,
+ }],
+ ['target_arch == "arm64"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/aarch64-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'arm64',
+ 'android_target_platform%': '21',
+ 'arm_version%': 'default',
+ }],
+ ['target_arch == "mipsel"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'mips',
+ 'android_target_platform%': '16',
+ }],
+ ['target_arch == "mips64el"', {
+ 'android_toolchain%': '<(android_ndk_root)/toolchains/mips64el-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
+ 'android_target_arch%': 'mips64',
+ 'android_target_platform%': '21',
+ }],
+ ],
+ },
+
+ # Copy conditionally-set variables out one scope.
+ 'android_target_arch%': '<(android_target_arch)',
+ 'android_target_platform%': '<(android_target_platform)',
+ 'android_toolchain%': '<(android_toolchain)',
+ 'arm_version%': '<(arm_version)',
+ 'host_os%': '<(host_os)',
+
+ 'conditions': [
+ ['android_ndk_root==""', {
+ 'variables': {
+ 'android_sysroot': '<(android_toolchain)/sysroot/',
+ 'android_stlport': '<(android_toolchain)/sources/cxx-stl/stlport/',
+ },
+ 'android_include': '<(android_sysroot)/usr/include',
+ 'conditions': [
+ ['target_arch=="x64"', {
+ 'android_lib': '<(android_sysroot)/usr/lib64',
+ }, {
+ 'android_lib': '<(android_sysroot)/usr/lib',
+ }],
+ ],
+ 'android_stlport_include': '<(android_stlport)/stlport',
+ 'android_stlport_libs': '<(android_stlport)/libs',
+ }, {
+ 'variables': {
+ 'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)',
+ 'android_stlport': '<(android_ndk_root)/sources/cxx-stl/stlport/',
+ },
+ 'android_include': '<(android_sysroot)/usr/include',
+ 'conditions': [
+ ['target_arch=="x64"', {
+ 'android_lib': '<(android_sysroot)/usr/lib64',
+ }, {
+ 'android_lib': '<(android_sysroot)/usr/lib',
+ }],
+ ],
+ 'android_stlport_include': '<(android_stlport)/stlport',
+ 'android_stlport_libs': '<(android_stlport)/libs',
+ }],
+ ],
+ 'android_stlport_library': 'stlport_static',
+ }], # OS=="android"
+ ['host_clang==1', {
+ 'host_cc': '<(clang_dir)/bin/clang',
+ 'host_cxx': '<(clang_dir)/bin/clang++',
+ }, {
+ 'host_cc': '<!(which gcc)',
+ 'host_cxx': '<!(which g++)',
+ }],
],
# Default ARM variable settings.
'arm_version%': 'default',
@@ -149,30 +371,96 @@
'target_defaults': {
'variables': {
'v8_code%': '<(v8_code)',
+ 'conditions':[
+ ['OS=="android"', {
+ 'host_os%': '<(host_os)',
+ }],
+ ],
},
'default_configuration': 'Debug',
'configurations': {
'DebugBaseCommon': {
- 'cflags': [ '-g', '-O0' ],
'conditions': [
- ['(v8_target_arch=="ia32" or v8_target_arch=="x87") and \
- OS=="linux"', {
- 'defines': [
- '_GLIBCXX_DEBUG'
- ],
+ ['OS=="aix"', {
+ 'cflags': [ '-g', '-Og', '-gxcoff' ],
+ }, {
+ 'cflags': [ '-g', '-O0' ],
}],
],
},
'Optdebug': {
- 'inherit_from': [ 'DebugBaseCommon', 'DebugBase2' ],
+ 'inherit_from': [ 'DebugBaseCommon', 'DebugBase1' ],
},
'Debug': {
# Xcode insists on this empty entry.
},
'Release': {
- # Xcode insists on this empty entry.
+ 'cflags+': ['<@(release_extra_cflags)'],
},
+ 'conditions': [
+ ['OS=="win"', {
+ 'Optdebug_x64': {
+ 'inherit_from': ['Optdebug'],
+ },
+ 'Debug_x64': {
+ 'inherit_from': ['Debug'],
+ },
+ 'Release_x64': {
+ 'inherit_from': ['Release'],
+ },
+ }],
+ ],
},
+ 'conditions':[
+ ['clang==0', {
+ 'cflags+': ['-Wno-sign-compare',],
+ }],
+ ['clang==1 or host_clang==1', {
+ # This is here so that all files get recompiled after a clang roll and
+ # when turning clang on or off.
+ # (defines are passed via the command line, and build systems rebuild
+ # things when their commandline changes). Nothing should ever read this
+ # define.
+ 'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
+ 'conditions': [
+ ['host_clang==1', {
+ 'target_conditions': [
+ ['_toolset=="host"', {
+ 'cflags+': [
+ '-Wno-format-pedantic',
+ ],
+ }],
+ ],
+ }],
+ ['clang==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags+': [
+ '-Wno-format-pedantic',
+ ],
+ }],
+ ],
+ }],
+ ],
+ }],
+ ['fastbuild!=0', {
+ 'conditions': [
+ ['OS=="win" and fastbuild==1', {
+ 'msvs_settings': {
+ 'VCLinkerTool': {
+ # This tells the linker to generate .pdbs, so that
+ # we can get meaningful stack traces.
+ 'GenerateDebugInformation': 'true',
+ },
+ 'VCCLCompilerTool': {
+ # No debug info to be generated by compiler.
+ 'DebugInformationFormat': '0',
+ },
+ },
+ }],
+ ],
+ }], # fastbuild!=0
+ ],
'target_conditions': [
['v8_code == 0', {
'defines!': [
@@ -180,8 +468,34 @@
],
'conditions': [
['os_posix == 1 and OS != "mac"', {
+ # We don't want to get warnings from third-party code,
+ # so remove any existing warning-enabling flags like -Wall.
'cflags!': [
+ '-pedantic',
+ '-Wall',
'-Werror',
+ '-Wextra',
+ '-Wshorten-64-to-32',
+ ],
+ 'cflags+': [
+ # Clang considers the `register` keyword as deprecated, but
+ # ICU uses it all over the place.
+ '-Wno-deprecated-register',
+ # ICU uses its own deprecated functions.
+ '-Wno-deprecated-declarations',
+ # ICU prefers `a && b || c` over `(a && b) || c`.
+ '-Wno-logical-op-parentheses',
+ # ICU has some `unsigned < 0` checks.
+ '-Wno-tautological-compare',
+ # uresdata.c has switch(RES_GET_TYPE(x)) code. The
+ # RES_GET_TYPE macro returns an UResType enum, but some switch
+ # statement contains case values that aren't part of that
+ # enum (e.g. URES_TABLE32 which is in UResInternalType). This
+ # is on purpose.
+ '-Wno-switch',
+ ],
+ 'cflags_cc!': [
+ '-Wnon-virtual-dtor',
],
}],
['OS == "mac"', {
@@ -201,67 +515,215 @@
],
},
'conditions': [
- ['asan==1', {
+ ['os_posix==1 and OS!="mac"', {
'target_defaults': {
- 'cflags_cc+': [
- '-fno-omit-frame-pointer',
- '-gline-tables-only',
- '-fsanitize=address',
- '-w', # http://crbug.com/162783
- ],
- 'cflags_cc!': [
- '-fomit-frame-pointer',
- ],
- 'ldflags': [
- '-fsanitize=address',
+ 'conditions': [
+ # Common options for AddressSanitizer, LeakSanitizer,
+ # ThreadSanitizer, MemorySanitizer and CFI builds.
+ ['asan==1 or lsan==1 or tsan==1 or msan==1 or cfi_vptr==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fno-omit-frame-pointer',
+ '-gline-tables-only',
+ ],
+ 'cflags!': [
+ '-fomit-frame-pointer',
+ ],
+ }],
+ ],
+ }],
+ ['asan==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=address',
+ ],
+ 'ldflags': [
+ '-fsanitize=address',
+ ],
+ 'defines': [
+ 'ADDRESS_SANITIZER',
+ ],
+ }],
+ ],
+ }],
+ ['lsan==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=leak',
+ ],
+ 'ldflags': [
+ '-fsanitize=leak',
+ ],
+ 'defines': [
+ 'LEAK_SANITIZER',
+ ],
+ }],
+ ],
+ }],
+ ['tsan==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=thread',
+ ],
+ 'ldflags': [
+ '-fsanitize=thread',
+ ],
+ 'defines': [
+ 'THREAD_SANITIZER',
+ ],
+ }],
+ ],
+ }],
+ ['msan==1', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=memory',
+ '-fsanitize-memory-track-origins=<(msan_track_origins)',
+ '-fPIC',
+ ],
+ 'ldflags': [
+ '-fsanitize=memory',
+ '-pie',
+ ],
+ 'defines': [
+ 'MEMORY_SANITIZER',
+ ],
+ }],
+ ],
+ }],
+ ['use_custom_libcxx==1', {
+ 'dependencies': [
+ '<(DEPTH)/buildtools/third_party/libc++/libc++.gyp:libcxx_proxy',
+ ],
+ }],
+ ['sanitizer_coverage!=0', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize-coverage=<(sanitizer_coverage)',
+ ],
+ 'defines': [
+ 'SANITIZER_COVERAGE',
+ ],
+ }],
+ ],
+ }],
+ ['linux_use_bundled_gold==1 and not (clang==0 and use_lto==1)', {
+ # Put our binutils, which contains gold in the search path. We pass
+ # the path to gold to the compiler. gyp leaves unspecified what the
+ # cwd is when running the compiler, so the normal gyp path-munging
+ # fails us. This hack gets the right path.
+ #
+ # Disabled when using GCC LTO because GCC also uses the -B search
+ # path at link time to find "as", and our bundled "as" can only
+ # target x86.
+ 'ldflags': [
+ # Note, Chromium allows ia32 host arch as well, we limit this to
+ # x64 in v8.
+ '-B<(base_dir)/third_party/binutils/Linux_x64/Release/bin',
+ ],
+ }],
],
},
}],
- ['tsan==1', {
+ ['OS=="mac"', {
'target_defaults': {
- 'cflags+': [
- '-fno-omit-frame-pointer',
- '-gline-tables-only',
- '-fsanitize=thread',
- '-fPIC',
- '-Wno-c++11-extensions',
+ 'conditions': [
+ ['asan==1', {
+ 'xcode_settings': {
+ # FIXME(machenbach): This is outdated compared to common.gypi.
+ 'OTHER_CFLAGS+': [
+ '-fno-omit-frame-pointer',
+ '-gline-tables-only',
+ '-fsanitize=address',
+ '-w', # http://crbug.com/162783
+ ],
+ 'OTHER_CFLAGS!': [
+ '-fomit-frame-pointer',
+ ],
+ 'defines': [
+ 'ADDRESS_SANITIZER',
+ ],
+ },
+ 'dependencies': [
+ '<(DEPTH)/build/mac/asan.gyp:asan_dynamic_runtime',
+ ],
+ 'target_conditions': [
+ ['_type!="static_library"', {
+ 'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
+ }],
+ ],
+ }],
+ ['sanitizer_coverage!=0', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize-coverage=<(sanitizer_coverage)',
+ ],
+ 'defines': [
+ 'SANITIZER_COVERAGE',
+ ],
+ }],
+ ],
+ }],
],
- 'cflags!': [
- '-fomit-frame-pointer',
- ],
- 'ldflags': [
- '-fsanitize=thread',
- '-pie',
- ],
- 'defines': [
- 'THREAD_SANITIZER',
- ],
- },
- }],
+ }, # target_defaults
+ }], # OS=="mac"
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
- or OS=="netbsd"', {
+ or OS=="netbsd" or OS=="aix"', {
'target_defaults': {
'cflags': [
'-Wall',
'<(werror)',
- '-W',
'-Wno-unused-parameter',
'-Wno-long-long',
'-pthread',
- '-fno-exceptions',
'-pedantic',
# Don't warn about the "struct foo f = {0};" initialization pattern.
'-Wno-missing-field-initializers',
+ '-Wno-gnu-zero-variadic-macro-arguments',
],
- 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
+ 'cflags_cc': [
+ '-Wnon-virtual-dtor',
+ '-fno-exceptions',
+ '-fno-rtti',
+ '-std=gnu++0x',
+ ],
'ldflags': [ '-pthread', ],
'conditions': [
+ # Don't warn about TRACE_EVENT_* macros with zero arguments passed to
+ # ##__VA_ARGS__. C99 strict mode prohibits having zero variadic macro
+ # arguments in gcc.
+ [ 'clang==0', {
+ 'cflags!' : [
+ '-pedantic' ,
+ # Don't warn about unrecognized command line option.
+ '-Wno-gnu-zero-variadic-macro-arguments',
+ ],
+ }],
+ [ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64" \
+ or v8_target_arch=="mips64el")', {
+ 'cflags': [ '-Wshorten-64-to-32' ],
+ }],
+ [ 'host_arch=="ppc64" and OS!="aix"', {
+ 'cflags': [ '-mminimal-toc' ],
+ }],
[ 'visibility=="hidden" and v8_enable_backtrace==0', {
'cflags': [ '-fvisibility=hidden' ],
}],
[ 'component=="shared_library"', {
'cflags': [ '-fPIC', ],
}],
+ [ 'coverage==1', {
+ 'cflags!': [ '-O3', '-O2', '-O1', ],
+ 'cflags': [ '-fprofile-arcs', '-ftest-coverage', '-O0'],
+ 'ldflags': [ '-fprofile-arcs'],
+ }],
],
},
}],
@@ -272,13 +734,17 @@
'cflags': [
'-Wall',
'<(werror)',
- '-W',
'-Wno-unused-parameter',
- '-fno-exceptions',
# Don't warn about the "struct foo f = {0};" initialization pattern.
'-Wno-missing-field-initializers',
+ '-Wno-gnu-zero-variadic-macro-arguments',
],
- 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
+ 'cflags_cc': [
+ '-Wnon-virtual-dtor',
+ '-fno-exceptions',
+ '-fno-rtti',
+ '-std=gnu++0x',
+ ],
'conditions': [
[ 'visibility=="hidden"', {
'cflags': [ '-fvisibility=hidden' ],
@@ -315,7 +781,84 @@
}],
],
'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
- 'msvs_disabled_warnings': [4355, 4800],
+ 'msvs_disabled_warnings': [
+ # C4091: 'typedef ': ignored on left of 'X' when no variable is
+ # declared.
+ # This happens in a number of Windows headers. Dumb.
+ 4091,
+
+ # C4127: conditional expression is constant
+ # This warning can in theory catch dead code and other problems, but
+ # triggers in far too many desirable cases where the conditional
+ # expression is either set by macros or corresponds some legitimate
+ # compile-time constant expression (due to constant template args,
+ # conditionals comparing the sizes of different types, etc.). Some of
+ # these can be worked around, but it's not worth it.
+ 4127,
+
+ # C4351: new behavior: elements of array 'array' will be default
+ # initialized
+ # This is a silly "warning" that basically just alerts you that the
+ # compiler is going to actually follow the language spec like it's
+ # supposed to, instead of not following it like old buggy versions
+ # did. There's absolutely no reason to turn this on.
+ 4351,
+
+ # C4355: 'this': used in base member initializer list
+ # It's commonly useful to pass |this| to objects in a class'
+ # initializer list. While this warning can catch real bugs, most of
+ # the time the constructors in question don't attempt to call methods
+ # on the passed-in pointer (until later), and annotating every legit
+ # usage of this is simply more hassle than the warning is worth.
+ 4355,
+
+ # C4503: 'identifier': decorated name length exceeded, name was
+ # truncated
+ # This only means that some long error messages might have truncated
+ # identifiers in the presence of lots of templates. It has no effect
+ # on program correctness and there's no real reason to waste time
+ # trying to prevent it.
+ 4503,
+
+ # Warning C4589 says: "Constructor of abstract class ignores
+ # initializer for virtual base class." Disable this warning because it
+ # is flaky in VS 2015 RTM. It triggers on compiler generated
+ # copy-constructors in some cases.
+ 4589,
+
+ # C4611: interaction between 'function' and C++ object destruction is
+ # non-portable
+ # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN
+ # suggests using exceptions instead of setjmp/longjmp for C++, but
+ # Chromium code compiles without exception support. We therefore have
+ # to use setjmp/longjmp for e.g. JPEG decode error handling, which
+ # means we have to turn off this warning (and be careful about how
+ # object destruction happens in such cases).
+ 4611,
+
+ # TODO(jochen): These warnings are level 4. They will be slowly
+ # removed as code is fixed.
+ 4100, # Unreferenced formal parameter
+ 4121, # Alignment of a member was sensitive to packing
+ 4244, # Conversion from 'type1' to 'type2', possible loss of data
+ 4302, # Truncation from 'type 1' to 'type 2'
+ 4309, # Truncation of constant value
+ 4311, # Pointer truncation from 'type' to 'type'
+ 4312, # Conversion from 'type1' to 'type2' of greater size
+ 4505, # Unreferenced local function has been removed
+ 4510, # Default constructor could not be generated
+ 4512, # Assignment operator could not be generated
+ 4610, # Object can never be instantiated
+ 4800, # Forcing value to bool.
+ 4838, # Narrowing conversion. Doesn't seem to be very useful.
+ 4995, # 'X': name was marked as #pragma deprecated
+ 4996, # 'X': was declared deprecated (for GetVersionEx).
+
+ # These are variable shadowing warnings that are new in VS2015. We
+ # should work through these at some point -- they may be removed from
+ # the RTM release in the /W4 set.
+ 4456, 4457, 4458, 4459,
+ ],
'msvs_settings': {
'VCCLCompilerTool': {
'MinimalRebuild': 'false',
@@ -415,10 +958,10 @@
'WARNING_CFLAGS': [
'-Wall',
'-Wendif-labels',
- '-W',
'-Wno-unused-parameter',
# Don't warn about the "struct foo f = {0};" initialization pattern.
'-Wno-missing-field-initializers',
+ '-Wno-gnu-zero-variadic-macro-arguments',
],
},
'conditions': [
@@ -432,6 +975,12 @@
'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x', # -std=gnu++0x
},
+ 'conditions': [
+ ['v8_target_arch=="x64" or v8_target_arch=="arm64" \
+ or v8_target_arch=="mips64el"', {
+ 'xcode_settings': {'WARNING_CFLAGS': ['-Wshorten-64-to-32']},
+ }],
+ ],
}],
],
'target_conditions': [
@@ -441,11 +990,249 @@
], # target_conditions
}, # target_defaults
}], # OS=="mac"
- ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
- 'and OS!="win"', {
+ ['OS=="android"', {
+ 'target_defaults': {
+ 'defines': [
+ 'ANDROID',
+ 'V8_ANDROID_LOG_STDOUT',
+ ],
+ 'configurations': {
+ 'Release': {
+ 'cflags': [
+ '-fomit-frame-pointer',
+ ],
+ }, # Release
+ }, # configurations
+ 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'],
+ 'cflags_cc': [ '-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!': [
+ '-pthread', # Not supported by Android toolchain.
+ ],
+ 'cflags': [
+ '-ffunction-sections',
+ '-funwind-tables',
+ '-fstack-protector',
+ '-fno-short-enums',
+ '-finline-limit=64',
+ '-Wa,--noexecstack',
+ # Note: This include is in cflags to ensure that it comes after
+ # all of the includes.
+ '-I<(android_include)',
+ '-I<(android_stlport_include)',
+ ],
+ 'cflags_cc': [
+ '-Wno-error=non-virtual-dtor', # TODO(michaelbai): Fix warnings.
+ ],
+ 'defines': [
+ 'ANDROID',
+ #'__GNU_SOURCE=1', # Necessary for clone()
+ 'USE_STLPORT=1',
+ '_STLP_USE_PTR_SPECIALIZATIONS=1',
+ 'HAVE_OFF64_T',
+ 'HAVE_SYS_UIO_H',
+ 'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
+ ],
+ 'ldflags!': [
+ '-pthread', # Not supported by Android toolchain.
+ ],
+ 'ldflags': [
+ '-nostdlib',
+ '-Wl,--no-undefined',
+ '-Wl,-rpath-link=<(android_lib)',
+ '-L<(android_lib)',
+ ],
+ 'libraries!': [
+ '-lrt', # librt is built into Bionic.
+ # Not supported by Android toolchain.
+ # Where do these come from? Can't find references in
+ # any Chromium gyp or gypi file. Maybe they come from
+ # gyp itself?
+ '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4',
+ ],
+ 'libraries': [
+ '-l<(android_stlport_library)',
+ # Manually link the libgcc.a that the cross compiler uses.
+ '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
+ '-lc',
+ '-ldl',
+ '-lstdc++',
+ '-lm',
+ ],
+ 'conditions': [
+ ['target_arch == "arm"', {
+ 'ldflags': [
+ # Enable identical code folding to reduce size.
+ '-Wl,--icf=safe',
+ ],
+ }],
+ ['target_arch=="arm" and arm_version==7', {
+ 'cflags': [
+ '-march=armv7-a',
+ '-mtune=cortex-a8',
+ '-mfpu=vfp3',
+ ],
+ 'ldflags': [
+ '-L<(android_stlport_libs)/armeabi-v7a',
+ ],
+ }],
+ ['target_arch=="arm" and arm_version < 7', {
+ 'ldflags': [
+ '-L<(android_stlport_libs)/armeabi',
+ ],
+ }],
+ ['target_arch=="x64"', {
+ 'ldflags': [
+ '-L<(android_stlport_libs)/x86_64',
+ ],
+ }],
+ ['target_arch=="arm64"', {
+ 'ldflags': [
+ '-L<(android_stlport_libs)/arm64-v8a',
+ ],
+ }],
+ ['target_arch=="ia32" or target_arch=="x87"', {
+ # The x86 toolchain currently has problems with stack-protector.
+ 'cflags!': [
+ '-fstack-protector',
+ ],
+ 'cflags': [
+ '-fno-stack-protector',
+ ],
+ 'ldflags': [
+ '-L<(android_stlport_libs)/x86',
+ ],
+ }],
+ ['target_arch=="mipsel"', {
+ # The mips toolchain currently has problems with stack-protector.
+ 'cflags!': [
+ '-fstack-protector',
+ '-U__linux__'
+ ],
+ 'cflags': [
+ '-fno-stack-protector',
+ ],
+ 'ldflags': [
+ '-L<(android_stlport_libs)/mips',
+ ],
+ }],
+ ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64" or target_arch=="ia32") and component!="shared_library"', {
+ 'cflags': [
+ '-fPIE',
+ ],
+ 'ldflags': [
+ '-pie',
+ ],
+ }],
+ ],
+ 'target_conditions': [
+ ['_type=="executable"', {
+ 'conditions': [
+ ['target_arch=="arm64" or target_arch=="x64"', {
+ 'ldflags': [
+ '-Wl,-dynamic-linker,/system/bin/linker64',
+ ],
+ }, {
+ 'ldflags': [
+ '-Wl,-dynamic-linker,/system/bin/linker',
+ ],
+ }]
+ ],
+ 'ldflags': [
+ '-Bdynamic',
+ '-Wl,-z,nocopyreloc',
+ # crtbegin_dynamic.o should be the last item in ldflags.
+ '<(android_lib)/crtbegin_dynamic.o',
+ ],
+ 'libraries': [
+ # crtend_android.o needs to be the last item in libraries.
+ # Do not add any libraries after this!
+ '<(android_lib)/crtend_android.o',
+ ],
+ }],
+ ['_type=="shared_library"', {
+ 'ldflags': [
+ '-Wl,-shared,-Bsymbolic',
+ '<(android_lib)/crtbegin_so.o',
+ ],
+ }],
+ ['_type=="static_library"', {
+ 'ldflags': [
+ # Don't export symbols from statically linked libraries.
+ '-Wl,--exclude-libs=ALL',
+ ],
+ }],
+ ],
+ }], # _toolset=="target"
+ # Settings for building host targets using the system toolchain.
+ ['_toolset=="host"', {
+ 'cflags': [ '-pthread' ],
+ 'ldflags': [ '-pthread' ],
+ 'ldflags!': [
+ '-Wl,-z,noexecstack',
+ '-Wl,--gc-sections',
+ '-Wl,-O1',
+ '-Wl,--as-needed',
+ ],
+ }],
+ ], # target_conditions
+ }, # target_defaults
+ }], # OS=="android"
+ ['OS=="android" and clang==0', {
+ # Hardcode the compiler names in the Makefile so that
+ # it won't depend on the environment at make time.
'make_global_settings': [
- ['CC', '<(make_clang_dir)/bin/clang'],
- ['CXX', '<(make_clang_dir)/bin/clang++'],
+ ['CC', '<!(/bin/echo -n <(android_toolchain)/*-gcc)'],
+ ['CXX', '<!(/bin/echo -n <(android_toolchain)/*-g++)'],
+ ['CC.host', '<(host_cc)'],
+ ['CXX.host', '<(host_cxx)'],
+ ],
+ }],
+ ['clang!=1 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
+ 'make_global_settings': [
+ ['CC.host', '<(clang_dir)/bin/clang'],
+ ['CXX.host', '<(clang_dir)/bin/clang++'],
+ ],
+ }],
+ ['clang==0 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
+ 'target_conditions': [
+ ['_toolset=="host"', {
+ 'cflags_cc': [ '-std=gnu++11', ],
+ }],
+ ],
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="host"', { 'cflags!': [ '-Wno-unused-local-typedefs' ]}],
+ ],
+ },
+ }],
+ ['clang==1 and "<(GENERATOR)"=="ninja"', {
+ # See http://crbug.com/110262
+ 'target_defaults': {
+ 'cflags': [ '-fcolor-diagnostics' ],
+ 'xcode_settings': { 'OTHER_CFLAGS': [ '-fcolor-diagnostics' ] },
+ },
+ }],
+ ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
+ 'and OS!="win" and "<(GENERATOR)"=="make"', {
+ 'make_global_settings': [
+ ['CC', '<(clang_dir)/bin/clang'],
+ ['CXX', '<(clang_dir)/bin/clang++'],
+ ['CC.host', '$(CC)'],
+ ['CXX.host', '$(CXX)'],
+ ],
+ }],
+ ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
+ 'and OS!="win" and "<(GENERATOR)"=="ninja"', {
+ 'make_global_settings': [
+ ['CC', '<(clang_dir)/bin/clang'],
+ ['CXX', '<(clang_dir)/bin/clang++'],
['CC.host', '$(CC)'],
['CXX.host', '$(CXX)'],
],
@@ -453,8 +1240,131 @@
['clang==1 and OS=="win"', {
'make_global_settings': [
# On Windows, gyp's ninja generator only looks at CC.
- ['CC', '<(make_clang_dir)/bin/clang-cl'],
+ ['CC', '<(clang_dir)/bin/clang-cl'],
],
}],
+ ['OS=="linux" and target_arch=="arm" and host_arch!="arm" and clang==0 and "<(GENERATOR)"=="ninja"', {
+ # Set default ARM cross tools on linux. These can be overridden
+ # using CC,CXX,CC.host and CXX.host environment variables.
+ 'make_global_settings': [
+ ['CC', '<!(which arm-linux-gnueabihf-gcc)'],
+ ['CXX', '<!(which arm-linux-gnueabihf-g++)'],
+ ['CC.host', '<(host_cc)'],
+ ['CXX.host', '<(host_cxx)'],
+ ],
+ }],
+ # TODO(yyanagisawa): supports GENERATOR==make
+ # make generator doesn't support CC_wrapper without CC
+ # in make_global_settings yet.
+ ['use_goma==1 and ("<(GENERATOR)"=="ninja" or clang==1)', {
+ 'make_global_settings': [
+ ['CC_wrapper', '<(gomadir)/gomacc'],
+ ['CXX_wrapper', '<(gomadir)/gomacc'],
+ ['CC.host_wrapper', '<(gomadir)/gomacc'],
+ ['CXX.host_wrapper', '<(gomadir)/gomacc'],
+ ],
+ }],
+ ['use_lto==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-flto',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['use_lto==1 and clang==0', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-ffat-lto-objects',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['use_lto==1 and clang==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'arflags': [
+ '--plugin', '<(clang_dir)/lib/LLVMgold.so',
+ ],
+ # Apply a lower optimization level with lto. Chromium does this
+ # for non-official builds only - a differentiation that doesn't
+ # exist in v8.
+ 'ldflags': [
+ '-Wl,--plugin-opt,O1',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['use_lto==1 and clang==0', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'ldflags': [
+ '-flto=32',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['use_lto==1 and clang==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'ldflags': [
+ '-flto',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['cfi_diag==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fno-sanitize-trap=cfi',
+ '-fno-sanitize-recover=cfi',
+ ],
+ 'cflags_cc!': [
+ '-fno-rtti',
+ ],
+ 'cflags!': [
+ '-fno-rtti',
+ ],
+ 'ldflags': [
+ '-fno-sanitize-trap=cfi',
+ '-fno-sanitize-recover=cfi',
+ ],
+ }],
+ ],
+ },
+ }],
+ ['cfi_vptr==1', {
+ 'target_defaults': {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'cflags': [
+ '-fsanitize=cfi-vcall',
+ '-fsanitize=cfi-derived-cast',
+ '-fsanitize=cfi-unrelated-cast',
+ '-fsanitize-blacklist=<(cfi_blacklist)',
+ ],
+ 'ldflags': [
+ '-fsanitize=cfi-vcall',
+ '-fsanitize=cfi-derived-cast',
+ '-fsanitize=cfi-unrelated-cast',
+ ],
+ }],
+ ],
+ },
+ }],
],
}
diff --git a/build/toolchain.gypi b/build/toolchain.gypi
index ac10065..e1cd791 100644
--- a/build/toolchain.gypi
+++ b/build/toolchain.gypi
@@ -31,7 +31,14 @@
'variables': {
'msvs_use_common_release': 0,
'clang%': 0,
+ 'asan%': 0,
+ 'lsan%': 0,
+ 'msan%': 0,
+ 'tsan%': 0,
+ 'ubsan%': 0,
+ 'ubsan_vptr%': 0,
'v8_target_arch%': '<(target_arch)',
+ 'v8_host_byteorder%': '<!(python -c "import sys; print sys.byteorder")',
# Native Client builds currently use the V8 ARM JIT and
# arm/simulator-arm.cc to defer the significant effort required
# for NaCl JIT support. The nacl_target_arch variable provides
@@ -54,6 +61,9 @@
# Similar to the ARM hard float ABI but on MIPS.
'v8_use_mips_abi_hardfloat%': 'true',
+ # Force disable libstdc++ debug mode.
+ 'disable_glibcxx_debug%': 0,
+
'v8_enable_backtrace%': 0,
# Enable profiling support. Only required on Windows.
@@ -79,19 +89,54 @@
# Allow to suppress the array bounds warning (default is no suppression).
'wno_array_bounds%': '',
+ # Override where to find binutils
+ 'binutils_dir%': '',
+
+ 'conditions': [
+ ['OS=="linux" and host_arch=="x64"', {
+ 'binutils_dir%': 'third_party/binutils/Linux_x64/Release/bin',
+ }],
+ ['OS=="linux" and host_arch=="ia32"', {
+ 'binutils_dir%': 'third_party/binutils/Linux_ia32/Release/bin',
+ }],
+
+ # linux_use_bundled_gold: whether to use the gold linker binary checked
+ # into third_party/binutils. Force this off via GYP_DEFINES when you
+ # are using a custom toolchain and need to control -B in ldflags.
+ # Do not use 32-bit gold on 32-bit hosts as it runs out address space
+ # for component=static_library builds.
+ ['OS=="linux" and (target_arch=="x64" or target_arch=="arm")', {
+ 'linux_use_bundled_gold%': 1,
+ }, {
+ 'linux_use_bundled_gold%': 0,
+ }],
+ # linux_use_bundled_binutils: whether to use the binary binutils
+ # checked into third_party/binutils. These are not multi-arch so cannot
+ # be used except on x86 and x86-64 (the only two architectures which
+ # are currently checke in). Force this off via GYP_DEFINES when you
+ # are using a custom toolchain and need to control -B in cflags.
+ ['OS=="linux" and (target_arch=="ia32" or target_arch=="x64")', {
+ 'linux_use_bundled_binutils%': 1,
+ }, {
+ 'linux_use_bundled_binutils%': 0,
+ }],
+ # linux_use_gold_flags: whether to use build flags that rely on gold.
+ # On by default for x64 Linux.
+ ['OS=="linux" and target_arch=="x64"', {
+ 'linux_use_gold_flags%': 1,
+ }, {
+ 'linux_use_gold_flags%': 0,
+ }],
+ ],
+
# Link-Time Optimizations
'use_lto%': 0,
-
- 'variables': {
- # This is set when building the Android WebView inside the Android build
- # system, using the 'android' gyp backend.
- 'android_webview_build%': 0,
- },
- # Copy it out one scope.
- 'android_webview_build%': '<(android_webview_build)',
},
'conditions': [
- ['host_arch=="ia32" or host_arch=="x64" or clang==1', {
+ ['host_arch=="ia32" or host_arch=="x64" or \
+ host_arch=="ppc" or host_arch=="ppc64" or \
+ host_arch=="s390" or host_arch=="s390x" or \
+ clang==1', {
'variables': {
'host_cxx_is_biarch%': 1,
},
@@ -101,7 +146,8 @@
},
}],
['target_arch=="ia32" or target_arch=="x64" or target_arch=="x87" or \
- clang==1', {
+ target_arch=="ppc" or target_arch=="ppc64" or target_arch=="s390" or \
+ target_arch=="s390x" or clang==1', {
'variables': {
'target_cxx_is_biarch%': 1,
},
@@ -150,7 +196,7 @@
'target_conditions': [
['_toolset=="host"', {
'conditions': [
- ['v8_target_arch==host_arch and android_webview_build==0', {
+ ['v8_target_arch==host_arch', {
# Host built with an Arm CXX compiler.
'conditions': [
[ 'arm_version==7', {
@@ -193,7 +239,7 @@
}], # _toolset=="host"
['_toolset=="target"', {
'conditions': [
- ['v8_target_arch==target_arch and android_webview_build==0', {
+ ['v8_target_arch==target_arch', {
# Target built with an Arm CXX compiler.
'conditions': [
[ 'arm_version==7', {
@@ -232,10 +278,12 @@
}],
],
}],
- # Disable LTO for v8
- # v8 is optimized for speed, which takes precedence over
- # size optimization in LTO.
- ['use_lto==1', {
+ # Disable GCC LTO for v8
+ # v8 is optimized for speed. Because GCC LTO merges flags at link
+ # time, we disable LTO to prevent any -O2 flags from taking
+ # precedence over v8's -Os flag. However, LLVM LTO does not work
+ # this way so we keep LTO enabled under LLVM.
+ ['clang==0 and use_lto==1', {
'cflags!': [
'-flto',
'-ffat-lto-objects',
@@ -250,6 +298,55 @@
'V8_TARGET_ARCH_ARM64',
],
}],
+ ['v8_target_arch=="s390" or v8_target_arch=="s390x"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_S390',
+ ],
+ 'conditions': [
+ ['v8_target_arch=="s390x"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_S390X',
+ ],
+ }],
+ ['v8_host_byteorder=="little"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_S390_LE_SIM',
+ ],
+ }],
+ ],
+ }], # s390
+ ['v8_target_arch=="ppc" or v8_target_arch=="ppc64"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_PPC',
+ ],
+ 'conditions': [
+ ['v8_target_arch=="ppc64"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_PPC64',
+ ],
+ }],
+ ['v8_host_byteorder=="little"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_PPC_LE',
+ ],
+ }],
+ ['v8_host_byteorder=="big"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_PPC_BE',
+ ],
+ 'conditions': [
+ ['OS=="aix"', {
+ # Work around AIX ceil, trunc and round oddities.
+ 'cflags': [ '-mcpu=power5+ -mfprnd' ],
+ }],
+ ['OS=="aix"', {
+ # Work around AIX assembler popcntb bug.
+ 'cflags': [ '-mno-popcntb' ],
+ }],
+ ],
+ }],
+ ],
+ }], # ppc
['v8_target_arch=="ia32"', {
'defines': [
'V8_TARGET_ARCH_IA32',
@@ -261,6 +358,30 @@
],
'cflags': ['-march=i586'],
}], # v8_target_arch=="x87"
+ ['(v8_target_arch=="mips" or v8_target_arch=="mipsel" \
+ or v8_target_arch=="mips64" or v8_target_arch=="mips64el") \
+ and v8_target_arch==target_arch', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ # Target built with a Mips CXX compiler.
+ 'variables': {
+ 'ldso_path%': '<!(/bin/echo -n $LDSO_PATH)',
+ 'ld_r_path%': '<!(/bin/echo -n $LD_R_PATH)',
+ },
+ 'conditions': [
+ ['ldso_path!=""', {
+ 'ldflags': ['-Wl,--dynamic-linker=<(ldso_path)'],
+ }],
+ ['ld_r_path!=""', {
+ 'ldflags': ['-Wl,--rpath=<(ld_r_path)'],
+ }],
+ [ 'clang==1', {
+ 'cflags': ['-integrated-as'],
+ }],
+ ],
+ }],
+ ],
+ }],
['v8_target_arch=="mips"', {
'defines': [
'V8_TARGET_ARCH_MIPS',
@@ -285,9 +406,12 @@
'target_conditions': [
['_toolset=="target"', {
'conditions': [
- ['v8_target_arch==target_arch and android_webview_build==0', {
+ ['v8_target_arch==target_arch', {
# Target built with a Mips CXX compiler.
- 'cflags': ['-EB'],
+ 'cflags': [
+ '-EB',
+ '-Wno-error=array-bounds', # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
+ ],
'ldflags': ['-EB'],
'conditions': [
[ 'v8_use_mips_abi_hardfloat=="true"', {
@@ -303,12 +427,13 @@
'FPU_MODE_FP64',
],
'cflags!': ['-mfp32', '-mfpxx'],
- 'cflags': ['-mips32r6', '-Wa,-mips32r6'],
- 'ldflags': [
- '-mips32r6',
- '-Wl,--dynamic-linker=$(LDSO_PATH)',
- '-Wl,--rpath=$(LD_R_PATH)',
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32r6'],
+ }],
],
+ 'cflags': ['-mips32r6'],
+ 'ldflags': ['-mips32r6'],
}],
['mips_arch_variant=="r2"', {
'conditions': [
@@ -333,8 +458,11 @@
],
'cflags': ['-mfp32'],
}],
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32r2'],
+ }],
],
- 'cflags': ['-mips32r2', '-Wa,-mips32r2'],
+ 'cflags': ['-mips32r2'],
'ldflags': ['-mips32r2'],
}],
['mips_arch_variant=="r1"', {
@@ -342,7 +470,12 @@
'FPU_MODE_FP32',
],
'cflags!': ['-mfp64', '-mfpxx'],
- 'cflags': ['-mips32', '-Wa,-mips32'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32'],
+ }],
+ ],
+ 'cflags': ['-mips32'],
'ldflags': ['-mips32'],
}],
['mips_arch_variant=="rx"', {
@@ -351,7 +484,12 @@
'FPU_MODE_FPXX',
],
'cflags!': ['-mfp64', '-mfp32'],
- 'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32'],
+ }],
+ ],
+ 'cflags': ['-mips32', '-mfpxx'],
'ldflags': ['-mips32'],
}],
],
@@ -469,9 +607,12 @@
'target_conditions': [
['_toolset=="target"', {
'conditions': [
- ['v8_target_arch==target_arch and android_webview_build==0', {
+ ['v8_target_arch==target_arch', {
# Target built with a Mips CXX compiler.
- 'cflags': ['-EL'],
+ 'cflags': [
+ '-EL',
+ '-Wno-error=array-bounds', # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
+ ],
'ldflags': ['-EL'],
'conditions': [
[ 'v8_use_mips_abi_hardfloat=="true"', {
@@ -487,12 +628,13 @@
'FPU_MODE_FP64',
],
'cflags!': ['-mfp32', '-mfpxx'],
- 'cflags': ['-mips32r6', '-Wa,-mips32r6'],
- 'ldflags': [
- '-mips32r6',
- '-Wl,--dynamic-linker=$(LDSO_PATH)',
- '-Wl,--rpath=$(LD_R_PATH)',
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32r6'],
+ }],
],
+ 'cflags': ['-mips32r6'],
+ 'ldflags': ['-mips32r6'],
}],
['mips_arch_variant=="r2"', {
'conditions': [
@@ -517,13 +659,21 @@
],
'cflags': ['-mfp32'],
}],
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32r2'],
+ }],
],
- 'cflags': ['-mips32r2', '-Wa,-mips32r2'],
+ 'cflags': ['-mips32r2'],
'ldflags': ['-mips32r2'],
}],
['mips_arch_variant=="r1"', {
'cflags!': ['-mfp64', '-mfpxx'],
- 'cflags': ['-mips32', '-Wa,-mips32'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32'],
+ }],
+ ],
+ 'cflags': ['-mips32'],
'ldflags': ['-mips32'],
}],
['mips_arch_variant=="rx"', {
@@ -532,7 +682,12 @@
'FPU_MODE_FPXX',
],
'cflags!': ['-mfp64', '-mfp32'],
- 'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips32'],
+ }],
+ ],
+ 'cflags': ['-mips32', '-mfpxx'],
'ldflags': ['-mips32'],
}],
['mips_arch_variant=="loongson"', {
@@ -540,8 +695,13 @@
'_MIPS_ARCH_LOONGSON',
'FPU_MODE_FP32',
],
- 'cflags!': ['-mfp64', '-mfp32', '-mfpxx'],
- 'cflags': ['-mips3', '-Wa,-mips3'],
+ 'cflags!': ['-mfp64', '-mfpxx'],
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips3'],
+ }],
+ ],
+ 'cflags': ['-mips3', '-mfp32'],
}],
],
}, {
@@ -646,7 +806,7 @@
}],
],
}], # v8_target_arch=="mipsel"
- ['v8_target_arch=="mips64el"', {
+ ['v8_target_arch=="mips64el" or v8_target_arch=="mips64"', {
'defines': [
'V8_TARGET_ARCH_MIPS64',
],
@@ -656,6 +816,16 @@
'CAN_USE_FPU_INSTRUCTIONS',
],
}],
+ [ 'v8_host_byteorder=="little"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_MIPS64_LE',
+ ],
+ }],
+ [ 'v8_host_byteorder=="big"', {
+ 'defines': [
+ 'V8_TARGET_ARCH_MIPS64_BE',
+ ],
+ }],
[ 'v8_use_mips_abi_hardfloat=="true"', {
'defines': [
'__mips_hard_float=1',
@@ -670,10 +840,19 @@
'target_conditions': [
['_toolset=="target"', {
'conditions': [
- ['v8_target_arch==target_arch and android_webview_build==0', {
- 'cflags': ['-EL'],
- 'ldflags': ['-EL'],
+ ['v8_target_arch==target_arch', {
+ 'cflags': [
+ '-Wno-error=array-bounds', # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
+ ],
'conditions': [
+ ['v8_target_arch=="mips64el"', {
+ 'cflags': ['-EL'],
+ 'ldflags': ['-EL'],
+ }],
+ ['v8_target_arch=="mips64"', {
+ 'cflags': ['-EB'],
+ 'ldflags': ['-EB'],
+ }],
[ 'v8_use_mips_abi_hardfloat=="true"', {
'cflags': ['-mhard-float'],
'ldflags': ['-mhard-float'],
@@ -683,21 +862,23 @@
}],
['mips_arch_variant=="r6"', {
'defines': ['_MIPS_ARCH_MIPS64R6',],
- 'cflags': ['-mips64r6', '-mabi=64', '-Wa,-mips64r6'],
- 'ldflags': [
- '-mips64r6', '-mabi=64',
- '-Wl,--dynamic-linker=$(LDSO_PATH)',
- '-Wl,--rpath=$(LD_R_PATH)',
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips64r6'],
+ }],
],
+ 'cflags': ['-mips64r6', '-mabi=64'],
+ 'ldflags': ['-mips64r6', '-mabi=64'],
}],
['mips_arch_variant=="r2"', {
'defines': ['_MIPS_ARCH_MIPS64R2',],
- 'cflags': ['-mips64r2', '-mabi=64', '-Wa,-mips64r2'],
- 'ldflags': [
- '-mips64r2', '-mabi=64',
- '-Wl,--dynamic-linker=$(LDSO_PATH)',
- '-Wl,--rpath=$(LD_R_PATH)',
+ 'conditions': [
+ [ 'clang==0', {
+ 'cflags': ['-Wa,-mips64r2'],
+ }],
],
+ 'cflags': ['-mips64r2', '-mabi=64'],
+ 'ldflags': ['-mips64r2', '-mabi=64'],
}],
],
}, {
@@ -755,6 +936,26 @@
'-mx32',
],
}], # v8_target_arch=="x32"
+ ['linux_use_gold_flags==1', {
+ # Newer gccs and clangs support -fuse-ld, use the flag to force gold
+ # selection.
+ # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html
+ 'ldflags': [ '-fuse-ld=gold', ],
+ }],
+ ['linux_use_bundled_binutils==1', {
+ 'cflags': [
+ '-B<!(cd <(DEPTH) && pwd -P)/<(binutils_dir)',
+ ],
+ }],
+ ['linux_use_bundled_gold==1', {
+ # Put our binutils, which contains gold in the search path. We pass
+ # the path to gold to the compiler. gyp leaves unspecified what the
+ # cwd is when running the compiler, so the normal gyp path-munging
+ # fails us. This hack gets the right path.
+ 'ldflags': [
+ '-B<!(cd <(DEPTH) && pwd -P)/<(binutils_dir)',
+ ],
+ }],
['OS=="win"', {
'defines': [
'WIN32',
@@ -783,17 +984,34 @@
},
},
}],
- ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
+ ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
+ or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
+ v8_target_arch=="ia32"', {
+ 'cflags': [
+ '-msse2',
+ '-mfpmath=sse',
+ '-mmmx', # Allows mmintrin.h for MMX intrinsics.
+ ],
+ }],
+ ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
(v8_target_arch=="arm" or v8_target_arch=="ia32" or \
v8_target_arch=="x87" or v8_target_arch=="mips" or \
- v8_target_arch=="mipsel")', {
+ v8_target_arch=="mipsel" or v8_target_arch=="ppc" or \
+ v8_target_arch=="s390")', {
'target_conditions': [
['_toolset=="host"', {
'conditions': [
['host_cxx_is_biarch==1', {
- 'cflags': [ '-m32' ],
- 'ldflags': [ '-m32' ]
+ 'conditions': [
+ ['host_arch=="s390" or host_arch=="s390x"', {
+ 'cflags': [ '-m31' ],
+ 'ldflags': [ '-m31' ]
+ },{
+ 'cflags': [ '-m32' ],
+ 'ldflags': [ '-m32' ]
+ }],
+ ],
}],
],
'xcode_settings': {
@@ -803,14 +1021,15 @@
['_toolset=="target"', {
'conditions': [
['target_cxx_is_biarch==1 and nacl_target_arch!="nacl_x64"', {
- 'cflags': [ '-m32' ],
- 'ldflags': [ '-m32' ],
- }],
- # Enable feedback-directed optimisation when building in android.
- [ 'android_webview_build == 1', {
- 'aosp_build_settings': {
- 'LOCAL_FDO_SUPPORT': 'true',
- },
+ 'conditions': [
+ ['host_arch=="s390" or host_arch=="s390x"', {
+ 'cflags': [ '-m31' ],
+ 'ldflags': [ '-m31' ]
+ },{
+ 'cflags': [ '-m32' ],
+ 'ldflags': [ '-m32' ],
+ }],
+ ],
}],
],
'xcode_settings': {
@@ -820,7 +1039,8 @@
],
}],
['(OS=="linux" or OS=="android") and \
- (v8_target_arch=="x64" or v8_target_arch=="arm64")', {
+ (v8_target_arch=="x64" or v8_target_arch=="arm64" or \
+ v8_target_arch=="ppc64" or v8_target_arch=="s390x")', {
'target_conditions': [
['_toolset=="host"', {
'conditions': [
@@ -836,18 +1056,12 @@
'cflags': [ '-m64' ],
'ldflags': [ '-m64' ],
}],
- # Enable feedback-directed optimisation when building in android.
- [ 'android_webview_build == 1', {
- 'aosp_build_settings': {
- 'LOCAL_FDO_SUPPORT': 'true',
- },
- }],
]
}],
],
}],
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
- or OS=="netbsd" or OS=="qnx"', {
+ or OS=="netbsd" or OS=="qnx" or OS=="aix"', {
'conditions': [
[ 'v8_no_strict_aliasing==1', {
'cflags': [ '-fno-strict-aliasing' ],
@@ -863,6 +1077,21 @@
['OS=="netbsd"', {
'cflags': [ '-I/usr/pkg/include' ],
}],
+ ['OS=="aix"', {
+ 'defines': [
+ # Support for malloc(0)
+ '_LINUX_SOURCE_COMPAT=1',
+ '_ALL_SOURCE=1'],
+ 'conditions': [
+ [ 'v8_target_arch=="ppc"', {
+ 'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ],
+ }],
+ [ 'v8_target_arch=="ppc64"', {
+ 'cflags': [ '-maix64' ],
+ 'ldflags': [ '-maix64' ],
+ }],
+ ],
+ }],
], # conditions
'configurations': {
# Abstract configuration for v8_optimized_debug == 0.
@@ -883,9 +1112,12 @@
'LinkIncremental': '2',
},
},
+ 'variables': {
+ 'v8_enable_slow_dchecks%': 1,
+ },
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
- OS=="qnx"', {
+ OS=="qnx" or OS=="aix"', {
'cflags!': [
'-O3',
'-O2',
@@ -902,9 +1134,11 @@
'GCC_OPTIMIZATION_LEVEL': '0', # -O0
},
}],
- ],
- 'defines': [
- 'ENABLE_SLOW_DCHECKS',
+ ['v8_enable_slow_dchecks==1', {
+ 'defines': [
+ 'ENABLE_SLOW_DCHECKS',
+ ],
+ }],
],
}, # DebugBase0
# Abstract configuration for v8_optimized_debug == 1.
@@ -912,55 +1146,6 @@
'abstract': 1,
'msvs_settings': {
'VCCLCompilerTool': {
- 'Optimization': '1',
- 'InlineFunctionExpansion': '2',
- 'EnableIntrinsicFunctions': 'true',
- 'FavorSizeOrSpeed': '0',
- 'StringPooling': 'true',
- 'BasicRuntimeChecks': '0',
- 'conditions': [
- ['component=="shared_library"', {
- 'RuntimeLibrary': '3', # /MDd
- }, {
- 'RuntimeLibrary': '1', # /MTd
- }],
- ],
- },
- 'VCLinkerTool': {
- 'LinkIncremental': '2',
- },
- },
- 'defines': [
- 'ENABLE_SLOW_DCHECKS',
- ],
- 'conditions': [
- ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
- OS=="qnx"', {
- 'cflags!': [
- '-O0',
- '-O3', # TODO(2807) should be -O1.
- '-O2',
- '-Os',
- ],
- 'cflags': [
- '-fdata-sections',
- '-ffunction-sections',
- '-O1', # TODO(2807) should be -O3.
- ],
- }],
- ['OS=="mac"', {
- 'xcode_settings': {
- 'GCC_OPTIMIZATION_LEVEL': '3', # -O3
- 'GCC_STRICT_ALIASING': 'YES',
- },
- }],
- ],
- }, # DebugBase1
- # Abstract configuration for v8_optimized_debug == 2.
- 'DebugBase2': {
- 'abstract': 1,
- 'msvs_settings': {
- 'VCCLCompilerTool': {
'Optimization': '2',
'InlineFunctionExpansion': '2',
'EnableIntrinsicFunctions': 'true',
@@ -981,9 +1166,12 @@
'EnableCOMDATFolding': '2',
},
},
+ 'variables': {
+ 'v8_enable_slow_dchecks%': 0,
+ },
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
- OS=="qnx"', {
+ OS=="qnx" or OS=="aix"', {
'cflags!': [
'-O0',
'-O1',
@@ -995,7 +1183,9 @@
],
'conditions': [
# TODO(crbug.com/272548): Avoid -O3 in NaCl
- ['nacl_target_arch=="none"', {
+ # Don't use -O3 with sanitizers.
+ ['nacl_target_arch=="none" and asan==0 and msan==0 and lsan==0 \
+ and tsan==0 and ubsan==0 and ubsan_vptr==0', {
'cflags': ['-O3'],
'cflags!': ['-O2'],
}, {
@@ -1010,8 +1200,13 @@
'GCC_STRICT_ALIASING': 'YES',
},
}],
+ ['v8_enable_slow_dchecks==1', {
+ 'defines': [
+ 'ENABLE_SLOW_DCHECKS',
+ ],
+ }],
],
- }, # DebugBase2
+ }, # DebugBase1
# Common settings for the Debug configuration.
'DebugBaseCommon': {
'abstract': 1,
@@ -1025,13 +1220,26 @@
],
'conditions': [
['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
- OS=="qnx"', {
+ OS=="qnx" or OS=="aix"', {
'cflags': [ '-Woverloaded-virtual', '<(wno_array_bounds)', ],
}],
['OS=="linux" and v8_enable_backtrace==1', {
# Support for backtrace_symbols.
'ldflags': [ '-rdynamic' ],
}],
+ ['OS=="linux" and disable_glibcxx_debug==0', {
+ # Enable libstdc++ debugging facilities to help catch problems
+ # early, see http://crbug.com/65151 .
+ 'defines': ['_GLIBCXX_DEBUG=1',],
+ }],
+ ['OS=="aix"', {
+ 'ldflags': [ '-Wl,-bbigtoc' ],
+ 'conditions': [
+ ['v8_target_arch=="ppc64"', {
+ 'cflags': [ '-maix64 -mcmodel=large' ],
+ }],
+ ],
+ }],
['OS=="android"', {
'variables': {
'android_full_debug%': 1,
@@ -1047,6 +1255,23 @@
}],
],
}],
+ # TODO(pcc): Re-enable in LTO builds once we've fixed the intermittent
+ # link failures (crbug.com/513074).
+ ['linux_use_gold_flags==1 and use_lto==0', {
+ 'target_conditions': [
+ ['_toolset=="target"', {
+ 'ldflags': [
+ # Experimentation found that using four linking threads
+ # saved ~20% of link time.
+ # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
+ # Only apply this to the target linker, since the host
+ # linker might not be gold, but isn't used much anyway.
+ '-Wl,--threads',
+ '-Wl,--thread-count=4',
+ ],
+ }],
+ ],
+ }],
],
}, # DebugBaseCommon
'Debug': {
@@ -1054,18 +1279,18 @@
'conditions': [
['v8_optimized_debug==0', {
'inherit_from': ['DebugBase0'],
- }],
- ['v8_optimized_debug==1', {
+ }, {
'inherit_from': ['DebugBase1'],
}],
- ['v8_optimized_debug==2', {
- 'inherit_from': ['DebugBase2'],
- }],
],
}, # Debug
'Release': {
+ 'variables': {
+ 'v8_enable_slow_dchecks%': 0,
+ },
'conditions': [
- ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
+ ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \
+ or OS=="aix"', {
'cflags!': [
'-Os',
],
@@ -1076,7 +1301,9 @@
],
'conditions': [
# TODO(crbug.com/272548): Avoid -O3 in NaCl
- ['nacl_target_arch=="none"', {
+ # Don't use -O3 with sanitizers.
+ ['nacl_target_arch=="none" and asan==0 and msan==0 and lsan==0 \
+ and tsan==0 and ubsan==0 and ubsan_vptr==0', {
'cflags': ['-O3'],
'cflags!': ['-O2'],
}, {
@@ -1130,6 +1357,11 @@
},
},
}], # OS=="win"
+ ['v8_enable_slow_dchecks==1', {
+ 'defines': [
+ 'ENABLE_SLOW_DCHECKS',
+ ],
+ }],
], # conditions
}, # Release
}, # configurations
diff --git a/build/vs_toolchain.py b/build/vs_toolchain.py
new file mode 100644
index 0000000..294ade3
--- /dev/null
+++ b/build/vs_toolchain.py
@@ -0,0 +1,268 @@
+#!/usr/bin/env python
+# Copyright 2015 the V8 project authors. All rights reserved.
+# Copyright 2014 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import json
+import os
+import pipes
+import shutil
+import subprocess
+import sys
+import vs_toolchain
+
+
+script_dir = os.path.dirname(os.path.realpath(__file__))
+chrome_src = os.path.abspath(os.path.join(script_dir, os.pardir))
+SRC_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
+sys.path.insert(1, os.path.join(chrome_src, 'tools'))
+sys.path.insert(0, os.path.join(chrome_src, 'build', 'gyp', 'pylib'))
+json_data_file = os.path.join(script_dir, 'win_toolchain.json')
+
+
+import gyp
+
+
+def SetEnvironmentAndGetRuntimeDllDirs():
+ """Sets up os.environ to use the depot_tools VS toolchain with gyp, and
+ returns the location of the VS runtime DLLs so they can be copied into
+ the output directory after gyp generation.
+ """
+ vs2013_runtime_dll_dirs = None
+ depot_tools_win_toolchain = \
+ bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
+ # When running on a non-Windows host, only do this if the SDK has explicitly
+ # been downloaded before (in which case json_data_file will exist).
+ if ((sys.platform in ('win32', 'cygwin') or os.path.exists(json_data_file))
+ and depot_tools_win_toolchain):
+ if not os.path.exists(json_data_file):
+ Update()
+ with open(json_data_file, 'r') as tempf:
+ toolchain_data = json.load(tempf)
+
+ toolchain = toolchain_data['path']
+ version = toolchain_data['version']
+ win_sdk = toolchain_data.get('win_sdk')
+ if not win_sdk:
+ win_sdk = toolchain_data['win8sdk']
+ wdk = toolchain_data['wdk']
+ # TODO(scottmg): The order unfortunately matters in these. They should be
+ # split into separate keys for x86 and x64. (See CopyVsRuntimeDlls call
+ # below). http://crbug.com/345992
+ vs2013_runtime_dll_dirs = toolchain_data['runtime_dirs']
+
+ os.environ['GYP_MSVS_OVERRIDE_PATH'] = toolchain
+ os.environ['GYP_MSVS_VERSION'] = version
+ # We need to make sure windows_sdk_path is set to the automated
+ # toolchain values in GYP_DEFINES, but don't want to override any
+ # otheroptions.express
+ # values there.
+ gyp_defines_dict = gyp.NameValueListToDict(gyp.ShlexEnv('GYP_DEFINES'))
+ gyp_defines_dict['windows_sdk_path'] = win_sdk
+ os.environ['GYP_DEFINES'] = ' '.join('%s=%s' % (k, pipes.quote(str(v)))
+ for k, v in gyp_defines_dict.iteritems())
+ os.environ['WINDOWSSDKDIR'] = win_sdk
+ os.environ['WDK_DIR'] = wdk
+ # Include the VS runtime in the PATH in case it's not machine-installed.
+ runtime_path = ';'.join(vs2013_runtime_dll_dirs)
+ os.environ['PATH'] = runtime_path + ';' + os.environ['PATH']
+ return vs2013_runtime_dll_dirs
+
+
+def _VersionNumber():
+ """Gets the standard version number ('120', '140', etc.) based on
+ GYP_MSVS_VERSION."""
+ if os.environ['GYP_MSVS_VERSION'] == '2013':
+ return '120'
+ elif os.environ['GYP_MSVS_VERSION'] == '2015':
+ return '140'
+ else:
+ raise ValueError('Unexpected GYP_MSVS_VERSION')
+
+
+def _CopyRuntimeImpl(target, source):
+ """Copy |source| to |target| if it doesn't already exist or if it
+ needs to be updated.
+ """
+ if (os.path.isdir(os.path.dirname(target)) and
+ (not os.path.isfile(target) or
+ os.stat(target).st_mtime != os.stat(source).st_mtime)):
+ print 'Copying %s to %s...' % (source, target)
+ if os.path.exists(target):
+ os.unlink(target)
+ shutil.copy2(source, target)
+
+
+def _CopyRuntime2013(target_dir, source_dir, dll_pattern):
+ """Copy both the msvcr and msvcp runtime DLLs, only if the target doesn't
+ exist, but the target directory does exist."""
+ for file_part in ('p', 'r'):
+ dll = dll_pattern % file_part
+ target = os.path.join(target_dir, dll)
+ source = os.path.join(source_dir, dll)
+ _CopyRuntimeImpl(target, source)
+
+
+def _CopyRuntime2015(target_dir, source_dir, dll_pattern):
+ """Copy both the msvcp and vccorlib runtime DLLs, only if the target doesn't
+ exist, but the target directory does exist."""
+ for file_part in ('msvcp', 'vccorlib'):
+ dll = dll_pattern % file_part
+ target = os.path.join(target_dir, dll)
+ source = os.path.join(source_dir, dll)
+ _CopyRuntimeImpl(target, source)
+
+
+def CopyVsRuntimeDlls(output_dir, runtime_dirs):
+ """Copies the VS runtime DLLs from the given |runtime_dirs| to the output
+ directory so that even if not system-installed, built binaries are likely to
+ be able to run.
+
+ This needs to be run after gyp has been run so that the expected target
+ output directories are already created.
+ """
+ x86, x64 = runtime_dirs
+ out_debug = os.path.join(output_dir, 'Debug')
+ out_debug_nacl64 = os.path.join(output_dir, 'Debug', 'x64')
+ out_release = os.path.join(output_dir, 'Release')
+ out_release_nacl64 = os.path.join(output_dir, 'Release', 'x64')
+ out_debug_x64 = os.path.join(output_dir, 'Debug_x64')
+ out_release_x64 = os.path.join(output_dir, 'Release_x64')
+
+ if os.path.exists(out_debug) and not os.path.exists(out_debug_nacl64):
+ os.makedirs(out_debug_nacl64)
+ if os.path.exists(out_release) and not os.path.exists(out_release_nacl64):
+ os.makedirs(out_release_nacl64)
+ if os.environ.get('GYP_MSVS_VERSION') == '2015':
+ _CopyRuntime2015(out_debug, x86, '%s140d.dll')
+ _CopyRuntime2015(out_release, x86, '%s140.dll')
+ _CopyRuntime2015(out_debug_x64, x64, '%s140d.dll')
+ _CopyRuntime2015(out_release_x64, x64, '%s140.dll')
+ _CopyRuntime2015(out_debug_nacl64, x64, '%s140d.dll')
+ _CopyRuntime2015(out_release_nacl64, x64, '%s140.dll')
+ else:
+ # VS2013 is the default.
+ _CopyRuntime2013(out_debug, x86, 'msvc%s120d.dll')
+ _CopyRuntime2013(out_release, x86, 'msvc%s120.dll')
+ _CopyRuntime2013(out_debug_x64, x64, 'msvc%s120d.dll')
+ _CopyRuntime2013(out_release_x64, x64, 'msvc%s120.dll')
+ _CopyRuntime2013(out_debug_nacl64, x64, 'msvc%s120d.dll')
+ _CopyRuntime2013(out_release_nacl64, x64, 'msvc%s120.dll')
+
+ # Copy the PGO runtime library to the release directories.
+ if os.environ.get('GYP_MSVS_OVERRIDE_PATH'):
+ pgo_x86_runtime_dir = os.path.join(os.environ.get('GYP_MSVS_OVERRIDE_PATH'),
+ 'VC', 'bin')
+ pgo_x64_runtime_dir = os.path.join(pgo_x86_runtime_dir, 'amd64')
+ pgo_runtime_dll = 'pgort' + _VersionNumber() + '.dll'
+ source_x86 = os.path.join(pgo_x86_runtime_dir, pgo_runtime_dll)
+ if os.path.exists(source_x86):
+ _CopyRuntimeImpl(os.path.join(out_release, pgo_runtime_dll), source_x86)
+ source_x64 = os.path.join(pgo_x64_runtime_dir, pgo_runtime_dll)
+ if os.path.exists(source_x64):
+ _CopyRuntimeImpl(os.path.join(out_release_x64, pgo_runtime_dll),
+ source_x64)
+
+
+def CopyDlls(target_dir, configuration, target_cpu):
+ """Copy the VS runtime DLLs into the requested directory as needed.
+
+ configuration is one of 'Debug' or 'Release'.
+ target_cpu is one of 'x86' or 'x64'.
+
+ The debug configuration gets both the debug and release DLLs; the
+ release config only the latter.
+ """
+ vs2013_runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
+ if not vs2013_runtime_dll_dirs:
+ return
+
+ x64_runtime, x86_runtime = vs2013_runtime_dll_dirs
+ runtime_dir = x64_runtime if target_cpu == 'x64' else x86_runtime
+ _CopyRuntime2013(
+ target_dir, runtime_dir, 'msvc%s' + _VersionNumber() + '.dll')
+ if configuration == 'Debug':
+ _CopyRuntime2013(
+ target_dir, runtime_dir, 'msvc%s' + _VersionNumber() + 'd.dll')
+
+
+def _GetDesiredVsToolchainHashes():
+ """Load a list of SHA1s corresponding to the toolchains that we want installed
+ to build with."""
+ if os.environ.get('GYP_MSVS_VERSION') == '2015':
+ return ['49ae4b60d898182fc3f521c2fcda82c453915011']
+ else:
+ # Default to VS2013.
+ return ['ee7d718ec60c2dc5d255bbe325909c2021a7efef']
+
+
+def Update(force=False):
+ """Requests an update of the toolchain to the specific hashes we have at
+ this revision. The update outputs a .json of the various configuration
+ information required to pass to gyp which we use in |GetToolchainDir()|.
+ """
+ if force != False and force != '--force':
+ print >>sys.stderr, 'Unknown parameter "%s"' % force
+ return 1
+ if force == '--force' or os.path.exists(json_data_file):
+ force = True
+
+ depot_tools_win_toolchain = \
+ bool(int(os.environ.get('DEPOT_TOOLS_WIN_TOOLCHAIN', '1')))
+ if ((sys.platform in ('win32', 'cygwin') or force) and
+ depot_tools_win_toolchain):
+ import find_depot_tools
+ depot_tools_path = find_depot_tools.add_depot_tools_to_path()
+ get_toolchain_args = [
+ sys.executable,
+ os.path.join(depot_tools_path,
+ 'win_toolchain',
+ 'get_toolchain_if_necessary.py'),
+ '--output-json', json_data_file,
+ ] + _GetDesiredVsToolchainHashes()
+ if force:
+ get_toolchain_args.append('--force')
+ subprocess.check_call(get_toolchain_args)
+
+ return 0
+
+
+def GetToolchainDir():
+ """Gets location information about the current toolchain (must have been
+ previously updated by 'update'). This is used for the GN build."""
+ runtime_dll_dirs = SetEnvironmentAndGetRuntimeDllDirs()
+
+ # If WINDOWSSDKDIR is not set, search the default SDK path and set it.
+ if not 'WINDOWSSDKDIR' in os.environ:
+ default_sdk_path = 'C:\\Program Files (x86)\\Windows Kits\\8.1'
+ if os.path.isdir(default_sdk_path):
+ os.environ['WINDOWSSDKDIR'] = default_sdk_path
+
+ print '''vs_path = "%s"
+sdk_path = "%s"
+vs_version = "%s"
+wdk_dir = "%s"
+runtime_dirs = "%s"
+''' % (
+ os.environ['GYP_MSVS_OVERRIDE_PATH'],
+ os.environ['WINDOWSSDKDIR'],
+ os.environ['GYP_MSVS_VERSION'],
+ os.environ.get('WDK_DIR', ''),
+ ';'.join(runtime_dll_dirs or ['None']))
+
+
+def main():
+ commands = {
+ 'update': Update,
+ 'get_toolchain_dir': GetToolchainDir,
+ 'copy_dlls': CopyDlls,
+ }
+ if len(sys.argv) < 2 or sys.argv[1] not in commands:
+ print >>sys.stderr, 'Expected one of: %s' % ', '.join(commands)
+ return 1
+ return commands[sys.argv[1]](*sys.argv[2:])
+
+
+if __name__ == '__main__':
+ sys.exit(main())