toolchain.gypi 46.1 KB
Newer Older
1
# Copyright 2013 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
# 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.

28 29
# Shared definitions for all V8-related targets.

30 31
{
  'variables': {
32
    'msvs_use_common_release': 0,
33
    'clang%': 0,
34 35 36 37 38 39
    'asan%': 0,
    'lsan%': 0,
    'msan%': 0,
    'tsan%': 0,
    'ubsan%': 0,
    'ubsan_vptr%': 0,
40
    'v8_target_arch%': '<(target_arch)',
41
    'v8_host_byteorder%': '<!(python -c "import sys; print sys.byteorder")',
42 43 44 45 46 47 48
    # Native Client builds currently use the V8 ARM JIT and
    # arm/simulator-arm.cc to defer the significant effort required
    # for NaCl JIT support. The nacl_target_arch variable provides
    # the 'true' target arch for places in this file that need it.
    # TODO(bradchen): get rid of nacl_target_arch when someday
    # NaCl V8 builds stop using the ARM simulator
    'nacl_target_arch%': 'none',     # must be set externally
49

50 51 52 53 54 55
    # Setting 'v8_can_use_vfp32dregs' to 'true' will cause V8 to use the VFP
    # registers d16-d31 in the generated code, both in the snapshot and for the
    # ARM target. Leaving the default value of 'false' will avoid the use of
    # these registers in the snapshot and use CPU feature probing when running
    # on the target.
    'v8_can_use_vfp32dregs%': 'false',
56
    'arm_test_noprobe%': 'off',
57

58 59 60 61 62 63
    # Similar to vfp but on MIPS.
    'v8_can_use_fpu_instructions%': 'true',

    # Similar to the ARM hard float ABI but on MIPS.
    'v8_use_mips_abi_hardfloat%': 'true',

64 65 66
    # Force disable libstdc++ debug mode.
    'disable_glibcxx_debug%': 0,

67
    'v8_enable_backtrace%': 0,
68

69 70 71
    # Enable profiling support. Only required on Windows.
    'v8_enable_prof%': 0,

72 73 74
    # Some versions of GCC 4.5 seem to need -fno-strict-aliasing.
    'v8_no_strict_aliasing%': 0,

75 76 77 78
    # Chrome needs this definition unconditionally. For standalone V8 builds,
    # it's handled in build/standalone.gypi.
    'want_separate_host_toolset%': 1,

79 80 81 82 83
    # Toolset the d8 binary should be compiled for. Possible values are 'host'
    # and 'target'. If you want to run v8 tests, it needs to be set to 'target'.
    # The setting is ignored if want_separate_host_toolset is 0.
    'v8_toolset_for_d8%': 'target',

84 85 86
    # Control usage of a separate ignition snapshot file.
    'v8_separate_ignition_snapshot%': 0,

87
    'host_os%': '<(OS)',
88
    'werror%': '-Werror',
89 90
    # For a shared library build, results in "libv8-<(soname_version).so".
    'soname_version%': '',
91 92 93

    # Allow to suppress the array bounds warning (default is no suppression).
    'wno_array_bounds%': '',
94

95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134
    # Override where to find binutils
    'binutils_dir%': '',

    'conditions': [
      ['OS=="linux" and host_arch=="x64"', {
        'binutils_dir%': 'third_party/binutils/Linux_x64/Release/bin',
      }],
      ['OS=="linux" and host_arch=="ia32"', {
        'binutils_dir%': 'third_party/binutils/Linux_ia32/Release/bin',
      }],

      # linux_use_bundled_gold: whether to use the gold linker binary checked
      # into third_party/binutils.  Force this off via GYP_DEFINES when you
      # are using a custom toolchain and need to control -B in ldflags.
      # Do not use 32-bit gold on 32-bit hosts as it runs out address space
      # for component=static_library builds.
      ['OS=="linux" and (target_arch=="x64" or target_arch=="arm")', {
        'linux_use_bundled_gold%': 1,
      }, {
        'linux_use_bundled_gold%': 0,
      }],
      # linux_use_bundled_binutils: whether to use the binary binutils
      # checked into third_party/binutils.  These are not multi-arch so cannot
      # be used except on x86 and x86-64 (the only two architectures which
      # are currently checke in).  Force this off via GYP_DEFINES when you
      # are using a custom toolchain and need to control -B in cflags.
      ['OS=="linux" and (target_arch=="ia32" or target_arch=="x64")', {
        'linux_use_bundled_binutils%': 1,
      }, {
        'linux_use_bundled_binutils%': 0,
      }],
      # linux_use_gold_flags: whether to use build flags that rely on gold.
      # On by default for x64 Linux.
      ['OS=="linux" and target_arch=="x64"', {
        'linux_use_gold_flags%': 1,
      }, {
        'linux_use_gold_flags%': 0,
      }],
    ],

135 136
    # Link-Time Optimizations
    'use_lto%': 0,
137
  },
138
  'conditions': [
139 140
    ['host_arch=="ia32" or host_arch=="x64" or \
      host_arch=="ppc" or host_arch=="ppc64" or \
141
      host_arch=="s390" or host_arch=="s390x" or \
142
      clang==1', {
143 144 145 146 147 148 149 150 151
      'variables': {
        'host_cxx_is_biarch%': 1,
       },
     }, {
      'variables': {
        'host_cxx_is_biarch%': 0,
      },
    }],
    ['target_arch=="ia32" or target_arch=="x64" or target_arch=="x87" or \
152 153
      target_arch=="ppc" or target_arch=="ppc64" or target_arch=="s390" or \
      target_arch=="s390x" or clang==1', {
154 155 156 157 158 159 160 161 162
      'variables': {
        'target_cxx_is_biarch%': 1,
       },
     }, {
      'variables': {
        'target_cxx_is_biarch%': 0,
      },
    }],
  ],
