toolchain.gypi 32.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 33
    'msvs_use_common_release': 0,
    'gcc_version%': 'unknown',
34
    'clang%': 0,
35
    'v8_target_arch%': '<(target_arch)',
36 37 38 39 40 41 42
    # 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
43

44 45 46 47 48 49
    # 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',
50
    'arm_test_noprobe%': 'off',
51

52 53 54 55 56 57
    # 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',

58
    # Default arch variant for MIPS.
59
    'mips_arch_variant%': 'r2',
60

61 62 63 64 65 66 67 68
    # 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',

69
    'v8_enable_backtrace%': 0,
70

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

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

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

81 82 83 84 85
    # 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',

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

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

94 95 96
    # Link-Time Optimizations
    'use_lto%': 0,

97 98 99 100
    'variables': {
      # This is set when building the Android WebView inside the Android build
      # system, using the 'android' gyp backend.
      'android_webview_build%': 0,
101 102 103
    },
    # Copy it out one scope.
    'android_webview_build%': '<(android_webview_build)',
104
  },
105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125
  'conditions': [
    ['host_arch=="ia32" or host_arch=="x64" or clang==1', {
      'variables': {
        'host_cxx_is_biarch%': 1,
       },
     }, {
      'variables': {
        'host_cxx_is_biarch%': 0,
      },
    }],
    ['target_arch=="ia32" or target_arch=="x64" or target_arch=="x87" or \
      clang==1', {
      'variables': {
        'target_cxx_is_biarch%': 1,
       },
     }, {
      'variables': {
        'target_cxx_is_biarch%': 0,
      },
    }],
  ],
126
  'target_defaults': {
127
    'conditions': [
128 129 130 131
      ['v8_target_arch=="arm"', {
        'defines': [
          'V8_TARGET_ARCH_ARM',
        ],
132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161
        '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',
            ],
          }],
        ],
162 163 164
        'target_conditions': [
          ['_toolset=="host"', {
            'conditions': [
165
              ['v8_target_arch==host_arch and android_webview_build==0', {
166
                # Host built with an Arm CXX compiler.
167
                'conditions': [
168
                  [ 'arm_version==7', {
169 170
                    'cflags': ['-march=armv7-a',],
                  }],
171
                  [ 'arm_version==7 or arm_version=="default"', {
172
                    'conditions': [
173 174
                      [ 'arm_fpu!="default"', {
                        'cflags': ['-mfpu=<(arm_fpu)',],
175
                      }],
176
                    ],
177 178 179 180 181 182 183 184 185 186
                  }],
                  [ 'arm_float_abi!="default"', {
                    'cflags': ['-mfloat-abi=<(arm_float_abi)',],
                  }],
                  [ 'arm_thumb==1', {
                    'cflags': ['-mthumb',],
                  }],
                  [ 'arm_thumb==0', {
                    'cflags': ['-marm',],
                  }],
187 188
                ],
              }, {
189 190
                # 'v8_target_arch!=host_arch'
                # Host not built with an Arm CXX compiler (simulator build).
191 192 193 194 195 196 197 198 199 200 201
                'conditions': [
                  [ 'arm_float_abi=="hard"', {
                    'defines': [
                      'USE_EABI_HARDFLOAT=1',
                    ],
                  }],
                  [ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
                    'defines': [
                      'USE_EABI_HARDFLOAT=0',
                    ],
                  }],
202 203
                ],
              }],
204
            ],
205 206
          }],  # _toolset=="host"
          ['_toolset=="target"', {
207
            'conditions': [
208
              ['v8_target_arch==target_arch and android_webview_build==0', {
209
                # Target built with an Arm CXX compiler.
210
                'conditions': [
211
                  [ 'arm_version==7', {
212 213
                    'cflags': ['-march=armv7-a',],
                  }],
214
                  [ 'arm_version==7 or arm_version=="default"', {
215
                    'conditions': [
216 217
                      [ 'arm_fpu!="default"', {
                        'cflags': ['-mfpu=<(arm_fpu)',],
218 219 220 221 222 223 224 225 226 227 228 229 230 231
                      }],
                    ],
                  }],
                  [ 'arm_float_abi!="default"', {
                    'cflags': ['-mfloat-abi=<(arm_float_abi)',],
                  }],
                  [ 'arm_thumb==1', {
                    'cflags': ['-mthumb',],
                  }],
                  [ 'arm_thumb==0', {
                    'cflags': ['-marm',],
                  }],
                ],
              }, {
232 233
                # 'v8_target_arch!=target_arch'
                # Target not built with an Arm CXX compiler (simulator build).
234 235
                'conditions': [
                  [ 'arm_float_abi=="hard"', {
236
                    'defines': [
237
                      'USE_EABI_HARDFLOAT=1',
238 239
                    ],
                  }],
240
                  [ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
241
                    'defines': [
242
                      'USE_EABI_HARDFLOAT=0',
243 244 245 246
                    ],
                  }],
                ],
              }],
247 248 249 250 251 252 253 254 255
              # Disable LTO for v8
              # v8 is optimized for speed, which takes precedence over
              # size optimization in LTO.
              ['use_lto==1', {
                'cflags!': [
                  '-flto',
                  '-ffat-lto-objects',
                ],
              }],
256 257
            ],
          }],  # _toolset=="target"
