blob: b09122b538e33b27ada26fac414cf007656c8e7d [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',
Ben Murdochb8a8cc12014-11-26 15:28:44 +000036 'asan%': 0,
37 'tsan%': 0,
Ben Murdoch69a99ed2011-11-30 16:03:39 +000038 'visibility%': 'hidden',
Ben Murdochb8a8cc12014-11-26 15:28:44 +000039 'v8_enable_backtrace%': 0,
40 'v8_enable_i18n_support%': 1,
41 'v8_deprecation_warnings': 1,
Ben Murdoch69a99ed2011-11-30 16:03:39 +000042 'msvs_multi_core_compile%': '1',
Ben Murdochb8a8cc12014-11-26 15:28:44 +000043 'mac_deployment_target%': '10.5',
Ben Murdoch69a99ed2011-11-30 16:03:39 +000044 'variables': {
45 'variables': {
Ben Murdoch3ef787d2012-04-12 10:51:47 +010046 'variables': {
47 'conditions': [
Ben Murdochb8a8cc12014-11-26 15:28:44 +000048 ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or \
49 OS=="netbsd" or OS=="mac" or OS=="qnx"', {
50 # This handles the Unix platforms we generally deal with.
Ben Murdoch3ef787d2012-04-12 10:51:47 +010051 # Anything else gets passed through, which probably won't work
52 # very well; such hosts should pass an explicit target_arch
53 # to gyp.
Ben Murdochb8a8cc12014-11-26 15:28:44 +000054 'host_arch%': '<!pymod_do_main(detect_v8_host_arch)',
Ben Murdoch3ef787d2012-04-12 10:51:47 +010055 }, {
Ben Murdochb8a8cc12014-11-26 15:28:44 +000056 # OS!="linux" and OS!="freebsd" and OS!="openbsd" and
57 # OS!="netbsd" and OS!="mac"
Ben Murdoch3ef787d2012-04-12 10:51:47 +010058 'host_arch%': 'ia32',
59 }],
60 ],
61 },
62 'host_arch%': '<(host_arch)',
63 'target_arch%': '<(host_arch)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +000064 },
65 'host_arch%': '<(host_arch)',
Ben Murdoch3ef787d2012-04-12 10:51:47 +010066 'target_arch%': '<(target_arch)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +000067 'v8_target_arch%': '<(target_arch)',
68 },
69 'host_arch%': '<(host_arch)',
70 'target_arch%': '<(target_arch)',
71 'v8_target_arch%': '<(v8_target_arch)',
Ben Murdoch3ef787d2012-04-12 10:51:47 +010072 'werror%': '-Werror',
Ben Murdochb8a8cc12014-11-26 15:28:44 +000073
74 # .gyp files or targets should set v8_code to 1 if they build V8 specific
75 # code, as opposed to external code. This variable is used to control such
76 # things as the set of warnings to enable, and whether warnings are treated
77 # as errors.
78 'v8_code%': 0,
79
80 # Speeds up Debug builds:
81 # 0 - Compiler optimizations off (debuggable) (default). This may
82 # be 5x slower than Release (or worse).
83 # 1 - Turn on compiler optimizations. This may be hard or impossible to
84 # debug. This may still be 2x slower than Release (or worse).
85 # 2 - Turn on optimizations, and also #undef DEBUG / #define NDEBUG
86 # (but leave V8_ENABLE_CHECKS and most other assertions enabled.
87 # This may cause some v8 tests to fail in the Debug configuration.
88 # This roughly matches the performance of a Release build and can
89 # be used by embedders that need to build their own code as debug
90 # but don't want or need a debug version of V8. This should produce
91 # near-release speeds.
92 'v8_optimized_debug%': 0,
93
94 # Relative path to icu.gyp from this file.
95 'icu_gyp_path': '../third_party/icu/icu.gyp',
96
Ben Murdoch69a99ed2011-11-30 16:03:39 +000097 'conditions': [
98 ['(v8_target_arch=="arm" and host_arch!="arm") or \
Ben Murdochb8a8cc12014-11-26 15:28:44 +000099 (v8_target_arch=="arm64" and host_arch!="arm64") or \
100 (v8_target_arch=="mipsel" and host_arch!="mipsel") or \
101 (v8_target_arch=="mips64el" and host_arch!="mips64el") or \
102 (v8_target_arch=="x64" and host_arch!="x64") or \
103 (OS=="android" or OS=="qnx")', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000104 'want_separate_host_toolset': 1,
105 }, {
106 'want_separate_host_toolset': 0,
107 }],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000108 ['OS == "win"', {
109 'os_posix%': 0,
110 }, {
111 'os_posix%': 1,
112 }],
113 ['(v8_target_arch=="ia32" or v8_target_arch=="x64" or v8_target_arch=="x87") and \
114 (OS=="linux" or OS=="mac")', {
115 'v8_enable_gdbjit%': 1,
116 }, {
117 'v8_enable_gdbjit%': 0,
118 }],
119 ['OS=="mac"', {
120 'clang%': 1,
121 }, {
122 'clang%': 0,
123 }],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000124 ],
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000125 # Default ARM variable settings.
126 'arm_version%': 'default',
127 'arm_fpu%': 'vfpv3',
128 'arm_float_abi%': 'default',
129 'arm_thumb': 'default',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000130 },
131 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000132 'variables': {
133 'v8_code%': '<(v8_code)',
134 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000135 'default_configuration': 'Debug',
136 'configurations': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000137 'DebugBaseCommon': {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000138 'cflags': [ '-g', '-O0' ],
139 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000140 'Optdebug': {
141 'inherit_from': [ 'DebugBaseCommon', 'DebugBase2' ],
142 },
143 'Debug': {
144 # Xcode insists on this empty entry.
145 },
146 'Release': {
147 # Xcode insists on this empty entry.
148 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000149 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000150 'target_conditions': [
151 ['v8_code == 0', {
152 'defines!': [
153 'DEBUG',
154 ],
155 'conditions': [
156 ['os_posix == 1 and OS != "mac"', {
157 'cflags!': [
158 '-Werror',
159 ],
160 }],
161 ['OS == "mac"', {
162 'xcode_settings': {
163 'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror
164 },
165 }],
166 ['OS == "win"', {
167 'msvs_settings': {
168 'VCCLCompilerTool': {
169 'WarnAsError': 'false',
170 },
171 },
172 }],
173 ],
174 }],
175 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000176 },
177 'conditions': [
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000178 ['asan==1', {
179 'target_defaults': {
180 'cflags_cc+': [
181 '-fno-omit-frame-pointer',
182 '-gline-tables-only',
183 '-fsanitize=address',
184 '-w', # http://crbug.com/162783
185 ],
186 'cflags_cc!': [
187 '-fomit-frame-pointer',
188 ],
189 'ldflags': [
190 '-fsanitize=address',
191 ],
192 },
193 }],
194 ['tsan==1', {
195 'target_defaults': {
196 'cflags+': [
197 '-fno-omit-frame-pointer',
198 '-gline-tables-only',
199 '-fsanitize=thread',
200 '-fPIC',
201 '-Wno-c++11-extensions',
202 ],
203 'cflags!': [
204 '-fomit-frame-pointer',
205 ],
206 'ldflags': [
207 '-fsanitize=thread',
208 '-pie',
209 ],
210 'defines': [
211 'THREAD_SANITIZER',
212 ],
213 },
214 }],
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100215 ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
216 or OS=="netbsd"', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000217 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000218 'cflags': [
219 '-Wall',
220 '<(werror)',
221 '-W',
222 '-Wno-unused-parameter',
223 '-Wno-long-long',
224 '-pthread',
225 '-fno-exceptions',
226 '-pedantic',
227 # Don't warn about the "struct foo f = {0};" initialization pattern.
228 '-Wno-missing-field-initializers',
229 ],
230 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000231 'ldflags': [ '-pthread', ],
232 'conditions': [
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000233 [ 'visibility=="hidden" and v8_enable_backtrace==0', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000234 'cflags': [ '-fvisibility=hidden' ],
235 }],
236 [ 'component=="shared_library"', {
237 'cflags': [ '-fPIC', ],
238 }],
239 ],
240 },
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100241 }],
242 # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
243 # or OS=="netbsd"'
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000244 ['OS=="qnx"', {
245 'target_defaults': {
246 'cflags': [
247 '-Wall',
248 '<(werror)',
249 '-W',
250 '-Wno-unused-parameter',
251 '-fno-exceptions',
252 # Don't warn about the "struct foo f = {0};" initialization pattern.
253 '-Wno-missing-field-initializers',
254 ],
255 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
256 'conditions': [
257 [ 'visibility=="hidden"', {
258 'cflags': [ '-fvisibility=hidden' ],
259 }],
260 [ 'component=="shared_library"', {
261 'cflags': [ '-fPIC' ],
262 }],
263 ],
264 'target_conditions': [
265 [ '_toolset=="host" and host_os=="linux"', {
266 'cflags': [ '-pthread' ],
267 'ldflags': [ '-pthread' ],
268 'libraries': [ '-lrt' ],
269 }],
270 [ '_toolset=="target"', {
271 'cflags': [ '-Wno-psabi' ],
272 'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
273 }],
274 ],
275 },
276 }], # OS=="qnx"
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000277 ['OS=="win"', {
278 'target_defaults': {
279 'defines': [
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000280 '_CRT_SECURE_NO_DEPRECATE',
281 '_CRT_NONSTDC_NO_DEPRECATE',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000282 '_USING_V110_SDK71_',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000283 ],
284 'conditions': [
285 ['component=="static_library"', {
286 'defines': [
287 '_HAS_EXCEPTIONS=0',
288 ],
289 }],
290 ],
291 'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
292 'msvs_disabled_warnings': [4355, 4800],
293 'msvs_settings': {
294 'VCCLCompilerTool': {
295 'MinimalRebuild': 'false',
296 'BufferSecurityCheck': 'true',
297 'EnableFunctionLevelLinking': 'true',
298 'RuntimeTypeInfo': 'false',
299 'WarningLevel': '3',
300 'WarnAsError': 'true',
301 'DebugInformationFormat': '3',
302 'Detect64BitPortabilityProblems': 'false',
303 'conditions': [
304 [ 'msvs_multi_core_compile', {
305 'AdditionalOptions': ['/MP'],
306 }],
307 ['component=="shared_library"', {
308 'ExceptionHandling': '1', # /EHsc
309 }, {
310 'ExceptionHandling': '0',
311 }],
312 ],
313 },
314 'VCLibrarianTool': {
315 'AdditionalOptions': ['/ignore:4221'],
316 },
317 'VCLinkerTool': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000318 'MinimumRequiredVersion': '5.01', # XP.
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000319 'AdditionalDependencies': [
320 'ws2_32.lib',
321 ],
322 'GenerateDebugInformation': 'true',
323 'MapFileName': '$(OutDir)\\$(TargetName).map',
324 'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
325 'FixedBaseAddress': '1',
326 # LinkIncremental values:
327 # 0 == default
328 # 1 == /INCREMENTAL:NO
329 # 2 == /INCREMENTAL
330 'LinkIncremental': '1',
331 # SubSystem values:
332 # 0 == not set
333 # 1 == /SUBSYSTEM:CONSOLE
334 # 2 == /SUBSYSTEM:WINDOWS
335 'SubSystem': '1',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000336
337 'conditions': [
338 ['v8_enable_i18n_support==1', {
339 'AdditionalDependencies': [
340 'advapi32.lib',
341 ],
342 }],
343 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000344 },
345 },
346 },
347 }], # OS=="win"
348 ['OS=="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000349 'xcode_settings': {
350 'SYMROOT': '<(DEPTH)/xcodebuild',
351 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000352 'target_defaults': {
353 'xcode_settings': {
354 'ALWAYS_SEARCH_USER_PATHS': 'NO',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000355 'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000356 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
357 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
358 # (Equivalent to -fPIC)
359 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
360 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
361 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
362 # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
363 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
364 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
365 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000366 'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
367 # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
368 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000369 'PREBINDING': 'NO', # No -Wl,-prebind
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000370 'SYMROOT': '<(DEPTH)/xcodebuild',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000371 'USE_HEADERMAP': 'NO',
372 'OTHER_CFLAGS': [
373 '-fno-strict-aliasing',
374 ],
375 'WARNING_CFLAGS': [
376 '-Wall',
377 '-Wendif-labels',
378 '-W',
379 '-Wno-unused-parameter',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000380 # Don't warn about the "struct foo f = {0};" initialization pattern.
381 '-Wno-missing-field-initializers',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000382 ],
383 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000384 'conditions': [
385 ['werror==""', {
386 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
387 }, {
388 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
389 }],
390 ['clang==1', {
391 'xcode_settings': {
392 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
393 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x', # -std=gnu++0x
394 },
395 }],
396 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000397 'target_conditions': [
398 ['_type!="static_library"', {
399 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
400 }],
401 ], # target_conditions
402 }, # target_defaults
403 }], # OS=="mac"
404 ],
405}