configure: allow V8 snapshot for cross-compilation
[platform/upstream/nodejs.git] / common.gypi
1 {
2   'variables': {
3     'werror': '',                     # Turn off -Werror in V8 build.
4     'visibility%': 'hidden',          # V8's visibility setting
5     'target_arch%': 'ia32',           # set v8's target architecture
6     'host_arch%': 'ia32',             # set v8's host architecture
7     'want_separate_host_toolset%': 0, # V8 should not build target and host
8     'library%': 'static_library',     # allow override to 'shared_library' for DLL/.so builds
9     'component%': 'static_library',   # NB. these names match with what V8 expects
10     'msvs_multi_core_compile': '0',   # we do enable multicore compiles, but not using the V8 way
11     'gcc_version%': 'unknown',
12     'clang%': 0,
13     'python%': 'python',
14
15     # Turn on optimizations that may trigger compiler bugs.
16     # Use at your own risk. Do *NOT* report bugs if this option is enabled.
17     'node_unsafe_optimizations%': 0,
18
19     # Enable V8's post-mortem debugging only on unix flavors.
20     'conditions': [
21       ['OS != "win"', {
22         'v8_postmortem_support': 'true'
23       }],
24       ['GENERATOR == "ninja"', {
25         'OBJ_DIR': '<(PRODUCT_DIR)/obj',
26         'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a',
27       }, {
28         'OBJ_DIR': '<(PRODUCT_DIR)/obj.target',
29         'V8_BASE': '<(PRODUCT_DIR)/obj.target/deps/v8/tools/gyp/libv8_base.a',
30       }],
31     ],
32   },
33
34   'target_defaults': {
35     'default_configuration': 'Release',
36     'configurations': {
37       'Debug': {
38         'defines': [ 'DEBUG', '_DEBUG' ],
39         'cflags': [ '-g', '-O0' ],
40         'conditions': [
41           ['target_arch=="x64"', {
42             'msvs_configuration_platform': 'x64',
43           }],
44         ],
45         'msvs_settings': {
46           'VCCLCompilerTool': {
47             'RuntimeLibrary': 1, # static debug
48             'Optimization': 0, # /Od, no optimization
49             'MinimalRebuild': 'false',
50             'OmitFramePointers': 'false',
51             'BasicRuntimeChecks': 3, # /RTC1
52           },
53           'VCLinkerTool': {
54             'LinkIncremental': 2, # enable incremental linking
55           },
56         },
57         'xcode_settings': {
58           'GCC_OPTIMIZATION_LEVEL': '0', # stop gyp from defaulting to -Os
59         },
60       },
61       'Release': {
62         'conditions': [
63           ['target_arch=="x64"', {
64             'msvs_configuration_platform': 'x64',
65           }],
66           ['node_unsafe_optimizations==1', {
67             'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
68             'ldflags': [ '-Wl,--gc-sections' ],
69           }, {
70             'cflags': [ '-O2', '-fno-strict-aliasing' ],
71             'cflags!': [ '-O3', '-fstrict-aliasing' ],
72             'conditions': [
73               # Required by the dtrace post-processor. Unfortunately,
74               # some gcc/binutils combos generate bad code when
75               # -ffunction-sections is enabled. Let's hope for the best.
76               ['OS=="solaris"', {
77                 'cflags': [ '-ffunction-sections', '-fdata-sections' ],
78               }, {
79                 'cflags!': [ '-ffunction-sections', '-fdata-sections' ],
80               }],
81               ['clang == 0 and gcc_version >= 40', {
82                 'cflags': [ '-fno-tree-vrp' ],
83               }],
84               ['clang == 0 and gcc_version <= 44', {
85                 'cflags': [ '-fno-tree-sink' ],
86               }],
87             ],
88           }],
89           ['OS=="solaris"', {
90             # pull in V8's postmortem metadata
91             'ldflags': [ '-Wl,-z,allextract' ]
92           }],
93           ['OS!="mac" and OS!="win"', {
94             'cflags': [ '-fno-omit-frame-pointer' ],
95           }],
96         ],
97         'msvs_settings': {
98           'VCCLCompilerTool': {
99             'RuntimeLibrary': 0, # static release
100             'Optimization': 3, # /Ox, full optimization
101             'FavorSizeOrSpeed': 1, # /Ot, favour speed over size
102             'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
103             'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG
104             'OmitFramePointers': 'true',
105             'EnableFunctionLevelLinking': 'true',
106             'EnableIntrinsicFunctions': 'true',
107             'RuntimeTypeInfo': 'false',
108             'ExceptionHandling': '0',
109             'AdditionalOptions': [
110               '/MP', # compile across multiple CPUs
111             ],
112           },
113           'VCLibrarianTool': {
114             'AdditionalOptions': [
115               '/LTCG', # link time code generation
116             ],
117           },
118           'VCLinkerTool': {
119             'LinkTimeCodeGeneration': 1, # link-time code generation
120             'OptimizeReferences': 2, # /OPT:REF
121             'EnableCOMDATFolding': 2, # /OPT:ICF
122             'LinkIncremental': 1, # disable incremental linking
123           },
124         },
125       }
126     },
127     'msvs_settings': {
128       'VCCLCompilerTool': {
129         'StringPooling': 'true', # pool string literals
130         'DebugInformationFormat': 3, # Generate a PDB
131         'WarningLevel': 3,
132         'BufferSecurityCheck': 'true',
133         'ExceptionHandling': 1, # /EHsc
134         'SuppressStartupBanner': 'true',
135         'WarnAsError': 'false',
136       },
137       'VCLibrarianTool': {
138       },
139       'VCLinkerTool': {
140         'conditions': [
141           ['target_arch=="x64"', {
142             'TargetMachine' : 17 # /MACHINE:X64
143           }],
144         ],
145         'GenerateDebugInformation': 'true',
146         'RandomizedBaseAddress': 2, # enable ASLR
147         'DataExecutionPrevention': 2, # enable DEP
148         'AllowIsolation': 'true',
149         'SuppressStartupBanner': 'true',
150         'target_conditions': [
151           ['_type=="executable"', {
152             'SubSystem': 1, # console executable
153           }],
154         ],
155       },
156     },
157     'conditions': [
158       ['OS == "win"', {
159         'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
160         'defines': [
161           'WIN32',
162           # we don't really want VC++ warning us about
163           # how dangerous C functions are...
164           '_CRT_SECURE_NO_DEPRECATE',
165           # ... or that C implementations shouldn't use
166           # POSIX names
167           '_CRT_NONSTDC_NO_DEPRECATE',
168           'BUILDING_V8_SHARED=1',
169           'BUILDING_UV_SHARED=1',
170         ],
171       }],
172       [ 'OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="solaris"', {
173         'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', '-pthread', ],
174         'cflags_cc': [ '-fno-rtti', '-fno-exceptions' ],
175         'ldflags': [ '-pthread', '-rdynamic' ],
176         'target_conditions': [
177           ['_type=="static_library"', {
178             'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19
179           }],
180         ],
181         'conditions': [
182           [ 'target_arch=="ia32"', {
183             'cflags': [ '-m32' ],
184             'ldflags': [ '-m32' ],
185           }],
186           [ 'target_arch=="x64"', {
187             'cflags': [ '-m64' ],
188             'ldflags': [ '-m64' ],
189           }],
190           [ 'OS=="solaris"', {
191             'cflags': [ '-pthreads' ],
192             'ldflags': [ '-pthreads' ],
193             'cflags!': [ '-pthread' ],
194             'ldflags!': [ '-pthread' ],
195           }],
196         ],
197       }],
198       ['OS=="mac"', {
199         'defines': ['_DARWIN_USE_64_BIT_INODE=1'],
200         'xcode_settings': {
201           'ALWAYS_SEARCH_USER_PATHS': 'NO',
202           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
203           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
204                                                     # (Equivalent to -fPIC)
205           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
206           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
207           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
208           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
209           'PREBINDING': 'NO',                       # No -Wl,-prebind
210           'MACOSX_DEPLOYMENT_TARGET': '10.5',       # -mmacosx-version-min=10.5
211           'USE_HEADERMAP': 'NO',
212           'OTHER_CFLAGS': [
213             '-fno-strict-aliasing',
214           ],
215           'WARNING_CFLAGS': [
216             '-Wall',
217             '-Wendif-labels',
218             '-W',
219             '-Wno-unused-parameter',
220           ],
221         },
222         'target_conditions': [
223           ['_type!="static_library"', {
224             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
225           }],
226         ],
227         'conditions': [
228           ['target_arch=="ia32"', {
229             'xcode_settings': {'ARCHS': ['i386']},
230           }],
231           ['target_arch=="x64"', {
232             'xcode_settings': {'ARCHS': ['x86_64']},
233           }],
234         ],
235       }],
236       ['OS=="freebsd" and node_use_dtrace=="true"', {
237         'libraries': [ '-lelf' ],
238       }]
239     ],
240   }
241 }