258 259
        ],
      }],  # v8_target_arch=="arm"
260
      ['v8_target_arch=="arm64"', {
261
        'defines': [
262
          'V8_TARGET_ARCH_ARM64',
263 264
        ],
      }],
265 266 267 268 269
      ['v8_target_arch=="ia32"', {
        'defines': [
          'V8_TARGET_ARCH_IA32',
        ],
      }],  # v8_target_arch=="ia32"
danno@chromium.org's avatar
danno@chromium.org committed
270 271 272 273
      ['v8_target_arch=="x87"', {
        'defines': [
          'V8_TARGET_ARCH_X87',
        ],
274
        'cflags': ['-march=i586'],
danno@chromium.org's avatar
danno@chromium.org committed
275
      }],  # v8_target_arch=="x87"
276 277 278 279 280
      ['v8_target_arch=="mips"', {
        'defines': [
          'V8_TARGET_ARCH_MIPS',
        ],
        'conditions': [
281
          ['v8_target_arch==target_arch and android_webview_build==0', {
282
            # Target built with a Mips CXX compiler.
283 284 285 286 287 288 289 290 291 292 293 294
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': ['-EB'],
                'ldflags': ['-EB'],
                'conditions': [
                  [ 'v8_use_mips_abi_hardfloat=="true"', {
                    'cflags': ['-mhard-float'],
                    'ldflags': ['-mhard-float'],
                  }, {
                    'cflags': ['-msoft-float'],
                    'ldflags': ['-msoft-float'],
                  }],
295 296 297 298 299 300 301 302 303 304
                  ['mips_fpu_mode=="fp64"', {
                    'cflags': ['-mfp64'],
                  }],
                  ['mips_fpu_mode=="fpxx"', {
                    'cflags': ['-mfpxx'],
                  }],
                  ['mips_fpu_mode=="fp32"', {
                    'cflags': ['-mfp32'],
                  }],
                  ['mips_arch_variant=="r6"', {
305
                    'cflags!': ['-mfp32', '-mfpxx'],
306 307 308 309 310 311 312
                    'cflags': ['-mips32r6', '-Wa,-mips32r6'],
                    'ldflags': [
                      '-mips32r6',
                      '-Wl,--dynamic-linker=$(LDSO_PATH)',
                      '-Wl,--rpath=$(LD_R_PATH)',
                    ],
                  }],
313
                  ['mips_arch_variant=="r2"', {
314
                    'cflags': ['-mips32r2', '-Wa,-mips32r2'],
315
                    'ldflags': ['-mips32r2'],
316
                  }],
317
                  ['mips_arch_variant=="r1"', {
318
                    'cflags!': ['-mfp64', '-mfpxx'],
319
                    'cflags': ['-mips32', '-Wa,-mips32'],
320
                    'ldflags': ['-mips32'],
321 322
                  }],
                  ['mips_arch_variant=="rx"', {
323 324 325
                    'cflags!': ['-mfp64', '-mfp32'],
                    'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'],
                    'ldflags': ['-mips32'],
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345
                  }],
                ],
              }],
            ],
          }],
          [ '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'
            ],
          }],
