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