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