346 347 348 349 350 351 352 353 354 355 356 357
          ['mips_arch_variant=="rx"', {
            'defines': [
              '_MIPS_ARCH_MIPS32RX',
              'FPU_MODE_FPXX',
            ],
          }],
          ['mips_arch_variant=="r6"', {
            'defines': [
              '_MIPS_ARCH_MIPS32R6',
              'FPU_MODE_FP64',
            ],
          }],
358
          ['mips_arch_variant=="r2"', {
359
            'defines': ['_MIPS_ARCH_MIPS32R2',],
360 361 362 363 364 365 366 367 368 369 370 371 372 373
            'conditions': [
              ['mips_fpu_mode=="fp64"', {
                'defines': ['FPU_MODE_FP64',],
              }],
              ['mips_fpu_mode=="fpxx"', {
                'defines': ['FPU_MODE_FPXX',],
              }],
              ['mips_fpu_mode=="fp32"', {
                'defines': ['FPU_MODE_FP32',],
              }],
            ],
          }],
          ['mips_arch_variant=="r1"', {
            'defines': ['FPU_MODE_FP32',],
374 375 376
          }],
        ],
      }],  # v8_target_arch=="mips"
377
      ['v8_target_arch=="mipsel"', {
378 379 380 381
        'defines': [
          'V8_TARGET_ARCH_MIPS',
        ],
        'conditions': [
382
          ['v8_target_arch==target_arch and android_webview_build==0', {
383
            # Target built with a Mips CXX compiler.
384 385 386 387 388 389 390 391 392 393 394 395
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': ['-EL'],
                'ldflags': ['-EL'],
                'conditions': [
                  [ 'v8_use_mips_abi_hardfloat=="true"', {
                    'cflags': ['-mhard-float'],
                    'ldflags': ['-mhard-float'],
                  }, {
                    'cflags': ['-msoft-float'],
                    'ldflags': ['-msoft-float'],
                  }],
396 397 398 399 400 401 402 403 404 405
                  ['mips_fpu_mode=="fp64"', {
                    'cflags': ['-mfp64'],
                  }],
                  ['mips_fpu_mode=="fpxx"', {
                    'cflags': ['-mfpxx'],
                  }],
                  ['mips_fpu_mode=="fp32"', {
                    'cflags': ['-mfp32'],
                  }],
                  ['mips_arch_variant=="r6"', {
406
                    'cflags!': ['-mfp32', '-mfpxx'],
407 408 409 410 411 412 413
                    'cflags': ['-mips32r6', '-Wa,-mips32r6'],
                    'ldflags': [
                      '-mips32r6',
                      '-Wl,--dynamic-linker=$(LDSO_PATH)',
                      '-Wl,--rpath=$(LD_R_PATH)',
                    ],
                  }],
414
                  ['mips_arch_variant=="r2"', {
415
                    'cflags': ['-mips32r2', '-Wa,-mips32r2'],
416
                    'ldflags': ['-mips32r2'],
417
                  }],
418
                  ['mips_arch_variant=="r1"', {
419
                    'cflags!': ['-mfp64', '-mfpxx'],
420
                    'cflags': ['-mips32', '-Wa,-mips32'],
421
                    'ldflags': ['-mips32'],
422 423
                  }],
                  ['mips_arch_variant=="rx"', {
424 425 426
                    'cflags!': ['-mfp64', '-mfp32'],
                    'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'],
                    'ldflags': ['-mips32'],
427
                  }],
428
                  ['mips_arch_variant=="loongson"', {
429
                    'cflags!': ['-mfp64', '-mfp32', '-mfpxx'],
430 431
                    'cflags': ['-mips3', '-Wa,-mips3'],
                  }],
432 433 434
                ],
              }],
            ],
435
          }],