163
  'target_defaults': {
164
    'conditions': [
165 166 167 168
      ['v8_target_arch=="arm"', {
        'defines': [
          'V8_TARGET_ARCH_ARM',
        ],
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198
        'conditions': [
          [ 'arm_version==7 or arm_version=="default"', {
            'defines': [
              'CAN_USE_ARMV7_INSTRUCTIONS',
            ],
          }],
          [ 'arm_fpu=="vfpv3-d16" or arm_fpu=="default"', {
            'defines': [
              'CAN_USE_VFP3_INSTRUCTIONS',
            ],
          }],
          [ 'arm_fpu=="vfpv3"', {
            'defines': [
              'CAN_USE_VFP3_INSTRUCTIONS',
              'CAN_USE_VFP32DREGS',
            ],
          }],
          [ 'arm_fpu=="neon"', {
            'defines': [
              'CAN_USE_VFP3_INSTRUCTIONS',
              'CAN_USE_VFP32DREGS',
              'CAN_USE_NEON',
            ],
          }],
          [ 'arm_test_noprobe=="on"', {
            'defines': [
              'ARM_TEST_NO_FEATURE_PROBE',
            ],
          }],
        ],
199 200 201
        'target_conditions': [
          ['_toolset=="host"', {
            'conditions': [
202
              ['v8_target_arch==host_arch', {
203
                # Host built with an Arm CXX compiler.
204
                'conditions': [
205
                  [ 'arm_version==7', {
206 207
                    'cflags': ['-march=armv7-a',],
                  }],
208
                  [ 'arm_version==7 or arm_version=="default"', {
209
                    'conditions': [
210 211
                      [ 'arm_fpu!="default"', {
                        'cflags': ['-mfpu=<(arm_fpu)',],
212
                      }],
213
                    ],
214 215 216 217 218 219 220 221 222 223
                  }],
                  [ 'arm_float_abi!="default"', {
                    'cflags': ['-mfloat-abi=<(arm_float_abi)',],
                  }],
                  [ 'arm_thumb==1', {
                    'cflags': ['-mthumb',],
                  }],
                  [ 'arm_thumb==0', {
                    'cflags': ['-marm',],
                  }],
224 225
                ],
              }, {
226 227
                # 'v8_target_arch!=host_arch'
                # Host not built with an Arm CXX compiler (simulator build).
228 229 230 231 232 233 234 235 236 237 238
                'conditions': [
                  [ 'arm_float_abi=="hard"', {
                    'defines': [
                      'USE_EABI_HARDFLOAT=1',
                    ],
                  }],
                  [ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
                    'defines': [
                      'USE_EABI_HARDFLOAT=0',
                    ],
                  }],
239 240
                ],
              }],
241
            ],
242 243
          }],  # _toolset=="host"
          ['_toolset=="target"', {
244
            'conditions': [
245
              ['v8_target_arch==target_arch', {
246
                # Target built with an Arm CXX compiler.
247
                'conditions': [
248
                  [ 'arm_version==7', {
249 250
                    'cflags': ['-march=armv7-a',],
                  }],
251
                  [ 'arm_version==7 or arm_version=="default"', {
252
                    'conditions': [
253 254
                      [ 'arm_fpu!="default"', {
                        'cflags': ['-mfpu=<(arm_fpu)',],
255 256 257 258 259 260 261 262 263 264 265 266 267 268
                      }],
                    ],
                  }],
                  [ 'arm_float_abi!="default"', {
                    'cflags': ['-mfloat-abi=<(arm_float_abi)',],
                  }],
                  [ 'arm_thumb==1', {
                    'cflags': ['-mthumb',],
                  }],
                  [ 'arm_thumb==0', {
                    'cflags': ['-marm',],
                  }],
                ],
              }, {
269 270
                # 'v8_target_arch!=target_arch'
                # Target not built with an Arm CXX compiler (simulator build).
271 272
                'conditions': [
                  [ 'arm_float_abi=="hard"', {
273
                    'defines': [
274
                      'USE_EABI_HARDFLOAT=1',
275 276
                    ],
                  }],
277
                  [ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
278
                    'defines': [
279
                      'USE_EABI_HARDFLOAT=0',
280 281 282 283
                    ],
                  }],
                ],
              }],
pcc's avatar
pcc committed
284 285 286 287 288 289
              # Disable GCC LTO for v8
              # v8 is optimized for speed. Because GCC LTO merges flags at link
              # time, we disable LTO to prevent any -O2 flags from taking
              # precedence over v8's -Os flag. However, LLVM LTO does not work
              # this way so we keep LTO enabled under LLVM.
              ['clang==0 and use_lto==1', {
290 291 292 293 294
                'cflags!': [
                  '-flto',
                  '-ffat-lto-objects',
                ],
              }],
295 296
            ],
          }],  # _toolset=="target"
297 298
        ],
      }],  # v8_target_arch=="arm"
299
      ['v8_target_arch=="arm64"', {
300
        'defines': [
301
          'V8_TARGET_ARCH_ARM64',
302 303
        ],
      }],
304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320
      ['v8_target_arch=="s390" or v8_target_arch=="s390x"', {
        'defines': [
          'V8_TARGET_ARCH_S390',
        ],
        'conditions': [
          ['v8_target_arch=="s390x"', {
            'defines': [
              'V8_TARGET_ARCH_S390X',
            ],
          }],
          ['v8_host_byteorder=="little"', {
            'defines': [
              'V8_TARGET_ARCH_S390_LE_SIM',
            ],
          }],
          ],
      }],  # s390
