standalone.gypi 47.5 KB
Newer Older
1
# Copyright 2012 the V8 project authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
#     * Redistributions of source code must retain the above copyright
#       notice, this list of conditions and the following disclaimer.
#     * Redistributions in binary form must reproduce the above
#       copyright notice, this list of conditions and the following
#       disclaimer in the documentation and/or other materials provided
#       with the distribution.
#     * Neither the name of Google Inc. nor the names of its
#       contributors may be used to endorse or promote products derived
#       from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

# Definitions to be used when building stand-alone V8 binaries.

{
31 32 33
  # We need to include toolchain.gypi here for third-party sources that don't
  # directly include it themselves.
  'includes': ['toolchain.gypi'],
34 35
  'variables': {
    'component%': 'static_library',
machenbach's avatar
machenbach committed
36
    'clang_xcode%': 0,
37 38 39
    # Track where uninitialized memory originates from. From fastest to
    # slowest: 0 - no tracking, 1 - track only the initial allocation site, 2
    # - track the chain of stores leading from allocation site to use site.
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
    # TODO(jochen): Turn this on.
jochen's avatar
jochen committed
46
    'v8_imminent_deprecation_warnings%': 0,
47
    'msvs_multi_core_compile%': '1',
48
    'mac_deployment_target%': '10.5',
49
    'release_extra_cflags%': '',
50 51
    'variables': {
      'variables': {
52 53
        'variables': {
          '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 58 59
              # Anything else gets passed through, which probably won't work
              # very well; such hosts should pass an explicit target_arch
              # 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 65 66 67 68 69
              'host_arch%': 'ia32',
            }],
          ],
        },
        'host_arch%': '<(host_arch)',
        'target_arch%': '<(host_arch)',
70
        'base_dir%': '<!(cd <(DEPTH) && python -c "import os; print os.getcwd()")',
71
      },
72
      'base_dir%': '<(base_dir)',
73
      'host_arch%': '<(host_arch)',
74
      'target_arch%': '<(target_arch)',
75
      'v8_target_arch%': '<(target_arch)',
76 77 78 79
      'asan%': 0,
      'lsan%': 0,
      'msan%': 0,
      'tsan%': 0,
80 81 82 83
      # Enable coverage gathering instrumentation in sanitizer tools. This flag
      # also controls coverage granularity (1 for function-level, 2 for
      # block-level, 3 for edge-level).
      'sanitizer_coverage%': 0,
84 85 86 87
      # Use libc++ (buildtools/third_party/libc++ and
      # buildtools/third_party/libc++abi) instead of stdlibc++ as standard
      # library. This is intended to be used for instrumented builds.
      'use_custom_libcxx%': 0,
machenbach's avatar
machenbach committed
88

89
      'clang_dir%': '<(base_dir)/third_party/llvm-build/Release+Asserts',
90

91 92 93 94 95 96 97
      'use_lto%': 0,

      # Control Flow Integrity for virtual calls and casts.
      # See http://clang.llvm.org/docs/ControlFlowIntegrity.html
      'cfi_vptr%': 0,
      'cfi_diag%': 0,

98 99
      'cfi_blacklist%': '<(base_dir)/tools/cfi/blacklist.txt',

100 101 102 103
      # Set to 1 to enable fast builds.
      # TODO(machenbach): Only configured for windows.
      'fastbuild%': 0,

machenbach's avatar
machenbach committed
104 105 106 107 108 109 110 111 112 113 114 115
      # goma settings.
      # 1 to use goma.
      # If no gomadir is set, it uses the default gomadir.
      'use_goma%': 0,
      'gomadir%': '',
      'conditions': [
        # Set default gomadir.
        ['OS=="win"', {
          'gomadir': 'c:\\goma\\goma-win',
        }, {
          'gomadir': '<!(/bin/echo -n ${HOME}/goma)',
        }],
116 117 118 119 120
        ['host_arch!="ppc" and host_arch!="ppc64" and host_arch!="ppc64le"', {
          'host_clang%': '1',
        }, {
          'host_clang%': '0',
        }],
121 122 123 124 125 126 127 128 129 130
        # linux_use_bundled_gold: whether to use the gold linker binary checked
        # into third_party/binutils.  Force this off via GYP_DEFINES when you
        # are using a custom toolchain and need to control -B in ldflags.
        # Do not use 32-bit gold on 32-bit hosts as it runs out address space
        # for component=static_library builds.
        ['(OS=="linux" or OS=="android") and (target_arch=="x64" or target_arch=="arm" or (target_arch=="ia32" and host_arch=="x64"))', {
          'linux_use_bundled_gold%': 1,
        }, {
          'linux_use_bundled_gold%': 0,
        }],
131 132 133

        # TODO(machenbach): Remove the conditions as more configurations are
        # supported.
134
        ['OS=="linux" or OS=="win"', {
135 136 137 138
          'test_isolation_mode%': 'check',
        }, {
          'test_isolation_mode%': 'noop',
        }],
machenbach's avatar
machenbach committed
139
      ],
140
    },
141
    'base_dir%': '<(base_dir)',
142
    'clang_dir%': '<(clang_dir)',
143
    'host_arch%': '<(host_arch)',
144
    'host_clang%': '<(host_clang)',
145 146
    'target_arch%': '<(target_arch)',
    'v8_target_arch%': '<(v8_target_arch)',
147
    'werror%': '-Werror',
machenbach's avatar
machenbach committed
148 149
    'use_goma%': '<(use_goma)',
    'gomadir%': '<(gomadir)',
150 151 152 153
    'asan%': '<(asan)',
    'lsan%': '<(lsan)',
    'msan%': '<(msan)',
    'tsan%': '<(tsan)',
154
    'sanitizer_coverage%': '<(sanitizer_coverage)',
