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