321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
      ['v8_target_arch=="ppc" or v8_target_arch=="ppc64"', {
        'defines': [
          'V8_TARGET_ARCH_PPC',
        ],
        'conditions': [
          ['v8_target_arch=="ppc64"', {
            'defines': [
              'V8_TARGET_ARCH_PPC64',
            ],
          }],
          ['v8_host_byteorder=="little"', {
            'defines': [
              'V8_TARGET_ARCH_PPC_LE',
            ],
          }],
          ['v8_host_byteorder=="big"', {
            'defines': [
              'V8_TARGET_ARCH_PPC_BE',
            ],
340 341 342 343 344 345 346 347 348 349
            'conditions': [
              ['OS=="aix"', {
                # Work around AIX ceil, trunc and round oddities.
                'cflags': [ '-mcpu=power5+ -mfprnd' ],
              }],
              ['OS=="aix"', {
                # Work around AIX assembler popcntb bug.
                'cflags': [ '-mno-popcntb' ],
              }],
            ],
350 351 352
          }],
        ],
      }],  # ppc
353 354 355 356 357
      ['v8_target_arch=="ia32"', {
        'defines': [
          'V8_TARGET_ARCH_IA32',
        ],
      }],  # v8_target_arch=="ia32"
danno@chromium.org's avatar
danno@chromium.org committed
358 359 360 361
      ['v8_target_arch=="x87"', {
        'defines': [
          'V8_TARGET_ARCH_X87',
        ],
362
        'cflags': ['-march=i586'],
danno@chromium.org's avatar
danno@chromium.org committed
363
      }],  # v8_target_arch=="x87"
364
      ['(v8_target_arch=="mips" or v8_target_arch=="mipsel" \
365 366
        or v8_target_arch=="mips64" or v8_target_arch=="mips64el") \
         and v8_target_arch==target_arch', {
367 368 369 370 371 372 373 374 375 376 377 378 379 380
        'target_conditions': [
          ['_toolset=="target"', {
            # Target built with a Mips CXX compiler.
            'variables': {
              'ldso_path%': '<!(/bin/echo -n $LDSO_PATH)',
              'ld_r_path%': '<!(/bin/echo -n $LD_R_PATH)',
            },
            'conditions': [
              ['ldso_path!=""', {
                'ldflags': ['-Wl,--dynamic-linker=<(ldso_path)'],
              }],
              ['ld_r_path!=""', {
                'ldflags': ['-Wl,--rpath=<(ld_r_path)'],
              }],
381 382 383
              [ 'clang==1', {
                'cflags': ['-integrated-as'],
              }],
384 385 386 387
            ],
          }],
        ],
      }],
388 389 390 391 392
      ['v8_target_arch=="mips"', {
        'defines': [
          'V8_TARGET_ARCH_MIPS',
        ],
        'conditions': [
393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411
          [ 'v8_can_use_fpu_instructions=="true"', {
            'defines': [
              'CAN_USE_FPU_INSTRUCTIONS',
            ],
          }],
          [ 'v8_use_mips_abi_hardfloat=="true"', {
            'defines': [
              '__mips_hard_float=1',
              'CAN_USE_FPU_INSTRUCTIONS',
            ],
          }, {
            'defines': [
              '__mips_soft_float=1'
            ]
          }],
        ],
        'target_conditions': [
          ['_toolset=="target"', {
            'conditions': [
412
              ['v8_target_arch==target_arch', {
413
                # Target built with a Mips CXX compiler.
414 415 416 417
                'cflags': [
                  '-EB',
                  '-Wno-error=array-bounds',  # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
                ],
418 419 420 421 422 423 424 425 426
                'ldflags': ['-EB'],
                'conditions': [
                  [ 'v8_use_mips_abi_hardfloat=="true"', {
                    'cflags': ['-mhard-float'],
                    'ldflags': ['-mhard-float'],
                  }, {
                    'cflags': ['-msoft-float'],
                    'ldflags': ['-msoft-float'],
                  }],
427
                  ['mips_arch_variant=="r6"', {
428 429 430 431
                    'defines': [
                      '_MIPS_ARCH_MIPS32R6',
                      'FPU_MODE_FP64',
                    ],
432
                    'cflags!': ['-mfp32', '-mfpxx'],
433 434 435 436 437 438
                    'conditions': [
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips32r6'],
                      }],
                    ],
                    'cflags': ['-mips32r6'],
439
                    'ldflags': ['-mips32r6'],
440
                  }],
441
                  ['mips_arch_variant=="r2"', {
442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463
                    'conditions': [
                      [ 'mips_fpu_mode=="fp64"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FP64',
                        ],
                        'cflags': ['-mfp64'],
                      }],
                      ['mips_fpu_mode=="fpxx"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FPXX',
                        ],
                        'cflags': ['-mfpxx'],
                      }],
                      ['mips_fpu_mode=="fp32"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FP32',
                        ],
                        'cflags': ['-mfp32'],
                      }],
464 465 466
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips32r2'],
                      }],
467
                    ],
468
                    'cflags': ['-mips32r2'],
469
                    'ldflags': ['-mips32r2'],
470
                  }],
471
                  ['mips_arch_variant=="r1"', {
472 473 474
                    'defines': [
                      'FPU_MODE_FP32',
                    ],
475
                    'cflags!': ['-mfp64', '-mfpxx'],
476 477 478 479 480 481
                    'conditions': [
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips32'],
                      }],
                    ],
                    'cflags': ['-mips32'],
482
                    'ldflags': ['-mips32'],
483 484
                  }],
                  ['mips_arch_variant=="rx"', {
485 486 487 488
                    'defines': [
                      '_MIPS_ARCH_MIPS32RX',
                      'FPU_MODE_FPXX',
                    ],
489
                    'cflags!': ['-mfp64', '-mfp32'],
490 491 492 493 494 495
                    'conditions': [
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips32'],
                      }],
                    ],
                    'cflags': ['-mips32', '-mfpxx'],