155
    'use_custom_libcxx%': '<(use_custom_libcxx)',
156 157 158 159
    'linux_use_bundled_gold%': '<(linux_use_bundled_gold)',
    'use_lto%': '<(use_lto)',
    'cfi_vptr%': '<(cfi_vptr)',
    'cfi_diag%': '<(cfi_diag)',
160
    'cfi_blacklist%': '<(cfi_blacklist)',
161
    'test_isolation_mode%': '<(test_isolation_mode)',
162
    'fastbuild%': '<(fastbuild)',
163

164
    # Add a simple extras solely for the purpose of the cctests
165
    'v8_extra_library_files': ['../test/cctest/test-extra.js'],
166
    'v8_experimental_extra_library_files': ['../test/cctest/test-experimental-extra.js'],
167

168 169 170 171 172 173
    # .gyp files or targets should set v8_code to 1 if they build V8 specific
    # code, as opposed to external code.  This variable is used to control such
    # things as the set of warnings to enable, and whether warnings are treated
    # as errors.
    'v8_code%': 0,

174 175 176
    # Speeds up Debug builds:
    # 0 - Compiler optimizations off (debuggable) (default). This may
    #     be 5x slower than Release (or worse).
177 178 179 180 181 182 183
    # 1 - Turn on optimizations and disable slow DCHECKs, but leave
    #     V8_ENABLE_CHECKS and most other assertions enabled.  This may cause
    #     some v8 tests to fail in the Debug configuration.  This roughly
    #     matches the performance of a Release build and can be used by
    #     embedders that need to build their own code as debug but don't want
    #     or need a debug version of V8. This should produce near-release
    #     speeds.
184 185
    'v8_optimized_debug%': 0,

186 187 188 189
    # Use external files for startup data blobs:
    # the JS builtins sources and the start snapshot.
    # Embedders that don't use standalone.gypi will need to add
    # their own default value.
190
    'v8_use_external_startup_data%': 1,
191

192 193 194
    # Relative path to icu.gyp from this file.
    'icu_gyp_path': '../third_party/icu/icu.gyp',

195 196
    'conditions': [
      ['(v8_target_arch=="arm" and host_arch!="arm") or \
197
        (v8_target_arch=="arm64" and host_arch!="arm64") or \
198
        (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
199
        (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
200
        (v8_target_arch=="x64" and host_arch!="x64") or \
201
        (OS=="android" or OS=="qnx")', {
202 203 204 205
        'want_separate_host_toolset': 1,
      }, {
        'want_separate_host_toolset': 0,
      }],
206 207 208 209 210
      ['OS == "win"', {
        'os_posix%': 0,
      }, {
        'os_posix%': 1,
      }],
machenbach's avatar
machenbach committed
211 212 213
      ['OS=="win" and use_goma==1', {
        # goma doesn't support pch yet.
        'chromium_win_pch': 0,
214 215
        # goma doesn't support PDB yet.
        'fastbuild%': 1,
machenbach's avatar
machenbach committed
216
      }],
217 218
      ['((v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
        (OS=="linux" or OS=="mac")) or (v8_target_arch=="ppc64" and OS=="linux")', {
219 220 221 222
        'v8_enable_gdbjit%': 1,
      }, {
        'v8_enable_gdbjit%': 0,
      }],
223
      ['(OS=="linux" or OS=="mac") and (target_arch=="ia32" or target_arch=="x64") and \
224
        (v8_target_arch!="x87" and v8_target_arch!="x32")', {
225 226 227 228
        'clang%': 1,
      }, {
        'clang%': 0,
      }],
229 230 231 232
      ['asan==1 or lsan==1 or msan==1 or tsan==1', {
        'clang%': 1,
        'use_allocator%': 'none',
      }],
233 234 235 236 237 238 239 240 241 242 243 244
      ['asan==1 and OS=="linux"', {
        'use_custom_libcxx%': 1,
      }],
      ['tsan==1', {
        'use_custom_libcxx%': 1,
      }],
      ['msan==1', {
        # Use a just-built, MSan-instrumented libc++ instead of the system-wide
        # libstdc++. This is required to avoid false positive reports whenever
        # the C++ standard library is used.
        'use_custom_libcxx%': 1,
      }],
245 246 247
      ['cfi_vptr==1', {
        'use_lto%': 1,
      }],
