1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
8 # This code gets run a lot and debugged rarely, so it should be fast
9 # by default. See http://crbug.com/388949.
10 'debug_optimize': '2',
11 'win_debug_Optimization': '0',
12 # Run time checks are incompatible with any level of optimizations.
13 'win_debug_RuntimeChecks': '0',
17 'tcmalloc_dir': '../../third_party/tcmalloc/chromium',
18 'use_vtable_verify%': 0,
21 # Only executables and not libraries should depend on the
22 # allocator target; only the application (the final executable)
23 # knows what allocator makes sense.
25 'target_name': 'allocator',
26 'type': 'static_library',
27 'direct_dependent_settings': {
32 'IgnoreDefaultLibraryNames': ['libcmtd.lib', 'libcmt.lib'],
33 'AdditionalDependencies': [
34 '<(SHARED_INTERMEDIATE_DIR)/allocator/libcmt.lib'
43 'PERFTOOLS_DLL_DECL=',
49 '../third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
52 # TODO(sgk): merge this with build/common.gypi settings
54 'AdditionalOptions': ['/ignore:4006,4221'],
57 'AdditionalOptions': ['/ignore:4006'],
64 'RuntimeLibrary': '0',
68 # Provide a way to force disable debugallocation in Debug builds,
69 # e.g. for profiling (it's more rare to profile Debug builds,
70 # but people sometimes need to do that).
71 'disable_debugallocation%': 0,
74 ['disable_debugallocation==0', {
76 # Use debugallocation for Debug builds to catch problems early
77 # and cleanly, http://crbug.com/30715 .
78 'TCMALLOC_FOR_DEBUGALLOCATION',
85 ['use_allocator=="tcmalloc"', {
86 # Disable the heap checker in tcmalloc.
92 '<(tcmalloc_dir)/src/base',
93 '<(tcmalloc_dir)/src',
97 # Generated for our configuration from tcmalloc's build
99 '<(tcmalloc_dir)/src/config.h',
100 '<(tcmalloc_dir)/src/config_android.h',
101 '<(tcmalloc_dir)/src/config_linux.h',
102 '<(tcmalloc_dir)/src/config_win.h',
104 # all tcmalloc native and forked files
105 '<(tcmalloc_dir)/src/addressmap-inl.h',
106 '<(tcmalloc_dir)/src/base/abort.cc',
107 '<(tcmalloc_dir)/src/base/abort.h',
108 '<(tcmalloc_dir)/src/base/arm_instruction_set_select.h',
109 '<(tcmalloc_dir)/src/base/atomicops-internals-arm-generic.h',
110 '<(tcmalloc_dir)/src/base/atomicops-internals-arm-v6plus.h',
111 '<(tcmalloc_dir)/src/base/atomicops-internals-linuxppc.h',
112 '<(tcmalloc_dir)/src/base/atomicops-internals-macosx.h',
113 '<(tcmalloc_dir)/src/base/atomicops-internals-windows.h',
114 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.cc',
115 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.h',
116 '<(tcmalloc_dir)/src/base/atomicops.h',
117 '<(tcmalloc_dir)/src/base/basictypes.h',
118 '<(tcmalloc_dir)/src/base/commandlineflags.h',
119 '<(tcmalloc_dir)/src/base/cycleclock.h',
120 # We don't list dynamic_annotations.c since its copy is already
121 # present in the dynamic_annotations target.
122 '<(tcmalloc_dir)/src/base/dynamic_annotations.h',
123 '<(tcmalloc_dir)/src/base/elf_mem_image.cc',
124 '<(tcmalloc_dir)/src/base/elf_mem_image.h',
125 '<(tcmalloc_dir)/src/base/elfcore.h',
126 '<(tcmalloc_dir)/src/base/googleinit.h',
127 '<(tcmalloc_dir)/src/base/linux_syscall_support.h',
128 '<(tcmalloc_dir)/src/base/linuxthreads.cc',
129 '<(tcmalloc_dir)/src/base/linuxthreads.h',
130 '<(tcmalloc_dir)/src/base/logging.cc',
131 '<(tcmalloc_dir)/src/base/logging.h',
132 '<(tcmalloc_dir)/src/base/low_level_alloc.cc',
133 '<(tcmalloc_dir)/src/base/low_level_alloc.h',
134 '<(tcmalloc_dir)/src/base/simple_mutex.h',
135 '<(tcmalloc_dir)/src/base/spinlock.cc',
136 '<(tcmalloc_dir)/src/base/spinlock.h',
137 '<(tcmalloc_dir)/src/base/spinlock_internal.cc',
138 '<(tcmalloc_dir)/src/base/spinlock_internal.h',
139 '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h',
140 '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h',
141 '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h',
142 '<(tcmalloc_dir)/src/base/stl_allocator.h',
143 '<(tcmalloc_dir)/src/base/synchronization_profiling.h',
144 '<(tcmalloc_dir)/src/base/sysinfo.cc',
145 '<(tcmalloc_dir)/src/base/sysinfo.h',
146 '<(tcmalloc_dir)/src/base/thread_annotations.h',
147 '<(tcmalloc_dir)/src/base/thread_lister.c',
148 '<(tcmalloc_dir)/src/base/thread_lister.h',
149 '<(tcmalloc_dir)/src/base/vdso_support.cc',
150 '<(tcmalloc_dir)/src/base/vdso_support.h',
151 '<(tcmalloc_dir)/src/central_freelist.cc',
152 '<(tcmalloc_dir)/src/central_freelist.h',
153 '<(tcmalloc_dir)/src/common.cc',
154 '<(tcmalloc_dir)/src/common.h',
155 '<(tcmalloc_dir)/src/debugallocation.cc',
156 '<(tcmalloc_dir)/src/free_list.cc',
157 '<(tcmalloc_dir)/src/free_list.h',
158 '<(tcmalloc_dir)/src/getpc.h',
159 '<(tcmalloc_dir)/src/gperftools/heap-checker.h',
160 '<(tcmalloc_dir)/src/gperftools/heap-profiler.h',
161 '<(tcmalloc_dir)/src/gperftools/malloc_extension.h',
162 '<(tcmalloc_dir)/src/gperftools/malloc_extension_c.h',
163 '<(tcmalloc_dir)/src/gperftools/malloc_hook.h',
164 '<(tcmalloc_dir)/src/gperftools/malloc_hook_c.h',
165 '<(tcmalloc_dir)/src/gperftools/profiler.h',
166 '<(tcmalloc_dir)/src/gperftools/stacktrace.h',
167 '<(tcmalloc_dir)/src/gperftools/tcmalloc.h',
168 '<(tcmalloc_dir)/src/heap-checker-bcad.cc',
169 '<(tcmalloc_dir)/src/heap-checker.cc',
170 '<(tcmalloc_dir)/src/heap-profile-table.cc',
171 '<(tcmalloc_dir)/src/heap-profile-table.h',
172 '<(tcmalloc_dir)/src/heap-profiler.cc',
173 '<(tcmalloc_dir)/src/internal_logging.cc',
174 '<(tcmalloc_dir)/src/internal_logging.h',
175 '<(tcmalloc_dir)/src/libc_override.h',
176 '<(tcmalloc_dir)/src/libc_override_gcc_and_weak.h',
177 '<(tcmalloc_dir)/src/libc_override_glibc.h',
178 '<(tcmalloc_dir)/src/libc_override_osx.h',
179 '<(tcmalloc_dir)/src/libc_override_redefine.h',
180 '<(tcmalloc_dir)/src/linked_list.h',
181 '<(tcmalloc_dir)/src/malloc_extension.cc',
182 '<(tcmalloc_dir)/src/malloc_hook-inl.h',
183 '<(tcmalloc_dir)/src/malloc_hook.cc',
184 '<(tcmalloc_dir)/src/malloc_hook_mmap_freebsd.h',
185 '<(tcmalloc_dir)/src/malloc_hook_mmap_linux.h',
186 '<(tcmalloc_dir)/src/maybe_threads.cc',
187 '<(tcmalloc_dir)/src/maybe_threads.h',
188 '<(tcmalloc_dir)/src/memfs_malloc.cc',
189 '<(tcmalloc_dir)/src/memory_region_map.cc',
190 '<(tcmalloc_dir)/src/memory_region_map.h',
191 '<(tcmalloc_dir)/src/packed-cache-inl.h',
192 '<(tcmalloc_dir)/src/page_heap.cc',
193 '<(tcmalloc_dir)/src/page_heap.h',
194 '<(tcmalloc_dir)/src/page_heap_allocator.h',
195 '<(tcmalloc_dir)/src/pagemap.h',
196 '<(tcmalloc_dir)/src/profile-handler.cc',
197 '<(tcmalloc_dir)/src/profile-handler.h',
198 '<(tcmalloc_dir)/src/profiledata.cc',
199 '<(tcmalloc_dir)/src/profiledata.h',
200 '<(tcmalloc_dir)/src/profiler.cc',
201 '<(tcmalloc_dir)/src/raw_printer.cc',
202 '<(tcmalloc_dir)/src/raw_printer.h',
203 '<(tcmalloc_dir)/src/sampler.cc',
204 '<(tcmalloc_dir)/src/sampler.h',
205 '<(tcmalloc_dir)/src/span.cc',
206 '<(tcmalloc_dir)/src/span.h',
207 '<(tcmalloc_dir)/src/stack_trace_table.cc',
208 '<(tcmalloc_dir)/src/stack_trace_table.h',
209 '<(tcmalloc_dir)/src/stacktrace.cc',
210 '<(tcmalloc_dir)/src/stacktrace_arm-inl.h',
211 '<(tcmalloc_dir)/src/stacktrace_config.h',
212 '<(tcmalloc_dir)/src/stacktrace_generic-inl.h',
213 '<(tcmalloc_dir)/src/stacktrace_libunwind-inl.h',
214 '<(tcmalloc_dir)/src/stacktrace_powerpc-inl.h',
215 '<(tcmalloc_dir)/src/stacktrace_win32-inl.h',
216 '<(tcmalloc_dir)/src/stacktrace_with_context.cc',
217 '<(tcmalloc_dir)/src/stacktrace_x86-inl.h',
218 '<(tcmalloc_dir)/src/static_vars.cc',
219 '<(tcmalloc_dir)/src/static_vars.h',
220 '<(tcmalloc_dir)/src/symbolize.cc',
221 '<(tcmalloc_dir)/src/symbolize.h',
222 '<(tcmalloc_dir)/src/system-alloc.cc',
223 '<(tcmalloc_dir)/src/system-alloc.h',
224 '<(tcmalloc_dir)/src/tcmalloc.cc',
225 '<(tcmalloc_dir)/src/tcmalloc_guard.h',
226 '<(tcmalloc_dir)/src/thread_cache.cc',
227 '<(tcmalloc_dir)/src/thread_cache.h',
229 'debugallocation_shim.cc',
231 # sources! means that these are not compiled directly.
233 # We simply don't use these, but list them above so that IDE
234 # users can view the full available source for reference, etc.
235 '<(tcmalloc_dir)/src/addressmap-inl.h',
236 '<(tcmalloc_dir)/src/base/atomicops-internals-linuxppc.h',
237 '<(tcmalloc_dir)/src/base/atomicops-internals-macosx.h',
238 '<(tcmalloc_dir)/src/base/atomicops-internals-x86-msvc.h',
239 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.h',
240 '<(tcmalloc_dir)/src/base/atomicops.h',
241 '<(tcmalloc_dir)/src/base/basictypes.h',
242 '<(tcmalloc_dir)/src/base/commandlineflags.h',
243 '<(tcmalloc_dir)/src/base/cycleclock.h',
244 '<(tcmalloc_dir)/src/base/elf_mem_image.h',
245 '<(tcmalloc_dir)/src/base/elfcore.h',
246 '<(tcmalloc_dir)/src/base/googleinit.h',
247 '<(tcmalloc_dir)/src/base/linux_syscall_support.h',
248 '<(tcmalloc_dir)/src/base/simple_mutex.h',
249 '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h',
250 '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h',
251 '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h',
252 '<(tcmalloc_dir)/src/base/stl_allocator.h',
253 '<(tcmalloc_dir)/src/base/thread_annotations.h',
254 '<(tcmalloc_dir)/src/getpc.h',
255 '<(tcmalloc_dir)/src/gperftools/heap-checker.h',
256 '<(tcmalloc_dir)/src/gperftools/heap-profiler.h',
257 '<(tcmalloc_dir)/src/gperftools/malloc_extension.h',
258 '<(tcmalloc_dir)/src/gperftools/malloc_extension_c.h',
259 '<(tcmalloc_dir)/src/gperftools/malloc_hook.h',
260 '<(tcmalloc_dir)/src/gperftools/malloc_hook_c.h',
261 '<(tcmalloc_dir)/src/gperftools/profiler.h',
262 '<(tcmalloc_dir)/src/gperftools/stacktrace.h',
263 '<(tcmalloc_dir)/src/gperftools/tcmalloc.h',
264 '<(tcmalloc_dir)/src/heap-checker-bcad.cc',
265 '<(tcmalloc_dir)/src/heap-checker.cc',
266 '<(tcmalloc_dir)/src/libc_override.h',
267 '<(tcmalloc_dir)/src/libc_override_gcc_and_weak.h',
268 '<(tcmalloc_dir)/src/libc_override_glibc.h',
269 '<(tcmalloc_dir)/src/libc_override_osx.h',
270 '<(tcmalloc_dir)/src/libc_override_redefine.h',
271 '<(tcmalloc_dir)/src/malloc_hook_mmap_freebsd.h',
272 '<(tcmalloc_dir)/src/malloc_hook_mmap_linux.h',
273 '<(tcmalloc_dir)/src/memfs_malloc.cc',
274 '<(tcmalloc_dir)/src/packed-cache-inl.h',
275 '<(tcmalloc_dir)/src/page_heap_allocator.h',
276 '<(tcmalloc_dir)/src/pagemap.h',
277 '<(tcmalloc_dir)/src/stacktrace_arm-inl.h',
278 '<(tcmalloc_dir)/src/stacktrace_config.h',
279 '<(tcmalloc_dir)/src/stacktrace_generic-inl.h',
280 '<(tcmalloc_dir)/src/stacktrace_libunwind-inl.h',
281 '<(tcmalloc_dir)/src/stacktrace_powerpc-inl.h',
282 '<(tcmalloc_dir)/src/stacktrace_win32-inl.h',
283 '<(tcmalloc_dir)/src/stacktrace_with_context.cc',
284 '<(tcmalloc_dir)/src/stacktrace_x86-inl.h',
285 '<(tcmalloc_dir)/src/tcmalloc_guard.h',
287 # Included by debugallocation_shim.cc.
288 '<(tcmalloc_dir)/src/debugallocation.cc',
289 '<(tcmalloc_dir)/src/tcmalloc.cc',
297 ['OS=="win" and component!="shared_library"', {
302 'allocator_shim_win.cc',
308 '<(tcmalloc_dir)/src/base/thread_lister.c',
309 '<(tcmalloc_dir)/src/base/thread_lister.h',
310 '<(tcmalloc_dir)/src/profile-handler.cc',
311 '<(tcmalloc_dir)/src/profile-handler.h',
312 '<(tcmalloc_dir)/src/profiledata.cc',
313 '<(tcmalloc_dir)/src/profiledata.h',
314 '<(tcmalloc_dir)/src/profiler.cc',
317 ['OS=="linux" or OS=="freebsd" or OS=="solaris" or OS=="android"', {
319 '<(tcmalloc_dir)/src/system-alloc.h',
321 # We enable all warnings by default, but upstream disables a few.
322 # Keep "-Wno-*" flags in sync with upstream by comparing against:
323 # http://code.google.com/p/google-perftools/source/browse/trunk/Makefile.am
326 '-Wno-unused-result',
329 '-fvisibility=hidden',
333 # Don't let linker rip this symbol out, otherwise the heap&cpu
334 # profilers will not initialize properly on startup.
335 '-Wl,-uIsHeapProfilerRunning,-uProfilerStart',
336 # Do the same for heap leak checker.
337 '-Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi',
338 '-Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl',
339 '-Wl,-u_ZN15HeapLeakChecker12IgnoreObjectEPKv,-u_ZN15HeapLeakChecker14UnIgnoreObjectEPKv',
342 [ 'use_vtable_verify==1', {
344 '-fvtable-verify=preinit',
347 ['order_profiling != 0', {
348 'target_conditions' : [
349 ['_toolset=="target"', {
350 'cflags!': [ '-finstrument-functions' ],
357 # This library is linked in to src/base.gypi:base and allocator_unittests
358 # It can't depend on either and nothing else should depend on it - all
359 # other code should use the interfaced provided by base.
360 'target_name': 'allocator_extension_thunks',
361 'type': 'static_library',
363 'allocator_extension_thunks.cc',
364 'allocator_extension_thunks.h',
366 'toolsets': ['host', 'target'],
373 ['OS=="win" and component!="shared_library"', {
376 'target_name': 'libcmt',
380 'action_name': 'libcmt',
385 '<(SHARED_INTERMEDIATE_DIR)/allocator/libcmt.lib',
390 '$(VCInstallDir)lib',
391 '<(SHARED_INTERMEDIATE_DIR)/allocator',
398 'target_name': 'allocator_unittests',
399 'type': 'executable',
402 'allocator_extension_thunks',
403 '../../testing/gtest.gyp:gtest',
410 '../profiler/alternate_timer.cc',
411 '../profiler/alternate_timer.h',
412 'allocator_unittest.cc',
417 ['OS=="win" and target_arch=="ia32"', {
420 'target_name': 'allocator_extension_thunks_win64',
421 'type': 'static_library',
423 'allocator_extension_thunks.cc',
424 'allocator_extension_thunks.h',
426 'toolsets': ['host', 'target'],
432 'msvs_target_platform': 'x64',
438 ['use_allocator=="tcmalloc"', {
441 'target_name': 'tcmalloc_unittest',
442 'type': 'executable',
444 'tcmalloc_unittest.cc',
447 '<(tcmalloc_dir)/src',
451 '../../testing/gtest.gyp:gtest',