436
          [ 'v8_can_use_fpu_instructions=="true"', {
437
            'defines': [
438
              'CAN_USE_FPU_INSTRUCTIONS',
439 440
            ],
          }],
441 442 443 444 445 446 447 448 449
          [ 'v8_use_mips_abi_hardfloat=="true"', {
            'defines': [
              '__mips_hard_float=1',
              'CAN_USE_FPU_INSTRUCTIONS',
            ],
          }, {
            'defines': [
              '__mips_soft_float=1'
            ],
450
          }],
451 452 453 454 455 456 457 458 459 460 461 462
          ['mips_arch_variant=="rx"', {
            'defines': [
              '_MIPS_ARCH_MIPS32RX',
              'FPU_MODE_FPXX',
            ],
          }],
          ['mips_arch_variant=="r6"', {
            'defines': [
              '_MIPS_ARCH_MIPS32R6',
               'FPU_MODE_FP64',
            ],
          }],
463
          ['mips_arch_variant=="r2"', {
464
            'defines': ['_MIPS_ARCH_MIPS32R2',],
465 466 467 468 469 470 471 472 473 474 475 476 477 478
            'conditions': [
              ['mips_fpu_mode=="fp64"', {
                'defines': ['FPU_MODE_FP64',],
              }],
              ['mips_fpu_mode=="fpxx"', {
                'defines': ['FPU_MODE_FPXX',],
              }],
              ['mips_fpu_mode=="fp32"', {
                'defines': ['FPU_MODE_FP32',],
              }],
            ],
          }],
          ['mips_arch_variant=="r1"', {
            'defines': ['FPU_MODE_FP32',],
479 480
          }],
          ['mips_arch_variant=="loongson"', {
481 482 483 484
            'defines': [
              '_MIPS_ARCH_LOONGSON',
              'FPU_MODE_FP32',
            ],
485 486
          }],
        ],
487
      }],  # v8_target_arch=="mipsel"
488 489 490 491 492
      ['v8_target_arch=="mips64el"', {
        'defines': [
          'V8_TARGET_ARCH_MIPS64',
        ],
        'conditions': [
493
          ['v8_target_arch==target_arch and android_webview_build==0', {
494
            # Target built with a Mips CXX compiler.
495 496 497 498 499 500 501 502 503 504 505 506
            'target_conditions': [
              ['_toolset=="target"', {
                'cflags': ['-EL'],
                'ldflags': ['-EL'],
                'conditions': [
                  [ 'v8_use_mips_abi_hardfloat=="true"', {
                    'cflags': ['-mhard-float'],
                    'ldflags': ['-mhard-float'],
                  }, {
                    'cflags': ['-msoft-float'],
                    'ldflags': ['-msoft-float'],
                  }],
507 508 509 510 511 512 513 514
                  ['mips_arch_variant=="r6"', {
                    'cflags': ['-mips64r6', '-mabi=64', '-Wa,-mips64r6'],
                    'ldflags': [
                      '-mips64r6', '-mabi=64',
                      '-Wl,--dynamic-linker=$(LDSO_PATH)',
                      '-Wl,--rpath=$(LD_R_PATH)',
                    ],
                  }],
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
                  ['mips_arch_variant=="r2"', {
                    'cflags': ['-mips64r2', '-mabi=64', '-Wa,-mips64r2'],
                    'ldflags': [
                      '-mips64r2', '-mabi=64',
                      '-Wl,--dynamic-linker=$(LDSO_PATH)',
                      '-Wl,--rpath=$(LD_R_PATH)',
                    ],
                  }],
                ],
              }],
            ],
          }],
          [ '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'
            ],
          }],
542 543 544
          ['mips_arch_variant=="r6"', {
            'defines': ['_MIPS_ARCH_MIPS64R6',],
          }],
545 546 547 548 549
          ['mips_arch_variant=="r2"', {
            'defines': ['_MIPS_ARCH_MIPS64R2',],
          }],
        ],
      }],  # v8_target_arch=="mips64el"