248 249 250 251 252 253
      ['OS=="android"', {
        # Location of Android NDK.
        'variables': {
          'variables': {
            # The Android toolchain needs to use the absolute path to the NDK
            # because it is used at different levels in the GYP files.
254
            'android_ndk_root%': '<(base_dir)/third_party/android_tools/ndk/',
255 256 257 258 259 260
            'android_host_arch%': "<!(uname -m | sed -e 's/i[3456]86/x86/')",
            'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
          },

          # Copy conditionally-set variables out one scope.
          'android_ndk_root%': '<(android_ndk_root)',
261
          'host_os%': '<(host_os)',
262 263 264 265

          'conditions': [
            ['target_arch == "ia32"', {
              'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
266 267
              'android_target_arch%': 'x86',
              'android_target_platform%': '16',
268 269 270
            }],
            ['target_arch == "x64"', {
              'android_toolchain%': '<(android_ndk_root)/toolchains/x86_64-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
271 272
              'android_target_arch%': 'x86_64',
              'android_target_platform%': '21',
273 274 275
            }],
            ['target_arch=="arm"', {
              'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
276 277 278
              'android_target_arch%': 'arm',
              'android_target_platform%': '16',
              'arm_version%': 7,
279 280 281
            }],
            ['target_arch == "arm64"', {
              'android_toolchain%': '<(android_ndk_root)/toolchains/aarch64-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
282 283 284
              'android_target_arch%': 'arm64',
              'android_target_platform%': '21',
              'arm_version%': 'default',
285 286 287
            }],
            ['target_arch == "mipsel"', {
              'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
288 289
              'android_target_arch%': 'mips',
              'android_target_platform%': '16',
290 291 292
            }],
            ['target_arch == "mips64el"', {
              'android_toolchain%': '<(android_ndk_root)/toolchains/mips64el-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
293 294
              'android_target_arch%': 'mips64',
              'android_target_platform%': '21',
295 296 297 298
            }],
          ],
        },

299
        # Copy conditionally-set variables out one scope.
300 301
        'android_target_arch%': '<(android_target_arch)',
        'android_target_platform%': '<(android_target_platform)',
302
        'android_toolchain%': '<(android_toolchain)',
303 304
        'arm_version%': '<(arm_version)',
        'host_os%': '<(host_os)',
305

306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340
        'conditions': [
          ['android_ndk_root==""', {
            'variables': {
              'android_sysroot': '<(android_toolchain)/sysroot/',
              'android_stlport': '<(android_toolchain)/sources/cxx-stl/stlport/',
            },
            'android_include': '<(android_sysroot)/usr/include',
            'conditions': [
              ['target_arch=="x64"', {
                'android_lib': '<(android_sysroot)/usr/lib64',
              }, {
                'android_lib': '<(android_sysroot)/usr/lib',
              }],
            ],
            'android_stlport_include': '<(android_stlport)/stlport',
            'android_stlport_libs': '<(android_stlport)/libs',
          }, {
            'variables': {
              'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)',
              'android_stlport': '<(android_ndk_root)/sources/cxx-stl/stlport/',
            },
            'android_include': '<(android_sysroot)/usr/include',
            'conditions': [
              ['target_arch=="x64"', {
                'android_lib': '<(android_sysroot)/usr/lib64',
              }, {
                'android_lib': '<(android_sysroot)/usr/lib',
              }],
            ],
            'android_stlport_include': '<(android_stlport)/stlport',
            'android_stlport_libs': '<(android_stlport)/libs',
          }],
        ],
        'android_stlport_library': 'stlport_static',
      }],  # OS=="android"
341
      ['host_clang==1', {
342 343
        'host_cc': '<(clang_dir)/bin/clang',
        'host_cxx': '<(clang_dir)/bin/clang++',
344 345 346 347
      }, {
        'host_cc': '<!(which gcc)',
        'host_cxx': '<!(which g++)',
      }],
348
    ],
349
    # Default ARM variable settings.
350
    'arm_version%': 'default',
351
    'arm_fpu%': 'vfpv3',
352 353
    'arm_float_abi%': 'default',
    'arm_thumb': 'default',
354 355 356 357 358 359 360 361 362 363

    # Default MIPS variable settings.
    'mips_arch_variant%': 'r2',
    # Possible values fp32, fp64, fpxx.
    # fp32 - 32 32-bit FPU registers are available, doubles are placed in
    #        register pairs.
    # fp64 - 32 64-bit FPU registers are available.
    # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
    #        detection
    'mips_fpu_mode%': 'fp32',
364 365
  },
  'target_defaults': {
366 367
    'variables': {
      'v8_code%': '<(v8_code)',
368 369 370 371 372
      'conditions':[
        ['OS=="android"', {
          'host_os%': '<(host_os)',
        }],
      ],
373
    },
374 375
    'default_configuration': 'Debug',
    'configurations': {
376
      'DebugBaseCommon': {
377
        'conditions': [
378 379 380 381
          ['OS=="aix"', {
            'cflags': [ '-g', '-Og', '-gxcoff' ],
          }, {
            'cflags': [ '-g', '-O0' ],
382
          }],
383
        ],
384
      },
385
      'Optdebug': {
386
        'inherit_from': [ 'DebugBaseCommon', 'DebugBase1' ],
387 388 389 390
      },
      'Debug': {
        # Xcode insists on this empty entry.
      },
391
      'Release': {
392
        'cflags+': ['<@(release_extra_cflags)'],
393
      },
394 395 396 397 398 399 400 401 402 403 404 405 406
      'conditions': [
        ['OS=="win"', {
          'Optdebug_x64': {
            'inherit_from': ['Optdebug'],
          },
          'Debug_x64': {
            'inherit_from': ['Debug'],
          },
          'Release_x64': {
            'inherit_from': ['Release'],
          },
        }],
      ],
407
    },
408 409 410 411 412 413 414 415
    'conditions':[
      ['(clang==1 or host_clang==1) and OS!="win"', {
        # This is here so that all files get recompiled after a clang roll and
        # when turning clang on or off.
        # (defines are passed via the command line, and build systems rebuild
        # things when their commandline changes). Nothing should ever read this
        # define.
        'defines': ['CR_CLANG_REVISION=<!(<(DEPTH)/tools/clang/scripts/update.sh --print-revision)'],
416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434
        'conditions': [
          ['host_clang==1', {
            'target_conditions': [
              ['_toolset=="host"', {
                'cflags+': [
                  '-Wno-format-pedantic',
                 ],
              }],
           ],
          }],
          ['clang==1', {
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags+': [
                  '-Wno-format-pedantic',
                 ],
              }],
           ],
          }],
machenbach's avatar
machenbach committed
435
        ],
436
      }],
437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453
      ['fastbuild!=0', {
        'conditions': [
          ['OS=="win" and fastbuild==1', {
            'msvs_settings': {
              'VCLinkerTool': {
                # This tells the linker to generate .pdbs, so that
                # we can get meaningful stack traces.
                'GenerateDebugInformation': 'true',
              },
              'VCCLCompilerTool': {
                # No debug info to be generated by compiler.
                'DebugInformationFormat': '0',
              },
            },
          }],
        ],
      }],  # fastbuild!=0
