blob: 32ad028f092b85570cc948af3056cca7b310fb28 [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',
Paul Lind18a7ebb2014-12-17 22:29:32 -0800130
131 # Default MIPS variable settings.
132 'mips_arch_variant%': 'r2',
133 # Possible values fp32, fp64, fpxx.
134 # fp32 - 32 32-bit FPU registers are available, doubles are placed in
135 # register pairs.
136 # fp64 - 32 64-bit FPU registers are available.
137 # fpxx - compatibility mode, it chooses fp32 or fp64 depending on runtime
138 # detection
139 'mips_fpu_mode%': 'fp32',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000140 },
141 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000142 'variables': {
143 'v8_code%': '<(v8_code)',
144 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000145 'default_configuration': 'Debug',
146 'configurations': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000147 'DebugBaseCommon': {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000148 'cflags': [ '-g', '-O0' ],
149 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000150 'Optdebug': {
151 'inherit_from': [ 'DebugBaseCommon', 'DebugBase2' ],
152 },
153 'Debug': {
154 # Xcode insists on this empty entry.
155 },
156 'Release': {
157 # Xcode insists on this empty entry.
158 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000159 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000160 'target_conditions': [
161 ['v8_code == 0', {
162 'defines!': [
163 'DEBUG',
164 ],
165 'conditions': [
166 ['os_posix == 1 and OS != "mac"', {
167 'cflags!': [
168 '-Werror',
169 ],
170 }],
171 ['OS == "mac"', {
172 'xcode_settings': {
173 'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO', # -Werror
174 },
175 }],
176 ['OS == "win"', {
177 'msvs_settings': {
178 'VCCLCompilerTool': {
179 'WarnAsError': 'false',
180 },
181 },
182 }],
183 ],
184 }],
185 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000186 },
187 'conditions': [
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000188 ['asan==1', {
189 'target_defaults': {
190 'cflags_cc+': [
191 '-fno-omit-frame-pointer',
192 '-gline-tables-only',
193 '-fsanitize=address',
194 '-w', # http://crbug.com/162783
195 ],
196 'cflags_cc!': [
197 '-fomit-frame-pointer',
198 ],
199 'ldflags': [
200 '-fsanitize=address',
201 ],
202 },
203 }],
204 ['tsan==1', {
205 'target_defaults': {
206 'cflags+': [
207 '-fno-omit-frame-pointer',
208 '-gline-tables-only',
209 '-fsanitize=thread',
210 '-fPIC',
211 '-Wno-c++11-extensions',
212 ],
213 'cflags!': [
214 '-fomit-frame-pointer',
215 ],
216 'ldflags': [
217 '-fsanitize=thread',
218 '-pie',
219 ],
220 'defines': [
221 'THREAD_SANITIZER',
222 ],
223 },
224 }],
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100225 ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris" \
226 or OS=="netbsd"', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000227 'target_defaults': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000228 'cflags': [
229 '-Wall',
230 '<(werror)',
231 '-W',
232 '-Wno-unused-parameter',
233 '-Wno-long-long',
234 '-pthread',
235 '-fno-exceptions',
236 '-pedantic',
237 # Don't warn about the "struct foo f = {0};" initialization pattern.
238 '-Wno-missing-field-initializers',
239 ],
240 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000241 'ldflags': [ '-pthread', ],
242 'conditions': [
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000243 [ 'visibility=="hidden" and v8_enable_backtrace==0', {
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000244 'cflags': [ '-fvisibility=hidden' ],
245 }],
246 [ 'component=="shared_library"', {
247 'cflags': [ '-fPIC', ],
248 }],
249 ],
250 },
Ben Murdoch3ef787d2012-04-12 10:51:47 +0100251 }],
252 # 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"
253 # or OS=="netbsd"'
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000254 ['OS=="qnx"', {
255 'target_defaults': {
256 'cflags': [
257 '-Wall',
258 '<(werror)',
259 '-W',
260 '-Wno-unused-parameter',
261 '-fno-exceptions',
262 # Don't warn about the "struct foo f = {0};" initialization pattern.
263 '-Wno-missing-field-initializers',
264 ],
265 'cflags_cc': [ '-Wnon-virtual-dtor', '-fno-rtti', '-std=gnu++0x' ],
266 'conditions': [
267 [ 'visibility=="hidden"', {
268 'cflags': [ '-fvisibility=hidden' ],
269 }],
270 [ 'component=="shared_library"', {
271 'cflags': [ '-fPIC' ],
272 }],
273 ],
274 'target_conditions': [
275 [ '_toolset=="host" and host_os=="linux"', {
276 'cflags': [ '-pthread' ],
277 'ldflags': [ '-pthread' ],
278 'libraries': [ '-lrt' ],
279 }],
280 [ '_toolset=="target"', {
281 'cflags': [ '-Wno-psabi' ],
282 'libraries': [ '-lbacktrace', '-lsocket', '-lm' ],
283 }],
284 ],
285 },
286 }], # OS=="qnx"
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000287 ['OS=="win"', {
288 'target_defaults': {
289 'defines': [
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000290 '_CRT_SECURE_NO_DEPRECATE',
291 '_CRT_NONSTDC_NO_DEPRECATE',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000292 '_USING_V110_SDK71_',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000293 ],
294 'conditions': [
295 ['component=="static_library"', {
296 'defines': [
297 '_HAS_EXCEPTIONS=0',
298 ],
299 }],
300 ],
301 'msvs_cygwin_dirs': ['<(DEPTH)/third_party/cygwin'],
302 'msvs_disabled_warnings': [4355, 4800],
303 'msvs_settings': {
304 'VCCLCompilerTool': {
305 'MinimalRebuild': 'false',
306 'BufferSecurityCheck': 'true',
307 'EnableFunctionLevelLinking': 'true',
308 'RuntimeTypeInfo': 'false',
309 'WarningLevel': '3',
310 'WarnAsError': 'true',
311 'DebugInformationFormat': '3',
312 'Detect64BitPortabilityProblems': 'false',
313 'conditions': [
314 [ 'msvs_multi_core_compile', {
315 'AdditionalOptions': ['/MP'],
316 }],
317 ['component=="shared_library"', {
318 'ExceptionHandling': '1', # /EHsc
319 }, {
320 'ExceptionHandling': '0',
321 }],
322 ],
323 },
324 'VCLibrarianTool': {
325 'AdditionalOptions': ['/ignore:4221'],
326 },
327 'VCLinkerTool': {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000328 'MinimumRequiredVersion': '5.01', # XP.
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000329 'AdditionalDependencies': [
330 'ws2_32.lib',
331 ],
332 'GenerateDebugInformation': 'true',
333 'MapFileName': '$(OutDir)\\$(TargetName).map',
334 'ImportLibrary': '$(OutDir)\\lib\\$(TargetName).lib',
335 'FixedBaseAddress': '1',
336 # LinkIncremental values:
337 # 0 == default
338 # 1 == /INCREMENTAL:NO
339 # 2 == /INCREMENTAL
340 'LinkIncremental': '1',
341 # SubSystem values:
342 # 0 == not set
343 # 1 == /SUBSYSTEM:CONSOLE
344 # 2 == /SUBSYSTEM:WINDOWS
345 'SubSystem': '1',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000346
347 'conditions': [
348 ['v8_enable_i18n_support==1', {
349 'AdditionalDependencies': [
350 'advapi32.lib',
351 ],
352 }],
353 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000354 },
355 },
356 },
357 }], # OS=="win"
358 ['OS=="mac"', {
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000359 'xcode_settings': {
360 'SYMROOT': '<(DEPTH)/xcodebuild',
361 },
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000362 'target_defaults': {
363 'xcode_settings': {
364 'ALWAYS_SEARCH_USER_PATHS': 'NO',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000365 'GCC_C_LANGUAGE_STANDARD': 'c99', # -std=c99
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000366 'GCC_CW_ASM_SYNTAX': 'NO', # No -fasm-blocks
367 'GCC_DYNAMIC_NO_PIC': 'NO', # No -mdynamic-no-pic
368 # (Equivalent to -fPIC)
369 'GCC_ENABLE_CPP_EXCEPTIONS': 'NO', # -fno-exceptions
370 'GCC_ENABLE_CPP_RTTI': 'NO', # -fno-rtti
371 'GCC_ENABLE_PASCAL_STRINGS': 'NO', # No -mpascal-strings
372 # GCC_INLINES_ARE_PRIVATE_EXTERN maps to -fvisibility-inlines-hidden
373 'GCC_INLINES_ARE_PRIVATE_EXTERN': 'YES',
374 'GCC_SYMBOLS_PRIVATE_EXTERN': 'YES', # -fvisibility=hidden
375 'GCC_THREADSAFE_STATICS': 'NO', # -fno-threadsafe-statics
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000376 'GCC_WARN_NON_VIRTUAL_DESTRUCTOR': 'YES', # -Wnon-virtual-dtor
377 # MACOSX_DEPLOYMENT_TARGET maps to -mmacosx-version-min
378 'MACOSX_DEPLOYMENT_TARGET': '<(mac_deployment_target)',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000379 'PREBINDING': 'NO', # No -Wl,-prebind
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000380 'SYMROOT': '<(DEPTH)/xcodebuild',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000381 'USE_HEADERMAP': 'NO',
382 'OTHER_CFLAGS': [
383 '-fno-strict-aliasing',
384 ],
385 'WARNING_CFLAGS': [
386 '-Wall',
387 '-Wendif-labels',
388 '-W',
389 '-Wno-unused-parameter',
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000390 # Don't warn about the "struct foo f = {0};" initialization pattern.
391 '-Wno-missing-field-initializers',
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000392 ],
393 },
Ben Murdochb8a8cc12014-11-26 15:28:44 +0000394 'conditions': [
395 ['werror==""', {
396 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'NO'},
397 }, {
398 'xcode_settings': {'GCC_TREAT_WARNINGS_AS_ERRORS': 'YES'},
399 }],
400 ['clang==1', {
401 'xcode_settings': {
402 'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
403 'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x', # -std=gnu++0x
404 },
405 }],
406 ],
Ben Murdoch69a99ed2011-11-30 16:03:39 +0000407 'target_conditions': [
408 ['_type!="static_library"', {
409 'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
410 }],
411 ], # target_conditions
412 }, # target_defaults
413 }], # OS=="mac"
414 ],
415}