496
                    'ldflags': ['-mips32'],
497 498
                  }],
                ],
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 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
              }, {
                # 'v8_target_arch!=target_arch'
                # Target not built with an MIPS CXX compiler (simulator build).
                'conditions': [
                  ['mips_arch_variant=="r6"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32R6',
                      'FPU_MODE_FP64',
                    ],
                  }],
                  ['mips_arch_variant=="r2"', {
                    'conditions': [
                      [ 'mips_fpu_mode=="fp64"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FP64',
                        ],
                      }],
                      ['mips_fpu_mode=="fpxx"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FPXX',
                        ],
                      }],
                      ['mips_fpu_mode=="fp32"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FP32',
                        ],
                      }],
                    ],
                  }],
                  ['mips_arch_variant=="r1"', {
                    'defines': [
                      'FPU_MODE_FP32',
                    ],
                  }],
                  ['mips_arch_variant=="rx"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32RX',
                      'FPU_MODE_FPXX',
                    ],
                  }],
                ],
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 587 588 589 590 591 592 593
          }],  #_toolset=="target"
          ['_toolset=="host"', {
            'conditions': [
              ['mips_arch_variant=="rx"', {
                'defines': [
                  '_MIPS_ARCH_MIPS32RX',
                  'FPU_MODE_FPXX',
                ],
              }],
              ['mips_arch_variant=="r6"', {
                'defines': [
                  '_MIPS_ARCH_MIPS32R6',
                  'FPU_MODE_FP64',
                ],
              }],
              ['mips_arch_variant=="r2"', {
                'conditions': [
                  ['mips_fpu_mode=="fp64"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32R2',
                      'FPU_MODE_FP64',
                    ],
                  }],
                  ['mips_fpu_mode=="fpxx"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32R2',
                      'FPU_MODE_FPXX',
                    ],
                  }],
                  ['mips_fpu_mode=="fp32"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32R2',
                      'FPU_MODE_FP32'
                    ],
                  }],
                ],
              }],
              ['mips_arch_variant=="r1"', {
                'defines': ['FPU_MODE_FP32',],
              }],
            ]
          }],  #_toolset=="host"
        ],
      }],  # v8_target_arch=="mips"
      ['v8_target_arch=="mipsel"', {
        'defines': [
          'V8_TARGET_ARCH_MIPS',
        ],
        'conditions': [
594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609
          [ 'v8_can_use_fpu_instructions=="true"', {
            'defines': [
              'CAN_USE_FPU_INSTRUCTIONS',
            ],
          }],
          [ 'v8_use_mips_abi_hardfloat=="true"', {
            'defines': [
              '__mips_hard_float=1',
              'CAN_USE_FPU_INSTRUCTIONS',
            ],
          }, {
            'defines': [
              '__mips_soft_float=1'
            ],
          }],
        ],
610 611 612
        'target_conditions': [
          ['_toolset=="target"', {
            'conditions': [
613
              ['v8_target_arch==target_arch', {
614
                # Target built with a Mips CXX compiler.
615 616 617 618
                'cflags': [
                  '-EL',
                  '-Wno-error=array-bounds',  # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
                ],
619 620 621 622 623 624 625 626 627
                'ldflags': ['-EL'],
                'conditions': [
                  [ 'v8_use_mips_abi_hardfloat=="true"', {
                    'cflags': ['-mhard-float'],
                    'ldflags': ['-mhard-float'],
                  }, {
                    'cflags': ['-msoft-float'],
                    'ldflags': ['-msoft-float'],
                  }],
628
                  ['mips_arch_variant=="r6"', {
629 630 631 632
                    'defines': [
                      '_MIPS_ARCH_MIPS32R6',
                      'FPU_MODE_FP64',
                    ],
633
                    'cflags!': ['-mfp32', '-mfpxx'],
634 635 636 637 638 639
                    'conditions': [
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips32r6'],
                      }],
                    ],
                    'cflags': ['-mips32r6'],
640
                    'ldflags': ['-mips32r6'],
641
                  }],
642
                  ['mips_arch_variant=="r2"', {
643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664
                    'conditions': [
                      [ 'mips_fpu_mode=="fp64"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FP64',
                        ],
                        'cflags': ['-mfp64'],
                      }],
                      ['mips_fpu_mode=="fpxx"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FPXX',
                        ],
                        'cflags': ['-mfpxx'],
                      }],
                      ['mips_fpu_mode=="fp32"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FP32',
                        ],
                        'cflags': ['-mfp32'],
                      }],
665 666 667
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips32r2'],
                      }],
668
                    ],
669
                    'cflags': ['-mips32r2'],
670
                    'ldflags': ['-mips32r2'],
671
                  }],
672
                  ['mips_arch_variant=="r1"', {
673
                    'cflags!': ['-mfp64', '-mfpxx'],
674 675 676 677 678 679
                    'conditions': [
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips32'],
                      }],
                    ],
                    'cflags': ['-mips32'],
680
                    'ldflags': ['-mips32'],
681 682
                  }],
                  ['mips_arch_variant=="rx"', {
683 684 685 686
                    'defines': [
                      '_MIPS_ARCH_MIPS32RX',
                      'FPU_MODE_FPXX',
                    ],
687
                    'cflags!': ['-mfp64', '-mfp32'],
688 689 690 691 692 693
                    'conditions': [
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips32'],
                      }],
                    ],
                    'cflags': ['-mips32', '-mfpxx'],
694
                    'ldflags': ['-mips32'],
695
                  }],