454
    ],
455 456
    'target_conditions': [
      ['v8_code == 0', {
457 458 459
        'defines!': [
          'DEBUG',
        ],
460 461
        'conditions': [
          ['os_posix == 1 and OS != "mac"', {
462 463
            # We don't want to get warnings from third-party code,
            # so remove any existing warning-enabling flags like -Wall.
464
            'cflags!': [
465 466
              '-pedantic',
              '-Wall',
467
              '-Werror',
468
              '-Wextra',
469
              '-Wshorten-64-to-32',
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489
            ],
            'cflags+': [
              # Clang considers the `register` keyword as deprecated, but
              # ICU uses it all over the place.
              '-Wno-deprecated-register',
              # ICU uses its own deprecated functions.
              '-Wno-deprecated-declarations',
              # ICU prefers `a && b || c` over `(a && b) || c`.
              '-Wno-logical-op-parentheses',
              # ICU has some `unsigned < 0` checks.
              '-Wno-tautological-compare',
              # uresdata.c has switch(RES_GET_TYPE(x)) code. The
              # RES_GET_TYPE macro returns an UResType enum, but some switch
              # statement contains case values that aren't part of that
              # enum (e.g. URES_TABLE32 which is in UResInternalType). This
              # is on purpose.
              '-Wno-switch',
            ],
            'cflags_cc!': [
              '-Wnon-virtual-dtor',
490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
            ],
          }],
          ['OS == "mac"', {
            'xcode_settings': {
              'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO',    # -Werror
            },
          }],
          ['OS == "win"', {
            'msvs_settings': {
              'VCCLCompilerTool': {
                'WarnAsError': 'false',
              },
            },
          }],
        ],
      }],
    ],
507 508
  },
  'conditions': [
509
    ['os_posix==1 and OS!="mac"', {
510
      'target_defaults': {
511
        'conditions': [
512
          # Common options for AddressSanitizer, LeakSanitizer,
513 514
          # ThreadSanitizer, MemorySanitizer and CFI builds.
          ['asan==1 or lsan==1 or tsan==1 or msan==1 or cfi_vptr==1', {
515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': [
                  '-fno-omit-frame-pointer',
                  '-gline-tables-only',
                ],
                'cflags!': [
                  '-fomit-frame-pointer',
                ],
              }],
            ],
          }],
          ['asan==1', {
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': [
                  '-fsanitize=address',
                ],
                'ldflags': [
                  '-fsanitize=address',
                ],
                'defines': [
                  'ADDRESS_SANITIZER',
                ],
              }],
            ],
          }],
          ['lsan==1', {
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': [
                  '-fsanitize=leak',
                ],
                'ldflags': [
                  '-fsanitize=leak',
                ],
                'defines': [
                  'LEAK_SANITIZER',
                ],
              }],
            ],
          }],
          ['tsan==1', {
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': [
                  '-fsanitize=thread',
                ],
                'ldflags': [
                  '-fsanitize=thread',
                ],
                'defines': [
                  'THREAD_SANITIZER',
                ],
              }],
            ],
          }],
          ['msan==1', {
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': [
                  '-fsanitize=memory',
                  '-fsanitize-memory-track-origins=<(msan_track_origins)',
                ],
                'ldflags': [
                  '-fsanitize=memory',
                ],
                'defines': [
                  'MEMORY_SANITIZER',
                ],
              }],
            ],
587 588
          }],
          ['use_custom_libcxx==1', {
589 590 591 592
            'dependencies': [
              '<(DEPTH)/buildtools/third_party/libc++/libc++.gyp:libcxx_proxy',
            ],
          }],
593 594 595 596 597 598 599 600 601 602 603 604
          ['sanitizer_coverage!=0', {
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': [
                  '-fsanitize-coverage=<(sanitizer_coverage)',
                ],
                'defines': [
                  'SANITIZER_COVERAGE',
                ],
              }],
            ],
          }],
605 606 607 608 609 610 611 612 613 614 615 616 617 618 619
          ['linux_use_bundled_gold==1 and not (clang==0 and use_lto==1)', {
            # Put our binutils, which contains gold in the search path. We pass
            # the path to gold to the compiler. gyp leaves unspecified what the
            # cwd is when running the compiler, so the normal gyp path-munging
            # fails us. This hack gets the right path.
            #
            # Disabled when using GCC LTO because GCC also uses the -B search
            # path at link time to find "as", and our bundled "as" can only
            # target x86.
            'ldflags': [
              # Note, Chromium allows ia32 host arch as well, we limit this to
              # x64 in v8.
              '-B<(base_dir)/third_party/binutils/Linux_x64/Release/bin',
            ],
          }],
620 621 622
        ],
      },
    }],
623
    ['OS=="mac"', {
624
      'target_defaults': {
625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661
       'conditions': [
          ['asan==1', {
            'xcode_settings': {
              # FIXME(machenbach): This is outdated compared to common.gypi.
              'OTHER_CFLAGS+': [
                '-fno-omit-frame-pointer',
                '-gline-tables-only',
                '-fsanitize=address',
                '-w',  # http://crbug.com/162783
              ],
              'OTHER_CFLAGS!': [
                '-fomit-frame-pointer',
              ],
              'defines': [
                'ADDRESS_SANITIZER',
              ],
            },
            'dependencies': [
              '<(DEPTH)/build/mac/asan.gyp:asan_dynamic_runtime',
            ],
            'target_conditions': [
              ['_type!="static_library"', {
                'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
              }],
            ],
          }],
          ['sanitizer_coverage!=0', {
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': [
                  '-fsanitize-coverage=<(sanitizer_coverage)',
                ],
                'defines': [
                  'SANITIZER_COVERAGE',
                ],
              }],
            ],
662 663
          }],
        ],
