build: disable -Og when building with clang
[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 -Og 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     '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       ['OS=="mac"', {
42         'clang%': 1,
43       }, {
44         'clang%': 0,
45       }],
46     ],
47   },
48
49   'target_defaults': {
50     'default_configuration': 'Release',
51     'configurations': {
52       'Debug': {
53         'variables': {
54           'v8_enable_handle_zapping%': 1,
55         },
56         'defines': [ 'DEBUG', '_DEBUG' ],
57         'cflags': [ '-g' ],
58         'conditions': [
59           ['clang==1', {
60             'cflags': [ '-O0' ],  # https://llvm.org/bugs/show_bug.cgi?id=20765
61           }, {
62             'cflags': [ '-Og' ],  # Debug-friendly optimizations only.
63           }],
64           ['target_arch=="x64"', {
65             'msvs_configuration_platform': 'x64',
66           }],
67         ],
68         'msvs_settings': {
69           'VCCLCompilerTool': {
70             'RuntimeLibrary': 1, # static debug
71             'Optimization': 0, # /Od, no optimization
72             'MinimalRebuild': 'false',
73             'OmitFramePointers': 'false',
74             'BasicRuntimeChecks': 3, # /RTC1
75           },
76           'VCLinkerTool': {
77             'LinkIncremental': 2, # enable incremental linking
78           },
79         },
80         'xcode_settings': {
81           'GCC_OPTIMIZATION_LEVEL': '0', # stop gyp from defaulting to -Os
82         },
83       },
84       'Release': {
85         'variables': {
86           'v8_enable_handle_zapping%': 0,
87         },
88         'cflags': [ '-O3', '-ffunction-sections', '-fdata-sections' ],
89         'conditions': [
90           ['target_arch=="x64"', {
91             'msvs_configuration_platform': 'x64',
92           }],
93           ['OS=="solaris"', {
94             # pull in V8's postmortem metadata
95             'ldflags': [ '-Wl,-z,allextract' ]
96           }],
97           ['OS!="mac" and OS!="win"', {
98             'cflags': [ '-fno-omit-frame-pointer' ],
99           }],
100         ],
101         'msvs_settings': {
102           'VCCLCompilerTool': {
103             'RuntimeLibrary': 0, # static release
104             'Optimization': 3, # /Ox, full optimization
105             'FavorSizeOrSpeed': 1, # /Ot, favour speed over size
106             'InlineFunctionExpansion': 2, # /Ob2, inline anything eligible
107             'WholeProgramOptimization': 'true', # /GL, whole program optimization, needed for LTCG
108             'OmitFramePointers': 'true',
109             'EnableFunctionLevelLinking': 'true',
110             'EnableIntrinsicFunctions': 'true',
111             'RuntimeTypeInfo': 'false',
112             'AdditionalOptions': [
113               '/MP', # compile across multiple CPUs
114             ],
115           },
116           'VCLibrarianTool': {
117             'AdditionalOptions': [
118               '/LTCG', # link time code generation
119             ],
120           },
121           'VCLinkerTool': {
122             'LinkTimeCodeGeneration': 1, # link-time code generation
123             'OptimizeReferences': 2, # /OPT:REF
124             'EnableCOMDATFolding': 2, # /OPT:ICF
125             'LinkIncremental': 1, # disable incremental linking
126           },
127         },
128       }
129     },
130     # Forcibly disable -Werror.  We support a wide range of compilers, it's
131     # simply not feasible to squelch all warnings, never mind that the
132     # libraries in deps/ are not under our control.
133     'cflags!': ['-Werror'],
134     'msvs_settings': {
135       'VCCLCompilerTool': {
136         'StringPooling': 'true', # pool string literals
137         'DebugInformationFormat': 3, # Generate a PDB
138         'WarningLevel': 3,
139         'BufferSecurityCheck': 'true',
140         'ExceptionHandling': 0, # /EHsc
141         'SuppressStartupBanner': 'true',
142         'WarnAsError': 'false',
143       },
144       'VCLibrarianTool': {
145       },
146       'VCLinkerTool': {
147         'conditions': [
148           ['target_arch=="ia32"', {
149             'TargetMachine' : 1, # /MACHINE:X86
150             'target_conditions': [
151               ['_type=="executable"', {
152                 'AdditionalOptions': [ '/SubSystem:Console,"5.01"' ],
153               }],
154             ],
155           }],
156           ['target_arch=="x64"', {
157             'TargetMachine' : 17, # /MACHINE:AMD64
158             'target_conditions': [
159               ['_type=="executable"', {
160                 'AdditionalOptions': [ '/SubSystem:Console,"5.02"' ],
161               }],
162             ],
163           }],
164         ],
165         'GenerateDebugInformation': 'true',
166         'RandomizedBaseAddress': 2, # enable ASLR
167         'DataExecutionPrevention': 2, # enable DEP
168         'AllowIsolation': 'true',
169         'SuppressStartupBanner': 'true',
170       },
171     },
172     'msvs_disabled_warnings': [4351, 4355, 4800],
173     'conditions': [
174       ['asan != 0', {
175         'cflags+': [
176           '-fno-omit-frame-pointer',
177           '-fsanitize=address',
178           '-w',  # http://crbug.com/162783
179         ],
180         'cflags_cc+': [ '-gline-tables-only' ],
181         'cflags!': [ '-fomit-frame-pointer' ],
182         'ldflags': [ '-fsanitize=address' ],
183       }],
184       ['OS == "win"', {
185         'msvs_cygwin_shell': 0, # prevent actions from trying to use cygwin
186         'defines': [
187           'WIN32',
188           # we don't really want VC++ warning us about
189           # how dangerous C functions are...
190           '_CRT_SECURE_NO_DEPRECATE',
191           # ... or that C implementations shouldn't use
192           # POSIX names
193           '_CRT_NONSTDC_NO_DEPRECATE',
194           # Make sure the STL doesn't try to use exceptions
195           '_HAS_EXCEPTIONS=0',
196           'BUILDING_V8_SHARED=1',
197           'BUILDING_UV_SHARED=1',
198         ],
199       }],
200       [ 'OS in "linux freebsd openbsd solaris"', {
201         'cflags': [ '-pthread', ],
202         'ldflags': [ '-pthread' ],
203       }],
204       [ 'OS in "linux freebsd openbsd solaris android"', {
205         'cflags': [ '-Wall', '-Wextra', '-Wno-unused-parameter', ],
206         'cflags_cc': [ '-fno-rtti', '-fno-exceptions', '-std=gnu++0x' ],
207         'ldflags': [ '-rdynamic' ],
208         'target_conditions': [
209           ['_type=="static_library"', {
210             'standalone_static_library': 1, # disable thin archive which needs binutils >= 2.19
211           }],
212         ],
213         'conditions': [
214           [ 'target_arch=="ia32"', {
215             'cflags': [ '-m32' ],
216             'ldflags': [ '-m32' ],
217           }],
218           [ 'target_arch=="x32"', {
219             'cflags': [ '-mx32' ],
220             'ldflags': [ '-mx32' ],
221           }],
222           [ 'target_arch=="x64"', {
223             'cflags': [ '-m64' ],
224             'ldflags': [ '-m64' ],
225           }],
226           [ 'OS=="solaris"', {
227             'cflags': [ '-pthreads' ],
228             'ldflags': [ '-pthreads' ],
229             'cflags!': [ '-pthread' ],
230             'ldflags!': [ '-pthread' ],
231           }],
232         ],
233       }],
234       [ 'OS=="android"', {
235         'defines': ['_GLIBCXX_USE_C99_MATH'],
236         'libraries': [ '-llog' ],
237       }],
238       ['OS=="mac"', {
239         'defines': ['_DARWIN_USE_64_BIT_INODE=1'],
240         'xcode_settings': {
241           'ALWAYS_SEARCH_USER_PATHS': 'NO',
242           'GCC_CW_ASM_SYNTAX': 'NO',                # No -fasm-blocks
243           'GCC_DYNAMIC_NO_PIC': 'NO',               # No -mdynamic-no-pic
244                                                     # (Equivalent to -fPIC)
245           'GCC_ENABLE_CPP_EXCEPTIONS': 'NO',        # -fno-exceptions
246           'GCC_ENABLE_CPP_RTTI': 'NO',              # -fno-rtti
247           'GCC_ENABLE_PASCAL_STRINGS': 'NO',        # No -mpascal-strings
248           'GCC_THREADSAFE_STATICS': 'NO',           # -fno-threadsafe-statics
249           'PREBINDING': 'NO',                       # No -Wl,-prebind
250           'MACOSX_DEPLOYMENT_TARGET': '10.5',       # -mmacosx-version-min=10.5
251           'USE_HEADERMAP': 'NO',
252           'OTHER_CFLAGS': [
253             '-fno-strict-aliasing',
254           ],
255           'WARNING_CFLAGS': [
256             '-Wall',
257             '-Wendif-labels',
258             '-W',
259             '-Wno-unused-parameter',
260           ],
261         },
262         'target_conditions': [
263           ['_type!="static_library"', {
264             'xcode_settings': {'OTHER_LDFLAGS': ['-Wl,-search_paths_first']},
265           }],
266         ],
267         'conditions': [
268           ['target_arch=="ia32"', {
269             'xcode_settings': {'ARCHS': ['i386']},
270           }],
271           ['target_arch=="x64"', {
272             'xcode_settings': {'ARCHS': ['x86_64']},
273           }],
274           ['clang==1', {
275             'xcode_settings': {
276               'GCC_VERSION': 'com.apple.compilers.llvm.clang.1_0',
277               'CLANG_CXX_LANGUAGE_STANDARD': 'gnu++0x',  # -std=gnu++0x
278             },
279           }],
280         ],
281       }],
282       ['OS=="freebsd" and node_use_dtrace=="true"', {
283         'libraries': [ '-lelf' ],
284       }],
285       ['OS=="freebsd"', {
286         'ldflags': [
287           '-Wl,--export-dynamic',
288         ],
289       }]
290     ],
291   }
292 }