696
                  ['mips_arch_variant=="loongson"', {
697 698 699 700
                    'defines': [
                      '_MIPS_ARCH_LOONGSON',
                      'FPU_MODE_FP32',
                    ],
701
                    'cflags!': ['-mfp64', '-mfpxx'],
702 703 704 705 706 707
                    'conditions': [
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips3'],
                      }],
                    ],
                    'cflags': ['-mips3', '-mfp32'],
708
                  }],
709
                ],
710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759
              }, {
                # 'v8_target_arch!=target_arch'
                # Target not built with an MIPS CXX compiler (simulator build).
                'conditions': [
                  ['mips_arch_variant=="r6"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32R6',
                      'FPU_MODE_FP64',
                    ],
                  }],
                  ['mips_arch_variant=="r2"', {
                    'conditions': [
                      [ 'mips_fpu_mode=="fp64"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FP64',
                        ],
                      }],
                      ['mips_fpu_mode=="fpxx"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FPXX',
                        ],
                      }],
                      ['mips_fpu_mode=="fp32"', {
                        'defines': [
                          '_MIPS_ARCH_MIPS32R2',
                          'FPU_MODE_FP32',
                        ],
                      }],
                    ],
                  }],
                  ['mips_arch_variant=="r1"', {
                    'defines': [
                      'FPU_MODE_FP32',
                    ],
                  }],
                  ['mips_arch_variant=="rx"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32RX',
                      'FPU_MODE_FPXX',
                    ],
                  }],
                  ['mips_arch_variant=="loongson"', {
                    'defines': [
                      '_MIPS_ARCH_LOONGSON',
                      'FPU_MODE_FP32',
                    ],
                  }],
                ],
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
          }], #_toolset=="target
          ['_toolset=="host"', {
            'conditions': [
              ['mips_arch_variant=="rx"', {
                'defines': [
                  '_MIPS_ARCH_MIPS32RX',
                  'FPU_MODE_FPXX',
                ],
              }],
              ['mips_arch_variant=="r6"', {
                'defines': [
                  '_MIPS_ARCH_MIPS32R6',
                  'FPU_MODE_FP64',
                ],
              }],
              ['mips_arch_variant=="r2"', {
                'conditions': [
                  ['mips_fpu_mode=="fp64"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32R2',
                      'FPU_MODE_FP64',
                    ],
                  }],
                  ['mips_fpu_mode=="fpxx"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32R2',
                      'FPU_MODE_FPXX',
                    ],
                  }],
                  ['mips_fpu_mode=="fp32"', {
                    'defines': [
                      '_MIPS_ARCH_MIPS32R2',
                      'FPU_MODE_FP32'
                    ],
                  }],
                ],
              }],
              ['mips_arch_variant=="r1"', {
                'defines': ['FPU_MODE_FP32',],
              }],
              ['mips_arch_variant=="loongson"', {
                'defines': [
                  '_MIPS_ARCH_LOONGSON',
                  'FPU_MODE_FP32',
                ],
              }],
            ]
809
          }],
810 811
        ],
      }],  # v8_target_arch=="mipsel"
812
      ['v8_target_arch=="mips64el" or v8_target_arch=="mips64"', {
813 814 815 816
        'defines': [
          'V8_TARGET_ARCH_MIPS64',
        ],
        'conditions': [
817
          [ 'v8_can_use_fpu_instructions=="true"', {
818
            'defines': [
819
              'CAN_USE_FPU_INSTRUCTIONS',
820 821
            ],
          }],
822 823 824 825 826 827 828 829 830 831
          [ 'v8_host_byteorder=="little"', {
            'defines': [
              'V8_TARGET_ARCH_MIPS64_LE',
            ],
          }],
          [ 'v8_host_byteorder=="big"', {
            'defines': [
              'V8_TARGET_ARCH_MIPS64_BE',
            ],
          }],
832 833 834 835 836 837 838 839 840
          [ 'v8_use_mips_abi_hardfloat=="true"', {
            'defines': [
              '__mips_hard_float=1',
              'CAN_USE_FPU_INSTRUCTIONS',
            ],
          }, {
            'defines': [
              '__mips_soft_float=1'
            ],
841
          }],
842 843 844
         ],
        'target_conditions': [
          ['_toolset=="target"', {
845
            'conditions': [
846
              ['v8_target_arch==target_arch', {
847 848 849
                'cflags': [
                  '-Wno-error=array-bounds',  # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
                ],
850
                'conditions': [
851 852 853 854 855 856 857 858
                  ['v8_target_arch=="mips64el"', {
                    'cflags': ['-EL'],
                    'ldflags': ['-EL'],
                  }],
                  ['v8_target_arch=="mips64"', {
                    'cflags': ['-EB'],
                    'ldflags': ['-EB'],
                  }],
859 860 861 862 863 864 865
                  [ 'v8_use_mips_abi_hardfloat=="true"', {
                    'cflags': ['-mhard-float'],
                    'ldflags': ['-mhard-float'],
                  }, {
                    'cflags': ['-msoft-float'],
                    'ldflags': ['-msoft-float'],
                  }],
866
                  ['mips_arch_variant=="r6"', {
867
                    'defines': ['_MIPS_ARCH_MIPS64R6',],
868 869 870 871 872 873
                    'conditions': [
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips64r6'],
                      }],
                    ],
                    'cflags': ['-mips64r6', '-mabi=64'],
874
                    'ldflags': ['-mips64r6', '-mabi=64'],
875
                  }],
876
                  ['mips_arch_variant=="r2"', {
877
                    'defines': ['_MIPS_ARCH_MIPS64R2',],
878 879 880 881 882 883
                    'conditions': [
                      [ 'clang==0', {
                        'cflags': ['-Wa,-mips64r2'],
                      }],
                    ],
                    'cflags': ['-mips64r2', '-mabi=64'],
884
                    'ldflags': ['-mips64r2', '-mabi=64'],
885 886
                  }],
                ],
887 888 889 890 891 892 893 894 895 896 897
              }, {
                # 'v8_target_arch!=target_arch'
                # Target not built with an MIPS CXX compiler (simulator build).
                'conditions': [
                  ['mips_arch_variant=="r6"', {
                    'defines': ['_MIPS_ARCH_MIPS64R6',],
                  }],
                  ['mips_arch_variant=="r2"', {
                    'defines': ['_MIPS_ARCH_MIPS64R2',],
                  }],
                ],
898 899
              }],
            ],
900 901 902 903 904 905 906 907 908
          }],  #'_toolset=="target"
          ['_toolset=="host"', {
            'conditions': [
              ['mips_arch_variant=="r6"', {
                'defines': ['_MIPS_ARCH_MIPS64R6',],
              }],
              ['mips_arch_variant=="r2"', {
                'defines': ['_MIPS_ARCH_MIPS64R2',],
              }],
909
            ],
910
          }],  #'_toolset=="host"
911 912
        ],
      }],  # v8_target_arch=="mips64el"