664 665
      },  # target_defaults
    }],  # OS=="mac"
666
    ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
667
       or OS=="netbsd" or OS=="aix"', {
668
      'target_defaults': {
669 670 671 672 673 674 675 676 677 678
        'cflags': [
          '-Wall',
          '<(werror)',
          '-Wno-unused-parameter',
          '-Wno-long-long',
          '-pthread',
          '-pedantic',
          # Don't warn about the "struct foo f = {0};" initialization pattern.
          '-Wno-missing-field-initializers',
        ],
679 680 681 682 683 684
        'cflags_cc': [
          '-Wnon-virtual-dtor',
          '-fno-exceptions',
          '-fno-rtti',
          '-std=gnu++0x',
        ],
685 686
        'ldflags': [ '-pthread', ],
        'conditions': [
687 688
          [ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64" \
            or v8_target_arch=="mips64el")', {
689 690
            'cflags': [ '-Wshorten-64-to-32' ],
          }],
691
          [ 'host_arch=="ppc64" and OS!="aix"', {
692 693
            'cflags': [ '-mminimal-toc' ],
          }],
694
          [ 'visibility=="hidden" and v8_enable_backtrace==0', {
695 696
            'cflags': [ '-fvisibility=hidden' ],
          }],
697 698 699
          [ 'component=="shared_library"', {
            'cflags': [ '-fPIC', ],
          }],
700 701
        ],
      },
702 703 704
    }],
    # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
    #  or OS=="netbsd"'
705 706
    ['OS=="qnx"', {
      'target_defaults': {
707 708 709 710 711 712 713
        'cflags': [
          '-Wall',
          '<(werror)',
          '-Wno-unused-parameter',
          # Don't warn about the "struct foo f = {0};" initialization pattern.
          '-Wno-missing-field-initializers',
        ],
714 715 716 717 718 719
        'cflags_cc': [
          '-Wnon-virtual-dtor',
          '-fno-exceptions',
          '-fno-rtti',
          '-std=gnu++0x',
        ],
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740
        'conditions': [
          [ 'visibility=="hidden"', {
            'cflags': [ '-fvisibility=hidden' ],
          }],
          [ 'component=="shared_library"', {
            'cflags': [ '-fPIC' ],
          }],
        ],
        'target_conditions': [
          [ '_toolset=="host" and host_os=="linux"', {
            'cflags': [ '-pthread' ],
            'ldflags': [ '-pthread' ],
            'libraries': [ '-lrt' ],
          }],
          [ '_toolset=="target"', {
            'cflags': [ '-Wno-psabi' ],
            'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
          }],
        ],
      },
    }],  # OS=="qnx"
