blob: 6c88409dbee892ed9dcc6332f08104d1da5d1756 [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 Murdochda12d292016-06-02 14:46:10 +010047 'mac_deployment_target%': '10.7',
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
Ben Murdochda12d292016-06-02 14:46:10 +010071 # Instrument for code coverage and use coverage wrapper to exclude some
72 # files. Uses gcov if clang=0 is set explicitly. Otherwise,
73 # sanitizer_coverage must be set too.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000074 'coverage%': 0,
Ben Murdoch69a99ed2011-11-30 16:03:39 +000075 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000076 'base_dir%': '<(base_dir)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +000077 'host_arch%': '<(host_arch)',
Ben Murdoch3ef787d2012-04-12 10:51:47 +010078 'target_arch%': '<(target_arch)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +000079 'v8_target_arch%': '<(target_arch)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +000080 'coverage%': '<(coverage)',
81 'asan%': 0,
82 'lsan%': 0,
83 'msan%': 0,
84 'tsan%': 0,
85 # Enable coverage gathering instrumentation in sanitizer tools. This flag
86 # also controls coverage granularity (1 for function-level, 2 for
87 # block-level, 3 for edge-level).
88 'sanitizer_coverage%': 0,
89 # Use libc++ (buildtools/third_party/libc++ and
90 # buildtools/third_party/libc++abi) instead of stdlibc++ as standard
91 # library. This is intended to be used for instrumented builds.
92 'use_custom_libcxx%': 0,
93
94 'clang_dir%': '<(base_dir)/third_party/llvm-build/Release+Asserts',
95
96 'use_lto%': 0,
97
98 # Control Flow Integrity for virtual calls and casts.
99 # See http://clang.llvm.org/docs/ControlFlowIntegrity.html
100 'cfi_vptr%': 0,
101 'cfi_diag%': 0,
102
103 'cfi_blacklist%': '<(base_dir)/tools/cfi/blacklist.txt',
104
105 # Set to 1 to enable fast builds.
106 # TODO(machenbach): Only configured for windows.
107 'fastbuild%': 0,
108
109 # goma settings.
110 # 1 to use goma.
111 # If no gomadir is set, it uses the default gomadir.
112 'use_goma%': 0,
113 'gomadir%': '',
114
Ben Murdoch097c5b22016-05-18 11:27:45 +0100115 # Check if valgrind directories are present.
116 'has_valgrind%': '<!pymod_do_main(has_valgrind)',
117
Ben Murdochda12d292016-06-02 14:46:10 +0100118 'test_isolation_mode%': 'noop',
119
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000120 'conditions': [
121 # Set default gomadir.
122 ['OS=="win"', {
123 'gomadir': 'c:\\goma\\goma-win',
124 }, {
125 'gomadir': '<!(/bin/echo -n ${HOME}/goma)',
126 }],
Ben Murdochda12d292016-06-02 14:46:10 +0100127 ['host_arch!="ppc" and host_arch!="ppc64" and host_arch!="ppc64le" and host_arch!="s390" and host_arch!="s390x"', {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000128 'host_clang%': 1,
129 }, {
130 'host_clang%': 0,
131 }],
132 # linux_use_bundled_gold: whether to use the gold linker binary checked
133 # into third_party/binutils. Force this off via GYP_DEFINES when you
134 # are using a custom toolchain and need to control -B in ldflags.
135 # Do not use 32-bit gold on 32-bit hosts as it runs out address space
136 # for component=static_library builds.
137 ['(OS=="linux" or OS=="android") and (target_arch=="x64" or target_arch=="arm" or (target_arch=="ia32" and host_arch=="x64"))', {
138 'linux_use_bundled_gold%': 1,
139 }, {
140 'linux_use_bundled_gold%': 0,
141 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000142 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000143 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000144 'base_dir%': '<(base_dir)',
145 'clang_dir%': '<(clang_dir)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000146 'host_arch%': '<(host_arch)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000147 'host_clang%': '<(host_clang)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000148 'target_arch%': '<(target_arch)',
149 'v8_target_arch%': '<(v8_target_arch)',
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100150 'werror%': '-Werror',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000151 'use_goma%': '<(use_goma)',
152 'gomadir%': '<(gomadir)',
153 'asan%': '<(asan)',
154 'lsan%': '<(lsan)',
155 'msan%': '<(msan)',
156 'tsan%': '<(tsan)',
157 'sanitizer_coverage%': '<(sanitizer_coverage)',
158 'use_custom_libcxx%': '<(use_custom_libcxx)',
159 'linux_use_bundled_gold%': '<(linux_use_bundled_gold)',
160 'use_lto%': '<(use_lto)',
161 'cfi_vptr%': '<(cfi_vptr)',
162 'cfi_diag%': '<(cfi_diag)',
163 'cfi_blacklist%': '<(cfi_blacklist)',
164 'test_isolation_mode%': '<(test_isolation_mode)',
165 'fastbuild%': '<(fastbuild)',
166 'coverage%': '<(coverage)',
Ben Murdoch097c5b22016-05-18 11:27:45 +0100167 'has_valgrind%': '<(has_valgrind)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000168
169 # Add a simple extras solely for the purpose of the cctests
170 'v8_extra_library_files': ['../test/cctest/test-extra.js'],
171 'v8_experimental_extra_library_files': ['../test/cctest/test-experimental-extra.js'],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000172
173 # .gyp files or targets should set v8_code to 1 if they build V8 specific
174 # code, as opposed to external code. This variable is used to control such
175 # things as the set of warnings to enable, and whether warnings are treated
176 # as errors.
177 'v8_code%': 0,
178
179 # Speeds up Debug builds:
180 # 0 - Compiler optimizations off (debuggable) (default). This may
181 # be 5x slower than Release (or worse).
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000182 # 1 - Turn on optimizations and disable slow DCHECKs, but leave
183 # V8_ENABLE_CHECKS and most other assertions enabled. This may cause
184 # some v8 tests to fail in the Debug configuration. This roughly
185 # matches the performance of a Release build and can be used by
186 # embedders that need to build their own code as debug but don't want
187 # or need a debug version of V8. This should produce near-release
188 # speeds.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000189 'v8_optimized_debug%': 0,
190
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400191 # Use external files for startup data blobs:
192 # the JS builtins sources and the start snapshot.
193 # Embedders that don't use standalone.gypi will need to add
194 # their own default value.
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000195 'v8_use_external_startup_data%': 1,
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400196
Ben Murdoch097c5b22016-05-18 11:27:45 +0100197 # Use a separate ignition snapshot file in standalone builds.
198 'v8_separate_ignition_snapshot': 1,
199
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000200 # Relative path to icu.gyp from this file.
201 'icu_gyp_path': '../third_party/icu/icu.gyp',
202
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000203 'conditions': [
204 ['(v8_target_arch=="arm" and host_arch!="arm") or \
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000205 (v8_target_arch=="arm64" and host_arch!="arm64") or \
206 (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
207 (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
208 (v8_target_arch=="x64" and host_arch!="x64") or \
209 (OS=="android" or OS=="qnx")', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000210 'want_separate_host_toolset': 1,
211 }, {
212 'want_separate_host_toolset': 0,
213 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000214 ['OS == "win"', {
215 'os_posix%': 0,
216 }, {
217 'os_posix%': 1,
218 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000219 ['OS=="win" and use_goma==1', {
220 # goma doesn't support pch yet.
221 'chromium_win_pch': 0,
222 # goma doesn't support PDB yet.
223 'fastbuild%': 1,
224 }],
225 ['((v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
226 (OS=="linux" or OS=="mac")) or (v8_target_arch=="ppc64" and OS=="linux")', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000227 'v8_enable_gdbjit%': 1,
228 }, {
229 'v8_enable_gdbjit%': 0,
230 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000231 ['(OS=="linux" or OS=="mac") and (target_arch=="ia32" or target_arch=="x64") and \
Ben Murdochda12d292016-06-02 14:46:10 +0100232 (v8_target_arch!="x87" and v8_target_arch!="x32")', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000233 'clang%': 1,
234 }, {
235 'clang%': 0,
236 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000237 ['asan==1 or lsan==1 or msan==1 or tsan==1', {
238 'clang%': 1,
239 'use_allocator%': 'none',
240 }],
241 ['asan==1 and OS=="linux"', {
242 'use_custom_libcxx%': 1,
243 }],
244 ['tsan==1', {
245 'use_custom_libcxx%': 1,
246 }],
247 ['msan==1', {
248 # Use a just-built, MSan-instrumented libc++ instead of the system-wide
249 # libstdc++. This is required to avoid false positive reports whenever
250 # the C++ standard library is used.
251 'use_custom_libcxx%': 1,
252 }],
253 ['cfi_vptr==1', {
254 'use_lto%': 1,
255 }],
256 ['OS=="android"', {
257 # Location of Android NDK.
258 'variables': {
259 'variables': {
260 # The Android toolchain needs to use the absolute path to the NDK
261 # because it is used at different levels in the GYP files.
262 'android_ndk_root%': '<(base_dir)/third_party/android_tools/ndk/',
263 'android_host_arch%': "<!(uname -m | sed -e 's/i[3456]86/x86/')",
264 'host_os%': "<!(uname -s | sed -e 's/Linux/linux/;s/Darwin/mac/')",
265 },
266
267 # Copy conditionally-set variables out one scope.
268 'android_ndk_root%': '<(android_ndk_root)',
269 'host_os%': '<(host_os)',
270
271 'conditions': [
272 ['target_arch == "ia32"', {
273 'android_toolchain%': '<(android_ndk_root)/toolchains/x86-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
274 'android_target_arch%': 'x86',
275 'android_target_platform%': '16',
276 }],
277 ['target_arch == "x64"', {
278 'android_toolchain%': '<(android_ndk_root)/toolchains/x86_64-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
279 'android_target_arch%': 'x86_64',
280 'android_target_platform%': '21',
281 }],
282 ['target_arch=="arm"', {
283 'android_toolchain%': '<(android_ndk_root)/toolchains/arm-linux-androideabi-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
284 'android_target_arch%': 'arm',
285 'android_target_platform%': '16',
286 'arm_version%': 7,
287 }],
288 ['target_arch == "arm64"', {
289 'android_toolchain%': '<(android_ndk_root)/toolchains/aarch64-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
290 'android_target_arch%': 'arm64',
291 'android_target_platform%': '21',
292 'arm_version%': 'default',
293 }],
294 ['target_arch == "mipsel"', {
295 'android_toolchain%': '<(android_ndk_root)/toolchains/mipsel-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
296 'android_target_arch%': 'mips',
297 'android_target_platform%': '16',
298 }],
299 ['target_arch == "mips64el"', {
300 'android_toolchain%': '<(android_ndk_root)/toolchains/mips64el-linux-android-4.9/prebuilt/<(host_os)-<(android_host_arch)/bin',
301 'android_target_arch%': 'mips64',
302 'android_target_platform%': '21',
303 }],
304 ],
305 },
306
307 # Copy conditionally-set variables out one scope.
308 'android_target_arch%': '<(android_target_arch)',
309 'android_target_platform%': '<(android_target_platform)',
310 'android_toolchain%': '<(android_toolchain)',
311 'arm_version%': '<(arm_version)',
312 'host_os%': '<(host_os)',
313
314 'conditions': [
315 ['android_ndk_root==""', {
316 'variables': {
317 'android_sysroot': '<(android_toolchain)/sysroot/',
Ben Murdoch097c5b22016-05-18 11:27:45 +0100318 'android_stl': '<(android_toolchain)/sources/cxx-stl/',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000319 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000320 'conditions': [
321 ['target_arch=="x64"', {
322 'android_lib': '<(android_sysroot)/usr/lib64',
323 }, {
324 'android_lib': '<(android_sysroot)/usr/lib',
325 }],
326 ],
Ben Murdoch097c5b22016-05-18 11:27:45 +0100327 'android_libcpp_include': '<(android_stl)/llvm-libc++/libcxx/include',
328 'android_libcpp_abi_include': '<(android_stl)/llvm-libc++abi/libcxxabi/include',
329 'android_libcpp_libs': '<(android_stl)/llvm-libc++/libs',
330 'android_support_include': '<(android_toolchain)/sources/android/support/include',
331 'android_sysroot': '<(android_sysroot)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000332 }, {
333 'variables': {
334 'android_sysroot': '<(android_ndk_root)/platforms/android-<(android_target_platform)/arch-<(android_target_arch)',
Ben Murdoch097c5b22016-05-18 11:27:45 +0100335 'android_stl': '<(android_ndk_root)/sources/cxx-stl/',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000336 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000337 'conditions': [
338 ['target_arch=="x64"', {
339 'android_lib': '<(android_sysroot)/usr/lib64',
340 }, {
341 'android_lib': '<(android_sysroot)/usr/lib',
342 }],
343 ],
Ben Murdoch097c5b22016-05-18 11:27:45 +0100344 'android_libcpp_include': '<(android_stl)/llvm-libc++/libcxx/include',
345 'android_libcpp_abi_include': '<(android_stl)/llvm-libc++abi/libcxxabi/include',
346 'android_libcpp_libs': '<(android_stl)/llvm-libc++/libs',
347 'android_support_include': '<(android_ndk_root)/sources/android/support/include',
348 'android_sysroot': '<(android_sysroot)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000349 }],
350 ],
Ben Murdoch097c5b22016-05-18 11:27:45 +0100351 'android_libcpp_library': 'c++_static',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000352 }], # OS=="android"
353 ['host_clang==1', {
354 'host_cc': '<(clang_dir)/bin/clang',
355 'host_cxx': '<(clang_dir)/bin/clang++',
356 }, {
357 'host_cc': '<!(which gcc)',
358 'host_cxx': '<!(which g++)',
359 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000360 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000361 # Default ARM variable settings.
362 'arm_version%': 'default',
363 'arm_fpu%': 'vfpv3',
364 'arm_float_abi%': 'default',
365 'arm_thumb': 'default',
Paul Lind18a7ebb2014-12-17 22:29:32 -0800366
367 # Default MIPS variable settings.
368 'mips_arch_variant%': 'r2',
369 # Possible values fp32, fp64, fpxx.
370 # fp32 - 32 32-bit FPU registers are available, doubles are placed in
371 # register pairs.
372 # fp64 - 32 64-bit FPU registers are available.
373 # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
374 # detection
375 'mips_fpu_mode%': 'fp32',
Ben Murdoch097c5b22016-05-18 11:27:45 +0100376
377 # Indicates if gcmole tools are downloaded by a hook.
378 'gcmole%': 0,
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000379 },
380 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000381 'variables': {
382 'v8_code%': '<(v8_code)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000383 'conditions':[
384 ['OS=="android"', {
385 'host_os%': '<(host_os)',
386 }],
387 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000388 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000389 'default_configuration': 'Debug',
390 'configurations': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000391 'DebugBaseCommon': {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400392 'conditions': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000393 ['OS=="aix"', {
394 'cflags': [ '-g', '-Og', '-gxcoff' ],
395 }, {
396 'cflags': [ '-g', '-O0' ],
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400397 }],
398 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000399 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000400 'Optdebug': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000401 'inherit_from': [ 'DebugBaseCommon', 'DebugBase1' ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000402 },
403 'Debug': {
404 # Xcode insists on this empty entry.
405 },
406 'Release': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000407 'cflags+': ['<@(release_extra_cflags)'],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000408 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000409 'conditions': [
410 ['OS=="win"', {
411 'Optdebug_x64': {
412 'inherit_from': ['Optdebug'],
413 },
414 'Debug_x64': {
415 'inherit_from': ['Debug'],
416 },
417 'Release_x64': {
418 'inherit_from': ['Release'],
419 },
420 }],
421 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000422 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000423 'conditions':[
424 ['clang==0', {
425 'cflags+': ['-Wno-sign-compare',],
426 }],
427 ['clang==1 or host_clang==1', {
428 # This is here so that all files get recompiled after a clang roll and
429 # when turning clang on or off.
430 # (defines are passed via the command line, and build systems rebuild
431 # things when their commandline changes). Nothing should ever read this
432 # define.
433 'defines': ['CR_CLANG_REVISION=<!(python <(DEPTH)/tools/clang/scripts/update.py --print-revision)'],
434 'conditions': [
435 ['host_clang==1', {
436 'target_conditions': [
437 ['_toolset=="host"', {
438 'cflags+': [
439 '-Wno-format-pedantic',
440 ],
441 }],
442 ],
443 }],
444 ['clang==1', {
445 'target_conditions': [
446 ['_toolset=="target"', {
447 'cflags+': [
448 '-Wno-format-pedantic',
449 ],
450 }],
451 ],
452 }],
453 ],
454 }],
455 ['fastbuild!=0', {
456 'conditions': [
457 ['OS=="win" and fastbuild==1', {
458 'msvs_settings': {
459 'VCLinkerTool': {
460 # This tells the linker to generate .pdbs, so that
461 # we can get meaningful stack traces.
462 'GenerateDebugInformation': 'true',
463 },
464 'VCCLCompilerTool': {
465 # No debug info to be generated by compiler.
466 'DebugInformationFormat': '0',
467 },
468 },
469 }],
470 ],
471 }], # fastbuild!=0
472 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000473 'target_conditions': [
474 ['v8_code == 0', {
475 'defines!': [
476 'DEBUG',
477 ],
478 'conditions': [
479 ['os_posix == 1 and OS != "mac"', {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000480 # We don't want to get warnings from third-party code,
481 # so remove any existing warning-enabling flags like -Wall.
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000482 'cflags!': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000483 '-pedantic',
484 '-Wall',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000485 '-Werror',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000486 '-Wextra',
487 '-Wshorten-64-to-32',
488 ],
489 'cflags+': [
490 # Clang considers the `register` keyword as deprecated, but
491 # ICU uses it all over the place.
492 '-Wno-deprecated-register',
493 # ICU uses its own deprecated functions.
494 '-Wno-deprecated-declarations',
495 # ICU prefers `a && b || c` over `(a && b) || c`.
496 '-Wno-logical-op-parentheses',
497 # ICU has some `unsigned < 0` checks.
498 '-Wno-tautological-compare',
499 # uresdata.c has switch(RES_GET_TYPE(x)) code. The
500 # RES_GET_TYPE macro returns an UResType enum, but some switch
501 # statement contains case values that aren't part of that
502 # enum (e.g. URES_TABLE32 which is in UResInternalType). This
503 # is on purpose.
504 '-Wno-switch',
505 ],
506 'cflags_cc!': [
507 '-Wnon-virtual-dtor',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000508 ],
509 }],
510 ['OS == "mac"', {
511 'xcode_settings': {
512 'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror
513 },
514 }],
515 ['OS == "win"', {
516 'msvs_settings': {
517 'VCCLCompilerTool': {
518 'WarnAsError': 'false',
519 },
520 },
521 }],
522 ],
523 }],
524 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000525 },
526 'conditions': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000527 ['os_posix==1 and OS!="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000528 'target_defaults': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000529 'conditions': [
530 # Common options for AddressSanitizer, LeakSanitizer,
531 # ThreadSanitizer, MemorySanitizer and CFI builds.
532 ['asan==1 or lsan==1 or tsan==1 or msan==1 or cfi_vptr==1', {
533 'target_conditions': [
534 ['_toolset=="target"', {
535 'cflags': [
536 '-fno-omit-frame-pointer',
537 '-gline-tables-only',
538 ],
539 'cflags!': [
540 '-fomit-frame-pointer',
541 ],
542 }],
543 ],
544 }],
545 ['asan==1', {
546 'target_conditions': [
547 ['_toolset=="target"', {
548 'cflags': [
549 '-fsanitize=address',
550 ],
551 'ldflags': [
552 '-fsanitize=address',
553 ],
554 'defines': [
555 'ADDRESS_SANITIZER',
556 ],
557 }],
558 ],
559 }],
560 ['lsan==1', {
561 'target_conditions': [
562 ['_toolset=="target"', {
563 'cflags': [
564 '-fsanitize=leak',
565 ],
566 'ldflags': [
567 '-fsanitize=leak',
568 ],
569 'defines': [
570 'LEAK_SANITIZER',
571 ],
572 }],
573 ],
574 }],
575 ['tsan==1', {
576 'target_conditions': [
577 ['_toolset=="target"', {
578 'cflags': [
579 '-fsanitize=thread',
580 ],
581 'ldflags': [
582 '-fsanitize=thread',
583 ],
584 'defines': [
585 'THREAD_SANITIZER',
586 ],
587 }],
588 ],
589 }],
590 ['msan==1', {
591 'target_conditions': [
592 ['_toolset=="target"', {
593 'cflags': [
594 '-fsanitize=memory',
595 '-fsanitize-memory-track-origins=<(msan_track_origins)',
596 '-fPIC',
597 ],
598 'ldflags': [
599 '-fsanitize=memory',
600 '-pie',
601 ],
602 'defines': [
603 'MEMORY_SANITIZER',
604 ],
605 }],
606 ],
607 }],
608 ['use_custom_libcxx==1', {
609 'dependencies': [
610 '<(DEPTH)/buildtools/third_party/libc++/libc++.gyp:libcxx_proxy',
611 ],
612 }],
613 ['sanitizer_coverage!=0', {
614 'target_conditions': [
615 ['_toolset=="target"', {
616 'cflags': [
617 '-fsanitize-coverage=<(sanitizer_coverage)',
618 ],
619 'defines': [
620 'SANITIZER_COVERAGE',
621 ],
622 }],
623 ],
624 }],
625 ['linux_use_bundled_gold==1 and not (clang==0 and use_lto==1)', {
626 # Put our binutils, which contains gold in the search path. We pass
627 # the path to gold to the compiler. gyp leaves unspecified what the
628 # cwd is when running the compiler, so the normal gyp path-munging
629 # fails us. This hack gets the right path.
630 #
631 # Disabled when using GCC LTO because GCC also uses the -B search
632 # path at link time to find "as", and our bundled "as" can only
633 # target x86.
634 'ldflags': [
635 # Note, Chromium allows ia32 host arch as well, we limit this to
636 # x64 in v8.
637 '-B<(base_dir)/third_party/binutils/Linux_x64/Release/bin',
638 ],
639 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000640 ],
641 },
642 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000643 ['OS=="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000644 'target_defaults': {
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000645 'conditions': [
646 ['asan==1', {
647 'xcode_settings': {
648 # FIXME(machenbach): This is outdated compared to common.gypi.
649 'OTHER_CFLAGS+': [
650 '-fno-omit-frame-pointer',
651 '-gline-tables-only',
652 '-fsanitize=address',
653 '-w', # http://crbug.com/162783
654 ],
655 'OTHER_CFLAGS!': [
656 '-fomit-frame-pointer',
657 ],
658 'defines': [
659 'ADDRESS_SANITIZER',
660 ],
661 },
662 'dependencies': [
663 '<(DEPTH)/build/mac/asan.gyp:asan_dynamic_runtime',
664 ],
665 'target_conditions': [
666 ['_type!="static_library"', {
667 'xcode_settings': {'OTHER_LDFLAGS': ['-fsanitize=address']},
668 }],
669 ],
670 }],
671 ['sanitizer_coverage!=0', {
672 'target_conditions': [
673 ['_toolset=="target"', {
674 'cflags': [
675 '-fsanitize-coverage=<(sanitizer_coverage)',
676 ],
677 'defines': [
678 'SANITIZER_COVERAGE',
679 ],
680 }],
681 ],
682 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000683 ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000684 }, # target_defaults
685 }], # OS=="mac"
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100686 ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000687 or OS=="netbsd" or OS=="aix"', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000688 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000689 'cflags': [
690 '-Wall',
691 '<(werror)',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000692 '-Wno-unused-parameter',
693 '-Wno-long-long',
694 '-pthread',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000695 '-pedantic',
696 # Don't warn about the "struct foo f = {0};" initialization pattern.
697 '-Wno-missing-field-initializers',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000698 '-Wno-gnu-zero-variadic-macro-arguments',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000699 ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000700 'cflags_cc': [
701 '-Wnon-virtual-dtor',
702 '-fno-exceptions',
703 '-fno-rtti',
Ben Murdochda12d292016-06-02 14:46:10 +0100704 '-std=gnu++11',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000705 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000706 'ldflags': [ '-pthread', ],
707 'conditions': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000708 # Don't warn about TRACE_EVENT_* macros with zero arguments passed to
709 # ##__VA_ARGS__. C99 strict mode prohibits having zero variadic macro
710 # arguments in gcc.
711 [ 'clang==0', {
712 'cflags!' : [
713 '-pedantic' ,
714 # Don't warn about unrecognized command line option.
715 '-Wno-gnu-zero-variadic-macro-arguments',
716 ],
717 }],
718 [ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64" \
719 or v8_target_arch=="mips64el")', {
720 'cflags': [ '-Wshorten-64-to-32' ],
721 }],
722 [ 'host_arch=="ppc64" and OS!="aix"', {
723 'cflags': [ '-mminimal-toc' ],
724 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000725 [ 'visibility=="hidden" and v8_enable_backtrace==0', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000726 'cflags': [ '-fvisibility=hidden' ],
727 }],
728 [ 'component=="shared_library"', {
729 'cflags': [ '-fPIC', ],
730 }],
Ben Murdochda12d292016-06-02 14:46:10 +0100731 [ 'clang==0 and coverage==1', {
Ben Murdoch097c5b22016-05-18 11:27:45 +0100732 'cflags': [ '-fprofile-arcs', '-ftest-coverage'],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000733 'ldflags': [ '-fprofile-arcs'],
734 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000735 ],
736 },
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100737 }],
738 # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
739 # or OS=="netbsd"'
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000740 ['OS=="qnx"', {
741 'target_defaults': {
742 'cflags': [
743 '-Wall',
744 '<(werror)',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000745 '-Wno-unused-parameter',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000746 # Don't warn about the "struct foo f = {0};" initialization pattern.
747 '-Wno-missing-field-initializers',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000748 '-Wno-gnu-zero-variadic-macro-arguments',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000749 ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000750 'cflags_cc': [
751 '-Wnon-virtual-dtor',
752 '-fno-exceptions',
753 '-fno-rtti',
Ben Murdochda12d292016-06-02 14:46:10 +0100754 '-std=gnu++11',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000755 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000756 'conditions': [
757 [ 'visibility=="hidden"', {
758 'cflags': [ '-fvisibility=hidden' ],
759 }],
760 [ 'component=="shared_library"', {
761 'cflags': [ '-fPIC' ],
762 }],
763 ],
764 'target_conditions': [
765 [ '_toolset=="host" and host_os=="linux"', {
766 'cflags': [ '-pthread' ],
767 'ldflags': [ '-pthread' ],
768 'libraries': [ '-lrt' ],
769 }],
770 [ '_toolset=="target"', {
771 'cflags': [ '-Wno-psabi' ],
772 'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
773 }],
774 ],
775 },
776 }], # OS=="qnx"
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000777 ['OS=="win"', {
778 'target_defaults': {
779 'defines': [
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000780 '_CRT_SECURE_NO_DEPRECATE',
781 '_CRT_NONSTDC_NO_DEPRECATE',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000782 '_USING_V110_SDK71_',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000783 ],
784 'conditions': [
785 ['component=="static_library"', {
786 'defines': [
787 '_HAS_EXCEPTIONS=0',
788 ],
789 }],
790 ],
791 'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000792 'msvs_disabled_warnings': [
793 # C4091: 'typedef ': ignored on left of 'X' when no variable is
794 # declared.
795 # This happens in a number of Windows headers. Dumb.
796 4091,
797
798 # C4127: conditional expression is constant
799 # This warning can in theory catch dead code and other problems, but
800 # triggers in far too many desirable cases where the conditional
801 # expression is either set by macros or corresponds some legitimate
802 # compile-time constant expression (due to constant template args,
803 # conditionals comparing the sizes of different types, etc.). Some of
804 # these can be worked around, but it's not worth it.
805 4127,
806
807 # C4351: new behavior: elements of array 'array' will be default
808 # initialized
809 # This is a silly "warning" that basically just alerts you that the
810 # compiler is going to actually follow the language spec like it's
811 # supposed to, instead of not following it like old buggy versions
812 # did. There's absolutely no reason to turn this on.
813 4351,
814
815 # C4355: 'this': used in base member initializer list
816 # It's commonly useful to pass |this| to objects in a class'
817 # initializer list. While this warning can catch real bugs, most of
818 # the time the constructors in question don't attempt to call methods
819 # on the passed-in pointer (until later), and annotating every legit
820 # usage of this is simply more hassle than the warning is worth.
821 4355,
822
823 # C4503: 'identifier': decorated name length exceeded, name was
824 # truncated
825 # This only means that some long error messages might have truncated
826 # identifiers in the presence of lots of templates. It has no effect
827 # on program correctness and there's no real reason to waste time
828 # trying to prevent it.
829 4503,
830
831 # Warning C4589 says: "Constructor of abstract class ignores
832 # initializer for virtual base class." Disable this warning because it
833 # is flaky in VS 2015 RTM. It triggers on compiler generated
834 # copy-constructors in some cases.
835 4589,
836
837 # C4611: interaction between 'function' and C++ object destruction is
838 # non-portable
839 # This warning is unavoidable when using e.g. setjmp/longjmp. MSDN
840 # suggests using exceptions instead of setjmp/longjmp for C++, but
841 # Chromium code compiles without exception support. We therefore have
842 # to use setjmp/longjmp for e.g. JPEG decode error handling, which
843 # means we have to turn off this warning (and be careful about how
844 # object destruction happens in such cases).
845 4611,
846
847 # TODO(jochen): These warnings are level 4. They will be slowly
848 # removed as code is fixed.
849 4100, # Unreferenced formal parameter
850 4121, # Alignment of a member was sensitive to packing
851 4244, # Conversion from 'type1' to 'type2', possible loss of data
852 4302, # Truncation from 'type 1' to 'type 2'
853 4309, # Truncation of constant value
854 4311, # Pointer truncation from 'type' to 'type'
855 4312, # Conversion from 'type1' to 'type2' of greater size
856 4505, # Unreferenced local function has been removed
857 4510, # Default constructor could not be generated
858 4512, # Assignment operator could not be generated
859 4610, # Object can never be instantiated
860 4800, # Forcing value to bool.
861 4838, # Narrowing conversion. Doesn't seem to be very useful.
862 4995, # 'X': name was marked as #pragma deprecated
863 4996, # 'X': was declared deprecated (for GetVersionEx).
864
865 # These are variable shadowing warnings that are new in VS2015. We
866 # should work through these at some point -- they may be removed from
867 # the RTM release in the /W4 set.
868 4456, 4457, 4458, 4459,
869 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000870 'msvs_settings': {
871 'VCCLCompilerTool': {
872 'MinimalRebuild': 'false',
873 'BufferSecurityCheck': 'true',
874 'EnableFunctionLevelLinking': 'true',
875 'RuntimeTypeInfo': 'false',
876 'WarningLevel': '3',
877 'WarnAsError': 'true',
878 'DebugInformationFormat': '3',
879 'Detect64BitPortabilityProblems': 'false',
880 'conditions': [
881 [ 'msvs_multi_core_compile', {
882 'AdditionalOptions': ['/MP'],
883 }],
884 ['component=="shared_library"', {
885 'ExceptionHandling': '1', # /EHsc
886 }, {
887 'ExceptionHandling': '0',
888 }],
889 ],
890 },
891 'VCLibrarianTool': {
892 'AdditionalOptions': ['/ignore:4221'],
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400893 'conditions': [
894 ['v8_target_arch=="x64"', {
895 'TargetMachine': '17', # x64
896 }, {
897 'TargetMachine': '1', # ia32
898 }],
899 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000900 },
901 'VCLinkerTool': {
902 'AdditionalDependencies': [
903 'ws2_32.lib',
904 ],
905 'GenerateDebugInformation': 'true',
906 'MapFileName': '$(OutDir)\\$(TargetName).map',
907 'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
908 'FixedBaseAddress': '1',
909 # LinkIncremental values:
910 # 0 == default
911 # 1 == /INCREMENTAL:NO
912 # 2 == /INCREMENTAL
913 'LinkIncremental': '1',
914 # SubSystem values:
915 # 0 == not set
916 # 1 == /SUBSYSTEM:CONSOLE
917 # 2 == /SUBSYSTEM:WINDOWS
918 'SubSystem': '1',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000919
920 'conditions': [
921 ['v8_enable_i18n_support==1', {
922 'AdditionalDependencies': [
923 'advapi32.lib',
924 ],
925 }],
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400926 ['v8_target_arch=="x64"', {
927 'MinimumRequiredVersion': '5.02', # Server 2003.
928 'TargetMachine': '17', # x64
929 }, {
930 'MinimumRequiredVersion': '5.01', # XP.
931 'TargetMachine': '1', # ia32
932 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000933 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000934 },
935 },
936 },
937 }], # OS=="win"
938 ['OS=="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000939 'xcode_settings': {
Emily Bernierd0a1eb72015-03-24 16:35:39 -0400940 'SDKROOT': 'macosx',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000941 'SYMROOT': '<(DEPTH)/xcodebuild',
942 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000943 'target_defaults': {
944 'xcode_settings': {
945 'ALWAYS_SEARCH_USER_PATHS': 'NO',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000946 'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000947 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
948 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
949 # (Equivalent to -fPIC)
950 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
951 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
952 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
953 # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
954 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
955 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
956 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000957 'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
958 # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
959 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000960 'PREBINDING': 'NO', # No -Wl,-prebind
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000961 'SYMROOT': '<(DEPTH)/xcodebuild',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000962 'USE_HEADERMAP': 'NO',
963 'OTHER_CFLAGS': [
964 '-fno-strict-aliasing',
965 ],
966 'WARNING_CFLAGS': [
967 '-Wall',
968 '-Wendif-labels',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000969 '-Wno-unused-parameter',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000970 # Don't warn about the "struct foo f = {0};" initialization pattern.
971 '-Wno-missing-field-initializers',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000972 '-Wno-gnu-zero-variadic-macro-arguments',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000973 ],
974 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000975 'conditions': [
976 ['werror==""', {
977 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
978 }, {
979 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
980 }],
981 ['clang==1', {
982 'xcode_settings': {
983 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
Ben Murdochda12d292016-06-02 14:46:10 +0100984 'CLANG_CXX_LANGUAGE_STANDARD': 'c++11', # -std=c++11
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000985 },
Ben Murdoch4a90d5f2016-03-22 12:00:34 +0000986 'conditions': [
987 ['v8_target_arch=="x64" or v8_target_arch=="arm64" \
988 or v8_target_arch=="mips64el"', {
989 'xcode_settings': {'WARNING_CFLAGS': ['-Wshorten-64-to-32']},
990 }],
991 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000992 }],
993 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000994 'target_conditions': [
995 ['_type!="static_library"', {
996 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
997 }],
998 ], # target_conditions
999 }, # target_defaults
1000 }], # OS=="mac"
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001001 ['OS=="android"', {
1002 'target_defaults': {
1003 'defines': [
1004 'ANDROID',
1005 'V8_ANDROID_LOG_STDOUT',
1006 ],
1007 'configurations': {
1008 'Release': {
1009 'cflags': [
1010 '-fomit-frame-pointer',
1011 ],
1012 }, # Release
1013 }, # configurations
1014 'cflags': [ '-Wno-abi', '-Wall', '-W', '-Wno-unused-parameter'],
1015 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-fno-exceptions',
Ben Murdoch097c5b22016-05-18 11:27:45 +01001016 '-std=gnu++11' ],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001017 'target_conditions': [
1018 ['_toolset=="target"', {
1019 'cflags!': [
1020 '-pthread', # Not supported by Android toolchain.
1021 ],
1022 'cflags': [
1023 '-ffunction-sections',
1024 '-funwind-tables',
1025 '-fstack-protector',
1026 '-fno-short-enums',
1027 '-finline-limit=64',
1028 '-Wa,--noexecstack',
Ben Murdoch097c5b22016-05-18 11:27:45 +01001029 '--sysroot=<(android_sysroot)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001030 ],
1031 'cflags_cc': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001032 '-isystem<(android_libcpp_include)',
1033 '-isystem<(android_libcpp_abi_include)',
1034 '-isystem<(android_support_include)',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001035 ],
1036 'defines': [
1037 'ANDROID',
1038 #'__GNU_SOURCE=1', # Necessary for clone()
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001039 'HAVE_OFF64_T',
1040 'HAVE_SYS_UIO_H',
1041 'ANDROID_BINSIZE_HACK', # Enable temporary hacks to reduce binsize.
1042 ],
1043 'ldflags!': [
1044 '-pthread', # Not supported by Android toolchain.
1045 ],
1046 'ldflags': [
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001047 '-Wl,--no-undefined',
Ben Murdoch097c5b22016-05-18 11:27:45 +01001048 '--sysroot=<(android_sysroot)',
1049 '-nostdlib',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001050 ],
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': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001060 '-l<(android_libcpp_library)',
1061 '-latomic',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001062 # Manually link the libgcc.a that the cross compiler uses.
1063 '<!(<(android_toolchain)/*-gcc -print-libgcc-file-name)',
1064 '-lc',
1065 '-ldl',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001066 '-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': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001082 '-L<(android_libcpp_libs)/armeabi-v7a',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001083 ],
1084 }],
1085 ['target_arch=="arm" and arm_version < 7', {
1086 'ldflags': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001087 '-L<(android_libcpp_libs)/armeabi',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001088 ],
1089 }],
1090 ['target_arch=="x64"', {
1091 'ldflags': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001092 '-L<(android_libcpp_libs)/x86_64',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001093 ],
1094 }],
1095 ['target_arch=="arm64"', {
1096 'ldflags': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001097 '-L<(android_libcpp_libs)/arm64-v8a',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001098 ],
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': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001109 '-L<(android_libcpp_libs)/x86',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001110 ],
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': [
Ben Murdoch097c5b22016-05-18 11:27:45 +01001122 '-L<(android_libcpp_libs)/mips',
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001123 ],
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)', {
Ben Murdochda12d292016-06-02 14:46:10 +01001260 'conditions': [
1261 ['coverage==1', {
1262 # Wrap goma with coverage wrapper.
1263 'make_global_settings': [
1264 ['CC_wrapper', '<(base_dir)/build/coverage_wrapper.py <(gomadir)/gomacc'],
1265 ['CXX_wrapper', '<(base_dir)/build/coverage_wrapper.py <(gomadir)/gomacc'],
1266 ['CC.host_wrapper', '<(base_dir)/build/coverage_wrapper.py <(gomadir)/gomacc'],
1267 ['CXX.host_wrapper', '<(base_dir)/build/coverage_wrapper.py <(gomadir)/gomacc'],
1268 ],
1269 }, {
1270 # Use only goma wrapper.
1271 'make_global_settings': [
1272 ['CC_wrapper', '<(gomadir)/gomacc'],
1273 ['CXX_wrapper', '<(gomadir)/gomacc'],
1274 ['CC.host_wrapper', '<(gomadir)/gomacc'],
1275 ['CXX.host_wrapper', '<(gomadir)/gomacc'],
1276 ],
1277 }],
1278 ],
1279 }, {
1280 'conditions': [
1281 ['coverage==1', {
1282 # Use only coverage wrapper.
1283 'make_global_settings': [
1284 ['CC_wrapper', '<(base_dir)/build/coverage_wrapper.py'],
1285 ['CXX_wrapper', '<(base_dir)/build/coverage_wrapper.py'],
1286 ['CC.host_wrapper', '<(base_dir)/build/coverage_wrapper.py'],
1287 ['CXX.host_wrapper', '<(base_dir)/build/coverage_wrapper.py'],
1288 ],
1289 }],
Ben Murdoch4a90d5f2016-03-22 12:00:34 +00001290 ],
1291 }],
1292 ['use_lto==1', {
1293 'target_defaults': {
1294 'target_conditions': [
1295 ['_toolset=="target"', {
1296 'cflags': [
1297 '-flto',
1298 ],
1299 }],
1300 ],
1301 },
1302 }],
1303 ['use_lto==1 and clang==0', {
1304 'target_defaults': {
1305 'target_conditions': [
1306 ['_toolset=="target"', {
1307 'cflags': [
1308 '-ffat-lto-objects',
1309 ],
1310 }],
1311 ],
1312 },
1313 }],
1314 ['use_lto==1 and clang==1', {
1315 'target_defaults': {
1316 'target_conditions': [
1317 ['_toolset=="target"', {
1318 'arflags': [
1319 '--plugin', '<(clang_dir)/lib/LLVMgold.so',
1320 ],
1321 # Apply a lower optimization level with lto. Chromium does this
1322 # for non-official builds only - a differentiation that doesn't
1323 # exist in v8.
1324 'ldflags': [
1325 '-Wl,--plugin-opt,O1',
1326 ],
1327 }],
1328 ],
1329 },
1330 }],
1331 ['use_lto==1 and clang==0', {
1332 'target_defaults': {
1333 'target_conditions': [
1334 ['_toolset=="target"', {
1335 'ldflags': [
1336 '-flto=32',
1337 ],
1338 }],
1339 ],
1340 },
1341 }],
1342 ['use_lto==1 and clang==1', {
1343 'target_defaults': {
1344 'target_conditions': [
1345 ['_toolset=="target"', {
1346 'ldflags': [
1347 '-flto',
1348 ],
1349 }],
1350 ],
1351 },
1352 }],
1353 ['cfi_diag==1', {
1354 'target_defaults': {
1355 'target_conditions': [
1356 ['_toolset=="target"', {
1357 'cflags': [
1358 '-fno-sanitize-trap=cfi',
1359 '-fno-sanitize-recover=cfi',
1360 ],
1361 'cflags_cc!': [
1362 '-fno-rtti',
1363 ],
1364 'cflags!': [
1365 '-fno-rtti',
1366 ],
1367 'ldflags': [
1368 '-fno-sanitize-trap=cfi',
1369 '-fno-sanitize-recover=cfi',
1370 ],
1371 }],
1372 ],
1373 },
1374 }],
1375 ['cfi_vptr==1', {
1376 'target_defaults': {
1377 'target_conditions': [
1378 ['_toolset=="target"', {
1379 'cflags': [
1380 '-fsanitize=cfi-vcall',
1381 '-fsanitize=cfi-derived-cast',
1382 '-fsanitize=cfi-unrelated-cast',
1383 '-fsanitize-blacklist=<(cfi_blacklist)',
1384 ],
1385 'ldflags': [
1386 '-fsanitize=cfi-vcall',
1387 '-fsanitize=cfi-derived-cast',
1388 '-fsanitize=cfi-unrelated-cast',
1389 ],
1390 }],
1391 ],
1392 },
1393 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +00001394 ],
1395}