913 914 915 916 917 918 919 920 921
      ['v8_target_arch=="x64"', {
        'defines': [
          'V8_TARGET_ARCH_X64',
        ],
        'xcode_settings': {
          'ARCHS': [ 'x86_64' ],
        },
        'msvs_settings': {
          'VCLinkerTool': {
922
            'StackReserveSize': '2097152',
923 924
          },
        },
925
        'msvs_configuration_platform': 'x64',
926
      }],  # v8_target_arch=="x64"
927 928 929 930 931 932 933 934 935 936 937 938 939 940 941
      ['v8_target_arch=="x32"', {
        'defines': [
          # x32 port shares the source code with x64 port.
          'V8_TARGET_ARCH_X64',
          'V8_TARGET_ARCH_32_BIT',
        ],
        'cflags': [
          '-mx32',
          # Inhibit warning if long long type is used.
          '-Wno-long-long',
        ],
        'ldflags': [
          '-mx32',
        ],
      }],  # v8_target_arch=="x32"
942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961
      ['linux_use_gold_flags==1', {
        # Newer gccs and clangs support -fuse-ld, use the flag to force gold
        # selection.
        # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html
        'ldflags': [ '-fuse-ld=gold', ],
      }],
      ['linux_use_bundled_binutils==1', {
        'cflags': [
          '-B<!(cd <(DEPTH) && pwd -P)/<(binutils_dir)',
        ],
      }],
      ['linux_use_bundled_gold==1', {
        # Put our binutils, which contains gold in the search path. We pass
        # the path to gold to the compiler. gyp leaves unspecified what the
        # cwd is when running the compiler, so the normal gyp path-munging
        # fails us. This hack gets the right path.
        'ldflags': [
          '-B<!(cd <(DEPTH) && pwd -P)/<(binutils_dir)',
        ],
      }],
962 963 964 965
      ['OS=="win"', {
        'defines': [
          'WIN32',
        ],
966 967 968
        # 4351: VS 2005 and later are warning us that they've fixed a bug
        #       present in VS 2003 and earlier.
        'msvs_disabled_warnings': [4351],
969 970 971 972 973
        'msvs_configuration_attributes': {
          'OutputDirectory': '<(DEPTH)\\build\\$(ConfigurationName)',
          'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
          'CharacterSet': '1',
        },
974 975
      }],
      ['OS=="win" and v8_target_arch=="ia32"', {
976 977 978 979 980 981
        'msvs_settings': {
          'VCCLCompilerTool': {
            # Ensure no surprising artifacts from 80bit double math with x86.
            'AdditionalOptions': ['/arch:SSE2'],
          },
        },
982
      }],
983 984 985 986 987 988 989
      ['OS=="win" and v8_enable_prof==1', {
        'msvs_settings': {
          'VCLinkerTool': {
            'GenerateMapFile': 'true',
          },
        },
      }],
bmeurer's avatar
bmeurer committed
990 991 992 993 994 995 996 997 998
      ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
         or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
        v8_target_arch=="ia32"', {
        'cflags': [
          '-msse2',
          '-mfpmath=sse',
          '-mmmx',  # Allows mmintrin.h for MMX intrinsics.
        ],
      }],
999
      ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
1000
         or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
1001 1002
        (v8_target_arch=="arm" or v8_target_arch=="ia32" or \
         v8_target_arch=="x87" or v8_target_arch=="mips" or \
1003 1004
         v8_target_arch=="mipsel" or v8_target_arch=="ppc" or \
         v8_target_arch=="s390")', {
1005 1006
        'target_conditions': [
          ['_toolset=="host"', {
1007 1008
            'conditions': [
              ['host_cxx_is_biarch==1', {
1009 1010 1011 1012 1013 1014 1015 1016 1017
                'conditions': [
                  ['host_arch=="s390" or host_arch=="s390x"', {
                    'cflags': [ '-m31' ],
                    'ldflags': [ '-m31' ]
                  },{
                   'cflags': [ '-m32' ],
                   'ldflags': [ '-m32' ]
                  }],
                ],
1018 1019
              }],
            ],
1020 1021 1022
            'xcode_settings': {
              'ARCHS': [ 'i386' ],
            },
1023 1024
          }],
          ['_toolset=="target"', {
1025
            'conditions': [
1026
              ['target_cxx_is_biarch==1 and nacl_target_arch!="nacl_x64"', {
1027 1028 1029 1030 1031 1032 1033 1034 1035
                'conditions': [
                  ['host_arch=="s390" or host_arch=="s390x"', {
                    'cflags': [ '-m31' ],
                    'ldflags': [ '-m31' ]
                  },{
                   'cflags': [ '-m32' ],
                   'ldflags': [ '-m32' ],
                  }],
                ],
1036 1037
              }],
            ],
1038 1039 1040
            'xcode_settings': {
              'ARCHS': [ 'i386' ],
            },
1041 1042 1043
          }],
        ],
      }],
