win: disable exception handling for all builds
[platform/upstream/nodejs.git] / common.gypi
1 {
2   'variables': {
3     'asan%': 0,
4     'werror': '',                     # Turn off -Werror in V8 build.
5     'visibility%': 'hidden',          # V8's visibility setting
6     'target_arch%': 'ia32',           # set v8's target architecture
7     'host_arch%': 'ia32',             # set v8's host architecture
8     'want_separate_host_toolset%': 0, # V8 should not build target and host
9     'library%': 'static_library',     # allow override to 'shared_library' for DLL/.so builds
10     'component%': 'static_library',   # NB. these names match with what V8 expects
11     'msvs_multi_core_compile': '0',   # we do enable multicore compiles, but not using the V8 way
12     'python%': 'python',
13
14     'node_tag%': '',
15     'uv_library%': 'static_library',
16
17     # Default to -O0 for debug builds.
18     'v8_optimized_debug%': 0,
19
20     # Enable disassembler for `--print-code` v8 options
21     'v8_enable_disassembler': 1,
22
23     # Don't bake anything extra into the snapshot.
24     'v8_use_external_startup_data%': 0,
25
26     # Disable V8's post-mortem debugging; frequently broken and hardly used.
27     'v8_postmortem_support%': 'false',
28
29     'conditions': [
30       ['OS == "win"', {
31         'os_posix': 0,
32       }, {
33         'os_posix': 1,
34       }],
35       ['GENERATOR == "ninja" or OS== "mac"', {
36         'OBJ_DIR': '<(PRODUCT_DIR)/obj',
37         'V8_BASE': '<(PRODUCT_DIR)/libv8_base.a',
38       }, {
39         'OBJ_DIR': '<(PRODUCT_DIR)/obj.target',
40         'V8_BASE': '<(PRODUCT_DIR)/obj.target/deps/v8/tools/gyp/libv8_base.a',
41       }],
42       ['OS=="mac"', {
43         'clang%': 1,
44       }, {
45         'clang%': 0,
46       }],
47     ],
48   },
49
50   'target_defaults': {
51     'default_configuration': 'Release',
52     'configurations': {
53       'Debug': {
54         'variables': {
55           'v8_enable_handle_zapping%': 1,
56         },
57         'defines': [ 'DEBUG', '_DEBUG' ],
58         'cflags': [ '-g', '-O0' ],
59         'conditions': [
60           ['target_arch=="x64"', {
61             'msvs_configuration_platform': 'x64',
62           }],
63         ],
64         'msvs_settings': {
65           'VCCLCompilerTool': {
66             'RuntimeLibrary': 1, # static debug
67             'Optimization': 0, # /Od, no optimization
68             'MinimalRebuild': 'false',
69             'OmitFramePointers': 'false',
70             'BasicRuntimeChecks': 3, # /RTC1
71           },
72           'VCLinkerTool': {
73             'LinkIncremental': 2, # enable incremental linking
74           },
75         },
76         'xcode_settings': {
77           'GCC_OPTIMIZATION_LEVEL': '0', # stop gyp from defaulting to -Os
78         },
79       },
80       'Release': {
81         'variables': {
82           'v8_enable_handle_zapping%': 0,
83         },
84         'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
85         'conditions': [
86           ['target_arch=="x64"', {
87             'msvs_configuration_platform': 'x64',
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             'AdditionalOptions': [
109               '/MP', # compile across multiple CPUs
110             ],
111           },
112           'VCLibrarianTool': {
113             'AdditionalOptions': [
114               '/LTCG', # link time code generation
115             ],
116           },
117           'VCLinkerTool': {
118             'LinkTimeCodeGeneration': 1, # link-time code generation
119             'OptimizeReferences': 2, # /OPT:REF
120             'EnableCOMDATFolding': 2, # /OPT:ICF
121             'LinkIncremental': 1, # disable incremental linking
122           },
123         },
124       }
125     },
126     # Forcibly disable -Werror.  We support a wide range of compilers, it's
127     # simply not feasible to squelch all warnings, never mind that the
128     # libraries in deps/ are not under our control.
129     'cflags!': ['-Werror'],
130     'msvs_settings': {
131       'VCCLCompilerTool': {
132         'StringPooling': 'true', # pool string literals
133         'DebugInformationFormat': 3, # Generate a PDB
134         'WarningLevel': 3,
135         'BufferSecurityCheck': 'true',
136         'ExceptionHandling': 0, # /EHsc
137         'SuppressStartupBanner': 'true',
138         'WarnAsError': 'false',
139       },
140       'VCLibrarianTool': {
141       },
142       'VCLinkerTool': {
143         'conditions': [
144           ['target_arch=="x64"', {
145             'TargetMachine' : 17 # /MACHINE:X64
146           }],
147         ],
148         'GenerateDebugInformation': 'true',
149         'RandomizedBaseAddress': 2, # enable ASLR
150         'DataExecutionPrevention': 2, # enable DEP
151         'AllowIsolation': 'true',
152         'SuppressStartupBanner': 'true',
153         'target_conditions': [
154           ['_type=="executable"', {
155             'SubSystem': 1, # console executable
156           }],
157         ],
158       },
159     },
160     'msvs_disabled_warnings': [4351, 4355, 4800],
161     'conditions': [
162       ['asan != 0', {
163         'cflags+': [
164           '-fno-omit-frame-pointer',
165           '-fsanitize=address',
166           '-w',  # http://crbug.com/162783
167         ],
168         'cflags_cc+': [ '-gline-tables-only' ],
169         'cflags!': [ '-fomit-frame-pointer' ],
170         'ldflags': [ '-fsanitize=address' ],
171       }],
172       ['OS == "win"', {
173         'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
174         'defines': [
175           'WIN32',
176           # we don't really want VC++ warning us about
177           # how dangerous C functions are...
178           '_CRT_SECURE_NO_DEPRECATE',
179           # ... or that C implementations shouldn't use
180           # POSIX names
181           '_CRT_NONSTDC_NO_DEPRECATE',
182           'BUILDING_V8_SHARED=1',
183           'BUILDING_UV_SHARED=1',
184         ],
185       }],
186       [ 'OS in "linux freebsd openbsd solaris"', {
187         'cflags': [ '-pthread', ],
188         'ldflags': [ '-pthread' ],
189       }],
190       [ 'OS in "linux freebsd openbsd solaris android"', {
191         'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
192         'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++0x' ],
193         'ldflags': [ '-rdynamic' ],
194         'target_conditions': [
195           ['_type=="static_library"', {
196             'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19
197           }],
198         ],
199         'conditions': [
200           [ 'target_arch=="ia32"', {
201             'cflags': [ '-m32' ],
202             'ldflags': [ '-m32' ],
203           }],
204           [ 'target_arch=="x32"', {
205             'cflags': [ '-mx32' ],
206             'ldflags': [ '-mx32' ],
207           }],
208           [ 'target_arch=="x64"', {
209             'cflags': [ '-m64' ],
210             'ldflags': [ '-m64' ],
211           }],
212           [ 'OS=="solaris"', {
213             'cflags': [ '-pthreads' ],
214             'ldflags': [ '-pthreads' ],
215             'cflags!': [ '-pthread' ],
216             'ldflags!': [ '-pthread' ],
217           }],
218         ],
219       }],
220       [ 'OS=="android"', {
221         'defines': ['_GLIBCXX_USE_C99_MATH'],
222         'libraries': [ '-llog' ],
223       }],
224       ['OS=="mac"', {
225         'defines': ['_DARWIN_USE_64_BIT_INODE=1'],
226         'xcode_settings': {
227           'ALWAYS_SEARCH_USER_PATHS': 'NO',
228           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
229           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
230                                                     # (Equivalent to -fPIC)
231           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
232           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
233           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
234           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
235           'PREBINDING': 'NO',                       # No -Wl,-prebind
236           'MACOSX_DEPLOYMENT_TARGET': '10.5',       # -mmacosx-version-min=10.5
237           'USE_HEADERMAP': 'NO',
238           'OTHER_CFLAGS': [
239             '-fno-strict-aliasing',
240           ],
241           'WARNING_CFLAGS': [
242             '-Wall',
243             '-Wendif-labels',
244             '-W',
245             '-Wno-unused-parameter',
246           ],
247         },
248         'target_conditions': [
249           ['_type!="static_library"', {
250             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
251           }],
252         ],
253         'conditions': [
254           ['target_arch=="ia32"', {
255             'xcode_settings': {'ARCHS': ['i386']},
256           }],
257           ['target_arch=="x64"', {
258             'xcode_settings': {'ARCHS': ['x86_64']},
259           }],
260           ['clang==1', {
261             'xcode_settings': {
262               'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
263               'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x',  # -std=gnu++0x
264             },
265           }],
266         ],
267       }],
268       ['OS=="freebsd" and node_use_dtrace=="true"', {
269         'libraries': [ '-lelf' ],
270       }],
271       ['OS=="freebsd"', {
272         'ldflags': [
273           '-Wl,--export-dynamic',
274         ],
275       }]
276     ],
277   }
278 }