blob: 273d72b744e2b041029c0ec4d32350683678ec9d [file] [log] [blame]
Ben Murdoch3ef787d2012-04-12 10:51:47 +01001# Copyright 2012 the V8 project authors. All rights reserved.
Ben Murdoch69a99ed2011-11-30 16:03:39 +00002# Redistribution and use in source and binary forms, with or without
3# modification, are permitted provided that the following conditions are
4# met:
5#
6# * Redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer.
8# * Redistributions in binary form must reproduce the above
9# copyright notice, this list of conditions and the following
10# disclaimer in the documentation and/or other materials provided
11# with the distribution.
12# * Neither the name of Google Inc. nor the names of its
13# contributors may be used to endorse or promote products derived
14# from this software without specific prior written permission.
15#
16# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28# Definitions to be used when building stand-alone V8 binaries.
29
30{
Ben Murdochb8a8cc12014-11-26 15:28:44 +000031 # We need to include toolchain.gypi here for third-party sources that don't
32 # directly include it themselves.
33 'includes': ['toolchain.gypi'],
Ben Murdoch69a99ed2011-11-30 16:03:39 +000034 'variables': {
Ben Murdoch69a99ed2011-11-30 16:03:39 +000035 'component%': 'static_library',
Emily Bernierd0a1eb72015-03-24 16:35:39 -040036 'clang_xcode%': 0,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000037 # Track where uninitialized memory originates from. From fastest to
38 # slowest: 0 - no tracking, 1 - track only the initial allocation site, 2
39 # - track the chain of stores leading from allocation site to use site.
40 'msan_track_origins%': 2,
Ben Murdoch69a99ed2011-11-30 16:03:39 +000041 'visibility%': 'hidden',
Ben Murdochb8a8cc12014-11-26 15:28:44 +000042 'v8_enable_backtrace%': 0,
43 'v8_enable_i18n_support%': 1,
44 'v8_deprecation_warnings': 1,
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000045 'v8_imminent_deprecation_warnings': 1,
Ben Murdoch69a99ed2011-11-30 16:03:39 +000046 'msvs_multi_core_compile%': '1',
Ben Murdochb8a8cc12014-11-26 15:28:44 +000047 'mac_deployment_target%': '10.5',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000048 'release_extra_cflags%': '',
Ben Murdoch69a99ed2011-11-30 16:03:39 +000049 'variables': {
50 'variables': {
Ben Murdoch3ef787d2012-04-12 10:51:47 +010051 'variables': {
52 'conditions': [
Ben Murdochb8a8cc12014-11-26 15:28:44 +000053 ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000054 OS=="netbsd" or OS=="mac" or OS=="qnx" or OS=="aix"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000055 # This handles the Unix platforms we generally deal with.
Ben Murdoch3ef787d2012-04-12 10:51:47 +010056 # Anything else gets passed through, which probably won't work
57 # very well; such hosts should pass an explicit target_arch
58 # to gyp.
Ben Murdochb8a8cc12014-11-26 15:28:44 +000059 'host_arch%': '<!pymod_do_main(detect_v8_host_arch)',
Ben Murdoch3ef787d2012-04-12 10:51:47 +010060 }, {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000061 # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000062 # OS!="netbsd" and OS!="mac" and OS!="aix"
Ben Murdoch3ef787d2012-04-12 10:51:47 +010063 'host_arch%': 'ia32',
64 }],
65 ],
66 },
67 'host_arch%': '<(host_arch)',
68 'target_arch%': '<(host_arch)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000069 'base_dir%': '<!(cd <(DEPTH) && python -c "import os; print os.getcwd()")',
70
71 # Instrument for code coverage with gcov.
72 'coverage%': 0,
Ben Murdoch69a99ed2011-11-30 16:03:39 +000073 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000074 'base_dir%': '<(base_dir)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +000075 'host_arch%': '<(host_arch)',
Ben Murdoch3ef787d2012-04-12 10:51:47 +010076 'target_arch%': '<(target_arch)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +000077 'v8_target_arch%': '<(target_arch)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000078 'coverage%': '<(coverage)',
79 'asan%': 0,
80 'lsan%': 0,
81 'msan%': 0,
82 'tsan%': 0,
83 # Enable coverage gathering instrumentation in sanitizer tools. This flag
84 # also controls coverage granularity (1 for function-level, 2 for
85 # block-level, 3 for edge-level).
86 'sanitizer_coverage%': 0,
87 # Use libc++ (buildtools/third_party/libc++ and
88 # buildtools/third_party/libc++abi) instead of stdlibc++ as standard
89 # library. This is intended to be used for instrumented builds.
90 'use_custom_libcxx%': 0,
91
92 'clang_dir%': '<(base_dir)/third_party/llvm-build/Release+Asserts',
93
94 'use_lto%': 0,
95
96 # Control Flow Integrity for virtual calls and casts.
97 # See http://clang.llvm.org/docs/ControlFlowIntegrity.html
98 'cfi_vptr%': 0,
99 'cfi_diag%': 0,
100
101 'cfi_blacklist%': '<(base_dir)/tools/cfi/blacklist.txt',
102
103 # Set to 1 to enable fast builds.
104 # TODO(machenbach): Only configured for windows.
105 'fastbuild%': 0,
106
107 # goma settings.
108 # 1 to use goma.
109 # If no gomadir is set, it uses the default gomadir.
110 'use_goma%': 0,
111 'gomadir%': '',
112
113 'conditions': [
114 # Set default gomadir.
115 ['OS=="win"', {
116 'gomadir': 'c:\\goma\\goma-win',
117 }, {
118 'gomadir': '<!(/bin/echo -n ${HOME}/goma)',
119 }],
120 ['host_arch!="ppc" and host_arch!="ppc64" and host_arch!="ppc64le" and host_arch!="s390" and host_arch!="s390x" and \
121 coverage==0', {
122 'host_clang%': 1,
123 }, {
124 'host_clang%': 0,
125 }],
126 # linux_use_bundled_gold: whether to use the gold linker binary checked
127 # into third_party/binutils. Force this off via GYP_DEFINES when you
128 # are using a custom toolchain and need to control -B in ldflags.
129 # Do not use 32-bit gold on 32-bit hosts as it runs out address space
130 # for component=static_library builds.
131 ['(OS=="linux" or OS=="android") and (target_arch=="x64" or target_arch=="arm" or (target_arch=="ia32" and host_arch=="x64"))', {
132 'linux_use_bundled_gold%': 1,
133 }, {
134 'linux_use_bundled_gold%': 0,
135 }],
136
137 # TODO(machenbach): Remove the conditions as more configurations are
138 # supported.
139 ['OS=="linux" or OS=="win"', {
140 'test_isolation_mode%': 'check',
141 }, {
142 'test_isolation_mode%': 'noop',
143 }],
144 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000145 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000146 'base_dir%': '<(base_dir)',
147 'clang_dir%': '<(clang_dir)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000148 'host_arch%': '<(host_arch)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000149 'host_clang%': '<(host_clang)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000150 'target_arch%': '<(target_arch)',
151 'v8_target_arch%': '<(v8_target_arch)',
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100152 'werror%': '-Werror',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000153 'use_goma%': '<(use_goma)',
154 'gomadir%': '<(gomadir)',
155 'asan%': '<(asan)',
156 'lsan%': '<(lsan)',
157 'msan%': '<(msan)',
158 'tsan%': '<(tsan)',
159 'sanitizer_coverage%': '<(sanitizer_coverage)',
160 'use_custom_libcxx%': '<(use_custom_libcxx)',
161 'linux_use_bundled_gold%': '<(linux_use_bundled_gold)',
162 'use_lto%': '<(use_lto)',
163 'cfi_vptr%': '<(cfi_vptr)',
164 'cfi_diag%': '<(cfi_diag)',
165 'cfi_blacklist%': '<(cfi_blacklist)',
166 'test_isolation_mode%': '<(test_isolation_mode)',
167 'fastbuild%': '<(fastbuild)',
168 'coverage%': '<(coverage)',
169
170 # Add a simple extras solely for the purpose of the cctests
171 'v8_extra_library_files': ['../test/cctest/test-extra.js'],
172 'v8_experimental_extra_library_files': ['../test/cctest/test-experimental-extra.js'],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000173
174 # .gyp files or targets should set v8_code to 1 if they build V8 specific
175 # code, as opposed to external code. This variable is used to control such
176 # things as the set of warnings to enable, and whether warnings are treated
177 # as errors.
178 'v8_code%': 0,
179
180 # Speeds up Debug builds:
181 # 0 - Compiler optimizations off (debuggable) (default). This may
182 # be 5x slower than Release (or worse).
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000183 # 1 - Turn on optimizations and disable slow DCHECKs, but leave
184 # V8_ENABLE_CHECKS and most other assertions enabled. This may cause
185 # some v8 tests to fail in the Debug configuration. This roughly
186 # matches the performance of a Release build and can be used by
187 # embedders that need to build their own code as debug but don't want
188 # or need a debug version of V8. This should produce near-release
189 # speeds.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000190 'v8_optimized_debug%': 0,
191
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400192 # Use external files for startup data blobs:
193 # the JS builtins sources and the start snapshot.
194 # Embedders that don't use standalone.gypi will need to add
195 # their own default value.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000196 'v8_use_external_startup_data%': 1,
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400197
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000198 # Relative path to icu.gyp from this file.
199 'icu_gyp_path': '../third_party/icu/icu.gyp',
200
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000201 'conditions': [
202 ['(v8_target_arch=="arm" and host_arch!="arm") or \
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000203 (v8_target_arch=="arm64" and host_arch!="arm64") or \
204 (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
205 (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
206 (v8_target_arch=="x64" and host_arch!="x64") or \
207 (OS=="android" or OS=="qnx")', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000208 'want_separate_host_toolset': 1,
209 }, {
210 'want_separate_host_toolset': 0,
211 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000212 ['OS == "win"', {
213 'os_posix%': 0,
214 }, {
215 'os_posix%': 1,
216 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000217 ['OS=="win" and use_goma==1', {
218 # goma doesn't support pch yet.
219 'chromium_win_pch': 0,
220 # goma doesn't support PDB yet.
221 'fastbuild%': 1,
222 }],
223 ['((v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
224 (OS=="linux" or OS=="mac")) or (v8_target_arch=="ppc64" and OS=="linux")', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000225 'v8_enable_gdbjit%': 1,
226 }, {
227 'v8_enable_gdbjit%': 0,
228 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000229 ['(OS=="linux" or OS=="mac") and (target_arch=="ia32" or target_arch=="x64") and \
230 (v8_target_arch!="x87" and v8_target_arch!="x32") and coverage==0', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000231 'clang%': 1,
232 }, {
233 'clang%': 0,
234 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000235 ['asan==1 or lsan==1 or msan==1 or tsan==1', {
236 'clang%': 1,
237 'use_allocator%': 'none',
238 }],
239 ['asan==1 and OS=="linux"', {
240 'use_custom_libcxx%': 1,
241 }],
242 ['tsan==1', {
243 'use_custom_libcxx%': 1,
244 }],
245 ['msan==1', {
246 # Use a just-built, MSan-instrumented libc++ instead of the system-wide
247 # libstdc++. This is required to avoid false positive reports whenever
248 # the C++ standard library is used.
249 'use_custom_libcxx%': 1,
250 }],
251 ['cfi_vptr==1', {
252 'use_lto%': 1,
253 }],
254 ['OS=="android"', {
255 # Location of Android NDK.
256 'variables': {
257 'variables': {
258 # The Android toolchain needs to use the absolute path to the NDK
259 # because it is used at different levels in the GYP files.
260 'android_ndk_root%': '<(base_dir)/third_party/android_tools/ndk/',
261 'android_host_arch%': "<!(uname -m | sed -e 's/i[3456]86/x86/')",
262 'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
263 },
264
265 # Copy conditionally-set variables out one scope.
266 'android_ndk_root%': '<(android_ndk_root)',
267 'host_os%': '<(host_os)',
268
269 'conditions': [
270 ['target_arch == "ia32"', {
271 'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
272 'android_target_arch%': 'x86',
273 'android_target_platform%': '16',
274 }],
275 ['target_arch == "x64"', {
276 'android_toolchain%': '<(android_ndk_root)/toolchains/x86_64-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
277 'android_target_arch%': 'x86_64',
278 'android_target_platform%': '21',
279 }],
280 ['target_arch=="arm"', {
281 'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
282 'android_target_arch%': 'arm',
283 'android_target_platform%': '16',
284 'arm_version%': 7,
285 }],
286 ['target_arch == "arm64"', {
287 'android_toolchain%': '<(android_ndk_root)/toolchains/aarch64-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
288 'android_target_arch%': 'arm64',
289 'android_target_platform%': '21',
290 'arm_version%': 'default',
291 }],
292 ['target_arch == "mipsel"', {
293 'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
294 'android_target_arch%': 'mips',
295 'android_target_platform%': '16',
296 }],
297 ['target_arch == "mips64el"', {
298 'android_toolchain%': '<(android_ndk_root)/toolchains/mips64el-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
299 'android_target_arch%': 'mips64',
300 'android_target_platform%': '21',
301 }],
302 ],
303 },
304
305 # Copy conditionally-set variables out one scope.
306 'android_target_arch%': '<(android_target_arch)',
307 'android_target_platform%': '<(android_target_platform)',
308 'android_toolchain%': '<(android_toolchain)',
309 'arm_version%': '<(arm_version)',
310 'host_os%': '<(host_os)',
311
312 'conditions': [
313 ['android_ndk_root==""', {
314 'variables': {
315 'android_sysroot': '<(android_toolchain)/sysroot/',
316 'android_stlport': '<(android_toolchain)/sources/cxx-stl/stlport/',
317 },
318 'android_include': '<(android_sysroot)/usr/include',
319 'conditions': [
320 ['target_arch=="x64"', {
321 'android_lib': '<(android_sysroot)/usr/lib64',
322 }, {
323 'android_lib': '<(android_sysroot)/usr/lib',
324 }],
325 ],
326 'android_stlport_include': '<(android_stlport)/stlport',
327 'android_stlport_libs': '<(android_stlport)/libs',
328 }, {
329 'variables': {
330 'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)',
331 'android_stlport': '<(android_ndk_root)/sources/cxx-stl/stlport/',
332 },
333 'android_include': '<(android_sysroot)/usr/include',
334 'conditions': [
335 ['target_arch=="x64"', {
336 'android_lib': '<(android_sysroot)/usr/lib64',
337 }, {
338 'android_lib': '<(android_sysroot)/usr/lib',
339 }],
340 ],
341 'android_stlport_include': '<(android_stlport)/stlport',
342 'android_stlport_libs': '<(android_stlport)/libs',
343 }],
344 ],
345 'android_stlport_library': 'stlport_static',
346 }], # OS=="android"
347 ['host_clang==1', {
348 'host_cc': '<(clang_dir)/bin/clang',
349 'host_cxx': '<(clang_dir)/bin/clang++',
350 }, {
351 'host_cc': '<!(which gcc)',
352 'host_cxx': '<!(which g++)',
353 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000354 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000355 # Default ARM variable settings.
356 'arm_version%': 'default',
357 'arm_fpu%': 'vfpv3',
358 'arm_float_abi%': 'default',
359 'arm_thumb': 'default',
Paul Lind18a7ebb2014-12-17 22:29:32 -0800360
361 # Default MIPS variable settings.
362 'mips_arch_variant%': 'r2',
363 # Possible values fp32, fp64, fpxx.
364 # fp32 - 32 32-bit FPU registers are available, doubles are placed in
365 # register pairs.
366 # fp64 - 32 64-bit FPU registers are available.
367 # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
368 # detection
369 'mips_fpu_mode%': 'fp32',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000370 },
371 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000372 'variables': {
373 'v8_code%': '<(v8_code)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000374 'conditions':[
375 ['OS=="android"', {
376 'host_os%': '<(host_os)',
377 }],
378 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000379 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000380 'default_configuration': 'Debug',
381 'configurations': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000382 'DebugBaseCommon': {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400383 'conditions': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000384 ['OS=="aix"', {
385 'cflags': [ '-g', '-Og', '-gxcoff' ],
386 }, {
387 'cflags': [ '-g', '-O0' ],
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400388 }],
389 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000390 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000391 'Optdebug': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000392 'inherit_from': [ 'DebugBaseCommon', 'DebugBase1' ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000393 },
394 'Debug': {
395 # Xcode insists on this empty entry.
396 },
397 'Release': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000398 'cflags+': ['<@(release_extra_cflags)'],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000399 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000400 'conditions': [
401 ['OS=="win"', {
402 'Optdebug_x64': {
403 'inherit_from': ['Optdebug'],
404 },
405 'Debug_x64': {
406 'inherit_from': ['Debug'],
407 },
408 'Release_x64': {
409 'inherit_from': ['Release'],
410 },
411 }],
412 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000413 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000414 'conditions':[
415 ['clang==0', {
416 'cflags+': ['-Wno-sign-compare',],
417 }],
418 ['clang==1 or host_clang==1', {
419 # This is here so that all files get recompiled after a clang roll and
420 # when turning clang on or off.
421 # (defines are passed via the command line, and build systems rebuild
422 # things when their commandline changes). Nothing should ever read this
423 # define.
424 'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
425 'conditions': [
426 ['host_clang==1', {
427 'target_conditions': [
428 ['_toolset=="host"', {
429 'cflags+': [
430 '-Wno-format-pedantic',
431 ],
432 }],
433 ],
434 }],
435 ['clang==1', {
436 'target_conditions': [
437 ['_toolset=="target"', {
438 'cflags+': [
439 '-Wno-format-pedantic',
440 ],
441 }],
442 ],
443 }],
444 ],
445 }],
446 ['fastbuild!=0', {
447 'conditions': [
448 ['OS=="win" and fastbuild==1', {
449 'msvs_settings': {
450 'VCLinkerTool': {
451 # This tells the linker to generate .pdbs, so that
452 # we can get meaningful stack traces.
453 'GenerateDebugInformation': 'true',
454 },
455 'VCCLCompilerTool': {
456 # No debug info to be generated by compiler.
457 'DebugInformationFormat': '0',
458 },
459 },
460 }],
461 ],
462 }], # fastbuild!=0
463 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000464 'target_conditions': [
465 ['v8_code == 0', {
466 'defines!': [
467 'DEBUG',
468 ],
469 'conditions': [
470 ['os_posix == 1 and OS != "mac"', {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000471 # We don't want to get warnings from third-party code,
472 # so remove any existing warning-enabling flags like -Wall.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000473 'cflags!': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000474 '-pedantic',
475 '-Wall',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000476 '-Werror',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000477 '-Wextra',
478 '-Wshorten-64-to-32',
479 ],
480 'cflags+': [
481 # Clang considers the `register` keyword as deprecated, but
482 # ICU uses it all over the place.
483 '-Wno-deprecated-register',
484 # ICU uses its own deprecated functions.
485 '-Wno-deprecated-declarations',
486 # ICU prefers `a && b || c` over `(a && b) || c`.
487 '-Wno-logical-op-parentheses',
488 # ICU has some `unsigned < 0` checks.
489 '-Wno-tautological-compare',
490 # uresdata.c has switch(RES_GET_TYPE(x)) code. The
491 # RES_GET_TYPE macro returns an UResType enum, but some switch
492 # statement contains case values that aren't part of that
493 # enum (e.g. URES_TABLE32 which is in UResInternalType). This
494 # is on purpose.
495 '-Wno-switch',
496 ],
497 'cflags_cc!': [
498 '-Wnon-virtual-dtor',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000499 ],
500 }],
501 ['OS == "mac"', {
502 'xcode_settings': {
503 'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror
504 },
505 }],
506 ['OS == "win"', {
507 'msvs_settings': {
508 'VCCLCompilerTool': {
509 'WarnAsError': 'false',
510 },
511 },
512 }],
513 ],
514 }],
515 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000516 },
517 'conditions': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000518 ['os_posix==1 and OS!="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000519 'target_defaults': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000520 'conditions': [
521 # Common options for AddressSanitizer, LeakSanitizer,
522 # ThreadSanitizer, MemorySanitizer and CFI builds.
523 ['asan==1 or lsan==1 or tsan==1 or msan==1 or cfi_vptr==1', {
524 'target_conditions': [
525 ['_toolset=="target"', {
526 'cflags': [
527 '-fno-omit-frame-pointer',
528 '-gline-tables-only',
529 ],
530 'cflags!': [
531 '-fomit-frame-pointer',
532 ],
533 }],
534 ],
535 }],
536 ['asan==1', {
537 'target_conditions': [
538 ['_toolset=="target"', {
539 'cflags': [
540 '-fsanitize=address',
541 ],
542 'ldflags': [
543 '-fsanitize=address',
544 ],
545 'defines': [
546 'ADDRESS_SANITIZER',
547 ],
548 }],
549 ],
550 }],
551 ['lsan==1', {
552 'target_conditions': [
553 ['_toolset=="target"', {
554 'cflags': [
555 '-fsanitize=leak',
556 ],
557 'ldflags': [
558 '-fsanitize=leak',
559 ],
560 'defines': [
561 'LEAK_SANITIZER',
562 ],
563 }],
564 ],
565 }],
566 ['tsan==1', {
567 'target_conditions': [
568 ['_toolset=="target"', {
569 'cflags': [
570 '-fsanitize=thread',
571 ],
572 'ldflags': [
573 '-fsanitize=thread',
574 ],
575 'defines': [
576 'THREAD_SANITIZER',
577 ],
578 }],
579 ],
580 }],
581 ['msan==1', {
582 'target_conditions': [
583 ['_toolset=="target"', {
584 'cflags': [
585 '-fsanitize=memory',
586 '-fsanitize-memory-track-origins=<(msan_track_origins)',
587 '-fPIC',
588 ],
589 'ldflags': [
590 '-fsanitize=memory',
591 '-pie',
592 ],
593 'defines': [
594 'MEMORY_SANITIZER',
595 ],
596 }],
597 ],
598 }],
599 ['use_custom_libcxx==1', {
600 'dependencies': [
601 '<(DEPTH)/buildtools/third_party/libc++/libc++.gyp:libcxx_proxy',
602 ],
603 }],
604 ['sanitizer_coverage!=0', {
605 'target_conditions': [
606 ['_toolset=="target"', {
607 'cflags': [
608 '-fsanitize-coverage=<(sanitizer_coverage)',
609 ],
610 'defines': [
611 'SANITIZER_COVERAGE',
612 ],
613 }],
614 ],
615 }],
616 ['linux_use_bundled_gold==1 and not (clang==0 and use_lto==1)', {
617 # Put our binutils, which contains gold in the search path. We pass
618 # the path to gold to the compiler. gyp leaves unspecified what the
619 # cwd is when running the compiler, so the normal gyp path-munging
620 # fails us. This hack gets the right path.
621 #
622 # Disabled when using GCC LTO because GCC also uses the -B search
623 # path at link time to find "as", and our bundled "as" can only
624 # target x86.
625 'ldflags': [
626 # Note, Chromium allows ia32 host arch as well, we limit this to
627 # x64 in v8.
628 '-B<(base_dir)/third_party/binutils/Linux_x64/Release/bin',
629 ],
630 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000631 ],
632 },
633 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000634 ['OS=="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000635 'target_defaults': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000636 'conditions': [
637 ['asan==1', {
638 'xcode_settings': {
639 # FIXME(machenbach): This is outdated compared to common.gypi.
640 'OTHER_CFLAGS+': [
641 '-fno-omit-frame-pointer',
642 '-gline-tables-only',
643 '-fsanitize=address',
644 '-w', # http://crbug.com/162783
645 ],
646 'OTHER_CFLAGS!': [
647 '-fomit-frame-pointer',
648 ],
649 'defines': [
650 'ADDRESS_SANITIZER',
651 ],
652 },
653 'dependencies': [
654 '<(DEPTH)/build/mac/asan.gyp:asan_dynamic_runtime',
655 ],
656 'target_conditions': [
657 ['_type!="static_library"', {
658 'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
659 }],
660 ],
661 }],
662 ['sanitizer_coverage!=0', {
663 'target_conditions': [
664 ['_toolset=="target"', {
665 'cflags': [
666 '-fsanitize-coverage=<(sanitizer_coverage)',
667 ],
668 'defines': [
669 'SANITIZER_COVERAGE',
670 ],
671 }],
672 ],
673 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000674 ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000675 }, # target_defaults
676 }], # OS=="mac"
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100677 ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000678 or OS=="netbsd" or OS=="aix"', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000679 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000680 'cflags': [
681 '-Wall',
682 '<(werror)',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000683 '-Wno-unused-parameter',
684 '-Wno-long-long',
685 '-pthread',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000686 '-pedantic',
687 # Don't warn about the "struct foo f = {0};" initialization pattern.
688 '-Wno-missing-field-initializers',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000689 '-Wno-gnu-zero-variadic-macro-arguments',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000690 ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000691 'cflags_cc': [
692 '-Wnon-virtual-dtor',
693 '-fno-exceptions',
694 '-fno-rtti',
695 '-std=gnu++0x',
696 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000697 'ldflags': [ '-pthread', ],
698 'conditions': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000699 # Don't warn about TRACE_EVENT_* macros with zero arguments passed to
700 # ##__VA_ARGS__. C99 strict mode prohibits having zero variadic macro
701 # arguments in gcc.
702 [ 'clang==0', {
703 'cflags!' : [
704 '-pedantic' ,
705 # Don't warn about unrecognized command line option.
706 '-Wno-gnu-zero-variadic-macro-arguments',
707 ],
708 }],
709 [ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64" \
710 or v8_target_arch=="mips64el")', {
711 'cflags': [ '-Wshorten-64-to-32' ],
712 }],
713 [ 'host_arch=="ppc64" and OS!="aix"', {
714 'cflags': [ '-mminimal-toc' ],
715 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000716 [ 'visibility=="hidden" and v8_enable_backtrace==0', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000717 'cflags': [ '-fvisibility=hidden' ],
718 }],
719 [ 'component=="shared_library"', {
720 'cflags': [ '-fPIC', ],
721 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000722 [ 'coverage==1', {
723 'cflags!': [ '-O3', '-O2', '-O1', ],
724 'cflags': [ '-fprofile-arcs', '-ftest-coverage', '-O0'],
725 'ldflags': [ '-fprofile-arcs'],
726 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000727 ],
728 },
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100729 }],
730 # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
731 # or OS=="netbsd"'
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000732 ['OS=="qnx"', {
733 'target_defaults': {
734 'cflags': [
735 '-Wall',
736 '<(werror)',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000737 '-Wno-unused-parameter',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000738 # Don't warn about the "struct foo f = {0};" initialization pattern.
739 '-Wno-missing-field-initializers',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000740 '-Wno-gnu-zero-variadic-macro-arguments',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000741 ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000742 'cflags_cc': [
743 '-Wnon-virtual-dtor',
744 '-fno-exceptions',
745 '-fno-rtti',
746 '-std=gnu++0x',
747 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000748 'conditions': [
749 [ 'visibility=="hidden"', {
750 'cflags': [ '-fvisibility=hidden' ],
751 }],
752 [ 'component=="shared_library"', {
753 'cflags': [ '-fPIC' ],
754 }],
755 ],
756 'target_conditions': [
757 [ '_toolset=="host" and host_os=="linux"', {
758 'cflags': [ '-pthread' ],
759 'ldflags': [ '-pthread' ],
760 'libraries': [ '-lrt' ],
761 }],
762 [ '_toolset=="target"', {
763 'cflags': [ '-Wno-psabi' ],
764 'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
765 }],
766 ],
767 },
768 }], # OS=="qnx"
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000769 ['OS=="win"', {
770 'target_defaults': {
771 'defines': [
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000772 '_CRT_SECURE_NO_DEPRECATE',
773 '_CRT_NONSTDC_NO_DEPRECATE',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000774 '_USING_V110_SDK71_',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000775 ],
776 'conditions': [
777 ['component=="static_library"', {
778 'defines': [
779 '_HAS_EXCEPTIONS=0',
780 ],
781 }],
782 ],
783 'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000784 'msvs_disabled_warnings': [
785 # C4091: 'typedef ': ignored on left of 'X' when no variable is
786 # declared.
787 # This happens in a number of Windows headers. Dumb.
788 4091,
789
790 # C4127: conditional expression is constant
791 # This warning can in theory catch dead code and other problems, but
792 # triggers in far too many desirable cases where the conditional
793 # expression is either set by macros or corresponds some legitimate
794 # compile-time constant expression (due to constant template args,
795 # conditionals comparing the sizes of different types, etc.). Some of
796 # these can be worked around, but it's not worth it.
797 4127,
798
799 # C4351: new behavior: elements of array 'array' will be default
800 # initialized
801 # This is a silly "warning" that basically just alerts you that the
802 # compiler is going to actually follow the language spec like it's
803 # supposed to, instead of not following it like old buggy versions
804 # did. There's absolutely no reason to turn this on.
805 4351,
806
807 # C4355: 'this': used in base member initializer list
808 # It's commonly useful to pass |this| to objects in a class'
809 # initializer list. While this warning can catch real bugs, most of
810 # the time the constructors in question don't attempt to call methods
811 # on the passed-in pointer (until later), and annotating every legit
812 # usage of this is simply more hassle than the warning is worth.
813 4355,
814
815 # C4503: 'identifier': decorated name length exceeded, name was
816 # truncated
817 # This only means that some long error messages might have truncated
818 # identifiers in the presence of lots of templates. It has no effect
819 # on program correctness and there's no real reason to waste time
820 # trying to prevent it.
821 4503,
822
823 # Warning C4589 says: "Constructor of abstract class ignores
824 # initializer for virtual base class." Disable this warning because it
825 # is flaky in VS 2015 RTM. It triggers on compiler generated
826 # copy-constructors in some cases.
827 4589,
828
829 # C4611: interaction between 'function' and C++ object destruction is
830 # non-portable
831 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN
832 # suggests using exceptions instead of setjmp/longjmp for C++, but
833 # Chromium code compiles without exception support. We therefore have
834 # to use setjmp/longjmp for e.g. JPEG decode error handling, which
835 # means we have to turn off this warning (and be careful about how
836 # object destruction happens in such cases).
837 4611,
838
839 # TODO(jochen): These warnings are level 4. They will be slowly
840 # removed as code is fixed.
841 4100, # Unreferenced formal parameter
842 4121, # Alignment of a member was sensitive to packing
843 4244, # Conversion from 'type1' to 'type2', possible loss of data
844 4302, # Truncation from 'type 1' to 'type 2'
845 4309, # Truncation of constant value
846 4311, # Pointer truncation from 'type' to 'type'
847 4312, # Conversion from 'type1' to 'type2' of greater size
848 4505, # Unreferenced local function has been removed
849 4510, # Default constructor could not be generated
850 4512, # Assignment operator could not be generated
851 4610, # Object can never be instantiated
852 4800, # Forcing value to bool.
853 4838, # Narrowing conversion. Doesn't seem to be very useful.
854 4995, # 'X': name was marked as #pragma deprecated
855 4996, # 'X': was declared deprecated (for GetVersionEx).
856
857 # These are variable shadowing warnings that are new in VS2015. We
858 # should work through these at some point -- they may be removed from
859 # the RTM release in the /W4 set.
860 4456, 4457, 4458, 4459,
861 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000862 'msvs_settings': {
863 'VCCLCompilerTool': {
864 'MinimalRebuild': 'false',
865 'BufferSecurityCheck': 'true',
866 'EnableFunctionLevelLinking': 'true',
867 'RuntimeTypeInfo': 'false',
868 'WarningLevel': '3',
869 'WarnAsError': 'true',
870 'DebugInformationFormat': '3',
871 'Detect64BitPortabilityProblems': 'false',
872 'conditions': [
873 [ 'msvs_multi_core_compile', {
874 'AdditionalOptions': ['/MP'],
875 }],
876 ['component=="shared_library"', {
877 'ExceptionHandling': '1', # /EHsc
878 }, {
879 'ExceptionHandling': '0',
880 }],
881 ],
882 },
883 'VCLibrarianTool': {
884 'AdditionalOptions': ['/ignore:4221'],
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400885 'conditions': [
886 ['v8_target_arch=="x64"', {
887 'TargetMachine': '17', # x64
888 }, {
889 'TargetMachine': '1', # ia32
890 }],
891 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000892 },
893 'VCLinkerTool': {
894 'AdditionalDependencies': [
895 'ws2_32.lib',
896 ],
897 'GenerateDebugInformation': 'true',
898 'MapFileName': '$(OutDir)\\$(TargetName).map',
899 'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
900 'FixedBaseAddress': '1',
901 # LinkIncremental values:
902 # 0 == default
903 # 1 == /INCREMENTAL:NO
904 # 2 == /INCREMENTAL
905 'LinkIncremental': '1',
906 # SubSystem values:
907 # 0 == not set
908 # 1 == /SUBSYSTEM:CONSOLE
909 # 2 == /SUBSYSTEM:WINDOWS
910 'SubSystem': '1',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000911
912 'conditions': [
913 ['v8_enable_i18n_support==1', {
914 'AdditionalDependencies': [
915 'advapi32.lib',
916 ],
917 }],
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400918 ['v8_target_arch=="x64"', {
919 'MinimumRequiredVersion': '5.02', # Server 2003.
920 'TargetMachine': '17', # x64
921 }, {
922 'MinimumRequiredVersion': '5.01', # XP.
923 'TargetMachine': '1', # ia32
924 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000925 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000926 },
927 },
928 },
929 }], # OS=="win"
930 ['OS=="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000931 'xcode_settings': {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400932 'SDKROOT': 'macosx',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000933 'SYMROOT': '<(DEPTH)/xcodebuild',
934 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000935 'target_defaults': {
936 'xcode_settings': {
937 'ALWAYS_SEARCH_USER_PATHS': 'NO',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000938 'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000939 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
940 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
941 # (Equivalent to -fPIC)
942 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
943 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
944 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
945 # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
946 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
947 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
948 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000949 'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
950 # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
951 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000952 'PREBINDING': 'NO', # No -Wl,-prebind
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000953 'SYMROOT': '<(DEPTH)/xcodebuild',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000954 'USE_HEADERMAP': 'NO',
955 'OTHER_CFLAGS': [
956 '-fno-strict-aliasing',
957 ],
958 'WARNING_CFLAGS': [
959 '-Wall',
960 '-Wendif-labels',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000961 '-Wno-unused-parameter',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000962 # Don't warn about the "struct foo f = {0};" initialization pattern.
963 '-Wno-missing-field-initializers',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000964 '-Wno-gnu-zero-variadic-macro-arguments',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000965 ],
966 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000967 'conditions': [
968 ['werror==""', {
969 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
970 }, {
971 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
972 }],
973 ['clang==1', {
974 'xcode_settings': {
975 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
976 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x', # -std=gnu++0x
977 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000978 'conditions': [
979 ['v8_target_arch=="x64" or v8_target_arch=="arm64" \
980 or v8_target_arch=="mips64el"', {
981 'xcode_settings': {'WARNING_CFLAGS': ['-Wshorten-64-to-32']},
982 }],
983 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000984 }],
985 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000986 'target_conditions': [
987 ['_type!="static_library"', {
988 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
989 }],
990 ], # target_conditions
991 }, # target_defaults
992 }], # OS=="mac"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000993 ['OS=="android"', {
994 'target_defaults': {
995 'defines': [
996 'ANDROID',
997 'V8_ANDROID_LOG_STDOUT',
998 ],
999 'configurations': {
1000 'Release': {
1001 'cflags': [
1002 '-fomit-frame-pointer',
1003 ],
1004 }, # Release
1005 }, # configurations
1006 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'],
1007 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions',
1008 # Note: Using -std=c++0x will define __STRICT_ANSI__, which
1009 # in turn will leave out some template stuff for 'long
1010 # long'. What we want is -std=c++11, but this is not
1011 # supported by GCC 4.6 or Xcode 4.2
1012 '-std=gnu++0x' ],
1013 'target_conditions': [
1014 ['_toolset=="target"', {
1015 'cflags!': [
1016 '-pthread', # Not supported by Android toolchain.
1017 ],
1018 'cflags': [
1019 '-ffunction-sections',
1020 '-funwind-tables',
1021 '-fstack-protector',
1022 '-fno-short-enums',
1023 '-finline-limit=64',
1024 '-Wa,--noexecstack',
1025 # Note: This include is in cflags to ensure that it comes after
1026 # all of the includes.
1027 '-I<(android_include)',
1028 '-I<(android_stlport_include)',
1029 ],
1030 'cflags_cc': [
1031 '-Wno-error=non-virtual-dtor', # TODO(michaelbai): Fix warnings.
1032 ],
1033 'defines': [
1034 'ANDROID',
1035 #'__GNU_SOURCE=1', # Necessary for clone()
1036 'USE_STLPORT=1',
1037 '_STLP_USE_PTR_SPECIALIZATIONS=1',
1038 'HAVE_OFF64_T',
1039 'HAVE_SYS_UIO_H',
1040 'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
1041 ],
1042 'ldflags!': [
1043 '-pthread', # Not supported by Android toolchain.
1044 ],
1045 'ldflags': [
1046 '-nostdlib',
1047 '-Wl,--no-undefined',
1048 '-Wl,-rpath-link=<(android_lib)',
1049 '-L<(android_lib)',
1050 ],
1051 'libraries!': [
1052 '-lrt', # librt is built into Bionic.
1053 # Not supported by Android toolchain.
1054 # Where do these come from? Can't find references in
1055 # any Chromium gyp or gypi file. Maybe they come from
1056 # gyp itself?
1057 '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4',
1058 ],
1059 'libraries': [
1060 '-l<(android_stlport_library)',
1061 # Manually link the libgcc.a that the cross compiler uses.
1062 '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
1063 '-lc',
1064 '-ldl',
1065 '-lstdc++',
1066 '-lm',
1067 ],
1068 'conditions': [
1069 ['target_arch == "arm"', {
1070 'ldflags': [
1071 # Enable identical code folding to reduce size.
1072 '-Wl,--icf=safe',
1073 ],
1074 }],
1075 ['target_arch=="arm" and arm_version==7', {
1076 'cflags': [
1077 '-march=armv7-a',
1078 '-mtune=cortex-a8',
1079 '-mfpu=vfp3',
1080 ],
1081 'ldflags': [
1082 '-L<(android_stlport_libs)/armeabi-v7a',
1083 ],
1084 }],
1085 ['target_arch=="arm" and arm_version < 7', {
1086 'ldflags': [
1087 '-L<(android_stlport_libs)/armeabi',
1088 ],
1089 }],
1090 ['target_arch=="x64"', {
1091 'ldflags': [
1092 '-L<(android_stlport_libs)/x86_64',
1093 ],
1094 }],
1095 ['target_arch=="arm64"', {
1096 'ldflags': [
1097 '-L<(android_stlport_libs)/arm64-v8a',
1098 ],
1099 }],
1100 ['target_arch=="ia32" or target_arch=="x87"', {
1101 # The x86 toolchain currently has problems with stack-protector.
1102 'cflags!': [
1103 '-fstack-protector',
1104 ],
1105 'cflags': [
1106 '-fno-stack-protector',
1107 ],
1108 'ldflags': [
1109 '-L<(android_stlport_libs)/x86',
1110 ],
1111 }],
1112 ['target_arch=="mipsel"', {
1113 # The mips toolchain currently has problems with stack-protector.
1114 'cflags!': [
1115 '-fstack-protector',
1116 '-U__linux__'
1117 ],
1118 'cflags': [
1119 '-fno-stack-protector',
1120 ],
1121 'ldflags': [
1122 '-L<(android_stlport_libs)/mips',
1123 ],
1124 }],
1125 ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64" or target_arch=="ia32") and component!="shared_library"', {
1126 'cflags': [
1127 '-fPIE',
1128 ],
1129 'ldflags': [
1130 '-pie',
1131 ],
1132 }],
1133 ],
1134 'target_conditions': [
1135 ['_type=="executable"', {
1136 'conditions': [
1137 ['target_arch=="arm64" or target_arch=="x64"', {
1138 'ldflags': [
1139 '-Wl,-dynamic-linker,/system/bin/linker64',
1140 ],
1141 }, {
1142 'ldflags': [
1143 '-Wl,-dynamic-linker,/system/bin/linker',
1144 ],
1145 }]
1146 ],
1147 'ldflags': [
1148 '-Bdynamic',
1149 '-Wl,-z,nocopyreloc',
1150 # crtbegin_dynamic.o should be the last item in ldflags.
1151 '<(android_lib)/crtbegin_dynamic.o',
1152 ],
1153 'libraries': [
1154 # crtend_android.o needs to be the last item in libraries.
1155 # Do not add any libraries after this!
1156 '<(android_lib)/crtend_android.o',
1157 ],
1158 }],
1159 ['_type=="shared_library"', {
1160 'ldflags': [
1161 '-Wl,-shared,-Bsymbolic',
1162 '<(android_lib)/crtbegin_so.o',
1163 ],
1164 }],
1165 ['_type=="static_library"', {
1166 'ldflags': [
1167 # Don't export symbols from statically linked libraries.
1168 '-Wl,--exclude-libs=ALL',
1169 ],
1170 }],
1171 ],
1172 }], # _toolset=="target"
1173 # Settings for building host targets using the system toolchain.
1174 ['_toolset=="host"', {
1175 'cflags': [ '-pthread' ],
1176 'ldflags': [ '-pthread' ],
1177 'ldflags!': [
1178 '-Wl,-z,noexecstack',
1179 '-Wl,--gc-sections',
1180 '-Wl,-O1',
1181 '-Wl,--as-needed',
1182 ],
1183 }],
1184 ], # target_conditions
1185 }, # target_defaults
1186 }], # OS=="android"
1187 ['OS=="android" and clang==0', {
1188 # Hardcode the compiler names in the Makefile so that
1189 # it won't depend on the environment at make time.
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001190 'make_global_settings': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001191 ['CC', '<!(/bin/echo -n <(android_toolchain)/*-gcc)'],
1192 ['CXX', '<!(/bin/echo -n <(android_toolchain)/*-g++)'],
1193 ['CC.host', '<(host_cc)'],
1194 ['CXX.host', '<(host_cxx)'],
1195 ],
1196 }],
1197 ['clang!=1 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
1198 'make_global_settings': [
1199 ['CC.host', '<(clang_dir)/bin/clang'],
1200 ['CXX.host', '<(clang_dir)/bin/clang++'],
1201 ],
1202 }],
1203 ['clang==0 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
1204 'target_conditions': [
1205 ['_toolset=="host"', {
1206 'cflags_cc': [ '-std=gnu++11', ],
1207 }],
1208 ],
1209 'target_defaults': {
1210 'target_conditions': [
1211 ['_toolset=="host"', { 'cflags!': [ '-Wno-unused-local-typedefs' ]}],
1212 ],
1213 },
1214 }],
1215 ['clang==1 and "<(GENERATOR)"=="ninja"', {
1216 # See http://crbug.com/110262
1217 'target_defaults': {
1218 'cflags': [ '-fcolor-diagnostics' ],
1219 'xcode_settings': { 'OTHER_CFLAGS': [ '-fcolor-diagnostics' ] },
1220 },
1221 }],
1222 ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
1223 'and OS!="win" and "<(GENERATOR)"=="make"', {
1224 'make_global_settings': [
1225 ['CC', '<(clang_dir)/bin/clang'],
1226 ['CXX', '<(clang_dir)/bin/clang++'],
1227 ['CC.host', '$(CC)'],
1228 ['CXX.host', '$(CXX)'],
1229 ],
1230 }],
1231 ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
1232 'and OS!="win" and "<(GENERATOR)"=="ninja"', {
1233 'make_global_settings': [
1234 ['CC', '<(clang_dir)/bin/clang'],
1235 ['CXX', '<(clang_dir)/bin/clang++'],
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001236 ['CC.host', '$(CC)'],
1237 ['CXX.host', '$(CXX)'],
1238 ],
1239 }],
1240 ['clang==1 and OS=="win"', {
1241 'make_global_settings': [
1242 # On Windows, gyp's ninja generator only looks at CC.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001243 ['CC', '<(clang_dir)/bin/clang-cl'],
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001244 ],
1245 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001246 ['OS=="linux" and target_arch=="arm" and host_arch!="arm" and clang==0 and "<(GENERATOR)"=="ninja"', {
1247 # Set default ARM cross tools on linux. These can be overridden
1248 # using CC,CXX,CC.host and CXX.host environment variables.
1249 'make_global_settings': [
1250 ['CC', '<!(which arm-linux-gnueabihf-gcc)'],
1251 ['CXX', '<!(which arm-linux-gnueabihf-g++)'],
1252 ['CC.host', '<(host_cc)'],
1253 ['CXX.host', '<(host_cxx)'],
1254 ],
1255 }],
1256 # TODO(yyanagisawa): supports GENERATOR==make
1257 # make generator doesn't support CC_wrapper without CC
1258 # in make_global_settings yet.
1259 ['use_goma==1 and ("<(GENERATOR)"=="ninja" or clang==1)', {
1260 'make_global_settings': [
1261 ['CC_wrapper', '<(gomadir)/gomacc'],
1262 ['CXX_wrapper', '<(gomadir)/gomacc'],
1263 ['CC.host_wrapper', '<(gomadir)/gomacc'],
1264 ['CXX.host_wrapper', '<(gomadir)/gomacc'],
1265 ],
1266 }],
1267 ['use_lto==1', {
1268 'target_defaults': {
1269 'target_conditions': [
1270 ['_toolset=="target"', {
1271 'cflags': [
1272 '-flto',
1273 ],
1274 }],
1275 ],
1276 },
1277 }],
1278 ['use_lto==1 and clang==0', {
1279 'target_defaults': {
1280 'target_conditions': [
1281 ['_toolset=="target"', {
1282 'cflags': [
1283 '-ffat-lto-objects',
1284 ],
1285 }],
1286 ],
1287 },
1288 }],
1289 ['use_lto==1 and clang==1', {
1290 'target_defaults': {
1291 'target_conditions': [
1292 ['_toolset=="target"', {
1293 'arflags': [
1294 '--plugin', '<(clang_dir)/lib/LLVMgold.so',
1295 ],
1296 # Apply a lower optimization level with lto. Chromium does this
1297 # for non-official builds only - a differentiation that doesn't
1298 # exist in v8.
1299 'ldflags': [
1300 '-Wl,--plugin-opt,O1',
1301 ],
1302 }],
1303 ],
1304 },
1305 }],
1306 ['use_lto==1 and clang==0', {
1307 'target_defaults': {
1308 'target_conditions': [
1309 ['_toolset=="target"', {
1310 'ldflags': [
1311 '-flto=32',
1312 ],
1313 }],
1314 ],
1315 },
1316 }],
1317 ['use_lto==1 and clang==1', {
1318 'target_defaults': {
1319 'target_conditions': [
1320 ['_toolset=="target"', {
1321 'ldflags': [
1322 '-flto',
1323 ],
1324 }],
1325 ],
1326 },
1327 }],
1328 ['cfi_diag==1', {
1329 'target_defaults': {
1330 'target_conditions': [
1331 ['_toolset=="target"', {
1332 'cflags': [
1333 '-fno-sanitize-trap=cfi',
1334 '-fno-sanitize-recover=cfi',
1335 ],
1336 'cflags_cc!': [
1337 '-fno-rtti',
1338 ],
1339 'cflags!': [
1340 '-fno-rtti',
1341 ],
1342 'ldflags': [
1343 '-fno-sanitize-trap=cfi',
1344 '-fno-sanitize-recover=cfi',
1345 ],
1346 }],
1347 ],
1348 },
1349 }],
1350 ['cfi_vptr==1', {
1351 'target_defaults': {
1352 'target_conditions': [
1353 ['_toolset=="target"', {
1354 'cflags': [
1355 '-fsanitize=cfi-vcall',
1356 '-fsanitize=cfi-derived-cast',
1357 '-fsanitize=cfi-unrelated-cast',
1358 '-fsanitize-blacklist=<(cfi_blacklist)',
1359 ],
1360 'ldflags': [
1361 '-fsanitize=cfi-vcall',
1362 '-fsanitize=cfi-derived-cast',
1363 '-fsanitize=cfi-unrelated-cast',
1364 ],
1365 }],
1366 ],
1367 },
1368 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +00001369 ],
1370}