741 742 743 744 745
    ['OS=="win"', {
      'target_defaults': {
        'defines': [
          '_CRT_SECURE_NO_DEPRECATE',
          '_CRT_NONSTDC_NO_DEPRECATE',
746
          '_USING_V110_SDK71_',
747 748 749 750 751 752 753 754 755
        ],
        'conditions': [
          ['component=="static_library"', {
            'defines': [
              '_HAS_EXCEPTIONS=0',
            ],
          }],
        ],
        'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834
        'msvs_disabled_warnings': [
          # C4091: 'typedef ': ignored on left of 'X' when no variable is
          #                    declared.
          # This happens in a number of Windows headers. Dumb.
          4091,

          # C4127: conditional expression is constant
          # This warning can in theory catch dead code and other problems, but
          # triggers in far too many desirable cases where the conditional
          # expression is either set by macros or corresponds some legitimate
          # compile-time constant expression (due to constant template args,
          # conditionals comparing the sizes of different types, etc.).  Some of
          # these can be worked around, but it's not worth it.
          4127,

          # C4351: new behavior: elements of array 'array' will be default
          #        initialized
          # This is a silly "warning" that basically just alerts you that the
          # compiler is going to actually follow the language spec like it's
          # supposed to, instead of not following it like old buggy versions
          # did.  There's absolutely no reason to turn this on.
          4351,

          # C4355: 'this': used in base member initializer list
          # It's commonly useful to pass |this| to objects in a class'
          # initializer list.  While this warning can catch real bugs, most of
          # the time the constructors in question don't attempt to call methods
          # on the passed-in pointer (until later), and annotating every legit
          # usage of this is simply more hassle than the warning is worth.
          4355,

          # C4503: 'identifier': decorated name length exceeded, name was
          #        truncated
          # This only means that some long error messages might have truncated
          # identifiers in the presence of lots of templates.  It has no effect
          # on program correctness and there's no real reason to waste time
          # trying to prevent it.
          4503,

          # Warning C4589 says: "Constructor of abstract class ignores
          # initializer for virtual base class." Disable this warning because it
          # is flaky in VS 2015 RTM. It triggers on compiler generated
          # copy-constructors in some cases.
          4589,

          # C4611: interaction between 'function' and C++ object destruction is
          #        non-portable
          # This warning is unavoidable when using e.g. setjmp/longjmp.  MSDN
          # suggests using exceptions instead of setjmp/longjmp for C++, but
          # Chromium code compiles without exception support.  We therefore have
          # to use setjmp/longjmp for e.g. JPEG decode error handling, which
          # means we have to turn off this warning (and be careful about how
          # object destruction happens in such cases).
          4611,

          # TODO(jochen): These warnings are level 4. They will be slowly
          # removed as code is fixed.
          4100, # Unreferenced formal parameter
          4121, # Alignment of a member was sensitive to packing
          4244, # Conversion from 'type1' to 'type2', possible loss of data
          4302, # Truncation from 'type 1' to 'type 2'
          4309, # Truncation of constant value
          4311, # Pointer truncation from 'type' to 'type'
          4312, # Conversion from 'type1' to 'type2' of greater size
          4481, # Nonstandard extension used: override specifier 'keyword'
          4505, # Unreferenced local function has been removed
          4510, # Default constructor could not be generated
          4512, # Assignment operator could not be generated
          4610, # Object can never be instantiated
          4800, # Forcing value to bool.
          4838, # Narrowing conversion. Doesn't seem to be very useful.
          4995, # 'X': name was marked as #pragma deprecated
          4996, # 'X': was declared deprecated (for GetVersionEx).

          # These are variable shadowing warnings that are new in VS2015. We
          # should work through these at some point -- they may be removed from
          # the RTM release in the /W4 set.
          4456, 4457, 4458, 4459,
        ],
835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857
        'msvs_settings': {
          'VCCLCompilerTool': {
            'MinimalRebuild': 'false',
            'BufferSecurityCheck': 'true',
            'EnableFunctionLevelLinking': 'true',
            'RuntimeTypeInfo': 'false',
            'WarningLevel': '3',
            'WarnAsError': 'true',
            'DebugInformationFormat': '3',
            'Detect64BitPortabilityProblems': 'false',
            'conditions': [
              [ 'msvs_multi_core_compile', {
                'AdditionalOptions': ['/MP'],
              }],
              ['component=="shared_library"', {
                'ExceptionHandling': '1',  # /EHsc
              }, {
                'ExceptionHandling': '0',
              }],
            ],
          },
          'VCLibrarianTool': {
            'AdditionalOptions': ['/ignore:4221'],
858 859 860 861 862 863 864
            'conditions': [
              ['v8_target_arch=="x64"', {
                'TargetMachine': '17',  # x64
              }, {
                'TargetMachine': '1',  # ia32
              }],
            ],
865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883
          },
          'VCLinkerTool': {
            'AdditionalDependencies': [
              'ws2_32.lib',
            ],
            'GenerateDebugInformation': 'true',
            'MapFileName': '$(OutDir)\\$(TargetName).map',
            'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
            'FixedBaseAddress': '1',
            # LinkIncremental values:
            #   0 == default
            #   1 == /INCREMENTAL:NO
            #   2 == /INCREMENTAL
            'LinkIncremental': '1',
            # SubSystem values:
            #   0 == not set
            #   1 == /SUBSYSTEM:CONSOLE
            #   2 == /SUBSYSTEM:WINDOWS
            'SubSystem': '1',
884 885 886 887 888 889 890

            'conditions': [
              ['v8_enable_i18n_support==1', {
                'AdditionalDependencies': [
                  'advapi32.lib',
                ],
              }],
891 892 893 894 895 896 897
              ['v8_target_arch=="x64"', {
                'MinimumRequiredVersion': '5.02',  # Server 2003.
                'TargetMachine': '17',  # x64
              }, {
                'MinimumRequiredVersion': '5.01',  # XP.
                'TargetMachine': '1',  # ia32
              }],
898
            ],
899 900 901 902 903
          },
        },
      },
    }],  # OS=="win"
    ['OS=="mac"', {
904
      'xcode_settings': {
jochen's avatar
jochen committed
905
        'SDKROOT': 'macosx',
906 907
        'SYMROOT': '<(DEPTH)/xcodebuild',
      },
908 909 910
      'target_defaults': {
        'xcode_settings': {
          'ALWAYS_SEARCH_USER_PATHS': 'NO',
911
          'GCC_C_LANGUAGE_STANDARD': 'c99',         # -std=c99
912 913 914 915 916 917 918 919 920 921
          'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
          'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
                                                    # (Equivalent to -fPIC)
          'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
          'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
          'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
          # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
          'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
          'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES',      # -fvisibility=hidden
          'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
922
          'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
923 924
          # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
          'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
925
          'PREBINDING': 'NO',                       # No -Wl,-prebind
926
          'SYMROOT': '<(DEPTH)/xcodebuild',
927 928 929 930 931 932 933 934
          'USE_HEADERMAP': 'NO',
          'OTHER_CFLAGS': [
            '-fno-strict-aliasing',
          ],
          'WARNING_CFLAGS': [
            '-Wall',
            '-Wendif-labels',
            '-Wno-unused-parameter',
935 936
            # Don't warn about the "struct foo f = {0};" initialization pattern.
            '-Wno-missing-field-initializers',
937 938
          ],
        },
939 940 941 942 943 944
        'conditions': [
          ['werror==""', {
            'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
          }, {
            'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
          }],
945 946 947
          ['clang==1', {
            'xcode_settings': {
              'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
948
              'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x',  # -std=gnu++0x
949
            },
950 951 952 953 954 955
            'conditions': [
              ['v8_target_arch=="x64" or v8_target_arch=="arm64" \
                or v8_target_arch=="mips64el"', {
                'xcode_settings': {'WARNING_CFLAGS': ['-Wshorten-64-to-32']},
              }],
            ],
956
          }],
957
        ],
958 959 960 961 962 963 964
        'target_conditions': [
          ['_type!="static_library"', {
            'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
          }],
        ],  # target_conditions
      },  # target_defaults
    }],  # OS=="mac"