550 551 552 553 554 555 556 557 558
      ['v8_target_arch=="x64"', {
        'defines': [
          'V8_TARGET_ARCH_X64',
        ],
        'xcode_settings': {
          'ARCHS': [ 'x86_64' ],
        },
        'msvs_settings': {
          'VCLinkerTool': {
559
            'StackReserveSize': '2097152',
560 561
          },
        },
562
        'msvs_configuration_platform': 'x64',
563
      }],  # v8_target_arch=="x64"
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578
      ['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"
579 580 581 582
      ['OS=="win"', {
        'defines': [
          'WIN32',
        ],
583 584 585
        # 4351: VS 2005 and later are warning us that they've fixed a bug
        #       present in VS 2003 and earlier.
        'msvs_disabled_warnings': [4351],
586 587 588 589 590
        'msvs_configuration_attributes': {
          'OutputDirectory': '<(DEPTH)\\build\\$(ConfigurationName)',
          'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
          'CharacterSet': '1',
        },
591 592
      }],
      ['OS=="win" and v8_target_arch=="ia32"', {
593 594 595 596 597 598
        'msvs_settings': {
          'VCCLCompilerTool': {
            # Ensure no surprising artifacts from 80bit double math with x86.
            'AdditionalOptions': ['/arch:SSE2'],
          },
        },
599
      }],
600 601 602 603 604 605 606
      ['OS=="win" and v8_enable_prof==1', {
        'msvs_settings': {
          'VCLinkerTool': {
            'GenerateMapFile': 'true',
          },
        },
      }],
607
      ['(OS=="linux" or OS=="freebsd"  or OS=="openbsd" or OS=="solaris" \
608
         or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
609 610 611
        (v8_target_arch=="arm" or v8_target_arch=="ia32" or \
         v8_target_arch=="x87" or v8_target_arch=="mips" or \
         v8_target_arch=="mipsel")', {
612 613
        'target_conditions': [
          ['_toolset=="host"', {
614 615 616 617 618 619
            'conditions': [
              ['host_cxx_is_biarch==1', {
                'cflags': [ '-m32' ],
                'ldflags': [ '-m32' ]
              }],
            ],
620 621 622
            'xcode_settings': {
              'ARCHS': [ 'i386' ],
            },
623 624
          }],
          ['_toolset=="target"', {
625
            'conditions': [
626 627 628
              ['target_cxx_is_biarch==1 and nacl_target_arch!="nacl_x64"', {
                'cflags': [ '-m32' ],
                'ldflags': [ '-m32' ],
629
              }],
630 631 632 633 634 635
              # Enable feedback-directed optimisation when building in android.
              [ 'android_webview_build == 1', {
                'aosp_build_settings': {
                  'LOCAL_FDO_SUPPORT': 'true',
                },
              }],
636
            ],
637 638 639
            'xcode_settings': {
              'ARCHS': [ 'i386' ],
            },
640 641 642
          }],
        ],
      }],
643
      ['(OS=="linux" or OS=="android") and \
644
        (v8_target_arch=="x64" or v8_target_arch=="arm64")', {
645 646
        'target_conditions': [
          ['_toolset=="host"', {
647
            'conditions': [
648 649 650
              ['host_cxx_is_biarch==1', {
                'cflags': [ '-m64' ],
                'ldflags': [ '-m64' ]
651
              }],
652 653 654 655 656 657 658 659
             ],
           }],
           ['_toolset=="target"', {
             'conditions': [
               ['target_cxx_is_biarch==1', {
                 'cflags': [ '-m64' ],
                 'ldflags': [ '-m64' ],
               }],
660 661 662 663 664 665
               # Enable feedback-directed optimisation when building in android.
               [ 'android_webview_build == 1', {
                 'aosp_build_settings': {
                   'LOCAL_FDO_SUPPORT': 'true',
                 },
               }],
666 667 668 669 670 671 672 673 674 675 676 677 678 679
             ]
           }],
         ],
      }],
      ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
         or OS=="netbsd" or OS=="qnx"', {
        'conditions': [
          [ 'v8_no_strict_aliasing==1', {
            'cflags': [ '-fno-strict-aliasing' ],
          }],
        ],  # conditions
      }],
      ['OS=="solaris"', {
        'defines': [ '__C99FEATURES__=1' ],  # isinf() etc.
680
      }],