1044
      ['(OS=="linux" or OS=="android") and \
1045
        (v8_target_arch=="x64" or v8_target_arch=="arm64" or \
1046
         v8_target_arch=="ppc64" or v8_target_arch=="s390x")', {
1047 1048
        'target_conditions': [
          ['_toolset=="host"', {
1049
            'conditions': [
1050 1051 1052
              ['host_cxx_is_biarch==1', {
                'cflags': [ '-m64' ],
                'ldflags': [ '-m64' ]
1053
              }],
1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066
             ],
           }],
           ['_toolset=="target"', {
             'conditions': [
               ['target_cxx_is_biarch==1', {
                 'cflags': [ '-m64' ],
                 'ldflags': [ '-m64' ],
               }],
             ]
           }],
         ],
      }],
      ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
1067
         or OS=="netbsd" or OS=="qnx" or OS=="aix"', {
1068 1069 1070 1071 1072 1073 1074 1075
        'conditions': [
          [ 'v8_no_strict_aliasing==1', {
            'cflags': [ '-fno-strict-aliasing' ],
          }],
        ],  # conditions
      }],
      ['OS=="solaris"', {
        'defines': [ '__C99FEATURES__=1' ],  # isinf() etc.
1076
      }],
1077 1078 1079 1080 1081 1082
      ['OS=="freebsd" or OS=="openbsd"', {
        'cflags': [ '-I/usr/local/include' ],
      }],
      ['OS=="netbsd"', {
        'cflags': [ '-I/usr/pkg/include' ],
      }],
1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097
      ['OS=="aix"', {
        'defines': [
          # Support for malloc(0)
          '_LINUX_SOURCE_COMPAT=1',
          '_ALL_SOURCE=1'],
        'conditions': [
          [ 'v8_target_arch=="ppc"', {
            'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ],
          }],
          [ 'v8_target_arch=="ppc64"', {
            'cflags': [ '-maix64' ],
            'ldflags': [ '-maix64' ],
          }],
        ],
      }],
1098
    ],  # conditions
1099
    'configurations': {
1100 1101 1102
      # Abstract configuration for v8_optimized_debug == 0.
      'DebugBase0': {
        'abstract': 1,
1103 1104
        'msvs_settings': {
          'VCCLCompilerTool': {
1105
            'Optimization': '0',
1106
            'conditions': [
1107 1108 1109 1110
              ['component=="shared_library"', {
                'RuntimeLibrary': '3',  # /MDd
              }, {
                'RuntimeLibrary': '1',  # /MTd
1111
              }],
1112 1113 1114
            ],
          },
          'VCLinkerTool': {
1115 1116 1117
            'LinkIncremental': '2',
          },
        },
1118 1119 1120
        'variables': {
          'v8_enable_slow_dchecks%': 1,
        },
1121 1122
        'conditions': [
          ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
1123
            OS=="qnx" or OS=="aix"', {
1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139
            'cflags!': [
              '-O3',
              '-O2',
              '-O1',
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
            ],
          }],
          ['OS=="mac"', {
            'xcode_settings': {
               'GCC_OPTIMIZATION_LEVEL': '0',  # -O0
            },
          }],
1140 1141 1142 1143 1144
          ['v8_enable_slow_dchecks==1', {
            'defines': [
              'ENABLE_SLOW_DCHECKS',
            ],
          }],
1145
        ],
1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162
      },  # DebugBase0
      # Abstract configuration for v8_optimized_debug == 1.
      'DebugBase1': {
        'abstract': 1,
        'msvs_settings': {
          'VCCLCompilerTool': {
            'Optimization': '2',
            'InlineFunctionExpansion': '2',
            'EnableIntrinsicFunctions': 'true',
            'FavorSizeOrSpeed': '0',
            'StringPooling': 'true',
            'BasicRuntimeChecks': '0',
            'conditions': [
              ['component=="shared_library"', {
                'RuntimeLibrary': '3',  #/MDd
              }, {
                'RuntimeLibrary': '1',  #/MTd
1163
              }],
1164 1165 1166 1167 1168 1169 1170 1171
            ],
          },
          'VCLinkerTool': {
            'LinkIncremental': '1',
            'OptimizeReferences': '2',
            'EnableCOMDATFolding': '2',
          },
        },
1172 1173 1174
        'variables': {
          'v8_enable_slow_dchecks%': 0,
        },
1175 1176
        'conditions': [
          ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
1177
            OS=="qnx" or OS=="aix"', {
1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188
            'cflags!': [
              '-O0',
              '-O1',
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
            ],
            'conditions': [
              # TODO(crbug.com/272548): Avoid -O3 in NaCl
1189 1190 1191
              # Don't use -O3 with sanitizers.
              ['nacl_target_arch=="none" and asan==0 and msan==0 and lsan==0 \
                and tsan==0 and ubsan==0 and ubsan_vptr==0', {
1192 1193 1194 1195 1196
                'cflags': ['-O3'],
                'cflags!': ['-O2'],
                }, {
                'cflags': ['-O2'],
                'cflags!': ['-O3'],
1197 1198
              }],
            ],
1199
          }],
1200 1201 1202 1203 1204 1205
          ['OS=="mac"', {
            'xcode_settings': {
              'GCC_OPTIMIZATION_LEVEL': '3',  # -O3
              'GCC_STRICT_ALIASING': 'YES',
            },
          }],
1206 1207 1208 1209 1210
          ['v8_enable_slow_dchecks==1', {
            'defines': [
              'ENABLE_SLOW_DCHECKS',
            ],
          }],