965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033
    ['OS=="android"', {
      'target_defaults': {
        'defines': [
          'ANDROID',
          'V8_ANDROID_LOG_STDOUT',
        ],
        'configurations': {
          'Release': {
            'cflags': [
              '-fomit-frame-pointer',
            ],
          },  # Release
        },  # configurations
        'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'],
        'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions',
                       # Note: Using -std=c++0x will define __STRICT_ANSI__, which
                       # in turn will leave out some template stuff for 'long
                       # long'.  What we want is -std=c++11, but this is not
                       # supported by GCC 4.6 or Xcode 4.2
                       '-std=gnu++0x' ],
        'target_conditions': [
          ['_toolset=="target"', {
            'cflags!': [
              '-pthread',  # Not supported by Android toolchain.
            ],
            'cflags': [
              '-ffunction-sections',
              '-funwind-tables',
              '-fstack-protector',
              '-fno-short-enums',
              '-finline-limit=64',
              '-Wa,--noexecstack',
              # Note: This include is in cflags to ensure that it comes after
              # all of the includes.
              '-I<(android_include)',
              '-I<(android_stlport_include)',
            ],
            'cflags_cc': [
              '-Wno-error=non-virtual-dtor',  # TODO(michaelbai): Fix warnings.
            ],
            'defines': [
              'ANDROID',
              #'__GNU_SOURCE=1',  # Necessary for clone()
              'USE_STLPORT=1',
              '_STLP_USE_PTR_SPECIALIZATIONS=1',
              'HAVE_OFF64_T',
              'HAVE_SYS_UIO_H',
              'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
            ],
            'ldflags!': [
              '-pthread',  # Not supported by Android toolchain.
            ],
            'ldflags': [
              '-nostdlib',
              '-Wl,--no-undefined',
              '-Wl,-rpath-link=<(android_lib)',
              '-L<(android_lib)',
            ],
            'libraries!': [
                '-lrt',  # librt is built into Bionic.
                # Not supported by Android toolchain.
                # Where do these come from?  Can't find references in
                # any Chromium gyp or gypi file.  Maybe they come from
                # gyp itself?
                '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4',
              ],
              'libraries': [
                '-l<(android_stlport_library)',
                # Manually link the libgcc.a that the cross compiler uses.
1034
                '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158
                '-lc',
                '-ldl',
                '-lstdc++',
                '-lm',
            ],
            'conditions': [
              ['target_arch == "arm"', {
                'ldflags': [
                  # Enable identical code folding to reduce size.
                  '-Wl,--icf=safe',
                ],
              }],
              ['target_arch=="arm" and arm_version==7', {
                'cflags': [
                  '-march=armv7-a',
                  '-mtune=cortex-a8',
                  '-mfpu=vfp3',
                ],
                'ldflags': [
                  '-L<(android_stlport_libs)/armeabi-v7a',
                ],
              }],
              ['target_arch=="arm" and arm_version < 7', {
                'ldflags': [
                  '-L<(android_stlport_libs)/armeabi',
                ],
              }],
              ['target_arch=="x64"', {
                'ldflags': [
                  '-L<(android_stlport_libs)/x86_64',
                ],
              }],
              ['target_arch=="arm64"', {
                'ldflags': [
                  '-L<(android_stlport_libs)/arm64-v8a',
                ],
              }],
              ['target_arch=="ia32" or target_arch=="x87"', {
                # The x86 toolchain currently has problems with stack-protector.
                'cflags!': [
                  '-fstack-protector',
                ],
                'cflags': [
                  '-fno-stack-protector',
                ],
                'ldflags': [
                  '-L<(android_stlport_libs)/x86',
                ],
              }],
              ['target_arch=="mipsel"', {
                # The mips toolchain currently has problems with stack-protector.
                'cflags!': [
                  '-fstack-protector',
                  '-U__linux__'
                ],
                'cflags': [
                  '-fno-stack-protector',
                ],
                'ldflags': [
                  '-L<(android_stlport_libs)/mips',
                ],
              }],
              ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64" or target_arch=="ia32") and component!="shared_library"', {
                'cflags': [
                  '-fPIE',
                ],
                'ldflags': [
                  '-pie',
                ],
              }],
            ],
            'target_conditions': [
              ['_type=="executable"', {
                'conditions': [
                  ['target_arch=="arm64" or target_arch=="x64"', {
                    'ldflags': [
                      '-Wl,-dynamic-linker,/system/bin/linker64',
                    ],
                  }, {
                    'ldflags': [
                      '-Wl,-dynamic-linker,/system/bin/linker',
                    ],
                  }]
                ],
                'ldflags': [
                  '-Bdynamic',
                  '-Wl,-z,nocopyreloc',
                  # crtbegin_dynamic.o should be the last item in ldflags.
                  '<(android_lib)/crtbegin_dynamic.o',
                ],
                'libraries': [
                  # crtend_android.o needs to be the last item in libraries.
                  # Do not add any libraries after this!
                  '<(android_lib)/crtend_android.o',
                ],
              }],
              ['_type=="shared_library"', {
                'ldflags': [
                  '-Wl,-shared,-Bsymbolic',
                  '<(android_lib)/crtbegin_so.o',
                ],
              }],
              ['_type=="static_library"', {
                'ldflags': [
                  # Don't export symbols from statically linked libraries.
                  '-Wl,--exclude-libs=ALL',
                ],
              }],
            ],
          }],  # _toolset=="target"
          # Settings for building host targets using the system toolchain.
          ['_toolset=="host"', {
            'cflags': [ '-pthread' ],
            'ldflags': [ '-pthread' ],
            'ldflags!': [
              '-Wl,-z,noexecstack',
              '-Wl,--gc-sections',
              '-Wl,-O1',
              '-Wl,--as-needed',
            ],
          }],
        ],  # target_conditions
      },  # target_defaults
    }],  # OS=="android"
1159 1160 1161 1162 1163 1164 1165 1166 1167 1168
    ['OS=="android" and clang==0', {
      # Hardcode the compiler names in the Makefile so that
      # it won't depend on the environment at make time.
      'make_global_settings': [
        ['CC', '<!(/bin/echo -n <(android_toolchain)/*-gcc)'],
        ['CXX', '<!(/bin/echo -n <(android_toolchain)/*-g++)'],
        ['CC.host', '<(host_cc)'],
        ['CXX.host', '<(host_cxx)'],
      ],
    }],
