Home | History | Annotate | Download | only in gypfiles
      1 # Copyright 2012 the V8 project authors. All rights reserved.
      2 # Redistribution and use in source and binary forms, with or without
      3 # modification, are permitted provided that the following conditions are
      4 # met:
      5 #
      6 #     * Redistributions of source code must retain the above copyright
      7 #       notice, this list of conditions and the following disclaimer.
      8 #     * Redistributions in binary form must reproduce the above
      9 #       copyright notice, this list of conditions and the following
     10 #       disclaimer in the documentation and/or other materials provided
     11 #       with the distribution.
     12 #     * Neither the name of Google Inc. nor the names of its
     13 #       contributors may be used to endorse or promote products derived
     14 #       from this software without specific prior written permission.
     15 #
     16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
     19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
     20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
     22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
     26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     27 
     28 # Definitions to be used when building stand-alone V8 binaries.
     29 
     30 {
     31   # We need to include toolchain.gypi here for third-party sources that don't
     32   # directly include it themselves.
     33   'includes': ['toolchain.gypi'],
     34   'variables': {
     35     'component%': 'static_library',
     36     'clang_xcode%': 0,
     37     # Track where uninitialized memory originates from. From fastest to
     38     # slowest: 0 - no tracking, 1 - track only the initial allocation site, 2
     39     # - track the chain of stores leading from allocation site to use site.
     40     'msan_track_origins%': 2,
     41     'visibility%': 'hidden',
     42     'v8_enable_backtrace%': 0,
     43     'v8_enable_i18n_support%': 1,
     44     'v8_deprecation_warnings': 1,
     45     'v8_imminent_deprecation_warnings': 1,
     46     'msvs_multi_core_compile%': '1',
     47     'mac_deployment_target%': '10.7',
     48     'release_extra_cflags%': '',
     49     'v8_enable_inspector%': 0,
     50     'variables': {
     51       'variables': {
     52         'variables': {
     53           'variables': {
     54             'conditions': [
     55               ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
     56                  OS=="netbsd" or OS=="mac" or OS=="qnx" or OS=="aix"', {
     57                 # This handles the Unix platforms we generally deal with.
     58                 # Anything else gets passed through, which probably won't work
     59                 # very well; such hosts should pass an explicit target_arch
     60                 # to gyp.
     61                 'host_arch%': '<!pymod_do_main(detect_v8_host_arch)',
     62               }, {
     63                 # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
     64                 # OS!="netbsd" and OS!="mac" and OS!="aix"
     65                 'host_arch%': 'ia32',
     66               }],
     67             ],
     68           },
     69           'host_arch%': '<(host_arch)',
     70           'target_arch%': '<(host_arch)',
     71 
     72           # By default we build against a stable sysroot image to avoid
     73           # depending on the packages installed on the local machine. Set this
     74           # to 0 to build against locally installed headers and libraries (e.g.
     75           # if packaging for a linux distro)
     76           'use_sysroot%': 1,
     77         },
     78         'host_arch%': '<(host_arch)',
     79         'target_arch%': '<(target_arch)',
     80         'use_sysroot%': '<(use_sysroot)',
     81         'base_dir%': '<!(cd <(DEPTH) && python -c "import os; print os.getcwd()")',
     82 
     83         # Instrument for code coverage and use coverage wrapper to exclude some
     84         # files. Uses gcov if clang=0 is set explicitly. Otherwise,
     85         # sanitizer_coverage must be set too.
     86         'coverage%': 0,
     87 
     88         # Default sysroot if no sysroot can be provided.
     89         'sysroot%': '',
     90 
     91         'conditions': [
     92           # The system root for linux builds.
     93           ['OS=="linux" and use_sysroot==1', {
     94             'conditions': [
     95               ['target_arch=="arm"', {
     96                 'sysroot%': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_wheezy_arm-sysroot',
     97               }],
     98               ['target_arch=="x64"', {
     99                 'sysroot%': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_wheezy_amd64-sysroot',
    100               }],
    101               ['target_arch=="ia32"', {
    102                 'sysroot%': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_wheezy_i386-sysroot',
    103               }],
    104               ['target_arch=="mipsel"', {
    105                 'sysroot%': '<!(cd <(DEPTH) && pwd -P)/build/linux/debian_wheezy_mips-sysroot',
    106               }],
    107             ],
    108           }], # OS=="linux" and use_sysroot==1
    109         ],
    110       },
    111       'base_dir%': '<(base_dir)',
    112       'host_arch%': '<(host_arch)',
    113       'target_arch%': '<(target_arch)',
    114       'v8_target_arch%': '<(target_arch)',
    115       'coverage%': '<(coverage)',
    116       'sysroot%': '<(sysroot)',
    117       'asan%': 0,
    118       'lsan%': 0,
    119       'msan%': 0,
    120       'tsan%': 0,
    121       # Enable coverage gathering instrumentation in sanitizer tools. This flag
    122       # also controls coverage granularity (1 for function-level, 2 for
    123       # block-level, 3 for edge-level).
    124       'sanitizer_coverage%': 0,
    125 
    126       # Use dynamic libraries instrumented by one of the sanitizers
    127       # instead of the standard system libraries. Set this flag to download
    128       # prebuilt binaries from GCS.
    129       'use_prebuilt_instrumented_libraries%': 0,
    130 
    131       # Use libc++ (buildtools/third_party/libc++ and
    132       # buildtools/third_party/libc++abi) instead of stdlibc++ as standard
    133       # library. This is intended to be used for instrumented builds.
    134       'use_custom_libcxx%': 0,
    135 
    136       'clang_dir%': '<(base_dir)/third_party/llvm-build/Release+Asserts',
    137       'make_clang_dir%': '<(base_dir)/third_party/llvm-build/Release+Asserts',
    138 
    139       'use_lto%': 0,
    140 
    141       # Control Flow Integrity for virtual calls and casts.
    142       # See http://clang.llvm.org/docs/ControlFlowIntegrity.html
    143       'cfi_vptr%': 0,
    144       'cfi_diag%': 0,
    145 
    146       'cfi_blacklist%': '<(base_dir)/tools/cfi/blacklist.txt',
    147 
    148       # Set to 1 to enable fast builds.
    149       # TODO(machenbach): Only configured for windows.
    150       'fastbuild%': 0,
    151 
    152       # goma settings.
    153       # 1 to use goma.
    154       # If no gomadir is set, it uses the default gomadir.
    155       'use_goma%': 0,
    156       'gomadir%': '',
    157 
    158       'test_isolation_mode%': 'noop',
    159 
    160       # By default, use ICU data file (icudtl.dat).
    161       'icu_use_data_file_flag%': 1,
    162 
    163       'conditions': [
    164         # Set default gomadir.
    165         ['OS=="win"', {
    166           'gomadir': 'c:\\goma\\goma-win',
    167         }, {
    168           'gomadir': '<!(/bin/echo -n ${HOME}/goma)',
    169         }],
    170         ['host_arch!="ppc" and host_arch!="ppc64" and host_arch!="ppc64le" and host_arch!="s390" and host_arch!="s390x"', {
    171           'host_clang%': 1,
    172         }, {
    173           'host_clang%': 0,
    174         }],
    175         # linux_use_bundled_gold: whether to use the gold linker binary checked
    176         # into third_party/binutils.  Force this off via GYP_DEFINES when you
    177         # are using a custom toolchain and need to control -B in ldflags.
    178         # Do not use 32-bit gold on 32-bit hosts as it runs out address space
    179         # for component=static_library builds.
    180         ['((OS=="linux" or OS=="android") and (target_arch=="x64" or target_arch=="arm" or (target_arch=="ia32" and host_arch=="x64"))) or (OS=="linux" and target_arch=="mipsel")', {
    181           'linux_use_bundled_gold%': 1,
    182         }, {
    183           'linux_use_bundled_gold%': 0,
    184         }],
    185       ],
    186     },
    187     'base_dir%': '<(base_dir)',
    188     'clang_dir%': '<(clang_dir)',
    189     'make_clang_dir%': '<(make_clang_dir)',
    190     'host_arch%': '<(host_arch)',
    191     'host_clang%': '<(host_clang)',
    192     'target_arch%': '<(target_arch)',
    193     'v8_target_arch%': '<(v8_target_arch)',
    194     'werror%': '-Werror',
    195     'use_goma%': '<(use_goma)',
    196     'gomadir%': '<(gomadir)',
    197     'asan%': '<(asan)',
    198     'lsan%': '<(lsan)',
    199     'msan%': '<(msan)',
    200     'tsan%': '<(tsan)',
    201     'sanitizer_coverage%': '<(sanitizer_coverage)',
    202     'use_prebuilt_instrumented_libraries%': '<(use_prebuilt_instrumented_libraries)',
    203     'use_custom_libcxx%': '<(use_custom_libcxx)',
    204     'linux_use_bundled_gold%': '<(linux_use_bundled_gold)',
    205     'use_lto%': '<(use_lto)',
    206     'cfi_vptr%': '<(cfi_vptr)',
    207     'cfi_diag%': '<(cfi_diag)',
    208     'cfi_blacklist%': '<(cfi_blacklist)',
    209     'test_isolation_mode%': '<(test_isolation_mode)',
    210     'fastbuild%': '<(fastbuild)',
    211     'coverage%': '<(coverage)',
    212     'sysroot%': '<(sysroot)',
    213     'icu_use_data_file_flag%': '<(icu_use_data_file_flag)',
    214 
    215     # Add a simple extras solely for the purpose of the cctests
    216     'v8_extra_library_files': ['../test/cctest/test-extra.js'],
    217     'v8_experimental_extra_library_files': ['../test/cctest/test-experimental-extra.js'],
    218 
    219     # .gyp files or targets should set v8_code to 1 if they build V8 specific
    220     # code, as opposed to external code.  This variable is used to control such
    221     # things as the set of warnings to enable, and whether warnings are treated
    222     # as errors.
    223     'v8_code%': 0,
    224 
    225     # Speeds up Debug builds:
    226     # 0 - Compiler optimizations off (debuggable) (default). This may
    227     #     be 5x slower than Release (or worse).
    228     # 1 - Turn on optimizations and disable slow DCHECKs, but leave
    229     #     V8_ENABLE_CHECKS and most other assertions enabled.  This may cause
    230     #     some v8 tests to fail in the Debug configuration.  This roughly
    231     #     matches the performance of a Release build and can be used by
    232     #     embedders that need to build their own code as debug but don't want
    233     #     or need a debug version of V8. This should produce near-release
    234     #     speeds.
    235     'v8_optimized_debug%': 0,
    236 
    237     # Use external files for startup data blobs:
    238     # the JS builtins sources and the start snapshot.
    239     # Embedders that don't use standalone.gypi will need to add
    240     # their own default value.
    241     'v8_use_external_startup_data%': 1,
    242 
    243     # Relative path to icu.gyp from this file.
    244     'icu_gyp_path': '../third_party/icu/icu.gyp',
    245 
    246     # Relative path to inspector.gyp from this file.
    247     'inspector_gyp_path': '../src/v8-inspector/inspector.gyp',
    248 
    249     'conditions': [
    250       ['(v8_target_arch=="arm" and host_arch!="arm") or \
    251         (v8_target_arch=="arm64" and host_arch!="arm64") or \
    252         (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
    253         (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
    254         (v8_target_arch=="x64" and host_arch!="x64") or \
    255         (OS=="android" or OS=="qnx")', {
    256         'want_separate_host_toolset': 1,
    257       }, {
    258         'want_separate_host_toolset': 0,
    259       }],
    260       ['(v8_target_arch=="arm" and host_arch!="arm") or \
    261         (v8_target_arch=="arm64" and host_arch!="arm64") or \
    262         (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
    263         (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
    264         (v8_target_arch=="mips" and host_arch!="mips") or \
    265         (v8_target_arch=="mips64" and host_arch!="mips64") or \
    266         (v8_target_arch=="x64" and host_arch!="x64") or \
    267         (OS=="android" or OS=="qnx")', {
    268         'want_separate_host_toolset_mkpeephole': 1,
    269       }, {
    270         'want_separate_host_toolset_mkpeephole': 0,
    271       }],
    272       ['OS == "win"', {
    273         'os_posix%': 0,
    274       }, {
    275         'os_posix%': 1,
    276       }],
    277       ['OS=="win" and use_goma==1', {
    278         # goma doesn't support pch yet.
    279         'chromium_win_pch': 0,
    280         # goma doesn't support PDB yet.
    281         'fastbuild%': 1,
    282       }],
    283       ['((v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
    284         (OS=="linux" or OS=="mac")) or (v8_target_arch=="ppc64" and OS=="linux")', {
    285         'v8_enable_gdbjit%': 1,
    286       }, {
    287         'v8_enable_gdbjit%': 0,
    288       }],
    289       ['(OS=="linux" or OS=="mac") and (target_arch=="ia32" or target_arch=="x64") and \
    290         (v8_target_arch!="x87" and v8_target_arch!="x32")', {
    291         'clang%': 1,
    292       }, {
    293         'clang%': 0,
    294       }],
    295       ['asan==1 or lsan==1 or msan==1 or tsan==1', {
    296         'clang%': 1,
    297         'use_allocator%': 'none',
    298       }],
    299       ['asan==1 and OS=="linux"', {
    300         'use_custom_libcxx%': 1,
    301       }],
    302       ['tsan==1', {
    303         'use_custom_libcxx%': 1,
    304       }],
    305       ['msan==1', {
    306         # Use a just-built, MSan-instrumented libc++ instead of the system-wide
    307         # libstdc++. This is required to avoid false positive reports whenever
    308         # the C++ standard library is used.
    309         'use_custom_libcxx%': 1,
    310       }],
    311       ['cfi_vptr==1', {
    312         'use_lto%': 1,
    313       }],
    314       ['OS=="android"', {
    315         # Location of Android NDK.
    316         'variables': {
    317           'variables': {
    318             # The Android toolchain needs to use the absolute path to the NDK
    319             # because it is used at different levels in the GYP files.
    320             'android_ndk_root%': '<(base_dir)/third_party/android_tools/ndk/',
    321             'android_host_arch%': "<!(uname -m | sed -e 's/i[3456]86/x86/')",
    322             # Version of the NDK. Used to ensure full rebuilds on NDK rolls.
    323             'android_ndk_version%': 'r12b',
    324             'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
    325             'os_folder_name%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/darwin/')",
    326           },
    327 
    328           # Copy conditionally-set variables out one scope.
    329           'android_ndk_root%': '<(android_ndk_root)',
    330           'android_ndk_version%': '<(android_ndk_version)',
    331           'host_os%': '<(host_os)',
    332           'os_folder_name%': '<(os_folder_name)',
    333 
    334           'conditions': [
    335             ['target_arch == "ia32"', {
    336               'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
    337               'android_target_arch%': 'x86',
    338               'android_target_platform%': '16',
    339               'arm_version%': 'default',
    340             }],
    341             ['target_arch == "x64"', {
    342               'android_toolchain%': '<(android_ndk_root)/toolchains/x86_64-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
    343               'android_target_arch%': 'x86_64',
    344               'android_target_platform%': '21',
    345               'arm_version%': 'default',
    346             }],
    347             ['target_arch=="arm"', {
    348               'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
    349               'android_target_arch%': 'arm',
    350               'android_target_platform%': '16',
    351               'arm_version%': 7,
    352             }],
    353             ['target_arch == "arm64"', {
    354               'android_toolchain%': '<(android_ndk_root)/toolchains/aarch64-linux-android-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
    355               'android_target_arch%': 'arm64',
    356               'android_target_platform%': '21',
    357               'arm_version%': 'default',
    358             }],
    359             ['target_arch == "mipsel"', {
    360               'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
    361               'android_target_arch%': 'mips',
    362               'android_target_platform%': '16',
    363               'arm_version%': 'default',
    364             }],
    365             ['target_arch == "mips64el"', {
    366               'android_toolchain%': '<(android_ndk_root)/toolchains/mips64el-linux-android-4.9/prebuilt/<(os_folder_name)-<(android_host_arch)/bin',
    367               'android_target_arch%': 'mips64',
    368               'android_target_platform%': '21',
    369               'arm_version%': 'default',
    370             }],
    371           ],
    372         },
    373 
    374         # Copy conditionally-set variables out one scope.
    375         'android_ndk_version%': '<(android_ndk_version)',
    376         'android_target_arch%': '<(android_target_arch)',
    377         'android_target_platform%': '<(android_target_platform)',
    378         'android_toolchain%': '<(android_toolchain)',
    379         'arm_version%': '<(arm_version)',
    380         'host_os%': '<(host_os)',
    381 
    382         # Print to stdout on Android.
    383         'v8_android_log_stdout%': 1,
    384 
    385         'conditions': [
    386           ['android_ndk_root==""', {
    387             'variables': {
    388               'android_sysroot': '<(android_toolchain)/sysroot/',
    389               'android_stl': '<(android_toolchain)/sources/cxx-stl/',
    390             },
    391             'conditions': [
    392               ['target_arch=="x64"', {
    393                 'android_lib': '<(android_sysroot)/usr/lib64',
    394               }, {
    395                 'android_lib': '<(android_sysroot)/usr/lib',
    396               }],
    397             ],
    398             'android_libcpp_include': '<(android_stl)/llvm-libc++/libcxx/include',
    399             'android_libcpp_abi_include': '<(android_stl)/llvm-libc++abi/libcxxabi/include',
    400             'android_libcpp_libs': '<(android_stl)/llvm-libc++/libs',
    401             'android_support_include': '<(android_toolchain)/sources/android/support/include',
    402             'android_sysroot': '<(android_sysroot)',
    403           }, {
    404             'variables': {
    405               'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)',
    406               'android_stl': '<(android_ndk_root)/sources/cxx-stl/',
    407             },
    408             'conditions': [
    409               ['target_arch=="x64"', {
    410                 'android_lib': '<(android_sysroot)/usr/lib64',
    411               }, {
    412                 'android_lib': '<(android_sysroot)/usr/lib',
    413               }],
    414             ],
    415             'android_libcpp_include': '<(android_stl)/llvm-libc++/libcxx/include',
    416             'android_libcpp_abi_include': '<(android_stl)/llvm-libc++abi/libcxxabi/include',
    417             'android_libcpp_libs': '<(android_stl)/llvm-libc++/libs',
    418             'android_support_include': '<(android_ndk_root)/sources/android/support/include',
    419             'android_sysroot': '<(android_sysroot)',
    420           }],
    421         ],
    422         'android_libcpp_library': 'c++_static',
    423       }],  # OS=="android"
    424       ['host_clang==1', {
    425         'conditions':[
    426           ['OS=="android"', {
    427             'host_ld': '<!(which ld)',
    428             'host_ranlib': '<!(which ranlib)',
    429           }],
    430         ],
    431         'host_cc': '<(clang_dir)/bin/clang',
    432         'host_cxx': '<(clang_dir)/bin/clang++',
    433       }, {
    434         'host_cc': '<!(which gcc)',
    435         'host_cxx': '<!(which g++)',
    436       }],
    437     ],
    438     # Default ARM variable settings.
    439     'arm_version%': 'default',
    440     'arm_fpu%': 'vfpv3',
    441     'arm_float_abi%': 'default',
    442     'arm_thumb': 'default',
    443 
    444     # Default MIPS variable settings.
    445     'mips_arch_variant%': 'r2',
    446     # Possible values fp32, fp64, fpxx.
    447     # fp32 - 32 32-bit FPU registers are available, doubles are placed in
    448     #        register pairs.
    449     # fp64 - 32 64-bit FPU registers are available.
    450     # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
    451     #        detection
    452     'mips_fpu_mode%': 'fp32',
    453   },
    454   'target_defaults': {
    455     'variables': {
    456       'v8_code%': '<(v8_code)',
    457       'clang_warning_flags': [
    458         '-Wsign-compare',
    459         # TODO(thakis): https://crbug.com/604888
    460         '-Wno-undefined-var-template',
    461         # TODO(yangguo): issue 5258
    462         '-Wno-nonportable-include-path',
    463       ],
    464       'conditions':[
    465         ['OS=="android"', {
    466           'host_os%': '<(host_os)',
    467         }],
    468       ],
    469     },
    470     'includes': [ 'set_clang_warning_flags.gypi', ],
    471     'default_configuration': 'Debug',
    472     'configurations': {
    473       'DebugBaseCommon': {
    474         'conditions': [
    475           ['OS=="aix"', {
    476             'cflags': [ '-g', '-Og', '-gxcoff' ],
    477           }, {
    478             'cflags': [ '-g', '-O0' ],
    479           }],
    480         ],
    481       },
    482       'Optdebug': {
    483         'inherit_from': [ 'DebugBaseCommon', 'DebugBase1' ],
    484       },
    485       'Debug': {
    486         # Xcode insists on this empty entry.
    487       },
    488       'Release': {
    489         'cflags+': ['<@(release_extra_cflags)'],
    490       },
    491       'conditions': [
    492         ['OS=="win"', {
    493           'Optdebug_x64': {
    494             'inherit_from': ['Optdebug'],
    495           },
    496           'Debug_x64': {
    497             'inherit_from': ['Debug'],
    498           },
    499           'Release_x64': {
    500             'inherit_from': ['Release'],
    501           },
    502         }],
    503       ],
    504     },
    505     'conditions':[
    506       ['clang==0', {
    507         'cflags+': [
    508           '-Wno-uninitialized',
    509         ],
    510       }],
    511       ['clang==1 or host_clang==1', {
    512         # This is here so that all files get recompiled after a clang roll and
    513         # when turning clang on or off.
    514         # (defines are passed via the command line, and build systems rebuild
    515         # things when their commandline changes). Nothing should ever read this
    516         # define.
    517         'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
    518       }],
    519       ['clang==1 and target_arch=="ia32"', {
    520         'cflags': ['-mstack-alignment=16', '-mstackrealign'],
    521       }],
    522       ['fastbuild!=0', {
    523         'conditions': [
    524           ['OS=="win" and fastbuild==1', {
    525             'msvs_settings': {
    526               'VCLinkerTool': {
    527                 # This tells the linker to generate .pdbs, so that
    528                 # we can get meaningful stack traces.
    529                 'GenerateDebugInformation': 'true',
    530               },
    531               'VCCLCompilerTool': {
    532                 # No debug info to be generated by compiler.
    533                 'DebugInformationFormat': '0',
    534               },
    535             },
    536           }],
    537         ],
    538       }],  # fastbuild!=0
    539     ],
    540     'target_conditions': [
    541       ['v8_code == 0', {
    542         'defines!': [
    543           'DEBUG',
    544         ],
    545         'conditions': [
    546           ['os_posix == 1 and OS != "mac"', {
    547             # We don't want to get warnings from third-party code,
    548             # so remove any existing warning-enabling flags like -Wall.
    549             'cflags!': [
    550               '-pedantic',
    551               '-Wall',
    552               '-Werror',
    553               '-Wextra',
    554               '-Wshorten-64-to-32',
    555             ],
    556             'cflags+': [
    557               # Clang considers the `register` keyword as deprecated, but
    558               # ICU uses it all over the place.
    559               '-Wno-deprecated-register',
    560               # ICU uses its own deprecated functions.
    561               '-Wno-deprecated-declarations',
    562               # ICU prefers `a && b || c` over `(a && b) || c`.
    563               '-Wno-logical-op-parentheses',
    564               # ICU has some `unsigned < 0` checks.
    565               '-Wno-tautological-compare',
    566               # uresdata.c has switch(RES_GET_TYPE(x)) code. The
    567               # RES_GET_TYPE macro returns an UResType enum, but some switch
    568               # statement contains case values that aren't part of that
    569               # enum (e.g. URES_TABLE32 which is in UResInternalType). This
    570               # is on purpose.
    571               '-Wno-switch',
    572             ],
    573             'cflags_cc!': [
    574               '-Wnon-virtual-dtor',
    575             ],
    576           }],
    577           ['OS == "mac"', {
    578             'xcode_settings': {
    579               'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',    # -Werror
    580             },
    581           }],
    582           ['OS == "win"', {
    583             'msvs_settings': {
    584               'VCCLCompilerTool': {
    585                 'WarnAsError': 'false',
    586               },
    587             },
    588           }],
    589         ],
    590       }],
    591     ],
    592   },
    593   'conditions': [
    594     ['os_posix==1 and OS!="mac"', {
    595       'target_defaults': {
    596         'conditions': [
    597           # Common options for AddressSanitizer, LeakSanitizer,
    598           # ThreadSanitizer, MemorySanitizer and CFI builds.
    599           ['asan==1 or lsan==1 or tsan==1 or msan==1 or cfi_vptr==1', {
    600             'target_conditions': [
    601               ['_toolset=="target"', {
    602                 'cflags': [
    603                   '-fno-omit-frame-pointer',
    604                   '-gline-tables-only',
    605                 ],
    606                 'cflags!': [
    607                   '-fomit-frame-pointer',
    608                 ],
    609               }],
    610             ],
    611           }],
    612           ['asan==1', {
    613             'target_conditions': [
    614               ['_toolset=="target"', {
    615                 'cflags': [
    616                   '-fsanitize=address',
    617                 ],
    618                 'ldflags': [
    619                   '-fsanitize=address',
    620                 ],
    621                 'defines': [
    622                   'ADDRESS_SANITIZER',
    623                 ],
    624               }],
    625             ],
    626           }],
    627           ['lsan==1', {
    628             'target_conditions': [
    629               ['_toolset=="target"', {
    630                 'cflags': [
    631                   '-fsanitize=leak',
    632                 ],
    633                 'ldflags': [
    634                   '-fsanitize=leak',
    635                 ],
    636                 'defines': [
    637                   'LEAK_SANITIZER',
    638                 ],
    639               }],
    640             ],
    641           }],
    642           ['tsan==1', {
    643             'target_conditions': [
    644               ['_toolset=="target"', {
    645                 'cflags': [
    646                   '-fsanitize=thread',
    647                 ],
    648                 'ldflags': [
    649                   '-fsanitize=thread',
    650                 ],
    651                 'defines': [
    652                   'THREAD_SANITIZER',
    653                 ],
    654               }],
    655             ],
    656           }],
    657           ['msan==1', {
    658             'target_conditions': [
    659               ['_toolset=="target"', {
    660                 'cflags': [
    661                   '-fsanitize=memory',
    662                   '-fsanitize-memory-track-origins=<(msan_track_origins)',
    663                   '-fPIC',
    664                 ],
    665                 'ldflags': [
    666                   '-fsanitize=memory',
    667                   '-pie',
    668                 ],
    669                 'defines': [
    670                   'MEMORY_SANITIZER',
    671                 ],
    672               }],
    673             ],
    674           }],
    675           ['use_prebuilt_instrumented_libraries==1', {
    676             'dependencies': [
    677               '<(DEPTH)/third_party/instrumented_libraries/instrumented_libraries.gyp:prebuilt_instrumented_libraries',
    678             ],
    679           }],
    680           ['use_custom_libcxx==1', {
    681             'dependencies': [
    682               '<(DEPTH)/buildtools/third_party/libc++/libc++.gyp:libcxx_proxy',
    683             ],
    684           }],
    685           ['sanitizer_coverage!=0', {
    686             'target_conditions': [
    687               ['_toolset=="target"', {
    688                 'cflags': [
    689                   '-fsanitize-coverage=<(sanitizer_coverage)',
    690                 ],
    691                 'defines': [
    692                   'SANITIZER_COVERAGE',
    693                 ],
    694               }],
    695             ],
    696           }],
    697           ['linux_use_bundled_gold==1 and not (clang==0 and use_lto==1)', {
    698             # Put our binutils, which contains gold in the search path. We pass
    699             # the path to gold to the compiler. gyp leaves unspecified what the
    700             # cwd is when running the compiler, so the normal gyp path-munging
    701             # fails us. This hack gets the right path.
    702             #
    703             # Disabled when using GCC LTO because GCC also uses the -B search
    704             # path at link time to find "as", and our bundled "as" can only
    705             # target x86.
    706             'ldflags': [
    707               # Note, Chromium allows ia32 host arch as well, we limit this to
    708               # x64 in v8.
    709               '-B<(base_dir)/third_party/binutils/Linux_x64/Release/bin',
    710             ],
    711           }],
    712           ['sysroot!="" and clang==1', {
    713             'target_conditions': [
    714               ['_toolset=="target"', {
    715                 'cflags': [
    716                   '--sysroot=<(sysroot)',
    717                 ],
    718                 'ldflags': [
    719                   '--sysroot=<(sysroot)',
    720                   '<!(<(DEPTH)/build/linux/sysroot_ld_path.sh <(sysroot))',
    721                 ],
    722               }]]
    723           }],
    724         ],
    725       },
    726     }],
    727     ['OS=="mac"', {
    728       'target_defaults': {
    729        'conditions': [
    730           ['asan==1', {
    731             'xcode_settings': {
    732               # FIXME(machenbach): This is outdated compared to common.gypi.
    733               'OTHER_CFLAGS+': [
    734                 '-fno-omit-frame-pointer',
    735                 '-gline-tables-only',
    736                 '-fsanitize=address',
    737                 '-w',  # http://crbug.com/162783
    738               ],
    739               'OTHER_CFLAGS!': [
    740                 '-fomit-frame-pointer',
    741               ],
    742               'defines': [
    743                 'ADDRESS_SANITIZER',
    744               ],
    745             },
    746             'dependencies': [
    747               '<(DEPTH)/gypfiles/mac/asan.gyp:asan_dynamic_runtime',
    748             ],
    749             'target_conditions': [
    750               ['_type!="static_library"', {
    751                 'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
    752               }],
    753             ],
    754           }],
    755           ['sanitizer_coverage!=0', {
    756             'target_conditions': [
    757               ['_toolset=="target"', {
    758                 'cflags': [
    759                   '-fsanitize-coverage=<(sanitizer_coverage)',
    760                 ],
    761                 'defines': [
    762                   'SANITIZER_COVERAGE',
    763                 ],
    764               }],
    765             ],
    766           }],
    767         ],
    768       },  # target_defaults
    769     }],  # OS=="mac"
    770     ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
    771        or OS=="netbsd" or OS=="aix"', {
    772       'target_defaults': {
    773         'cflags': [
    774           '-Wall',
    775           '<(werror)',
    776           '-Wno-unused-parameter',
    777           '-pthread',
    778           '-pedantic',
    779           '-Wmissing-field-initializers',
    780           '-Wno-gnu-zero-variadic-macro-arguments',
    781         ],
    782         'cflags_cc': [
    783           '-Wnon-virtual-dtor',
    784           '-fno-exceptions',
    785           '-fno-rtti',
    786           '-std=gnu++11',
    787         ],
    788         'ldflags': [ '-pthread', ],
    789         'conditions': [
    790           # Don't warn about TRACE_EVENT_* macros with zero arguments passed to
    791           # ##__VA_ARGS__. C99 strict mode prohibits having zero variadic macro
    792           # arguments in gcc.
    793           [ 'clang==0', {
    794             'cflags!' : [
    795               '-pedantic' ,
    796               # Don't warn about unrecognized command line option.
    797               '-Wno-gnu-zero-variadic-macro-arguments',
    798             ],
    799           }],
    800           [ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64" \
    801             or v8_target_arch=="mips64el")', {
    802             'cflags': [ '-Wshorten-64-to-32' ],
    803           }],
    804           [ 'host_arch=="ppc64" and OS!="aix"', {
    805             'cflags': [ '-mminimal-toc' ],
    806           }],
    807           [ 'visibility=="hidden" and v8_enable_backtrace==0', {
    808             'cflags': [ '-fvisibility=hidden' ],
    809           }],
    810           [ 'component=="shared_library"', {
    811             'cflags': [ '-fPIC', ],
    812           }],
    813           [ 'clang==0 and coverage==1', {
    814             'cflags': [ '-fprofile-arcs', '-ftest-coverage'],
    815             'ldflags': [ '-fprofile-arcs'],
    816           }],
    817         ],
    818       },
    819     }],
    820     # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
    821     #  or OS=="netbsd"'
    822     ['OS=="qnx"', {
    823       'target_defaults': {
    824         'cflags': [
    825           '-Wall',
    826           '<(werror)',
    827           '-Wno-unused-parameter',
    828           # Don't warn about the "struct foo f = {0};" initialization pattern.
    829           '-Wno-missing-field-initializers',
    830           '-Wno-gnu-zero-variadic-macro-arguments',
    831         ],
    832         'cflags_cc': [
    833           '-Wnon-virtual-dtor',
    834           '-fno-exceptions',
    835           '-fno-rtti',
    836           '-std=gnu++11',
    837         ],
    838         'conditions': [
    839           [ 'visibility=="hidden"', {
    840             'cflags': [ '-fvisibility=hidden' ],
    841           }],
    842           [ 'component=="shared_library"', {
    843             'cflags': [ '-fPIC' ],
    844           }],
    845         ],
    846         'target_conditions': [
    847           [ '_toolset=="host" and host_os=="linux"', {
    848             'cflags': [ '-pthread' ],
    849             'ldflags': [ '-pthread' ],
    850             'libraries': [ '-lrt' ],
    851           }],
    852           [ '_toolset=="target"', {
    853             'cflags': [ '-Wno-psabi' ],
    854             'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
    855           }],
    856         ],
    857       },
    858     }],  # OS=="qnx"
    859     ['OS=="win"', {
    860       'target_defaults': {
    861         'defines': [
    862           '_CRT_SECURE_NO_DEPRECATE',
    863           '_CRT_NONSTDC_NO_DEPRECATE',
    864           '_USING_V110_SDK71_',
    865         ],
    866         'conditions': [
    867           ['component=="static_library"', {
    868             'defines': [
    869               '_HAS_EXCEPTIONS=0',
    870             ],
    871           }],
    872         ],
    873         'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
    874         'msvs_disabled_warnings': [
    875           # C4091: 'typedef ': ignored on left of 'X' when no variable is
    876           #                    declared.
    877           # This happens in a number of Windows headers. Dumb.
    878           4091,
    879 
    880           # C4127: conditional expression is constant
    881           # This warning can in theory catch dead code and other problems, but
    882           # triggers in far too many desirable cases where the conditional
    883           # expression is either set by macros or corresponds some legitimate
    884           # compile-time constant expression (due to constant template args,
    885           # conditionals comparing the sizes of different types, etc.).  Some of
    886           # these can be worked around, but it's not worth it.
    887           4127,
    888 
    889           # C4351: new behavior: elements of array 'array' will be default
    890           #        initialized
    891           # This is a silly "warning" that basically just alerts you that the
    892           # compiler is going to actually follow the language spec like it's
    893           # supposed to, instead of not following it like old buggy versions
    894           # did.  There's absolutely no reason to turn this on.
    895           4351,
    896 
    897           # C4355: 'this': used in base member initializer list
    898           # It's commonly useful to pass |this| to objects in a class'
    899           # initializer list.  While this warning can catch real bugs, most of
    900           # the time the constructors in question don't attempt to call methods
    901           # on the passed-in pointer (until later), and annotating every legit
    902           # usage of this is simply more hassle than the warning is worth.
    903           4355,
    904 
    905           # C4503: 'identifier': decorated name length exceeded, name was
    906           #        truncated
    907           # This only means that some long error messages might have truncated
    908           # identifiers in the presence of lots of templates.  It has no effect
    909           # on program correctness and there's no real reason to waste time
    910           # trying to prevent it.
    911           4503,
    912 
    913           # Warning C4589 says: "Constructor of abstract class ignores
    914           # initializer for virtual base class." Disable this warning because it
    915           # is flaky in VS 2015 RTM. It triggers on compiler generated
    916           # copy-constructors in some cases.
    917           4589,
    918 
    919           # C4611: interaction between 'function' and C++ object destruction is
    920           #        non-portable
    921           # This warning is unavoidable when using e.g. setjmp/longjmp.  MSDN
    922           # suggests using exceptions instead of setjmp/longjmp for C++, but
    923           # Chromium code compiles without exception support.  We therefore have
    924           # to use setjmp/longjmp for e.g. JPEG decode error handling, which
    925           # means we have to turn off this warning (and be careful about how
    926           # object destruction happens in such cases).
    927           4611,
    928 
    929           # TODO(jochen): These warnings are level 4. They will be slowly
    930           # removed as code is fixed.
    931           4100, # Unreferenced formal parameter
    932           4121, # Alignment of a member was sensitive to packing
    933           4244, # Conversion from 'type1' to 'type2', possible loss of data
    934           4302, # Truncation from 'type 1' to 'type 2'
    935           4309, # Truncation of constant value
    936           4311, # Pointer truncation from 'type' to 'type'
    937           4312, # Conversion from 'type1' to 'type2' of greater size
    938           4505, # Unreferenced local function has been removed
    939           4510, # Default constructor could not be generated
    940           4512, # Assignment operator could not be generated
    941           4610, # Object can never be instantiated
    942           4800, # Forcing value to bool.
    943           4838, # Narrowing conversion. Doesn't seem to be very useful.
    944           4995, # 'X': name was marked as #pragma deprecated
    945           4996, # 'X': was declared deprecated (for GetVersionEx).
    946 
    947           # These are variable shadowing warnings that are new in VS2015. We
    948           # should work through these at some point -- they may be removed from
    949           # the RTM release in the /W4 set.
    950           4456, 4457, 4458, 4459,
    951         ],
    952         'msvs_settings': {
    953           'VCCLCompilerTool': {
    954             'MinimalRebuild': 'false',
    955             'BufferSecurityCheck': 'true',
    956             'EnableFunctionLevelLinking': 'true',
    957             'RuntimeTypeInfo': 'false',
    958             'WarningLevel': '3',
    959             'WarnAsError': 'true',
    960             'DebugInformationFormat': '3',
    961             'Detect64BitPortabilityProblems': 'false',
    962             'conditions': [
    963               [ 'msvs_multi_core_compile', {
    964                 'AdditionalOptions': ['/MP'],
    965               }],
    966               ['component=="shared_library"', {
    967                 'ExceptionHandling': '1',  # /EHsc
    968               }, {
    969                 'ExceptionHandling': '0',
    970               }],
    971             ],
    972           },
    973           'VCLibrarianTool': {
    974             'AdditionalOptions': ['/ignore:4221'],
    975             'conditions': [
    976               ['v8_target_arch=="x64"', {
    977                 'TargetMachine': '17',  # x64
    978               }, {
    979                 'TargetMachine': '1',  # ia32
    980               }],
    981             ],
    982           },
    983           'VCLinkerTool': {
    984             'AdditionalDependencies': [
    985               'ws2_32.lib',
    986             ],
    987             'GenerateDebugInformation': 'true',
    988             'MapFileName': '$(OutDir)\\$(TargetName).map',
    989             'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
    990             'FixedBaseAddress': '1',
    991             # LinkIncremental values:
    992             #   0 == default
    993             #   1 == /INCREMENTAL:NO
    994             #   2 == /INCREMENTAL
    995             'LinkIncremental': '1',
    996             # SubSystem values:
    997             #   0 == not set
    998             #   1 == /SUBSYSTEM:CONSOLE
    999             #   2 == /SUBSYSTEM:WINDOWS
   1000             'SubSystem': '1',
   1001 
   1002             'conditions': [
   1003               ['v8_enable_i18n_support==1', {
   1004                 'AdditionalDependencies': [
   1005                   'advapi32.lib',
   1006                 ],
   1007               }],
   1008               ['v8_target_arch=="x64"', {
   1009                 'MinimumRequiredVersion': '5.02',  # Server 2003.
   1010                 'TargetMachine': '17',  # x64
   1011               }, {
   1012                 'MinimumRequiredVersion': '5.01',  # XP.
   1013                 'TargetMachine': '1',  # ia32
   1014               }],
   1015             ],
   1016           },
   1017           'conditions': [
   1018             ['clang==1', {
   1019               'VCCLCompilerTool': {
   1020                 'AdditionalOptions': [
   1021                   # Don't warn about unused function parameters.
   1022                   # (This is also used on other platforms.)
   1023                   '-Wno-unused-parameter',
   1024                   # Don't warn about the "struct foo f = {0};" initialization
   1025                   # pattern.
   1026                   '-Wno-missing-field-initializers',
   1027 
   1028                   # TODO(hans): Make this list shorter eventually, http://crbug.com/504657
   1029                   '-Qunused-arguments',  # http://crbug.com/504658
   1030                   '-Wno-microsoft-enum-value',  # http://crbug.com/505296
   1031                   '-Wno-unknown-pragmas',  # http://crbug.com/505314
   1032                   '-Wno-microsoft-cast',  # http://crbug.com/550065
   1033                 ],
   1034               },
   1035             }],
   1036             ['clang==1 and MSVS_VERSION == "2013"', {
   1037               'VCCLCompilerTool': {
   1038                 'AdditionalOptions': [
   1039                   '-fmsc-version=1800',
   1040                 ],
   1041               },
   1042             }],
   1043             ['clang==1 and MSVS_VERSION == "2015"', {
   1044               'VCCLCompilerTool': {
   1045                 'AdditionalOptions': [
   1046                   '-fmsc-version=1900',
   1047                 ],
   1048               },
   1049             }],
   1050           ],
   1051         },
   1052       },
   1053     }],  # OS=="win"
   1054     ['OS=="mac"', {
   1055       'xcode_settings': {
   1056         'SDKROOT': 'macosx',
   1057         'SYMROOT': '<(DEPTH)/xcodebuild',
   1058       },
   1059       'target_defaults': {
   1060         'xcode_settings': {
   1061           'ALWAYS_SEARCH_USER_PATHS': 'NO',
   1062           'GCC_C_LANGUAGE_STANDARD': 'c99',         # -std=c99
   1063           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
   1064           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
   1065                                                     # (Equivalent to -fPIC)
   1066           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
   1067           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
   1068           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
   1069           # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
   1070           'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
   1071           'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',      # -fvisibility=hidden
   1072           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
   1073           'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
   1074           # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
   1075           'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
   1076           'PREBINDING': 'NO',                       # No -Wl,-prebind
   1077           'SYMROOT': '<(DEPTH)/xcodebuild',
   1078           'USE_HEADERMAP': 'NO',
   1079           'OTHER_CFLAGS': [
   1080             '-fno-strict-aliasing',
   1081           ],
   1082           'WARNING_CFLAGS': [
   1083             '-Wall',
   1084             '-Wendif-labels',
   1085             '-Wno-unused-parameter',
   1086             # Don't warn about the "struct foo f = {0};" initialization pattern.
   1087             '-Wno-missing-field-initializers',
   1088             '-Wno-gnu-zero-variadic-macro-arguments',
   1089           ],
   1090         },
   1091         'conditions': [
   1092           ['werror==""', {
   1093             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
   1094           }, {
   1095             'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
   1096           }],
   1097           ['clang==1', {
   1098             'xcode_settings': {
   1099               'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
   1100               'CLANG_CXX_LANGUAGE_STANDARD': 'c++11',  # -std=c++11
   1101             },
   1102             'conditions': [
   1103               ['clang_xcode==0', {
   1104                 'xcode_settings': {
   1105                   'CC': '<(clang_dir)/bin/clang',
   1106                   'LDPLUSPLUS': '<(clang_dir)/bin/clang++',
   1107                   'CLANG_CXX_LIBRARY': 'libc++'
   1108                 },
   1109               }],
   1110               ['v8_target_arch=="x64" or v8_target_arch=="arm64" \
   1111                 or v8_target_arch=="mips64el"', {
   1112                 'xcode_settings': {'WARNING_CFLAGS': ['-Wshorten-64-to-32']},
   1113               }],
   1114             ],
   1115           }],
   1116         ],
   1117         'target_conditions': [
   1118           ['_type!="static_library"', {
   1119             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
   1120           }],
   1121         ],  # target_conditions
   1122       },  # target_defaults
   1123     }],  # OS=="mac"
   1124     ['OS=="android"', {
   1125       'target_defaults': {
   1126         'defines': [
   1127           'ANDROID',
   1128         ],
   1129         'configurations': {
   1130           'Release': {
   1131             'cflags': [
   1132               '-fomit-frame-pointer',
   1133             ],
   1134           },  # Release
   1135         },  # configurations
   1136         'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'],
   1137         'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions',
   1138                        '-std=gnu++11' ],
   1139         'target_conditions': [
   1140           ['_toolset=="target"', {
   1141             'cflags!': [
   1142               '-pthread',  # Not supported by Android toolchain.
   1143             ],
   1144             'cflags': [
   1145               '-ffunction-sections',
   1146               '-funwind-tables',
   1147               '-fstack-protector',
   1148               '-fno-short-enums',
   1149               '-finline-limit=64',
   1150               '-Wa,--noexecstack',
   1151               '--sysroot=<(android_sysroot)',
   1152             ],
   1153             'cflags_cc': [
   1154               '-isystem<(android_libcpp_include)',
   1155               '-isystem<(android_libcpp_abi_include)',
   1156               '-isystem<(android_support_include)',
   1157             ],
   1158             'defines': [
   1159               'ANDROID',
   1160               #'__GNU_SOURCE=1',  # Necessary for clone()
   1161               'HAVE_OFF64_T',
   1162               'HAVE_SYS_UIO_H',
   1163               'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
   1164               'ANDROID_NDK_VERSION=<(android_ndk_version)',
   1165             ],
   1166             'ldflags!': [
   1167               '-pthread',  # Not supported by Android toolchain.
   1168             ],
   1169             'ldflags': [
   1170               '-Wl,--no-undefined',
   1171               '--sysroot=<(android_sysroot)',
   1172               '-nostdlib',
   1173             ],
   1174             'libraries!': [
   1175                 '-lrt',  # librt is built into Bionic.
   1176                 # Not supported by Android toolchain.
   1177                 # Where do these come from?  Can't find references in
   1178                 # any Chromium gyp or gypi file.  Maybe they come from
   1179                 # gyp itself?
   1180                 '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4',
   1181               ],
   1182               'libraries': [
   1183                 '-l<(android_libcpp_library)',
   1184                 '-latomic',
   1185                 # Manually link the libgcc.a that the cross compiler uses.
   1186                 '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
   1187                 '-lc',
   1188                 '-ldl',
   1189                 '-lm',
   1190             ],
   1191             'conditions': [
   1192               ['target_arch == "arm"', {
   1193                 'ldflags': [
   1194                   # Enable identical code folding to reduce size.
   1195                   '-Wl,--icf=safe',
   1196                 ],
   1197               }],
   1198               ['target_arch=="arm" and arm_version==7', {
   1199                 'cflags': [
   1200                   '-march=armv7-a',
   1201                   '-mtune=cortex-a8',
   1202                   '-mfpu=vfp3',
   1203                 ],
   1204                 'ldflags': [
   1205                   '-L<(android_libcpp_libs)/armeabi-v7a',
   1206                 ],
   1207               }],
   1208               ['target_arch=="arm" and arm_version < 7', {
   1209                 'ldflags': [
   1210                   '-L<(android_libcpp_libs)/armeabi',
   1211                 ],
   1212               }],
   1213               ['target_arch=="x64"', {
   1214                 'ldflags': [
   1215                   '-L<(android_libcpp_libs)/x86_64',
   1216                 ],
   1217               }],
   1218               ['target_arch=="arm64"', {
   1219                 'ldflags': [
   1220                   '-L<(android_libcpp_libs)/arm64-v8a',
   1221                 ],
   1222               }],
   1223               ['target_arch=="ia32" or target_arch=="x87"', {
   1224                 # The x86 toolchain currently has problems with stack-protector.
   1225                 'cflags!': [
   1226                   '-fstack-protector',
   1227                 ],
   1228                 'cflags': [
   1229                   '-fno-stack-protector',
   1230                 ],
   1231                 'ldflags': [
   1232                   '-L<(android_libcpp_libs)/x86',
   1233                 ],
   1234               }],
   1235               ['target_arch=="mipsel"', {
   1236                 # The mips toolchain currently has problems with stack-protector.
   1237                 'cflags!': [
   1238                   '-fstack-protector',
   1239                   '-U__linux__'
   1240                 ],
   1241                 'cflags': [
   1242                   '-fno-stack-protector',
   1243                 ],
   1244                 'ldflags': [
   1245                   '-L<(android_libcpp_libs)/mips',
   1246                 ],
   1247               }],
   1248               ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64" or target_arch=="ia32") and component!="shared_library"', {
   1249                 'cflags': [
   1250                   '-fPIE',
   1251                 ],
   1252                 'ldflags': [
   1253                   '-pie',
   1254                 ],
   1255               }],
   1256             ],
   1257             'target_conditions': [
   1258               ['_type=="executable"', {
   1259                 'conditions': [
   1260                   ['target_arch=="arm64" or target_arch=="x64"', {
   1261                     'ldflags': [
   1262                       '-Wl,-dynamic-linker,/system/bin/linker64',
   1263                     ],
   1264                   }, {
   1265                     'ldflags': [
   1266                       '-Wl,-dynamic-linker,/system/bin/linker',
   1267                     ],
   1268                   }]
   1269                 ],
   1270                 'ldflags': [
   1271                   '-Bdynamic',
   1272                   '-Wl,-z,nocopyreloc',
   1273                   # crtbegin_dynamic.o should be the last item in ldflags.
   1274                   '<(android_lib)/crtbegin_dynamic.o',
   1275                 ],
   1276                 'libraries': [
   1277                   # crtend_android.o needs to be the last item in libraries.
   1278                   # Do not add any libraries after this!
   1279                   '<(android_lib)/crtend_android.o',
   1280                 ],
   1281               }],
   1282               ['_type=="shared_library"', {
   1283                 'ldflags': [
   1284                   '-Wl,-shared,-Bsymbolic',
   1285                   '<(android_lib)/crtbegin_so.o',
   1286                 ],
   1287               }],
   1288               ['_type=="static_library"', {
   1289                 'ldflags': [
   1290                   # Don't export symbols from statically linked libraries.
   1291                   '-Wl,--exclude-libs=ALL',
   1292                 ],
   1293               }],
   1294             ],
   1295           }],  # _toolset=="target"
   1296           # Settings for building host targets using the system toolchain.
   1297           ['_toolset=="host"', {
   1298             'cflags': [ '-pthread' ],
   1299             'ldflags': [ '-pthread' ],
   1300             'ldflags!': [
   1301               '-Wl,-z,noexecstack',
   1302               '-Wl,--gc-sections',
   1303               '-Wl,-O1',
   1304               '-Wl,--as-needed',
   1305             ],
   1306           }],
   1307         ],  # target_conditions
   1308       },  # target_defaults
   1309     }],  # OS=="android"
   1310     ['OS=="android" and clang==0', {
   1311       # Hardcode the compiler names in the Makefile so that
   1312       # it won't depend on the environment at make time.
   1313       'make_global_settings': [
   1314         ['LD', '<!(/bin/echo -n <(android_toolchain)/../*/bin/ld)'],
   1315         ['RANLIB', '<!(/bin/echo -n <(android_toolchain)/../*/bin/ranlib)'],
   1316         ['CC', '<!(/bin/echo -n <(android_toolchain)/*-gcc)'],
   1317         ['CXX', '<!(/bin/echo -n <(android_toolchain)/*-g++)'],
   1318         ['LD.host', '<(host_ld)'],
   1319         ['RANLIB.host', '<(host_ranlib)'],
   1320         ['CC.host', '<(host_cc)'],
   1321         ['CXX.host', '<(host_cxx)'],
   1322       ],
   1323     }],
   1324     ['clang!=1 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
   1325       'make_global_settings': [
   1326         ['CC.host', '<(clang_dir)/bin/clang'],
   1327         ['CXX.host', '<(clang_dir)/bin/clang++'],
   1328       ],
   1329     }],
   1330     ['clang==0 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
   1331       'target_conditions': [
   1332         ['_toolset=="host"', {
   1333           'cflags_cc': [ '-std=gnu++11', ],
   1334         }],
   1335       ],
   1336       'target_defaults': {
   1337         'target_conditions': [
   1338           ['_toolset=="host"', { 'cflags!': [ '-Wno-unused-local-typedefs' ]}],
   1339         ],
   1340       },
   1341     }],
   1342     ['clang==1 and "<(GENERATOR)"=="ninja"', {
   1343       # See http://crbug.com/110262
   1344       'target_defaults': {
   1345         'cflags': [ '-fcolor-diagnostics' ],
   1346         'xcode_settings': { 'OTHER_CFLAGS': [ '-fcolor-diagnostics' ] },
   1347       },
   1348     }],
   1349     ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
   1350         'and OS!="win" and "<(GENERATOR)"=="make"', {
   1351       'make_global_settings': [
   1352         ['CC', '<(clang_dir)/bin/clang'],
   1353         ['CXX', '<(clang_dir)/bin/clang++'],
   1354         ['CC.host', '$(CC)'],
   1355         ['CXX.host', '$(CXX)'],
   1356       ],
   1357     }],
   1358     ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
   1359         'and OS!="win" and "<(GENERATOR)"=="ninja"', {
   1360       'make_global_settings': [
   1361         ['CC', '<(clang_dir)/bin/clang'],
   1362         ['CXX', '<(clang_dir)/bin/clang++'],
   1363         ['CC.host', '$(CC)'],
   1364         ['CXX.host', '$(CXX)'],
   1365       ],
   1366     }],
   1367     ['clang==1 and OS=="win"', {
   1368       'make_global_settings': [
   1369         # On Windows, gyp's ninja generator only looks at CC.
   1370         ['CC', '<(clang_dir)/bin/clang-cl'],
   1371       ],
   1372     }],
   1373     ['OS=="linux" and target_arch=="arm" and host_arch!="arm" and clang==0 and "<(GENERATOR)"=="ninja"', {
   1374       # Set default ARM cross tools on linux.  These can be overridden
   1375       # using CC,CXX,CC.host and CXX.host environment variables.
   1376       'make_global_settings': [
   1377         ['CC', '<!(which arm-linux-gnueabihf-gcc)'],
   1378         ['CXX', '<!(which arm-linux-gnueabihf-g++)'],
   1379         ['CC.host', '<(host_cc)'],
   1380         ['CXX.host', '<(host_cxx)'],
   1381       ],
   1382     }],
   1383     # TODO(yyanagisawa): supports GENERATOR==make
   1384     #  make generator doesn't support CC_wrapper without CC
   1385     #  in make_global_settings yet.
   1386     ['use_goma==1 and ("<(GENERATOR)"=="ninja" or clang==1)', {
   1387       'conditions': [
   1388         ['coverage==1', {
   1389           # Wrap goma with coverage wrapper.
   1390           'make_global_settings': [
   1391             ['CC_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py <(gomadir)/gomacc'],
   1392             ['CXX_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py <(gomadir)/gomacc'],
   1393             ['CC.host_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py <(gomadir)/gomacc'],
   1394             ['CXX.host_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py <(gomadir)/gomacc'],
   1395           ],
   1396         }, {
   1397           # Use only goma wrapper.
   1398           'make_global_settings': [
   1399             ['CC_wrapper', '<(gomadir)/gomacc'],
   1400             ['CXX_wrapper', '<(gomadir)/gomacc'],
   1401             ['CC.host_wrapper', '<(gomadir)/gomacc'],
   1402             ['CXX.host_wrapper', '<(gomadir)/gomacc'],
   1403           ],
   1404         }],
   1405       ],
   1406     }, {
   1407       'conditions': [
   1408         ['coverage==1', {
   1409           # Use only coverage wrapper.
   1410           'make_global_settings': [
   1411             ['CC_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py'],
   1412             ['CXX_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py'],
   1413             ['CC.host_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py'],
   1414             ['CXX.host_wrapper', '<(base_dir)/gypfiles/coverage_wrapper.py'],
   1415           ],
   1416         }],
   1417       ],
   1418     }],
   1419     ['use_lto==1', {
   1420       'target_defaults': {
   1421         'target_conditions': [
   1422           ['_toolset=="target"', {
   1423             'cflags': [
   1424               '-flto',
   1425             ],
   1426           }],
   1427         ],
   1428       },
   1429     }],
   1430     ['use_lto==1 and clang==0', {
   1431       'target_defaults': {
   1432         'target_conditions': [
   1433           ['_toolset=="target"', {
   1434             'cflags': [
   1435               '-ffat-lto-objects',
   1436             ],
   1437           }],
   1438         ],
   1439       },
   1440     }],
   1441     ['use_lto==1 and clang==1', {
   1442       'target_defaults': {
   1443         'target_conditions': [
   1444           ['_toolset=="target"', {
   1445             'arflags': [
   1446               '--plugin', '<(clang_dir)/lib/LLVMgold.so',
   1447             ],
   1448             # Apply a lower optimization level with lto. Chromium does this
   1449             # for non-official builds only - a differentiation that doesn't
   1450             # exist in v8.
   1451             'ldflags': [
   1452               '-Wl,--plugin-opt,O1',
   1453             ],
   1454           }],
   1455         ],
   1456       },
   1457     }],
   1458     ['use_lto==1 and clang==0', {
   1459       'target_defaults': {
   1460         'target_conditions': [
   1461           ['_toolset=="target"', {
   1462             'ldflags': [
   1463               '-flto=32',
   1464             ],
   1465           }],
   1466         ],
   1467       },
   1468     }],
   1469     ['use_lto==1 and clang==1', {
   1470       'target_defaults': {
   1471         'target_conditions': [
   1472           ['_toolset=="target"', {
   1473             'ldflags': [
   1474               '-flto',
   1475             ],
   1476           }],
   1477         ],
   1478       },
   1479     }],
   1480     ['cfi_diag==1', {
   1481       'target_defaults': {
   1482         'target_conditions': [
   1483           ['_toolset=="target"', {
   1484             'cflags': [
   1485               '-fno-sanitize-trap=cfi',
   1486               '-fno-sanitize-recover=cfi',
   1487             ],
   1488             'cflags_cc!': [
   1489               '-fno-rtti',
   1490             ],
   1491             'cflags!': [
   1492               '-fno-rtti',
   1493             ],
   1494             'ldflags': [
   1495               '-fno-sanitize-trap=cfi',
   1496               '-fno-sanitize-recover=cfi',
   1497             ],
   1498           }],
   1499         ],
   1500       },
   1501     }],
   1502     ['cfi_vptr==1', {
   1503       'target_defaults': {
   1504         'target_conditions': [
   1505           ['_toolset=="target"', {
   1506             'cflags': [
   1507               '-fsanitize=cfi-vcall',
   1508               '-fsanitize=cfi-derived-cast',
   1509               '-fsanitize=cfi-unrelated-cast',
   1510               '-fsanitize-blacklist=<(cfi_blacklist)',
   1511             ],
   1512             'ldflags': [
   1513               '-fsanitize=cfi-vcall',
   1514               '-fsanitize=cfi-derived-cast',
   1515               '-fsanitize=cfi-unrelated-cast',
   1516             ],
   1517           }],
   1518         ],
   1519       },
   1520     }],
   1521   ],
   1522 }
   1523