blob: 5269b95f64dbd9cf2f6ecba7c9c0d8764a4bf550 [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
Ben Murdoch097c5b22016-05-18 11:27:45 +0100113 # Check if valgrind directories are present.
114 'has_valgrind%': '<!pymod_do_main(has_valgrind)',
115
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000116 'conditions': [
117 # Set default gomadir.
118 ['OS=="win"', {
119 'gomadir': 'c:\\goma\\goma-win',
120 }, {
121 'gomadir': '<!(/bin/echo -n ${HOME}/goma)',
122 }],
123 ['host_arch!="ppc" and host_arch!="ppc64" and host_arch!="ppc64le" and host_arch!="s390" and host_arch!="s390x" and \
124 coverage==0', {
125 'host_clang%': 1,
126 }, {
127 'host_clang%': 0,
128 }],
129 # linux_use_bundled_gold: whether to use the gold linker binary checked
130 # into third_party/binutils. Force this off via GYP_DEFINES when you
131 # are using a custom toolchain and need to control -B in ldflags.
132 # Do not use 32-bit gold on 32-bit hosts as it runs out address space
133 # for component=static_library builds.
134 ['(OS=="linux" or OS=="android") and (target_arch=="x64" or target_arch=="arm" or (target_arch=="ia32" and host_arch=="x64"))', {
135 'linux_use_bundled_gold%': 1,
136 }, {
137 'linux_use_bundled_gold%': 0,
138 }],
139
140 # TODO(machenbach): Remove the conditions as more configurations are
141 # supported.
142 ['OS=="linux" or OS=="win"', {
143 'test_isolation_mode%': 'check',
144 }, {
145 'test_isolation_mode%': 'noop',
146 }],
147 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000148 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000149 'base_dir%': '<(base_dir)',
150 'clang_dir%': '<(clang_dir)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000151 'host_arch%': '<(host_arch)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000152 'host_clang%': '<(host_clang)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000153 'target_arch%': '<(target_arch)',
154 'v8_target_arch%': '<(v8_target_arch)',
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100155 'werror%': '-Werror',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000156 'use_goma%': '<(use_goma)',
157 'gomadir%': '<(gomadir)',
158 'asan%': '<(asan)',
159 'lsan%': '<(lsan)',
160 'msan%': '<(msan)',
161 'tsan%': '<(tsan)',
162 'sanitizer_coverage%': '<(sanitizer_coverage)',
163 'use_custom_libcxx%': '<(use_custom_libcxx)',
164 'linux_use_bundled_gold%': '<(linux_use_bundled_gold)',
165 'use_lto%': '<(use_lto)',
166 'cfi_vptr%': '<(cfi_vptr)',
167 'cfi_diag%': '<(cfi_diag)',
168 'cfi_blacklist%': '<(cfi_blacklist)',
169 'test_isolation_mode%': '<(test_isolation_mode)',
170 'fastbuild%': '<(fastbuild)',
171 'coverage%': '<(coverage)',
Ben Murdoch097c5b22016-05-18 11:27:45 +0100172 'has_valgrind%': '<(has_valgrind)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000173
174 # Add a simple extras solely for the purpose of the cctests
175 'v8_extra_library_files': ['../test/cctest/test-extra.js'],
176 'v8_experimental_extra_library_files': ['../test/cctest/test-experimental-extra.js'],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000177
178 # .gyp files or targets should set v8_code to 1 if they build V8 specific
179 # code, as opposed to external code. This variable is used to control such
180 # things as the set of warnings to enable, and whether warnings are treated
181 # as errors.
182 'v8_code%': 0,
183
184 # Speeds up Debug builds:
185 # 0 - Compiler optimizations off (debuggable) (default). This may
186 # be 5x slower than Release (or worse).
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000187 # 1 - Turn on optimizations and disable slow DCHECKs, but leave
188 # V8_ENABLE_CHECKS and most other assertions enabled. This may cause
189 # some v8 tests to fail in the Debug configuration. This roughly
190 # matches the performance of a Release build and can be used by
191 # embedders that need to build their own code as debug but don't want
192 # or need a debug version of V8. This should produce near-release
193 # speeds.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000194 'v8_optimized_debug%': 0,
195
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400196 # Use external files for startup data blobs:
197 # the JS builtins sources and the start snapshot.
198 # Embedders that don't use standalone.gypi will need to add
199 # their own default value.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000200 'v8_use_external_startup_data%': 1,
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400201
Ben Murdoch097c5b22016-05-18 11:27:45 +0100202 # Use a separate ignition snapshot file in standalone builds.
203 'v8_separate_ignition_snapshot': 1,
204
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000205 # Relative path to icu.gyp from this file.
206 'icu_gyp_path': '../third_party/icu/icu.gyp',
207
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000208 'conditions': [
209 ['(v8_target_arch=="arm" and host_arch!="arm") or \
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000210 (v8_target_arch=="arm64" and host_arch!="arm64") or \
211 (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
212 (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
213 (v8_target_arch=="x64" and host_arch!="x64") or \
214 (OS=="android" or OS=="qnx")', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000215 'want_separate_host_toolset': 1,
216 }, {
217 'want_separate_host_toolset': 0,
218 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000219 ['OS == "win"', {
220 'os_posix%': 0,
221 }, {
222 'os_posix%': 1,
223 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000224 ['OS=="win" and use_goma==1', {
225 # goma doesn't support pch yet.
226 'chromium_win_pch': 0,
227 # goma doesn't support PDB yet.
228 'fastbuild%': 1,
229 }],
230 ['((v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
231 (OS=="linux" or OS=="mac")) or (v8_target_arch=="ppc64" and OS=="linux")', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000232 'v8_enable_gdbjit%': 1,
233 }, {
234 'v8_enable_gdbjit%': 0,
235 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000236 ['(OS=="linux" or OS=="mac") and (target_arch=="ia32" or target_arch=="x64") and \
237 (v8_target_arch!="x87" and v8_target_arch!="x32") and coverage==0', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000238 'clang%': 1,
239 }, {
240 'clang%': 0,
241 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000242 ['asan==1 or lsan==1 or msan==1 or tsan==1', {
243 'clang%': 1,
244 'use_allocator%': 'none',
245 }],
246 ['asan==1 and OS=="linux"', {
247 'use_custom_libcxx%': 1,
248 }],
249 ['tsan==1', {
250 'use_custom_libcxx%': 1,
251 }],
252 ['msan==1', {
253 # Use a just-built, MSan-instrumented libc++ instead of the system-wide
254 # libstdc++. This is required to avoid false positive reports whenever
255 # the C++ standard library is used.
256 'use_custom_libcxx%': 1,
257 }],
258 ['cfi_vptr==1', {
259 'use_lto%': 1,
260 }],
261 ['OS=="android"', {
262 # Location of Android NDK.
263 'variables': {
264 'variables': {
265 # The Android toolchain needs to use the absolute path to the NDK
266 # because it is used at different levels in the GYP files.
267 'android_ndk_root%': '<(base_dir)/third_party/android_tools/ndk/',
268 'android_host_arch%': "<!(uname -m | sed -e 's/i[3456]86/x86/')",
269 'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
270 },
271
272 # Copy conditionally-set variables out one scope.
273 'android_ndk_root%': '<(android_ndk_root)',
274 'host_os%': '<(host_os)',
275
276 'conditions': [
277 ['target_arch == "ia32"', {
278 'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
279 'android_target_arch%': 'x86',
280 'android_target_platform%': '16',
281 }],
282 ['target_arch == "x64"', {
283 'android_toolchain%': '<(android_ndk_root)/toolchains/x86_64-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
284 'android_target_arch%': 'x86_64',
285 'android_target_platform%': '21',
286 }],
287 ['target_arch=="arm"', {
288 'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
289 'android_target_arch%': 'arm',
290 'android_target_platform%': '16',
291 'arm_version%': 7,
292 }],
293 ['target_arch == "arm64"', {
294 'android_toolchain%': '<(android_ndk_root)/toolchains/aarch64-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
295 'android_target_arch%': 'arm64',
296 'android_target_platform%': '21',
297 'arm_version%': 'default',
298 }],
299 ['target_arch == "mipsel"', {
300 'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
301 'android_target_arch%': 'mips',
302 'android_target_platform%': '16',
303 }],
304 ['target_arch == "mips64el"', {
305 'android_toolchain%': '<(android_ndk_root)/toolchains/mips64el-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
306 'android_target_arch%': 'mips64',
307 'android_target_platform%': '21',
308 }],
309 ],
310 },
311
312 # Copy conditionally-set variables out one scope.
313 'android_target_arch%': '<(android_target_arch)',
314 'android_target_platform%': '<(android_target_platform)',
315 'android_toolchain%': '<(android_toolchain)',
316 'arm_version%': '<(arm_version)',
317 'host_os%': '<(host_os)',
318
319 'conditions': [
320 ['android_ndk_root==""', {
321 'variables': {
322 'android_sysroot': '<(android_toolchain)/sysroot/',
Ben Murdoch097c5b22016-05-18 11:27:45 +0100323 'android_stl': '<(android_toolchain)/sources/cxx-stl/',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000324 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000325 'conditions': [
326 ['target_arch=="x64"', {
327 'android_lib': '<(android_sysroot)/usr/lib64',
328 }, {
329 'android_lib': '<(android_sysroot)/usr/lib',
330 }],
331 ],
Ben Murdoch097c5b22016-05-18 11:27:45 +0100332 'android_libcpp_include': '<(android_stl)/llvm-libc++/libcxx/include',
333 'android_libcpp_abi_include': '<(android_stl)/llvm-libc++abi/libcxxabi/include',
334 'android_libcpp_libs': '<(android_stl)/llvm-libc++/libs',
335 'android_support_include': '<(android_toolchain)/sources/android/support/include',
336 'android_sysroot': '<(android_sysroot)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000337 }, {
338 'variables': {
339 'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)',
Ben Murdoch097c5b22016-05-18 11:27:45 +0100340 'android_stl': '<(android_ndk_root)/sources/cxx-stl/',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000341 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000342 'conditions': [
343 ['target_arch=="x64"', {
344 'android_lib': '<(android_sysroot)/usr/lib64',
345 }, {
346 'android_lib': '<(android_sysroot)/usr/lib',
347 }],
348 ],
Ben Murdoch097c5b22016-05-18 11:27:45 +0100349 'android_libcpp_include': '<(android_stl)/llvm-libc++/libcxx/include',
350 'android_libcpp_abi_include': '<(android_stl)/llvm-libc++abi/libcxxabi/include',
351 'android_libcpp_libs': '<(android_stl)/llvm-libc++/libs',
352 'android_support_include': '<(android_ndk_root)/sources/android/support/include',
353 'android_sysroot': '<(android_sysroot)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000354 }],
355 ],
Ben Murdoch097c5b22016-05-18 11:27:45 +0100356 'android_libcpp_library': 'c++_static',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000357 }], # OS=="android"
358 ['host_clang==1', {
359 'host_cc': '<(clang_dir)/bin/clang',
360 'host_cxx': '<(clang_dir)/bin/clang++',
361 }, {
362 'host_cc': '<!(which gcc)',
363 'host_cxx': '<!(which g++)',
364 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000365 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000366 # Default ARM variable settings.
367 'arm_version%': 'default',
368 'arm_fpu%': 'vfpv3',
369 'arm_float_abi%': 'default',
370 'arm_thumb': 'default',
Paul Lind18a7ebb2014-12-17 22:29:32 -0800371
372 # Default MIPS variable settings.
373 'mips_arch_variant%': 'r2',
374 # Possible values fp32, fp64, fpxx.
375 # fp32 - 32 32-bit FPU registers are available, doubles are placed in
376 # register pairs.
377 # fp64 - 32 64-bit FPU registers are available.
378 # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
379 # detection
380 'mips_fpu_mode%': 'fp32',
Ben Murdoch097c5b22016-05-18 11:27:45 +0100381
382 # Indicates if gcmole tools are downloaded by a hook.
383 'gcmole%': 0,
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000384 },
385 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000386 'variables': {
387 'v8_code%': '<(v8_code)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000388 'conditions':[
389 ['OS=="android"', {
390 'host_os%': '<(host_os)',
391 }],
392 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000393 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000394 'default_configuration': 'Debug',
395 'configurations': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000396 'DebugBaseCommon': {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400397 'conditions': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000398 ['OS=="aix"', {
399 'cflags': [ '-g', '-Og', '-gxcoff' ],
400 }, {
401 'cflags': [ '-g', '-O0' ],
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400402 }],
403 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000404 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000405 'Optdebug': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000406 'inherit_from': [ 'DebugBaseCommon', 'DebugBase1' ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000407 },
408 'Debug': {
409 # Xcode insists on this empty entry.
410 },
411 'Release': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000412 'cflags+': ['<@(release_extra_cflags)'],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000413 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000414 'conditions': [
415 ['OS=="win"', {
416 'Optdebug_x64': {
417 'inherit_from': ['Optdebug'],
418 },
419 'Debug_x64': {
420 'inherit_from': ['Debug'],
421 },
422 'Release_x64': {
423 'inherit_from': ['Release'],
424 },
425 }],
426 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000427 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000428 'conditions':[
429 ['clang==0', {
430 'cflags+': ['-Wno-sign-compare',],
431 }],
432 ['clang==1 or host_clang==1', {
433 # This is here so that all files get recompiled after a clang roll and
434 # when turning clang on or off.
435 # (defines are passed via the command line, and build systems rebuild
436 # things when their commandline changes). Nothing should ever read this
437 # define.
438 'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
439 'conditions': [
440 ['host_clang==1', {
441 'target_conditions': [
442 ['_toolset=="host"', {
443 'cflags+': [
444 '-Wno-format-pedantic',
445 ],
446 }],
447 ],
448 }],
449 ['clang==1', {
450 'target_conditions': [
451 ['_toolset=="target"', {
452 'cflags+': [
453 '-Wno-format-pedantic',
454 ],
455 }],
456 ],
457 }],
458 ],
459 }],
460 ['fastbuild!=0', {
461 'conditions': [
462 ['OS=="win" and fastbuild==1', {
463 'msvs_settings': {
464 'VCLinkerTool': {
465 # This tells the linker to generate .pdbs, so that
466 # we can get meaningful stack traces.
467 'GenerateDebugInformation': 'true',
468 },
469 'VCCLCompilerTool': {
470 # No debug info to be generated by compiler.
471 'DebugInformationFormat': '0',
472 },
473 },
474 }],
475 ],
476 }], # fastbuild!=0
477 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000478 'target_conditions': [
479 ['v8_code == 0', {
480 'defines!': [
481 'DEBUG',
482 ],
483 'conditions': [
484 ['os_posix == 1 and OS != "mac"', {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000485 # We don't want to get warnings from third-party code,
486 # so remove any existing warning-enabling flags like -Wall.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000487 'cflags!': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000488 '-pedantic',
489 '-Wall',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000490 '-Werror',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000491 '-Wextra',
492 '-Wshorten-64-to-32',
493 ],
494 'cflags+': [
495 # Clang considers the `register` keyword as deprecated, but
496 # ICU uses it all over the place.
497 '-Wno-deprecated-register',
498 # ICU uses its own deprecated functions.
499 '-Wno-deprecated-declarations',
500 # ICU prefers `a && b || c` over `(a && b) || c`.
501 '-Wno-logical-op-parentheses',
502 # ICU has some `unsigned < 0` checks.
503 '-Wno-tautological-compare',
504 # uresdata.c has switch(RES_GET_TYPE(x)) code. The
505 # RES_GET_TYPE macro returns an UResType enum, but some switch
506 # statement contains case values that aren't part of that
507 # enum (e.g. URES_TABLE32 which is in UResInternalType). This
508 # is on purpose.
509 '-Wno-switch',
510 ],
511 'cflags_cc!': [
512 '-Wnon-virtual-dtor',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000513 ],
514 }],
515 ['OS == "mac"', {
516 'xcode_settings': {
517 'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror
518 },
519 }],
520 ['OS == "win"', {
521 'msvs_settings': {
522 'VCCLCompilerTool': {
523 'WarnAsError': 'false',
524 },
525 },
526 }],
527 ],
528 }],
529 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000530 },
531 'conditions': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000532 ['os_posix==1 and OS!="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000533 'target_defaults': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000534 'conditions': [
535 # Common options for AddressSanitizer, LeakSanitizer,
536 # ThreadSanitizer, MemorySanitizer and CFI builds.
537 ['asan==1 or lsan==1 or tsan==1 or msan==1 or cfi_vptr==1', {
538 'target_conditions': [
539 ['_toolset=="target"', {
540 'cflags': [
541 '-fno-omit-frame-pointer',
542 '-gline-tables-only',
543 ],
544 'cflags!': [
545 '-fomit-frame-pointer',
546 ],
547 }],
548 ],
549 }],
550 ['asan==1', {
551 'target_conditions': [
552 ['_toolset=="target"', {
553 'cflags': [
554 '-fsanitize=address',
555 ],
556 'ldflags': [
557 '-fsanitize=address',
558 ],
559 'defines': [
560 'ADDRESS_SANITIZER',
561 ],
562 }],
563 ],
564 }],
565 ['lsan==1', {
566 'target_conditions': [
567 ['_toolset=="target"', {
568 'cflags': [
569 '-fsanitize=leak',
570 ],
571 'ldflags': [
572 '-fsanitize=leak',
573 ],
574 'defines': [
575 'LEAK_SANITIZER',
576 ],
577 }],
578 ],
579 }],
580 ['tsan==1', {
581 'target_conditions': [
582 ['_toolset=="target"', {
583 'cflags': [
584 '-fsanitize=thread',
585 ],
586 'ldflags': [
587 '-fsanitize=thread',
588 ],
589 'defines': [
590 'THREAD_SANITIZER',
591 ],
592 }],
593 ],
594 }],
595 ['msan==1', {
596 'target_conditions': [
597 ['_toolset=="target"', {
598 'cflags': [
599 '-fsanitize=memory',
600 '-fsanitize-memory-track-origins=<(msan_track_origins)',
601 '-fPIC',
602 ],
603 'ldflags': [
604 '-fsanitize=memory',
605 '-pie',
606 ],
607 'defines': [
608 'MEMORY_SANITIZER',
609 ],
610 }],
611 ],
612 }],
613 ['use_custom_libcxx==1', {
614 'dependencies': [
615 '<(DEPTH)/buildtools/third_party/libc++/libc++.gyp:libcxx_proxy',
616 ],
617 }],
618 ['sanitizer_coverage!=0', {
619 'target_conditions': [
620 ['_toolset=="target"', {
621 'cflags': [
622 '-fsanitize-coverage=<(sanitizer_coverage)',
623 ],
624 'defines': [
625 'SANITIZER_COVERAGE',
626 ],
627 }],
628 ],
629 }],
630 ['linux_use_bundled_gold==1 and not (clang==0 and use_lto==1)', {
631 # Put our binutils, which contains gold in the search path. We pass
632 # the path to gold to the compiler. gyp leaves unspecified what the
633 # cwd is when running the compiler, so the normal gyp path-munging
634 # fails us. This hack gets the right path.
635 #
636 # Disabled when using GCC LTO because GCC also uses the -B search
637 # path at link time to find "as", and our bundled "as" can only
638 # target x86.
639 'ldflags': [
640 # Note, Chromium allows ia32 host arch as well, we limit this to
641 # x64 in v8.
642 '-B<(base_dir)/third_party/binutils/Linux_x64/Release/bin',
643 ],
644 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000645 ],
646 },
647 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000648 ['OS=="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000649 'target_defaults': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000650 'conditions': [
651 ['asan==1', {
652 'xcode_settings': {
653 # FIXME(machenbach): This is outdated compared to common.gypi.
654 'OTHER_CFLAGS+': [
655 '-fno-omit-frame-pointer',
656 '-gline-tables-only',
657 '-fsanitize=address',
658 '-w', # http://crbug.com/162783
659 ],
660 'OTHER_CFLAGS!': [
661 '-fomit-frame-pointer',
662 ],
663 'defines': [
664 'ADDRESS_SANITIZER',
665 ],
666 },
667 'dependencies': [
668 '<(DEPTH)/build/mac/asan.gyp:asan_dynamic_runtime',
669 ],
670 'target_conditions': [
671 ['_type!="static_library"', {
672 'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
673 }],
674 ],
675 }],
676 ['sanitizer_coverage!=0', {
677 'target_conditions': [
678 ['_toolset=="target"', {
679 'cflags': [
680 '-fsanitize-coverage=<(sanitizer_coverage)',
681 ],
682 'defines': [
683 'SANITIZER_COVERAGE',
684 ],
685 }],
686 ],
687 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000688 ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000689 }, # target_defaults
690 }], # OS=="mac"
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100691 ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000692 or OS=="netbsd" or OS=="aix"', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000693 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000694 'cflags': [
695 '-Wall',
696 '<(werror)',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000697 '-Wno-unused-parameter',
698 '-Wno-long-long',
699 '-pthread',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000700 '-pedantic',
701 # Don't warn about the "struct foo f = {0};" initialization pattern.
702 '-Wno-missing-field-initializers',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000703 '-Wno-gnu-zero-variadic-macro-arguments',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000704 ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000705 'cflags_cc': [
706 '-Wnon-virtual-dtor',
707 '-fno-exceptions',
708 '-fno-rtti',
709 '-std=gnu++0x',
710 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000711 'ldflags': [ '-pthread', ],
712 'conditions': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000713 # Don't warn about TRACE_EVENT_* macros with zero arguments passed to
714 # ##__VA_ARGS__. C99 strict mode prohibits having zero variadic macro
715 # arguments in gcc.
716 [ 'clang==0', {
717 'cflags!' : [
718 '-pedantic' ,
719 # Don't warn about unrecognized command line option.
720 '-Wno-gnu-zero-variadic-macro-arguments',
721 ],
722 }],
723 [ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64" \
724 or v8_target_arch=="mips64el")', {
725 'cflags': [ '-Wshorten-64-to-32' ],
726 }],
727 [ 'host_arch=="ppc64" and OS!="aix"', {
728 'cflags': [ '-mminimal-toc' ],
729 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000730 [ 'visibility=="hidden" and v8_enable_backtrace==0', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000731 'cflags': [ '-fvisibility=hidden' ],
732 }],
733 [ 'component=="shared_library"', {
734 'cflags': [ '-fPIC', ],
735 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000736 [ 'coverage==1', {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100737 'cflags': [ '-fprofile-arcs', '-ftest-coverage'],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000738 'ldflags': [ '-fprofile-arcs'],
739 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000740 ],
741 },
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100742 }],
743 # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
744 # or OS=="netbsd"'
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000745 ['OS=="qnx"', {
746 'target_defaults': {
747 'cflags': [
748 '-Wall',
749 '<(werror)',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000750 '-Wno-unused-parameter',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000751 # Don't warn about the "struct foo f = {0};" initialization pattern.
752 '-Wno-missing-field-initializers',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000753 '-Wno-gnu-zero-variadic-macro-arguments',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000754 ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000755 'cflags_cc': [
756 '-Wnon-virtual-dtor',
757 '-fno-exceptions',
758 '-fno-rtti',
759 '-std=gnu++0x',
760 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000761 'conditions': [
762 [ 'visibility=="hidden"', {
763 'cflags': [ '-fvisibility=hidden' ],
764 }],
765 [ 'component=="shared_library"', {
766 'cflags': [ '-fPIC' ],
767 }],
768 ],
769 'target_conditions': [
770 [ '_toolset=="host" and host_os=="linux"', {
771 'cflags': [ '-pthread' ],
772 'ldflags': [ '-pthread' ],
773 'libraries': [ '-lrt' ],
774 }],
775 [ '_toolset=="target"', {
776 'cflags': [ '-Wno-psabi' ],
777 'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
778 }],
779 ],
780 },
781 }], # OS=="qnx"
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000782 ['OS=="win"', {
783 'target_defaults': {
784 'defines': [
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000785 '_CRT_SECURE_NO_DEPRECATE',
786 '_CRT_NONSTDC_NO_DEPRECATE',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000787 '_USING_V110_SDK71_',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000788 ],
789 'conditions': [
790 ['component=="static_library"', {
791 'defines': [
792 '_HAS_EXCEPTIONS=0',
793 ],
794 }],
795 ],
796 'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000797 'msvs_disabled_warnings': [
798 # C4091: 'typedef ': ignored on left of 'X' when no variable is
799 # declared.
800 # This happens in a number of Windows headers. Dumb.
801 4091,
802
803 # C4127: conditional expression is constant
804 # This warning can in theory catch dead code and other problems, but
805 # triggers in far too many desirable cases where the conditional
806 # expression is either set by macros or corresponds some legitimate
807 # compile-time constant expression (due to constant template args,
808 # conditionals comparing the sizes of different types, etc.). Some of
809 # these can be worked around, but it's not worth it.
810 4127,
811
812 # C4351: new behavior: elements of array 'array' will be default
813 # initialized
814 # This is a silly "warning" that basically just alerts you that the
815 # compiler is going to actually follow the language spec like it's
816 # supposed to, instead of not following it like old buggy versions
817 # did. There's absolutely no reason to turn this on.
818 4351,
819
820 # C4355: 'this': used in base member initializer list
821 # It's commonly useful to pass |this| to objects in a class'
822 # initializer list. While this warning can catch real bugs, most of
823 # the time the constructors in question don't attempt to call methods
824 # on the passed-in pointer (until later), and annotating every legit
825 # usage of this is simply more hassle than the warning is worth.
826 4355,
827
828 # C4503: 'identifier': decorated name length exceeded, name was
829 # truncated
830 # This only means that some long error messages might have truncated
831 # identifiers in the presence of lots of templates. It has no effect
832 # on program correctness and there's no real reason to waste time
833 # trying to prevent it.
834 4503,
835
836 # Warning C4589 says: "Constructor of abstract class ignores
837 # initializer for virtual base class." Disable this warning because it
838 # is flaky in VS 2015 RTM. It triggers on compiler generated
839 # copy-constructors in some cases.
840 4589,
841
842 # C4611: interaction between 'function' and C++ object destruction is
843 # non-portable
844 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN
845 # suggests using exceptions instead of setjmp/longjmp for C++, but
846 # Chromium code compiles without exception support. We therefore have
847 # to use setjmp/longjmp for e.g. JPEG decode error handling, which
848 # means we have to turn off this warning (and be careful about how
849 # object destruction happens in such cases).
850 4611,
851
852 # TODO(jochen): These warnings are level 4. They will be slowly
853 # removed as code is fixed.
854 4100, # Unreferenced formal parameter
855 4121, # Alignment of a member was sensitive to packing
856 4244, # Conversion from 'type1' to 'type2', possible loss of data
857 4302, # Truncation from 'type 1' to 'type 2'
858 4309, # Truncation of constant value
859 4311, # Pointer truncation from 'type' to 'type'
860 4312, # Conversion from 'type1' to 'type2' of greater size
861 4505, # Unreferenced local function has been removed
862 4510, # Default constructor could not be generated
863 4512, # Assignment operator could not be generated
864 4610, # Object can never be instantiated
865 4800, # Forcing value to bool.
866 4838, # Narrowing conversion. Doesn't seem to be very useful.
867 4995, # 'X': name was marked as #pragma deprecated
868 4996, # 'X': was declared deprecated (for GetVersionEx).
869
870 # These are variable shadowing warnings that are new in VS2015. We
871 # should work through these at some point -- they may be removed from
872 # the RTM release in the /W4 set.
873 4456, 4457, 4458, 4459,
874 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000875 'msvs_settings': {
876 'VCCLCompilerTool': {
877 'MinimalRebuild': 'false',
878 'BufferSecurityCheck': 'true',
879 'EnableFunctionLevelLinking': 'true',
880 'RuntimeTypeInfo': 'false',
881 'WarningLevel': '3',
882 'WarnAsError': 'true',
883 'DebugInformationFormat': '3',
884 'Detect64BitPortabilityProblems': 'false',
885 'conditions': [
886 [ 'msvs_multi_core_compile', {
887 'AdditionalOptions': ['/MP'],
888 }],
889 ['component=="shared_library"', {
890 'ExceptionHandling': '1', # /EHsc
891 }, {
892 'ExceptionHandling': '0',
893 }],
894 ],
895 },
896 'VCLibrarianTool': {
897 'AdditionalOptions': ['/ignore:4221'],
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400898 'conditions': [
899 ['v8_target_arch=="x64"', {
900 'TargetMachine': '17', # x64
901 }, {
902 'TargetMachine': '1', # ia32
903 }],
904 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000905 },
906 'VCLinkerTool': {
907 'AdditionalDependencies': [
908 'ws2_32.lib',
909 ],
910 'GenerateDebugInformation': 'true',
911 'MapFileName': '$(OutDir)\\$(TargetName).map',
912 'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
913 'FixedBaseAddress': '1',
914 # LinkIncremental values:
915 # 0 == default
916 # 1 == /INCREMENTAL:NO
917 # 2 == /INCREMENTAL
918 'LinkIncremental': '1',
919 # SubSystem values:
920 # 0 == not set
921 # 1 == /SUBSYSTEM:CONSOLE
922 # 2 == /SUBSYSTEM:WINDOWS
923 'SubSystem': '1',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000924
925 'conditions': [
926 ['v8_enable_i18n_support==1', {
927 'AdditionalDependencies': [
928 'advapi32.lib',
929 ],
930 }],
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400931 ['v8_target_arch=="x64"', {
932 'MinimumRequiredVersion': '5.02', # Server 2003.
933 'TargetMachine': '17', # x64
934 }, {
935 'MinimumRequiredVersion': '5.01', # XP.
936 'TargetMachine': '1', # ia32
937 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000938 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000939 },
940 },
941 },
942 }], # OS=="win"
943 ['OS=="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000944 'xcode_settings': {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400945 'SDKROOT': 'macosx',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000946 'SYMROOT': '<(DEPTH)/xcodebuild',
947 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000948 'target_defaults': {
949 'xcode_settings': {
950 'ALWAYS_SEARCH_USER_PATHS': 'NO',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000951 'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000952 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
953 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
954 # (Equivalent to -fPIC)
955 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
956 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
957 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
958 # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
959 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
960 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
961 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000962 'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
963 # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
964 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000965 'PREBINDING': 'NO', # No -Wl,-prebind
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000966 'SYMROOT': '<(DEPTH)/xcodebuild',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000967 'USE_HEADERMAP': 'NO',
968 'OTHER_CFLAGS': [
969 '-fno-strict-aliasing',
970 ],
971 'WARNING_CFLAGS': [
972 '-Wall',
973 '-Wendif-labels',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000974 '-Wno-unused-parameter',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000975 # Don't warn about the "struct foo f = {0};" initialization pattern.
976 '-Wno-missing-field-initializers',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000977 '-Wno-gnu-zero-variadic-macro-arguments',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000978 ],
979 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000980 'conditions': [
981 ['werror==""', {
982 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
983 }, {
984 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
985 }],
986 ['clang==1', {
987 'xcode_settings': {
988 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
989 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x', # -std=gnu++0x
990 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000991 'conditions': [
992 ['v8_target_arch=="x64" or v8_target_arch=="arm64" \
993 or v8_target_arch=="mips64el"', {
994 'xcode_settings': {'WARNING_CFLAGS': ['-Wshorten-64-to-32']},
995 }],
996 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000997 }],
998 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000999 'target_conditions': [
1000 ['_type!="static_library"', {
1001 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
1002 }],
1003 ], # target_conditions
1004 }, # target_defaults
1005 }], # OS=="mac"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001006 ['OS=="android"', {
1007 'target_defaults': {
1008 'defines': [
1009 'ANDROID',
1010 'V8_ANDROID_LOG_STDOUT',
1011 ],
1012 'configurations': {
1013 'Release': {
1014 'cflags': [
1015 '-fomit-frame-pointer',
1016 ],
1017 }, # Release
1018 }, # configurations
1019 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'],
1020 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions',
Ben Murdoch097c5b22016-05-18 11:27:45 +01001021 '-std=gnu++11' ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001022 'target_conditions': [
1023 ['_toolset=="target"', {
1024 'cflags!': [
1025 '-pthread', # Not supported by Android toolchain.
1026 ],
1027 'cflags': [
1028 '-ffunction-sections',
1029 '-funwind-tables',
1030 '-fstack-protector',
1031 '-fno-short-enums',
1032 '-finline-limit=64',
1033 '-Wa,--noexecstack',
Ben Murdoch097c5b22016-05-18 11:27:45 +01001034 '--sysroot=<(android_sysroot)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001035 ],
1036 'cflags_cc': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001037 '-isystem<(android_libcpp_include)',
1038 '-isystem<(android_libcpp_abi_include)',
1039 '-isystem<(android_support_include)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001040 ],
1041 'defines': [
1042 'ANDROID',
1043 #'__GNU_SOURCE=1', # Necessary for clone()
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001044 'HAVE_OFF64_T',
1045 'HAVE_SYS_UIO_H',
1046 'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
1047 ],
1048 'ldflags!': [
1049 '-pthread', # Not supported by Android toolchain.
1050 ],
1051 'ldflags': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001052 '-Wl,--no-undefined',
Ben Murdoch097c5b22016-05-18 11:27:45 +01001053 '--sysroot=<(android_sysroot)',
1054 '-nostdlib',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001055 ],
1056 'libraries!': [
1057 '-lrt', # librt is built into Bionic.
1058 # Not supported by Android toolchain.
1059 # Where do these come from? Can't find references in
1060 # any Chromium gyp or gypi file. Maybe they come from
1061 # gyp itself?
1062 '-lpthread', '-lnss3', '-lnssutil3', '-lsmime3', '-lplds4', '-lplc4', '-lnspr4',
1063 ],
1064 'libraries': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001065 '-l<(android_libcpp_library)',
1066 '-latomic',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001067 # Manually link the libgcc.a that the cross compiler uses.
1068 '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
1069 '-lc',
1070 '-ldl',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001071 '-lm',
1072 ],
1073 'conditions': [
1074 ['target_arch == "arm"', {
1075 'ldflags': [
1076 # Enable identical code folding to reduce size.
1077 '-Wl,--icf=safe',
1078 ],
1079 }],
1080 ['target_arch=="arm" and arm_version==7', {
1081 'cflags': [
1082 '-march=armv7-a',
1083 '-mtune=cortex-a8',
1084 '-mfpu=vfp3',
1085 ],
1086 'ldflags': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001087 '-L<(android_libcpp_libs)/armeabi-v7a',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001088 ],
1089 }],
1090 ['target_arch=="arm" and arm_version < 7', {
1091 'ldflags': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001092 '-L<(android_libcpp_libs)/armeabi',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001093 ],
1094 }],
1095 ['target_arch=="x64"', {
1096 'ldflags': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001097 '-L<(android_libcpp_libs)/x86_64',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001098 ],
1099 }],
1100 ['target_arch=="arm64"', {
1101 'ldflags': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001102 '-L<(android_libcpp_libs)/arm64-v8a',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001103 ],
1104 }],
1105 ['target_arch=="ia32" or target_arch=="x87"', {
1106 # The x86 toolchain currently has problems with stack-protector.
1107 'cflags!': [
1108 '-fstack-protector',
1109 ],
1110 'cflags': [
1111 '-fno-stack-protector',
1112 ],
1113 'ldflags': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001114 '-L<(android_libcpp_libs)/x86',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001115 ],
1116 }],
1117 ['target_arch=="mipsel"', {
1118 # The mips toolchain currently has problems with stack-protector.
1119 'cflags!': [
1120 '-fstack-protector',
1121 '-U__linux__'
1122 ],
1123 'cflags': [
1124 '-fno-stack-protector',
1125 ],
1126 'ldflags': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001127 '-L<(android_libcpp_libs)/mips',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001128 ],
1129 }],
1130 ['(target_arch=="arm" or target_arch=="arm64" or target_arch=="x64" or target_arch=="ia32") and component!="shared_library"', {
1131 'cflags': [
1132 '-fPIE',
1133 ],
1134 'ldflags': [
1135 '-pie',
1136 ],
1137 }],
1138 ],
1139 'target_conditions': [
1140 ['_type=="executable"', {
1141 'conditions': [
1142 ['target_arch=="arm64" or target_arch=="x64"', {
1143 'ldflags': [
1144 '-Wl,-dynamic-linker,/system/bin/linker64',
1145 ],
1146 }, {
1147 'ldflags': [
1148 '-Wl,-dynamic-linker,/system/bin/linker',
1149 ],
1150 }]
1151 ],
1152 'ldflags': [
1153 '-Bdynamic',
1154 '-Wl,-z,nocopyreloc',
1155 # crtbegin_dynamic.o should be the last item in ldflags.
1156 '<(android_lib)/crtbegin_dynamic.o',
1157 ],
1158 'libraries': [
1159 # crtend_android.o needs to be the last item in libraries.
1160 # Do not add any libraries after this!
1161 '<(android_lib)/crtend_android.o',
1162 ],
1163 }],
1164 ['_type=="shared_library"', {
1165 'ldflags': [
1166 '-Wl,-shared,-Bsymbolic',
1167 '<(android_lib)/crtbegin_so.o',
1168 ],
1169 }],
1170 ['_type=="static_library"', {
1171 'ldflags': [
1172 # Don't export symbols from statically linked libraries.
1173 '-Wl,--exclude-libs=ALL',
1174 ],
1175 }],
1176 ],
1177 }], # _toolset=="target"
1178 # Settings for building host targets using the system toolchain.
1179 ['_toolset=="host"', {
1180 'cflags': [ '-pthread' ],
1181 'ldflags': [ '-pthread' ],
1182 'ldflags!': [
1183 '-Wl,-z,noexecstack',
1184 '-Wl,--gc-sections',
1185 '-Wl,-O1',
1186 '-Wl,--as-needed',
1187 ],
1188 }],
1189 ], # target_conditions
1190 }, # target_defaults
1191 }], # OS=="android"
1192 ['OS=="android" and clang==0', {
1193 # Hardcode the compiler names in the Makefile so that
1194 # it won't depend on the environment at make time.
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001195 'make_global_settings': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001196 ['CC', '<!(/bin/echo -n <(android_toolchain)/*-gcc)'],
1197 ['CXX', '<!(/bin/echo -n <(android_toolchain)/*-g++)'],
1198 ['CC.host', '<(host_cc)'],
1199 ['CXX.host', '<(host_cxx)'],
1200 ],
1201 }],
1202 ['clang!=1 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
1203 'make_global_settings': [
1204 ['CC.host', '<(clang_dir)/bin/clang'],
1205 ['CXX.host', '<(clang_dir)/bin/clang++'],
1206 ],
1207 }],
1208 ['clang==0 and host_clang==1 and target_arch!="ia32" and target_arch!="x64"', {
1209 'target_conditions': [
1210 ['_toolset=="host"', {
1211 'cflags_cc': [ '-std=gnu++11', ],
1212 }],
1213 ],
1214 'target_defaults': {
1215 'target_conditions': [
1216 ['_toolset=="host"', { 'cflags!': [ '-Wno-unused-local-typedefs' ]}],
1217 ],
1218 },
1219 }],
1220 ['clang==1 and "<(GENERATOR)"=="ninja"', {
1221 # See http://crbug.com/110262
1222 'target_defaults': {
1223 'cflags': [ '-fcolor-diagnostics' ],
1224 'xcode_settings': { 'OTHER_CFLAGS': [ '-fcolor-diagnostics' ] },
1225 },
1226 }],
1227 ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
1228 'and OS!="win" and "<(GENERATOR)"=="make"', {
1229 'make_global_settings': [
1230 ['CC', '<(clang_dir)/bin/clang'],
1231 ['CXX', '<(clang_dir)/bin/clang++'],
1232 ['CC.host', '$(CC)'],
1233 ['CXX.host', '$(CXX)'],
1234 ],
1235 }],
1236 ['clang==1 and ((OS!="mac" and OS!="ios") or clang_xcode==0) '
1237 'and OS!="win" and "<(GENERATOR)"=="ninja"', {
1238 'make_global_settings': [
1239 ['CC', '<(clang_dir)/bin/clang'],
1240 ['CXX', '<(clang_dir)/bin/clang++'],
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001241 ['CC.host', '$(CC)'],
1242 ['CXX.host', '$(CXX)'],
1243 ],
1244 }],
1245 ['clang==1 and OS=="win"', {
1246 'make_global_settings': [
1247 # On Windows, gyp's ninja generator only looks at CC.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001248 ['CC', '<(clang_dir)/bin/clang-cl'],
Emily Bernierd0a1eb72015-03-24 16:35:39 -04001249 ],
1250 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001251 ['OS=="linux" and target_arch=="arm" and host_arch!="arm" and clang==0 and "<(GENERATOR)"=="ninja"', {
1252 # Set default ARM cross tools on linux. These can be overridden
1253 # using CC,CXX,CC.host and CXX.host environment variables.
1254 'make_global_settings': [
1255 ['CC', '<!(which arm-linux-gnueabihf-gcc)'],
1256 ['CXX', '<!(which arm-linux-gnueabihf-g++)'],
1257 ['CC.host', '<(host_cc)'],
1258 ['CXX.host', '<(host_cxx)'],
1259 ],
1260 }],
1261 # TODO(yyanagisawa): supports GENERATOR==make
1262 # make generator doesn't support CC_wrapper without CC
1263 # in make_global_settings yet.
1264 ['use_goma==1 and ("<(GENERATOR)"=="ninja" or clang==1)', {
1265 'make_global_settings': [
1266 ['CC_wrapper', '<(gomadir)/gomacc'],
1267 ['CXX_wrapper', '<(gomadir)/gomacc'],
1268 ['CC.host_wrapper', '<(gomadir)/gomacc'],
1269 ['CXX.host_wrapper', '<(gomadir)/gomacc'],
1270 ],
1271 }],
1272 ['use_lto==1', {
1273 'target_defaults': {
1274 'target_conditions': [
1275 ['_toolset=="target"', {
1276 'cflags': [
1277 '-flto',
1278 ],
1279 }],
1280 ],
1281 },
1282 }],
1283 ['use_lto==1 and clang==0', {
1284 'target_defaults': {
1285 'target_conditions': [
1286 ['_toolset=="target"', {
1287 'cflags': [
1288 '-ffat-lto-objects',
1289 ],
1290 }],
1291 ],
1292 },
1293 }],
1294 ['use_lto==1 and clang==1', {
1295 'target_defaults': {
1296 'target_conditions': [
1297 ['_toolset=="target"', {
1298 'arflags': [
1299 '--plugin', '<(clang_dir)/lib/LLVMgold.so',
1300 ],
1301 # Apply a lower optimization level with lto. Chromium does this
1302 # for non-official builds only - a differentiation that doesn't
1303 # exist in v8.
1304 'ldflags': [
1305 '-Wl,--plugin-opt,O1',
1306 ],
1307 }],
1308 ],
1309 },
1310 }],
1311 ['use_lto==1 and clang==0', {
1312 'target_defaults': {
1313 'target_conditions': [
1314 ['_toolset=="target"', {
1315 'ldflags': [
1316 '-flto=32',
1317 ],
1318 }],
1319 ],
1320 },
1321 }],
1322 ['use_lto==1 and clang==1', {
1323 'target_defaults': {
1324 'target_conditions': [
1325 ['_toolset=="target"', {
1326 'ldflags': [
1327 '-flto',
1328 ],
1329 }],
1330 ],
1331 },
1332 }],
1333 ['cfi_diag==1', {
1334 'target_defaults': {
1335 'target_conditions': [
1336 ['_toolset=="target"', {
1337 'cflags': [
1338 '-fno-sanitize-trap=cfi',
1339 '-fno-sanitize-recover=cfi',
1340 ],
1341 'cflags_cc!': [
1342 '-fno-rtti',
1343 ],
1344 'cflags!': [
1345 '-fno-rtti',
1346 ],
1347 'ldflags': [
1348 '-fno-sanitize-trap=cfi',
1349 '-fno-sanitize-recover=cfi',
1350 ],
1351 }],
1352 ],
1353 },
1354 }],
1355 ['cfi_vptr==1', {
1356 'target_defaults': {
1357 'target_conditions': [
1358 ['_toolset=="target"', {
1359 'cflags': [
1360 '-fsanitize=cfi-vcall',
1361 '-fsanitize=cfi-derived-cast',
1362 '-fsanitize=cfi-unrelated-cast',
1363 '-fsanitize-blacklist=<(cfi_blacklist)',
1364 ],
1365 'ldflags': [
1366 '-fsanitize=cfi-vcall',
1367 '-fsanitize=cfi-derived-cast',
1368 '-fsanitize=cfi-unrelated-cast',
1369 ],
1370 }],
1371 ],
1372 },
1373 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +00001374 ],
1375}