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