1169 1170
    ['clang!=1 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
      'make_global_settings': [
1171 1172
        ['CC.host', '<(clang_dir)/bin/clang'],
        ['CXX.host', '<(clang_dir)/bin/clang++'],
1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186
      ],
    }],
    ['clang==0 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
      'target_conditions': [
        ['_toolset=="host"', {
          'cflags_cc': [ '-std=gnu++11', ],
        }],
      ],
      'target_defaults': {
        'target_conditions': [
          ['_toolset=="host"', { 'cflags!': [ '-Wno-unused-local-typedefs' ]}],
        ],
      },
    }],
1187 1188 1189 1190 1191 1192 1193
    ['clang==1 and "<(GENERATOR)"=="ninja"', {
      # See http://crbug.com/110262
      'target_defaults': {
        'cflags': [ '-fcolor-diagnostics' ],
        'xcode_settings': { 'OTHER_CFLAGS': [ '-fcolor-diagnostics' ] },
      },
    }],
machenbach's avatar
machenbach committed
1194
    ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
bmeurer's avatar
bmeurer committed
1195
        'and OS!="win" and "<(GENERATOR)"=="make"', {
machenbach's avatar
machenbach committed
1196
      'make_global_settings': [
1197 1198
        ['CC', '<(clang_dir)/bin/clang'],
        ['CXX', '<(clang_dir)/bin/clang++'],
bmeurer's avatar
bmeurer committed
1199 1200 1201 1202 1203 1204 1205 1206 1207
        ['CC.host', '$(CC)'],
        ['CXX.host', '$(CXX)'],
      ],
    }],
    ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
        'and OS!="win" and "<(GENERATOR)"=="ninja"', {
      'make_global_settings': [
        ['CC', '<(clang_dir)/bin/clang'],
        ['CXX', '<(clang_dir)/bin/clang++'],
machenbach's avatar
machenbach committed
1208 1209 1210 1211 1212 1213 1214
        ['CC.host', '$(CC)'],
        ['CXX.host', '$(CXX)'],
      ],
    }],
    ['clang==1 and OS=="win"', {
      'make_global_settings': [
        # On Windows, gyp's ninja generator only looks at CC.
1215
        ['CC', '<(clang_dir)/bin/clang-cl'],
machenbach's avatar
machenbach committed
1216 1217
      ],
    }],
machenbach's avatar
machenbach committed
1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228
    # TODO(yyanagisawa): supports GENERATOR==make
    #  make generator doesn't support CC_wrapper without CC
    #  in make_global_settings yet.
    ['use_goma==1 and ("<(GENERATOR)"=="ninja" or clang==1)', {
      'make_global_settings': [
       ['CC_wrapper', '<(gomadir)/gomacc'],
       ['CXX_wrapper', '<(gomadir)/gomacc'],
       ['CC.host_wrapper', '<(gomadir)/gomacc'],
       ['CXX.host_wrapper', '<(gomadir)/gomacc'],
      ],
    }],
1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295
    ['use_lto==1', {
      'target_defaults': {
        'target_conditions': [
          ['_toolset=="target"', {
            'cflags': [
              '-flto',
            ],
          }],
        ],
      },
    }],
    ['use_lto==1 and clang==0', {
      'target_defaults': {
        'target_conditions': [
          ['_toolset=="target"', {
            'cflags': [
              '-ffat-lto-objects',
            ],
          }],
        ],
      },
    }],
    ['use_lto==1 and clang==1', {
      'target_defaults': {
        'target_conditions': [
          ['_toolset=="target"', {
            'arflags': [
              '--plugin', '<(clang_dir)/lib/LLVMgold.so',
            ],
            # Apply a lower optimization level with lto. Chromium does this
            # for non-official builds only - a differentiation that doesn't
            # exist in v8.
            'ldflags': [
              '-Wl,--plugin-opt,O1',
            ],
          }],
        ],
      },
    }],
    ['use_lto==1 and clang==0', {
      'target_defaults': {
        'target_conditions': [
          ['_toolset=="target"', {
            'ldflags': [
              '-flto=32',
            ],
          }],
        ],
      },
    }],
    ['use_lto==1 and clang==1', {
      'target_defaults': {
        'target_conditions': [
          ['_toolset=="target"', {
            'ldflags': [
              '-flto',
            ],
          }],
        ],
      },
    }],
    ['cfi_diag==1', {
      'target_defaults': {
        'target_conditions': [
          ['_toolset=="target"', {
            'cflags': [
              '-fno-sanitize-trap=cfi',
1296
              '-fno-sanitize-recover=cfi',
1297
            ],
1298 1299 1300 1301 1302 1303
            'cflags_cc!': [
              '-fno-rtti',
            ],
            'cflags!': [
              '-fno-rtti',
            ],
1304 1305
            'ldflags': [
              '-fno-sanitize-trap=cfi',
1306
              '-fno-sanitize-recover=cfi',
1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319
            ],
          }],
        ],
      },
    }],
    ['cfi_vptr==1', {
      'target_defaults': {
        'target_conditions': [
          ['_toolset=="target"', {
            'cflags': [
              '-fsanitize=cfi-vcall',
              '-fsanitize=cfi-derived-cast',
              '-fsanitize=cfi-unrelated-cast',
1320
              '-fsanitize-blacklist=<(cfi_blacklist)',
1321 1322 1323 1324 1325 1326 1327 1328 1329 1330
            ],
            'ldflags': [
              '-fsanitize=cfi-vcall',
              '-fsanitize=cfi-derived-cast',
              '-fsanitize=cfi-unrelated-cast',
            ],
          }],
        ],
      },
    }],
1331 1332
  ],
}