d4a9403cbd7b8b8d13a762c19a1cca157e52c0b9
[platform/upstream/nodejs.git] / deps / v8 / build / toolchain.gypi
1 # Copyright 2013 the V8 project authors. All rights reserved.
2 # Redistribution and use in source and binary forms, with or without
3 # modification, are permitted provided that the following conditions are
4 # met:
5 #
6 #     * Redistributions of source code must retain the above copyright
7 #       notice, this list of conditions and the following disclaimer.
8 #     * Redistributions in binary form must reproduce the above
9 #       copyright notice, this list of conditions and the following
10 #       disclaimer in the documentation and/or other materials provided
11 #       with the distribution.
12 #     * Neither the name of Google Inc. nor the names of its
13 #       contributors may be used to endorse or promote products derived
14 #       from this software without specific prior written permission.
15 #
16 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28 # Shared definitions for all V8-related targets.
29
30 {
31   'variables': {
32     'msvs_use_common_release': 0,
33     'clang%': 0,
34     'asan%': 0,
35     'lsan%': 0,
36     'msan%': 0,
37     'tsan%': 0,
38     'ubsan%': 0,
39     'ubsan_vptr%': 0,
40     'v8_target_arch%': '<(target_arch)',
41     'v8_host_byteorder%': '<!(python -c "import sys; print sys.byteorder")',
42     # Native Client builds currently use the V8 ARM JIT and
43     # arm/simulator-arm.cc to defer the significant effort required
44     # for NaCl JIT support. The nacl_target_arch variable provides
45     # the 'true' target arch for places in this file that need it.
46     # TODO(bradchen): get rid of nacl_target_arch when someday
47     # NaCl V8 builds stop using the ARM simulator
48     'nacl_target_arch%': 'none',     # must be set externally
49
50     # Setting 'v8_can_use_vfp32dregs' to 'true' will cause V8 to use the VFP
51     # registers d16-d31 in the generated code, both in the snapshot and for the
52     # ARM target. Leaving the default value of 'false' will avoid the use of
53     # these registers in the snapshot and use CPU feature probing when running
54     # on the target.
55     'v8_can_use_vfp32dregs%': 'false',
56     'arm_test_noprobe%': 'off',
57
58     # Similar to vfp but on MIPS.
59     'v8_can_use_fpu_instructions%': 'true',
60
61     # Similar to the ARM hard float ABI but on MIPS.
62     'v8_use_mips_abi_hardfloat%': 'true',
63
64     'v8_enable_backtrace%': 0,
65
66     # Enable profiling support. Only required on Windows.
67     'v8_enable_prof%': 0,
68
69     # Some versions of GCC 4.5 seem to need -fno-strict-aliasing.
70     'v8_no_strict_aliasing%': 0,
71
72     # Chrome needs this definition unconditionally. For standalone V8 builds,
73     # it's handled in build/standalone.gypi.
74     'want_separate_host_toolset%': 1,
75
76     # Toolset the d8 binary should be compiled for. Possible values are 'host'
77     # and 'target'. If you want to run v8 tests, it needs to be set to 'target'.
78     # The setting is ignored if want_separate_host_toolset is 0.
79     'v8_toolset_for_d8%': 'target',
80
81     'host_os%': '<(OS)',
82     'werror%': '-Werror',
83     # For a shared library build, results in "libv8-<(soname_version).so".
84     'soname_version%': '',
85
86     # Allow to suppress the array bounds warning (default is no suppression).
87     'wno_array_bounds%': '',
88
89     # Override where to find binutils
90     'binutils_dir%': '',
91
92     'conditions': [
93       ['OS=="linux" and host_arch=="x64"', {
94         'binutils_dir%': 'third_party/binutils/Linux_x64/Release/bin',
95       }],
96       ['OS=="linux" and host_arch=="ia32"', {
97         'binutils_dir%': 'third_party/binutils/Linux_ia32/Release/bin',
98       }],
99
100       # linux_use_bundled_gold: whether to use the gold linker binary checked
101       # into third_party/binutils.  Force this off via GYP_DEFINES when you
102       # are using a custom toolchain and need to control -B in ldflags.
103       # Do not use 32-bit gold on 32-bit hosts as it runs out address space
104       # for component=static_library builds.
105       ['OS=="linux" and (target_arch=="x64" or target_arch=="arm")', {
106         'linux_use_bundled_gold%': 1,
107       }, {
108         'linux_use_bundled_gold%': 0,
109       }],
110       # linux_use_bundled_binutils: whether to use the binary binutils
111       # checked into third_party/binutils.  These are not multi-arch so cannot
112       # be used except on x86 and x86-64 (the only two architectures which
113       # are currently checke in).  Force this off via GYP_DEFINES when you
114       # are using a custom toolchain and need to control -B in cflags.
115       ['OS=="linux" and (target_arch=="ia32" or target_arch=="x64")', {
116         'linux_use_bundled_binutils%': 1,
117       }, {
118         'linux_use_bundled_binutils%': 0,
119       }],
120       # linux_use_gold_flags: whether to use build flags that rely on gold.
121       # On by default for x64 Linux.
122       ['OS=="linux" and target_arch=="x64"', {
123         'linux_use_gold_flags%': 1,
124       }, {
125         'linux_use_gold_flags%': 0,
126       }],
127     ],
128
129     # Link-Time Optimizations
130     'use_lto%': 0,
131
132     'variables': {
133       # This is set when building the Android WebView inside the Android build
134       # system, using the 'android' gyp backend.
135       'android_webview_build%': 0,
136     },
137     # Copy it out one scope.
138     'android_webview_build%': '<(android_webview_build)',
139   },
140   'conditions': [
141     ['host_arch=="ia32" or host_arch=="x64" or \
142       host_arch=="ppc" or host_arch=="ppc64" or \
143       clang==1', {
144       'variables': {
145         'host_cxx_is_biarch%': 1,
146        },
147      }, {
148       'variables': {
149         'host_cxx_is_biarch%': 0,
150       },
151     }],
152     ['target_arch=="ia32" or target_arch=="x64" or target_arch=="x87" or \
153       target_arch=="ppc" or target_arch=="ppc64" or \
154       clang==1', {
155       'variables': {
156         'target_cxx_is_biarch%': 1,
157        },
158      }, {
159       'variables': {
160         'target_cxx_is_biarch%': 0,
161       },
162     }],
163   ],
164   'target_defaults': {
165     'conditions': [
166       ['v8_target_arch=="arm"', {
167         'defines': [
168           'V8_TARGET_ARCH_ARM',
169         ],
170         'conditions': [
171           [ 'arm_version==7 or arm_version=="default"', {
172             'defines': [
173               'CAN_USE_ARMV7_INSTRUCTIONS',
174             ],
175           }],
176           [ 'arm_fpu=="vfpv3-d16" or arm_fpu=="default"', {
177             'defines': [
178               'CAN_USE_VFP3_INSTRUCTIONS',
179             ],
180           }],
181           [ 'arm_fpu=="vfpv3"', {
182             'defines': [
183               'CAN_USE_VFP3_INSTRUCTIONS',
184               'CAN_USE_VFP32DREGS',
185             ],
186           }],
187           [ 'arm_fpu=="neon"', {
188             'defines': [
189               'CAN_USE_VFP3_INSTRUCTIONS',
190               'CAN_USE_VFP32DREGS',
191               'CAN_USE_NEON',
192             ],
193           }],
194           [ 'arm_test_noprobe=="on"', {
195             'defines': [
196               'ARM_TEST_NO_FEATURE_PROBE',
197             ],
198           }],
199         ],
200         'target_conditions': [
201           ['_toolset=="host"', {
202             'conditions': [
203               ['v8_target_arch==host_arch and android_webview_build==0', {
204                 # Host built with an Arm CXX compiler.
205                 'conditions': [
206                   [ 'arm_version==7', {
207                     'cflags': ['-march=armv7-a',],
208                   }],
209                   [ 'arm_version==7 or arm_version=="default"', {
210                     'conditions': [
211                       [ 'arm_fpu!="default"', {
212                         'cflags': ['-mfpu=<(arm_fpu)',],
213                       }],
214                     ],
215                   }],
216                   [ 'arm_float_abi!="default"', {
217                     'cflags': ['-mfloat-abi=<(arm_float_abi)',],
218                   }],
219                   [ 'arm_thumb==1', {
220                     'cflags': ['-mthumb',],
221                   }],
222                   [ 'arm_thumb==0', {
223                     'cflags': ['-marm',],
224                   }],
225                 ],
226               }, {
227                 # 'v8_target_arch!=host_arch'
228                 # Host not built with an Arm CXX compiler (simulator build).
229                 'conditions': [
230                   [ 'arm_float_abi=="hard"', {
231                     'defines': [
232                       'USE_EABI_HARDFLOAT=1',
233                     ],
234                   }],
235                   [ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
236                     'defines': [
237                       'USE_EABI_HARDFLOAT=0',
238                     ],
239                   }],
240                 ],
241               }],
242             ],
243           }],  # _toolset=="host"
244           ['_toolset=="target"', {
245             'conditions': [
246               ['v8_target_arch==target_arch and android_webview_build==0', {
247                 # Target built with an Arm CXX compiler.
248                 'conditions': [
249                   [ 'arm_version==7', {
250                     'cflags': ['-march=armv7-a',],
251                   }],
252                   [ 'arm_version==7 or arm_version=="default"', {
253                     'conditions': [
254                       [ 'arm_fpu!="default"', {
255                         'cflags': ['-mfpu=<(arm_fpu)',],
256                       }],
257                     ],
258                   }],
259                   [ 'arm_float_abi!="default"', {
260                     'cflags': ['-mfloat-abi=<(arm_float_abi)',],
261                   }],
262                   [ 'arm_thumb==1', {
263                     'cflags': ['-mthumb',],
264                   }],
265                   [ 'arm_thumb==0', {
266                     'cflags': ['-marm',],
267                   }],
268                 ],
269               }, {
270                 # 'v8_target_arch!=target_arch'
271                 # Target not built with an Arm CXX compiler (simulator build).
272                 'conditions': [
273                   [ 'arm_float_abi=="hard"', {
274                     'defines': [
275                       'USE_EABI_HARDFLOAT=1',
276                     ],
277                   }],
278                   [ 'arm_float_abi=="softfp" or arm_float_abi=="default"', {
279                     'defines': [
280                       'USE_EABI_HARDFLOAT=0',
281                     ],
282                   }],
283                 ],
284               }],
285               # Disable LTO for v8
286               # v8 is optimized for speed, which takes precedence over
287               # size optimization in LTO.
288               ['use_lto==1', {
289                 'cflags!': [
290                   '-flto',
291                   '-ffat-lto-objects',
292                 ],
293               }],
294             ],
295           }],  # _toolset=="target"
296         ],
297       }],  # v8_target_arch=="arm"
298       ['v8_target_arch=="arm64"', {
299         'defines': [
300           'V8_TARGET_ARCH_ARM64',
301         ],
302       }],
303       ['v8_target_arch=="ppc" or v8_target_arch=="ppc64"', {
304         'defines': [
305           'V8_TARGET_ARCH_PPC',
306         ],
307         'conditions': [
308           ['v8_target_arch=="ppc64"', {
309             'defines': [
310               'V8_TARGET_ARCH_PPC64',
311             ],
312           }],
313           ['v8_host_byteorder=="little"', {
314             'defines': [
315               'V8_TARGET_ARCH_PPC_LE',
316             ],
317           }],
318           ['v8_host_byteorder=="big"', {
319             'defines': [
320               'V8_TARGET_ARCH_PPC_BE',
321             ],
322             'conditions': [
323               ['OS=="aix"', {
324                 # Work around AIX ceil, trunc and round oddities.
325                 'cflags': [ '-mcpu=power5+ -mfprnd' ],
326               }],
327               ['OS=="aix"', {
328                 # Work around AIX assembler popcntb bug.
329                 'cflags': [ '-mno-popcntb' ],
330               }],
331             ],
332           }],
333         ],
334       }],  # ppc
335       ['v8_target_arch=="ia32"', {
336         'defines': [
337           'V8_TARGET_ARCH_IA32',
338         ],
339       }],  # v8_target_arch=="ia32"
340       ['v8_target_arch=="x87"', {
341         'defines': [
342           'V8_TARGET_ARCH_X87',
343         ],
344         'cflags': ['-march=i586'],
345       }],  # v8_target_arch=="x87"
346       ['v8_target_arch=="mips"', {
347         'defines': [
348           'V8_TARGET_ARCH_MIPS',
349         ],
350         'conditions': [
351           [ 'v8_can_use_fpu_instructions=="true"', {
352             'defines': [
353               'CAN_USE_FPU_INSTRUCTIONS',
354             ],
355           }],
356           [ 'v8_use_mips_abi_hardfloat=="true"', {
357             'defines': [
358               '__mips_hard_float=1',
359               'CAN_USE_FPU_INSTRUCTIONS',
360             ],
361           }, {
362             'defines': [
363               '__mips_soft_float=1'
364             ]
365           }],
366         ],
367         'target_conditions': [
368           ['_toolset=="target"', {
369             'conditions': [
370               ['v8_target_arch==target_arch and android_webview_build==0', {
371                 # Target built with a Mips CXX compiler.
372                 'cflags': [
373                   '-EB',
374                   '-Wno-error=array-bounds',  # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
375                 ],
376                 'ldflags': ['-EB'],
377                 'conditions': [
378                   [ 'v8_use_mips_abi_hardfloat=="true"', {
379                     'cflags': ['-mhard-float'],
380                     'ldflags': ['-mhard-float'],
381                   }, {
382                     'cflags': ['-msoft-float'],
383                     'ldflags': ['-msoft-float'],
384                   }],
385                   ['mips_arch_variant=="r6"', {
386                     'defines': [
387                       '_MIPS_ARCH_MIPS32R6',
388                       'FPU_MODE_FP64',
389                     ],
390                     'cflags!': ['-mfp32', '-mfpxx'],
391                     'cflags': ['-mips32r6', '-Wa,-mips32r6'],
392                     'ldflags': [
393                       '-mips32r6',
394                       '-Wl,--dynamic-linker=$(LDSO_PATH)',
395                       '-Wl,--rpath=$(LD_R_PATH)',
396                     ],
397                   }],
398                   ['mips_arch_variant=="r2"', {
399                     'conditions': [
400                       [ 'mips_fpu_mode=="fp64"', {
401                         'defines': [
402                           '_MIPS_ARCH_MIPS32R2',
403                           'FPU_MODE_FP64',
404                         ],
405                         'cflags': ['-mfp64'],
406                       }],
407                       ['mips_fpu_mode=="fpxx"', {
408                         'defines': [
409                           '_MIPS_ARCH_MIPS32R2',
410                           'FPU_MODE_FPXX',
411                         ],
412                         'cflags': ['-mfpxx'],
413                       }],
414                       ['mips_fpu_mode=="fp32"', {
415                         'defines': [
416                           '_MIPS_ARCH_MIPS32R2',
417                           'FPU_MODE_FP32',
418                         ],
419                         'cflags': ['-mfp32'],
420                       }],
421                     ],
422                     'cflags': ['-mips32r2', '-Wa,-mips32r2'],
423                     'ldflags': ['-mips32r2'],
424                   }],
425                   ['mips_arch_variant=="r1"', {
426                     'defines': [
427                       'FPU_MODE_FP32',
428                     ],
429                     'cflags!': ['-mfp64', '-mfpxx'],
430                     'cflags': ['-mips32', '-Wa,-mips32'],
431                     'ldflags': ['-mips32'],
432                   }],
433                   ['mips_arch_variant=="rx"', {
434                     'defines': [
435                       '_MIPS_ARCH_MIPS32RX',
436                       'FPU_MODE_FPXX',
437                     ],
438                     'cflags!': ['-mfp64', '-mfp32'],
439                     'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'],
440                     'ldflags': ['-mips32'],
441                   }],
442                 ],
443               }, {
444                 # 'v8_target_arch!=target_arch'
445                 # Target not built with an MIPS CXX compiler (simulator build).
446                 'conditions': [
447                   ['mips_arch_variant=="r6"', {
448                     'defines': [
449                       '_MIPS_ARCH_MIPS32R6',
450                       'FPU_MODE_FP64',
451                     ],
452                   }],
453                   ['mips_arch_variant=="r2"', {
454                     'conditions': [
455                       [ 'mips_fpu_mode=="fp64"', {
456                         'defines': [
457                           '_MIPS_ARCH_MIPS32R2',
458                           'FPU_MODE_FP64',
459                         ],
460                       }],
461                       ['mips_fpu_mode=="fpxx"', {
462                         'defines': [
463                           '_MIPS_ARCH_MIPS32R2',
464                           'FPU_MODE_FPXX',
465                         ],
466                       }],
467                       ['mips_fpu_mode=="fp32"', {
468                         'defines': [
469                           '_MIPS_ARCH_MIPS32R2',
470                           'FPU_MODE_FP32',
471                         ],
472                       }],
473                     ],
474                   }],
475                   ['mips_arch_variant=="r1"', {
476                     'defines': [
477                       'FPU_MODE_FP32',
478                     ],
479                   }],
480                   ['mips_arch_variant=="rx"', {
481                     'defines': [
482                       '_MIPS_ARCH_MIPS32RX',
483                       'FPU_MODE_FPXX',
484                     ],
485                   }],
486                 ],
487               }],
488             ],
489           }],  #_toolset=="target"
490           ['_toolset=="host"', {
491             'conditions': [
492               ['mips_arch_variant=="rx"', {
493                 'defines': [
494                   '_MIPS_ARCH_MIPS32RX',
495                   'FPU_MODE_FPXX',
496                 ],
497               }],
498               ['mips_arch_variant=="r6"', {
499                 'defines': [
500                   '_MIPS_ARCH_MIPS32R6',
501                   'FPU_MODE_FP64',
502                 ],
503               }],
504               ['mips_arch_variant=="r2"', {
505                 'conditions': [
506                   ['mips_fpu_mode=="fp64"', {
507                     'defines': [
508                       '_MIPS_ARCH_MIPS32R2',
509                       'FPU_MODE_FP64',
510                     ],
511                   }],
512                   ['mips_fpu_mode=="fpxx"', {
513                     'defines': [
514                       '_MIPS_ARCH_MIPS32R2',
515                       'FPU_MODE_FPXX',
516                     ],
517                   }],
518                   ['mips_fpu_mode=="fp32"', {
519                     'defines': [
520                       '_MIPS_ARCH_MIPS32R2',
521                       'FPU_MODE_FP32'
522                     ],
523                   }],
524                 ],
525               }],
526               ['mips_arch_variant=="r1"', {
527                 'defines': ['FPU_MODE_FP32',],
528               }],
529             ]
530           }],  #_toolset=="host"
531         ],
532       }],  # v8_target_arch=="mips"
533       ['v8_target_arch=="mipsel"', {
534         'defines': [
535           'V8_TARGET_ARCH_MIPS',
536         ],
537         'conditions': [
538           [ 'v8_can_use_fpu_instructions=="true"', {
539             'defines': [
540               'CAN_USE_FPU_INSTRUCTIONS',
541             ],
542           }],
543           [ 'v8_use_mips_abi_hardfloat=="true"', {
544             'defines': [
545               '__mips_hard_float=1',
546               'CAN_USE_FPU_INSTRUCTIONS',
547             ],
548           }, {
549             'defines': [
550               '__mips_soft_float=1'
551             ],
552           }],
553         ],
554         'target_conditions': [
555           ['_toolset=="target"', {
556             'conditions': [
557               ['v8_target_arch==target_arch and android_webview_build==0', {
558                 # Target built with a Mips CXX compiler.
559                 'cflags': [
560                   '-EL',
561                   '-Wno-error=array-bounds',  # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
562                 ],
563                 'ldflags': ['-EL'],
564                 'conditions': [
565                   [ 'v8_use_mips_abi_hardfloat=="true"', {
566                     'cflags': ['-mhard-float'],
567                     'ldflags': ['-mhard-float'],
568                   }, {
569                     'cflags': ['-msoft-float'],
570                     'ldflags': ['-msoft-float'],
571                   }],
572                   ['mips_arch_variant=="r6"', {
573                     'defines': [
574                       '_MIPS_ARCH_MIPS32R6',
575                       'FPU_MODE_FP64',
576                     ],
577                     'cflags!': ['-mfp32', '-mfpxx'],
578                     'cflags': ['-mips32r6', '-Wa,-mips32r6'],
579                     'ldflags': [
580                       '-mips32r6',
581                       '-Wl,--dynamic-linker=$(LDSO_PATH)',
582                       '-Wl,--rpath=$(LD_R_PATH)',
583                     ],
584                   }],
585                   ['mips_arch_variant=="r2"', {
586                     'conditions': [
587                       [ 'mips_fpu_mode=="fp64"', {
588                         'defines': [
589                           '_MIPS_ARCH_MIPS32R2',
590                           'FPU_MODE_FP64',
591                         ],
592                         'cflags': ['-mfp64'],
593                       }],
594                       ['mips_fpu_mode=="fpxx"', {
595                         'defines': [
596                           '_MIPS_ARCH_MIPS32R2',
597                           'FPU_MODE_FPXX',
598                         ],
599                         'cflags': ['-mfpxx'],
600                       }],
601                       ['mips_fpu_mode=="fp32"', {
602                         'defines': [
603                           '_MIPS_ARCH_MIPS32R2',
604                           'FPU_MODE_FP32',
605                         ],
606                         'cflags': ['-mfp32'],
607                       }],
608                     ],
609                     'cflags': ['-mips32r2', '-Wa,-mips32r2'],
610                     'ldflags': ['-mips32r2'],
611                   }],
612                   ['mips_arch_variant=="r1"', {
613                     'cflags!': ['-mfp64', '-mfpxx'],
614                     'cflags': ['-mips32', '-Wa,-mips32'],
615                     'ldflags': ['-mips32'],
616                   }],
617                   ['mips_arch_variant=="rx"', {
618                     'defines': [
619                       '_MIPS_ARCH_MIPS32RX',
620                       'FPU_MODE_FPXX',
621                     ],
622                     'cflags!': ['-mfp64', '-mfp32'],
623                     'cflags': ['-mips32', '-Wa,-mips32', '-mfpxx'],
624                     'ldflags': ['-mips32'],
625                   }],
626                   ['mips_arch_variant=="loongson"', {
627                     'defines': [
628                       '_MIPS_ARCH_LOONGSON',
629                       'FPU_MODE_FP32',
630                     ],
631                     'cflags!': ['-mfp64', '-mfp32', '-mfpxx'],
632                     'cflags': ['-mips3', '-Wa,-mips3'],
633                   }],
634                 ],
635               }, {
636                 # 'v8_target_arch!=target_arch'
637                 # Target not built with an MIPS CXX compiler (simulator build).
638                 'conditions': [
639                   ['mips_arch_variant=="r6"', {
640                     'defines': [
641                       '_MIPS_ARCH_MIPS32R6',
642                       'FPU_MODE_FP64',
643                     ],
644                   }],
645                   ['mips_arch_variant=="r2"', {
646                     'conditions': [
647                       [ 'mips_fpu_mode=="fp64"', {
648                         'defines': [
649                           '_MIPS_ARCH_MIPS32R2',
650                           'FPU_MODE_FP64',
651                         ],
652                       }],
653                       ['mips_fpu_mode=="fpxx"', {
654                         'defines': [
655                           '_MIPS_ARCH_MIPS32R2',
656                           'FPU_MODE_FPXX',
657                         ],
658                       }],
659                       ['mips_fpu_mode=="fp32"', {
660                         'defines': [
661                           '_MIPS_ARCH_MIPS32R2',
662                           'FPU_MODE_FP32',
663                         ],
664                       }],
665                     ],
666                   }],
667                   ['mips_arch_variant=="r1"', {
668                     'defines': [
669                       'FPU_MODE_FP32',
670                     ],
671                   }],
672                   ['mips_arch_variant=="rx"', {
673                     'defines': [
674                       '_MIPS_ARCH_MIPS32RX',
675                       'FPU_MODE_FPXX',
676                     ],
677                   }],
678                   ['mips_arch_variant=="loongson"', {
679                     'defines': [
680                       '_MIPS_ARCH_LOONGSON',
681                       'FPU_MODE_FP32',
682                     ],
683                   }],
684                 ],
685               }],
686             ],
687           }], #_toolset=="target
688           ['_toolset=="host"', {
689             'conditions': [
690               ['mips_arch_variant=="rx"', {
691                 'defines': [
692                   '_MIPS_ARCH_MIPS32RX',
693                   'FPU_MODE_FPXX',
694                 ],
695               }],
696               ['mips_arch_variant=="r6"', {
697                 'defines': [
698                   '_MIPS_ARCH_MIPS32R6',
699                   'FPU_MODE_FP64',
700                 ],
701               }],
702               ['mips_arch_variant=="r2"', {
703                 'conditions': [
704                   ['mips_fpu_mode=="fp64"', {
705                     'defines': [
706                       '_MIPS_ARCH_MIPS32R2',
707                       'FPU_MODE_FP64',
708                     ],
709                   }],
710                   ['mips_fpu_mode=="fpxx"', {
711                     'defines': [
712                       '_MIPS_ARCH_MIPS32R2',
713                       'FPU_MODE_FPXX',
714                     ],
715                   }],
716                   ['mips_fpu_mode=="fp32"', {
717                     'defines': [
718                       '_MIPS_ARCH_MIPS32R2',
719                       'FPU_MODE_FP32'
720                     ],
721                   }],
722                 ],
723               }],
724               ['mips_arch_variant=="r1"', {
725                 'defines': ['FPU_MODE_FP32',],
726               }],
727               ['mips_arch_variant=="loongson"', {
728                 'defines': [
729                   '_MIPS_ARCH_LOONGSON',
730                   'FPU_MODE_FP32',
731                 ],
732               }],
733             ]
734           }],
735         ],
736       }],  # v8_target_arch=="mipsel"
737       ['v8_target_arch=="mips64el"', {
738         'defines': [
739           'V8_TARGET_ARCH_MIPS64',
740         ],
741         'conditions': [
742           [ 'v8_can_use_fpu_instructions=="true"', {
743             'defines': [
744               'CAN_USE_FPU_INSTRUCTIONS',
745             ],
746           }],
747           [ 'v8_use_mips_abi_hardfloat=="true"', {
748             'defines': [
749               '__mips_hard_float=1',
750               'CAN_USE_FPU_INSTRUCTIONS',
751             ],
752           }, {
753             'defines': [
754               '__mips_soft_float=1'
755             ],
756           }],
757          ],
758         'target_conditions': [
759           ['_toolset=="target"', {
760             'conditions': [
761               ['v8_target_arch==target_arch and android_webview_build==0', {
762                 'cflags': [
763                   '-EL',
764                   '-Wno-error=array-bounds',  # Workaround https://gcc.gnu.org/bugzilla/show_bug.cgi?id=56273
765                 ],
766                 'ldflags': ['-EL'],
767                 'conditions': [
768                   [ 'v8_use_mips_abi_hardfloat=="true"', {
769                     'cflags': ['-mhard-float'],
770                     'ldflags': ['-mhard-float'],
771                   }, {
772                     'cflags': ['-msoft-float'],
773                     'ldflags': ['-msoft-float'],
774                   }],
775                   ['mips_arch_variant=="r6"', {
776                     'defines': ['_MIPS_ARCH_MIPS64R6',],
777                     'cflags': ['-mips64r6', '-mabi=64', '-Wa,-mips64r6'],
778                     'ldflags': [
779                       '-mips64r6', '-mabi=64',
780                       '-Wl,--dynamic-linker=$(LDSO_PATH)',
781                       '-Wl,--rpath=$(LD_R_PATH)',
782                     ],
783                   }],
784                   ['mips_arch_variant=="r2"', {
785                     'defines': ['_MIPS_ARCH_MIPS64R2',],
786                     'cflags': ['-mips64r2', '-mabi=64', '-Wa,-mips64r2'],
787                     'ldflags': [
788                       '-mips64r2', '-mabi=64',
789                       '-Wl,--dynamic-linker=$(LDSO_PATH)',
790                       '-Wl,--rpath=$(LD_R_PATH)',
791                     ],
792                   }],
793                 ],
794               }, {
795                 # 'v8_target_arch!=target_arch'
796                 # Target not built with an MIPS CXX compiler (simulator build).
797                 'conditions': [
798                   ['mips_arch_variant=="r6"', {
799                     'defines': ['_MIPS_ARCH_MIPS64R6',],
800                   }],
801                   ['mips_arch_variant=="r2"', {
802                     'defines': ['_MIPS_ARCH_MIPS64R2',],
803                   }],
804                 ],
805               }],
806             ],
807           }],  #'_toolset=="target"
808           ['_toolset=="host"', {
809             'conditions': [
810               ['mips_arch_variant=="r6"', {
811                 'defines': ['_MIPS_ARCH_MIPS64R6',],
812               }],
813               ['mips_arch_variant=="r2"', {
814                 'defines': ['_MIPS_ARCH_MIPS64R2',],
815               }],
816             ],
817           }],  #'_toolset=="host"
818         ],
819       }],  # v8_target_arch=="mips64el"
820       ['v8_target_arch=="x64"', {
821         'defines': [
822           'V8_TARGET_ARCH_X64',
823         ],
824         'xcode_settings': {
825           'ARCHS': [ 'x86_64' ],
826         },
827         'msvs_settings': {
828           'VCLinkerTool': {
829             'StackReserveSize': '2097152',
830           },
831         },
832         'msvs_configuration_platform': 'x64',
833       }],  # v8_target_arch=="x64"
834       ['v8_target_arch=="x32"', {
835         'defines': [
836           # x32 port shares the source code with x64 port.
837           'V8_TARGET_ARCH_X64',
838           'V8_TARGET_ARCH_32_BIT',
839         ],
840         'cflags': [
841           '-mx32',
842           # Inhibit warning if long long type is used.
843           '-Wno-long-long',
844         ],
845         'ldflags': [
846           '-mx32',
847         ],
848       }],  # v8_target_arch=="x32"
849       ['linux_use_gold_flags==1', {
850         # Newer gccs and clangs support -fuse-ld, use the flag to force gold
851         # selection.
852         # gcc -- http://gcc.gnu.org/onlinedocs/gcc-4.8.0/gcc/Optimize-Options.html
853         'ldflags': [ '-fuse-ld=gold', ],
854       }],
855       ['linux_use_bundled_binutils==1', {
856         'cflags': [
857           '-B<!(cd <(DEPTH) && pwd -P)/<(binutils_dir)',
858         ],
859       }],
860       ['linux_use_bundled_gold==1', {
861         # Put our binutils, which contains gold in the search path. We pass
862         # the path to gold to the compiler. gyp leaves unspecified what the
863         # cwd is when running the compiler, so the normal gyp path-munging
864         # fails us. This hack gets the right path.
865         'ldflags': [
866           '-B<!(cd <(DEPTH) && pwd -P)/<(binutils_dir)',
867         ],
868       }],
869       ['OS=="win"', {
870         'defines': [
871           'WIN32',
872         ],
873         # 4351: VS 2005 and later are warning us that they've fixed a bug
874         #       present in VS 2003 and earlier.
875         'msvs_disabled_warnings': [4351],
876         'msvs_configuration_attributes': {
877           'OutputDirectory': '<(DEPTH)\\build\\$(ConfigurationName)',
878           'IntermediateDirectory': '$(OutDir)\\obj\\$(ProjectName)',
879           'CharacterSet': '1',
880         },
881       }],
882       ['OS=="win" and v8_target_arch=="ia32"', {
883         'msvs_settings': {
884           'VCCLCompilerTool': {
885             # Ensure no surprising artifacts from 80bit double math with x86.
886             'AdditionalOptions': ['/arch:SSE2'],
887           },
888         },
889       }],
890       ['OS=="win" and v8_enable_prof==1', {
891         'msvs_settings': {
892           'VCLinkerTool': {
893             'GenerateMapFile': 'true',
894           },
895         },
896       }],
897       ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
898          or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
899         v8_target_arch=="ia32"', {
900         'cflags': [
901           '-msse2',
902           '-mfpmath=sse',
903           '-mmmx',  # Allows mmintrin.h for MMX intrinsics.
904         ],
905       }],
906       ['(OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
907          or OS=="netbsd" or OS=="mac" or OS=="android" or OS=="qnx") and \
908         (v8_target_arch=="arm" or v8_target_arch=="ia32" or \
909          v8_target_arch=="x87" or v8_target_arch=="mips" or \
910          v8_target_arch=="mipsel" or v8_target_arch=="ppc")', {
911         'target_conditions': [
912           ['_toolset=="host"', {
913             'conditions': [
914               ['host_cxx_is_biarch==1', {
915                 'cflags': [ '-m32' ],
916                 'ldflags': [ '-m32' ]
917               }],
918             ],
919             'xcode_settings': {
920               'ARCHS': [ 'i386' ],
921             },
922           }],
923           ['_toolset=="target"', {
924             'conditions': [
925               ['target_cxx_is_biarch==1 and nacl_target_arch!="nacl_x64"', {
926                 'cflags': [ '-m32' ],
927                 'ldflags': [ '-m32' ],
928               }],
929               # Enable feedback-directed optimisation when building in android.
930               [ 'android_webview_build == 1', {
931                 'aosp_build_settings': {
932                   'LOCAL_FDO_SUPPORT': 'true',
933                 },
934               }],
935             ],
936             'xcode_settings': {
937               'ARCHS': [ 'i386' ],
938             },
939           }],
940         ],
941       }],
942       ['(OS=="linux" or OS=="android") and \
943         (v8_target_arch=="x64" or v8_target_arch=="arm64" or \
944          v8_target_arch=="ppc64")', {
945         'target_conditions': [
946           ['_toolset=="host"', {
947             'conditions': [
948               ['host_cxx_is_biarch==1', {
949                 'cflags': [ '-m64' ],
950                 'ldflags': [ '-m64' ]
951               }],
952              ],
953            }],
954            ['_toolset=="target"', {
955              'conditions': [
956                ['target_cxx_is_biarch==1', {
957                  'cflags': [ '-m64' ],
958                  'ldflags': [ '-m64' ],
959                }],
960                # Enable feedback-directed optimisation when building in android.
961                [ 'android_webview_build == 1', {
962                  'aosp_build_settings': {
963                    'LOCAL_FDO_SUPPORT': 'true',
964                  },
965                }],
966              ]
967            }],
968          ],
969       }],
970       ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
971          or OS=="netbsd" or OS=="qnx" or OS=="aix"', {
972         'conditions': [
973           [ 'v8_no_strict_aliasing==1', {
974             'cflags': [ '-fno-strict-aliasing' ],
975           }],
976         ],  # conditions
977       }],
978       ['OS=="solaris"', {
979         'defines': [ '__C99FEATURES__=1' ],  # isinf() etc.
980       }],
981       ['OS=="freebsd" or OS=="openbsd"', {
982         'cflags': [ '-I/usr/local/include' ],
983       }],
984       ['OS=="netbsd"', {
985         'cflags': [ '-I/usr/pkg/include' ],
986       }],
987       ['OS=="aix"', {
988         'defines': [
989           # Support for malloc(0)
990           '_LINUX_SOURCE_COMPAT=1',
991           '_ALL_SOURCE=1'],
992         'conditions': [
993           [ 'v8_target_arch=="ppc"', {
994             'ldflags': [ '-Wl,-bmaxdata:0x60000000/dsa' ],
995           }],
996           [ 'v8_target_arch=="ppc64"', {
997             'cflags': [ '-maix64' ],
998             'ldflags': [ '-maix64' ],
999           }],
1000         ],
1001       }],
1002     ],  # conditions
1003     'configurations': {
1004       # Abstract configuration for v8_optimized_debug == 0.
1005       'DebugBase0': {
1006         'abstract': 1,
1007         'msvs_settings': {
1008           'VCCLCompilerTool': {
1009             'Optimization': '0',
1010             'conditions': [
1011               ['component=="shared_library"', {
1012                 'RuntimeLibrary': '3',  # /MDd
1013               }, {
1014                 'RuntimeLibrary': '1',  # /MTd
1015               }],
1016             ],
1017           },
1018           'VCLinkerTool': {
1019             'LinkIncremental': '2',
1020           },
1021         },
1022         'variables': {
1023           'v8_enable_slow_dchecks%': 1,
1024         },
1025         'conditions': [
1026           ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
1027             OS=="qnx" or OS=="aix"', {
1028             'cflags!': [
1029               '-O3',
1030               '-O2',
1031               '-O1',
1032               '-Os',
1033             ],
1034             'cflags': [
1035               '-fdata-sections',
1036               '-ffunction-sections',
1037             ],
1038           }],
1039           ['OS=="mac"', {
1040             'xcode_settings': {
1041                'GCC_OPTIMIZATION_LEVEL': '0',  # -O0
1042             },
1043           }],
1044           ['v8_enable_slow_dchecks==1', {
1045             'defines': [
1046               'ENABLE_SLOW_DCHECKS',
1047             ],
1048           }],
1049         ],
1050       },  # DebugBase0
1051       # Abstract configuration for v8_optimized_debug == 1.
1052       'DebugBase1': {
1053         'abstract': 1,
1054         'msvs_settings': {
1055           'VCCLCompilerTool': {
1056             'Optimization': '2',
1057             'InlineFunctionExpansion': '2',
1058             'EnableIntrinsicFunctions': 'true',
1059             'FavorSizeOrSpeed': '0',
1060             'StringPooling': 'true',
1061             'BasicRuntimeChecks': '0',
1062             'conditions': [
1063               ['component=="shared_library"', {
1064                 'RuntimeLibrary': '3',  #/MDd
1065               }, {
1066                 'RuntimeLibrary': '1',  #/MTd
1067               }],
1068             ],
1069           },
1070           'VCLinkerTool': {
1071             'LinkIncremental': '1',
1072             'OptimizeReferences': '2',
1073             'EnableCOMDATFolding': '2',
1074           },
1075         },
1076         'variables': {
1077           'v8_enable_slow_dchecks%': 0,
1078         },
1079         'conditions': [
1080           ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
1081             OS=="qnx" or OS=="aix"', {
1082             'cflags!': [
1083               '-O0',
1084               '-O1',
1085               '-Os',
1086             ],
1087             'cflags': [
1088               '-fdata-sections',
1089               '-ffunction-sections',
1090             ],
1091             'conditions': [
1092               # TODO(crbug.com/272548): Avoid -O3 in NaCl
1093               # Don't use -O3 with sanitizers.
1094               ['nacl_target_arch=="none" and asan==0 and msan==0 and lsan==0 \
1095                 and tsan==0 and ubsan==0 and ubsan_vptr==0', {
1096                 'cflags': ['-O3'],
1097                 'cflags!': ['-O2'],
1098                 }, {
1099                 'cflags': ['-O2'],
1100                 'cflags!': ['-O3'],
1101               }],
1102             ],
1103           }],
1104           ['OS=="mac"', {
1105             'xcode_settings': {
1106               'GCC_OPTIMIZATION_LEVEL': '3',  # -O3
1107               'GCC_STRICT_ALIASING': 'YES',
1108             },
1109           }],
1110           ['v8_enable_slow_dchecks==1', {
1111             'defines': [
1112               'ENABLE_SLOW_DCHECKS',
1113             ],
1114           }],
1115         ],
1116       },  # DebugBase1
1117       # Common settings for the Debug configuration.
1118       'DebugBaseCommon': {
1119         'abstract': 1,
1120         'defines': [
1121           'ENABLE_DISASSEMBLER',
1122           'V8_ENABLE_CHECKS',
1123           'OBJECT_PRINT',
1124           'VERIFY_HEAP',
1125           'DEBUG',
1126           'TRACE_MAPS'
1127         ],
1128         'conditions': [
1129           ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" or \
1130             OS=="qnx" or OS=="aix"', {
1131             'cflags': [ '-Woverloaded-virtual', '<(wno_array_bounds)', ],
1132           }],
1133           ['OS=="linux" and v8_enable_backtrace==1', {
1134             # Support for backtrace_symbols.
1135             'ldflags': [ '-rdynamic' ],
1136           }],
1137           ['OS=="aix"', {
1138             'ldflags': [ '-Wl,-bbigtoc' ],
1139           }],
1140           ['OS=="android"', {
1141             'variables': {
1142               'android_full_debug%': 1,
1143             },
1144             'conditions': [
1145               ['android_full_debug==0', {
1146                 # Disable full debug if we want a faster v8 in a debug build.
1147                 # TODO(2304): pass DISABLE_DEBUG_ASSERT instead of hiding DEBUG.
1148                 'defines!': [
1149                   'DEBUG',
1150                   'ENABLE_SLOW_DCHECKS',
1151                 ],
1152               }],
1153             ],
1154           }],
1155           ['linux_use_gold_flags==1', {
1156             'target_conditions': [
1157               ['_toolset=="target"', {
1158                 'ldflags': [
1159                   # Experimentation found that using four linking threads
1160                   # saved ~20% of link time.
1161                   # https://groups.google.com/a/chromium.org/group/chromium-dev/browse_thread/thread/281527606915bb36
1162                   # Only apply this to the target linker, since the host
1163                   # linker might not be gold, but isn't used much anyway.
1164                   '-Wl,--threads',
1165                   '-Wl,--thread-count=4',
1166                 ],
1167               }],
1168             ],
1169           }],
1170         ],
1171       },  # DebugBaseCommon
1172       'Debug': {
1173         'inherit_from': ['DebugBaseCommon'],
1174         'conditions': [
1175           ['v8_optimized_debug==0', {
1176             'inherit_from': ['DebugBase0'],
1177           }, {
1178             'inherit_from': ['DebugBase1'],
1179           }],
1180         ],
1181       },  # Debug
1182       'Release': {
1183         'variables': {
1184           'v8_enable_slow_dchecks%': 0,
1185         },
1186         'conditions': [
1187           ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \
1188             or OS=="aix"', {
1189             'cflags!': [
1190               '-Os',
1191             ],
1192             'cflags': [
1193               '-fdata-sections',
1194               '-ffunction-sections',
1195               '<(wno_array_bounds)',
1196             ],
1197             'conditions': [
1198               # TODO(crbug.com/272548): Avoid -O3 in NaCl
1199               # Don't use -O3 with sanitizers.
1200               ['nacl_target_arch=="none" and asan==0 and msan==0 and lsan==0 \
1201                 and tsan==0 and ubsan==0 and ubsan_vptr==0', {
1202                 'cflags': ['-O3'],
1203                 'cflags!': ['-O2'],
1204               }, {
1205                 'cflags': ['-O2'],
1206                 'cflags!': ['-O3'],
1207               }],
1208             ],
1209           }],
1210           ['OS=="android"', {
1211             'cflags!': [
1212               '-O3',
1213               '-Os',
1214             ],
1215             'cflags': [
1216               '-fdata-sections',
1217               '-ffunction-sections',
1218               '-O2',
1219             ],
1220           }],
1221           ['OS=="mac"', {
1222             'xcode_settings': {
1223               'GCC_OPTIMIZATION_LEVEL': '3',  # -O3
1224
1225               # -fstrict-aliasing.  Mainline gcc
1226               # enables this at -O2 and above,
1227               # but Apple gcc does not unless it
1228               # is specified explicitly.
1229               'GCC_STRICT_ALIASING': 'YES',
1230             },
1231           }],  # OS=="mac"
1232           ['OS=="win"', {
1233             'msvs_settings': {
1234               'VCCLCompilerTool': {
1235                 'Optimization': '2',
1236                 'InlineFunctionExpansion': '2',
1237                 'EnableIntrinsicFunctions': 'true',
1238                 'FavorSizeOrSpeed': '0',
1239                 'StringPooling': 'true',
1240                 'conditions': [
1241                   ['component=="shared_library"', {
1242                     'RuntimeLibrary': '2',  #/MD
1243                   }, {
1244                     'RuntimeLibrary': '0',  #/MT
1245                   }],
1246                 ],
1247               },
1248               'VCLinkerTool': {
1249                 'LinkIncremental': '1',
1250                 'OptimizeReferences': '2',
1251                 'EnableCOMDATFolding': '2',
1252               },
1253             },
1254           }],  # OS=="win"
1255           ['v8_enable_slow_dchecks==1', {
1256             'defines': [
1257               'ENABLE_SLOW_DCHECKS',
1258             ],
1259           }],
1260         ],  # conditions
1261       },  # Release
1262     },  # configurations
1263   },  # target_defaults
1264 }