681 682 683 684 685 686
      ['OS=="freebsd" or OS=="openbsd"', {
        'cflags': [ '-I/usr/local/include' ],
      }],
      ['OS=="netbsd"', {
        'cflags': [ '-I/usr/pkg/include' ],
      }],
687
    ],  # conditions
688
    'configurations': {
689 690 691
      # Abstract configuration for v8_optimized_debug == 0.
      'DebugBase0': {
        'abstract': 1,
692 693
        'msvs_settings': {
          'VCCLCompilerTool': {
694
            'Optimization': '0',
695
            'conditions': [
696 697 698 699
              ['component=="shared_library"', {
                'RuntimeLibrary': '3',  # /MDd
              }, {
                'RuntimeLibrary': '1',  # /MTd
700
              }],
701 702 703
            ],
          },
          'VCLinkerTool': {
704 705 706 707 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
            'LinkIncremental': '2',
          },
        },
        'conditions': [
          ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
            OS=="qnx"', {
            'cflags!': [
              '-O3',
              '-O2',
              '-O1',
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
            ],
          }],
          ['OS=="mac"', {
            'xcode_settings': {
               'GCC_OPTIMIZATION_LEVEL': '0',  # -O0
            },
          }],
        ],
      },  # DebugBase0
      # Abstract configuration for v8_optimized_debug == 1.
      'DebugBase1': {
        'abstract': 1,
        'msvs_settings': {
          'VCCLCompilerTool': {
            'Optimization': '1',
            'InlineFunctionExpansion': '2',
            'EnableIntrinsicFunctions': 'true',
            'FavorSizeOrSpeed': '0',
            'StringPooling': 'true',
            'BasicRuntimeChecks': '0',
739
            'conditions': [
740 741 742 743
              ['component=="shared_library"', {
                'RuntimeLibrary': '3',  # /MDd
              }, {
                'RuntimeLibrary': '1',  # /MTd
744 745
              }],
            ],
746
          },
747 748 749
          'VCLinkerTool': {
            'LinkIncremental': '2',
          },
750
        },
751
        'conditions': [
752 753
          ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
            OS=="qnx"', {
754 755 756 757 758 759 760 761 762 763 764
            'cflags!': [
              '-O0',
              '-O3', # TODO(2807) should be -O1.
              '-O2',
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
              '-O1', # TODO(2807) should be -O3.
            ],
765
            'conditions': [
766
              ['gcc_version==44 and clang==0', {
767
                'cflags': [
768 769
                  # Avoid crashes with gcc 4.4 in the v8 test suite.
                  '-fno-tree-vrp',
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
            ],
          }],
          ['OS=="mac"', {
            'xcode_settings': {
               'GCC_OPTIMIZATION_LEVEL': '3',  # -O3
               'GCC_STRICT_ALIASING': 'YES',
            },
          }],
        ],
      },  # DebugBase1
      # Abstract configuration for v8_optimized_debug == 2.
      'DebugBase2': {
        '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
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
            ],
          },
          'VCLinkerTool': {
            'LinkIncremental': '1',
            'OptimizeReferences': '2',
            'EnableCOMDATFolding': '2',
          },
        },
        'conditions': [
          ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
            OS=="qnx"', {
            'cflags!': [
              '-O0',
              '-O1',
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
            ],
            'defines': [
              'OPTIMIZED_DEBUG'
            ],
            'conditions': [
              # TODO(crbug.com/272548): Avoid -O3 in NaCl
              ['nacl_target_arch=="none"', {
                'cflags': ['-O3'],
                'cflags!': ['-O2'],
                }, {
                'cflags': ['-O2'],
                'cflags!': ['-O3'],
830
              }],
831
              ['gcc_version==44 and clang==0', {
832 833 834 835 836 837
                'cflags': [
                  # Avoid crashes with gcc 4.4 in the v8 test suite.
                  '-fno-tree-vrp',
                ],
              }],
            ],
838
          }],