1211
        ],
1212
      },  # DebugBase1
1213 1214 1215 1216 1217 1218 1219 1220
      # Common settings for the Debug configuration.
      'DebugBaseCommon': {
        'abstract': 1,
        'defines': [
          'ENABLE_DISASSEMBLER',
          'V8_ENABLE_CHECKS',
          'OBJECT_PRINT',
          'VERIFY_HEAP',
1221 1222
          'DEBUG',
          'TRACE_MAPS'
1223 1224 1225
        ],
        'conditions': [
          ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
1226
            OS=="qnx" or OS=="aix"', {
1227 1228
            'cflags': [ '-Woverloaded-virtual', '<(wno_array_bounds)', ],
          }],
1229 1230 1231 1232
          ['OS=="linux" and v8_enable_backtrace==1', {
            # Support for backtrace_symbols.
            'ldflags': [ '-rdynamic' ],
          }],
1233 1234 1235 1236 1237
          ['OS=="linux" and disable_glibcxx_debug==0', {
            # Enable libstdc++ debugging facilities to help catch problems
            # early, see http://crbug.com/65151 .
            'defines': ['_GLIBCXX_DEBUG=1',],
          }],
1238 1239
          ['OS=="aix"', {
            'ldflags': [ '-Wl,-bbigtoc' ],
1240 1241 1242 1243 1244
            'conditions': [
              ['v8_target_arch=="ppc64"', {
                'cflags': [ '-maix64 -mcmodel=large' ],
              }],
            ],
1245
          }],
1246 1247 1248 1249 1250 1251 1252 1253 1254 1255
          ['OS=="android"', {
            'variables': {
              'android_full_debug%': 1,
            },
            'conditions': [
              ['android_full_debug==0', {
                # Disable full debug if we want a faster v8 in a debug build.
                # TODO(2304): pass DISABLE_DEBUG_ASSERT instead of hiding DEBUG.
                'defines!': [
                  'DEBUG',
1256
                  'ENABLE_SLOW_DCHECKS',
1257 1258 1259 1260
                ],
              }],
            ],
          }],
1261 1262 1263
          # TODO(pcc): Re-enable in LTO builds once we've fixed the intermittent
          # link failures (crbug.com/513074).
          ['linux_use_gold_flags==1 and use_lto==0', {
1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277
            'target_conditions': [
              ['_toolset=="target"', {
                'ldflags': [
                  # Experimentation found that using four linking threads
                  # saved ~20% of link time.
                  # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
                  # Only apply this to the target linker, since the host
                  # linker might not be gold, but isn't used much anyway.
                  '-Wl,--threads',
                  '-Wl,--thread-count=4',
                ],
              }],
            ],
          }],
1278 1279 1280 1281 1282 1283 1284
        ],
      },  # DebugBaseCommon
      'Debug': {
        'inherit_from': ['DebugBaseCommon'],
        'conditions': [
          ['v8_optimized_debug==0', {
            'inherit_from': ['DebugBase0'],
1285
          }, {
1286 1287
            'inherit_from': ['DebugBase1'],
          }],
1288
        ],
1289
      },  # Debug
1290
      'Release': {
1291 1292 1293
        'variables': {
          'v8_enable_slow_dchecks%': 0,
        },
1294
        'conditions': [
1295 1296
          ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \
            or OS=="aix"', {
1297 1298 1299 1300 1301 1302
            'cflags!': [
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
1303
              '<(wno_array_bounds)',
1304 1305
            ],
            'conditions': [
1306
              # TODO(crbug.com/272548): Avoid -O3 in NaCl
1307 1308 1309
              # Don't use -O3 with sanitizers.
              ['nacl_target_arch=="none" and asan==0 and msan==0 and lsan==0 \
                and tsan==0 and ubsan==0 and ubsan_vptr==0', {
1310 1311 1312 1313 1314 1315
                'cflags': ['-O3'],
                'cflags!': ['-O2'],
              }, {
                'cflags': ['-O2'],
                'cflags!': ['-O3'],
              }],
1316 1317
            ],
          }],
1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328
          ['OS=="android"', {
            'cflags!': [
              '-O3',
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
              '-O2',
            ],
          }],
1329 1330 1331 1332 1333 1334 1335 1336 1337 1338
          ['OS=="mac"', {
            'xcode_settings': {
              'GCC_OPTIMIZATION_LEVEL': '3',  # -O3

              # -fstrict-aliasing.  Mainline gcc
              # enables this at -O2 and above,
              # but Apple gcc does not unless it
              # is specified explicitly.
              'GCC_STRICT_ALIASING': 'YES',
            },
1339
          }],  # OS=="mac"
1340 1341 1342 1343 1344 1345 1346 1347 1348
          ['OS=="win"', {
            'msvs_settings': {
              'VCCLCompilerTool': {
                'Optimization': '2',
                'InlineFunctionExpansion': '2',
                'EnableIntrinsicFunctions': 'true',
                'FavorSizeOrSpeed': '0',
                'StringPooling': 'true',
                'conditions': [
1349
                  ['component=="shared_library"', {
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361
                    'RuntimeLibrary': '2',  #/MD
                  }, {
                    'RuntimeLibrary': '0',  #/MT
                  }],
                ],
              },
              'VCLinkerTool': {
                'LinkIncremental': '1',
                'OptimizeReferences': '2',
                'EnableCOMDATFolding': '2',
              },
            },
1362
          }],  # OS=="win"
1363 1364 1365 1366 1367
          ['v8_enable_slow_dchecks==1', {
            'defines': [
              'ENABLE_SLOW_DCHECKS',
            ],
          }],
1368 1369 1370 1371
        ],  # conditions
      },  # Release
    },  # configurations
  },  # target_defaults
1372
}