839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861
          ['OS=="mac"', {
            'xcode_settings': {
              'GCC_OPTIMIZATION_LEVEL': '3',  # -O3
              'GCC_STRICT_ALIASING': 'YES',
            },
          }],
        ],
      },  # DebugBase2
      # Common settings for the Debug configuration.
      'DebugBaseCommon': {
        'abstract': 1,
        'defines': [
          'ENABLE_DISASSEMBLER',
          'V8_ENABLE_CHECKS',
          'OBJECT_PRINT',
          'VERIFY_HEAP',
          'DEBUG'
        ],
        'conditions': [
          ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
            OS=="qnx"', {
            'cflags': [ '-Woverloaded-virtual', '<(wno_array_bounds)', ],
          }],
862 863 864 865
          ['OS=="linux" and v8_enable_backtrace==1', {
            # Support for backtrace_symbols.
            'ldflags': [ '-rdynamic' ],
          }],
866 867 868 869 870 871 872 873 874 875 876 877 878 879
          ['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',
                ],
              }],
            ],
          }],
880 881 882 883 884 885 886 887 888 889 890 891 892
        ],
      },  # DebugBaseCommon
      'Debug': {
        'inherit_from': ['DebugBaseCommon'],
        'conditions': [
          ['v8_optimized_debug==0', {
            'inherit_from': ['DebugBase0'],
          }],
          ['v8_optimized_debug==1', {
            'inherit_from': ['DebugBase1'],
          }],
          ['v8_optimized_debug==2', {
            'inherit_from': ['DebugBase2'],
893
          }],
894
        ],
895
      },  # Debug
896 897
      'Release': {
        'conditions': [
898
          ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd"', {
899 900 901 902 903 904
            'cflags!': [
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
905
              '<(wno_array_bounds)',
906 907
            ],
            'conditions': [
908
              [ 'gcc_version==44 and clang==0', {
909 910 911 912 913
                'cflags': [
                  # Avoid crashes with gcc 4.4 in the v8 test suite.
                  '-fno-tree-vrp',
                ],
              }],
914 915 916 917 918 919 920 921
              # TODO(crbug.com/272548): Avoid -O3 in NaCl
              ['nacl_target_arch=="none"', {
                'cflags': ['-O3'],
                'cflags!': ['-O2'],
              }, {
                'cflags': ['-O2'],
                'cflags!': ['-O3'],
              }],
922 923
            ],
          }],
924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942
          ['OS=="android"', {
            'cflags!': [
              '-O3',
              '-Os',
            ],
            'cflags': [
              '-fdata-sections',
              '-ffunction-sections',
              '-O2',
            ],
            'conditions': [
              [ 'gcc_version==44 and clang==0', {
                'cflags': [
                  # Avoid crashes with gcc 4.4 in the v8 test suite.
                  '-fno-tree-vrp',
                ],
              }],
            ],
          }],
943 944 945 946 947 948 949 950 951 952
          ['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',
            },
953
          }],  # OS=="mac"
954 955 956 957 958 959 960 961 962
          ['OS=="win"', {
            'msvs_settings': {
              'VCCLCompilerTool': {
                'Optimization': '2',
                'InlineFunctionExpansion': '2',
                'EnableIntrinsicFunctions': 'true',
                'FavorSizeOrSpeed': '0',
                'StringPooling': 'true',
                'conditions': [
963
                  ['component=="shared_library"', {
964 965 966 967 968 969 970 971 972 973 974 975
                    'RuntimeLibrary': '2',  #/MD
                  }, {
                    'RuntimeLibrary': '0',  #/MT
                  }],
                ],
              },
              'VCLinkerTool': {
                'LinkIncremental': '1',
                'OptimizeReferences': '2',
                'EnableCOMDATFolding': '2',
              },
            },
976 977 978 979 980
          }],  # OS=="win"
        ],  # conditions
      },  # Release
    },  # configurations
  },  # target_defaults
981
}