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.
7 'jemalloc_dir': '../../third_party/jemalloc/chromium',
8 'tcmalloc_dir': '../../third_party/tcmalloc/chromium',
9 'use_vtable_verify%': 0,
13 'target_name': 'allocator',
14 'type': 'static_library',
15 # Make sure the allocation library is optimized to
16 # the hilt in official builds.
22 '<(tcmalloc_dir)/src/base',
23 '<(tcmalloc_dir)/src',
26 'direct_dependent_settings': {
31 'IgnoreDefaultLibraryNames': ['libcmtd.lib', 'libcmt.lib'],
32 'AdditionalDependencies': [
33 '<(SHARED_INTERMEDIATE_DIR)/allocator/libcmt.lib'
42 'PERFTOOLS_DLL_DECL=',
48 # Generated for our configuration from tcmalloc's build
50 '<(tcmalloc_dir)/src/config.h',
51 '<(tcmalloc_dir)/src/config_linux.h',
52 '<(tcmalloc_dir)/src/config_win.h',
54 # all tcmalloc native and forked files
55 '<(tcmalloc_dir)/src/addressmap-inl.h',
56 '<(tcmalloc_dir)/src/base/abort.cc',
57 '<(tcmalloc_dir)/src/base/abort.h',
58 '<(tcmalloc_dir)/src/base/arm_instruction_set_select.h',
59 '<(tcmalloc_dir)/src/base/atomicops-internals-linuxppc.h',
60 '<(tcmalloc_dir)/src/base/atomicops-internals-arm-generic.h',
61 '<(tcmalloc_dir)/src/base/atomicops-internals-arm-v6plus.h',
62 '<(tcmalloc_dir)/src/base/atomicops-internals-macosx.h',
63 '<(tcmalloc_dir)/src/base/atomicops-internals-windows.h',
64 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.cc',
65 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.h',
66 '<(tcmalloc_dir)/src/base/atomicops.h',
67 '<(tcmalloc_dir)/src/base/basictypes.h',
68 '<(tcmalloc_dir)/src/base/commandlineflags.h',
69 '<(tcmalloc_dir)/src/base/cycleclock.h',
70 # We don't list dynamic_annotations.c since its copy is already
71 # present in the dynamic_annotations target.
72 '<(tcmalloc_dir)/src/base/dynamic_annotations.h',
73 '<(tcmalloc_dir)/src/base/elf_mem_image.cc',
74 '<(tcmalloc_dir)/src/base/elf_mem_image.h',
75 '<(tcmalloc_dir)/src/base/elfcore.h',
76 '<(tcmalloc_dir)/src/base/googleinit.h',
77 '<(tcmalloc_dir)/src/base/linux_syscall_support.h',
78 '<(tcmalloc_dir)/src/base/linuxthreads.cc',
79 '<(tcmalloc_dir)/src/base/linuxthreads.h',
80 '<(tcmalloc_dir)/src/base/logging.cc',
81 '<(tcmalloc_dir)/src/base/logging.h',
82 '<(tcmalloc_dir)/src/base/low_level_alloc.cc',
83 '<(tcmalloc_dir)/src/base/low_level_alloc.h',
84 '<(tcmalloc_dir)/src/base/simple_mutex.h',
85 '<(tcmalloc_dir)/src/base/spinlock.cc',
86 '<(tcmalloc_dir)/src/base/spinlock.h',
87 '<(tcmalloc_dir)/src/base/spinlock_internal.cc',
88 '<(tcmalloc_dir)/src/base/spinlock_internal.h',
89 '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h',
90 '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h',
91 '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h',
92 '<(tcmalloc_dir)/src/base/stl_allocator.h',
93 '<(tcmalloc_dir)/src/base/synchronization_profiling.h',
94 '<(tcmalloc_dir)/src/base/sysinfo.cc',
95 '<(tcmalloc_dir)/src/base/sysinfo.h',
96 '<(tcmalloc_dir)/src/base/thread_annotations.h',
97 '<(tcmalloc_dir)/src/base/thread_lister.c',
98 '<(tcmalloc_dir)/src/base/thread_lister.h',
99 '<(tcmalloc_dir)/src/base/vdso_support.cc',
100 '<(tcmalloc_dir)/src/base/vdso_support.h',
101 '<(tcmalloc_dir)/src/central_freelist.cc',
102 '<(tcmalloc_dir)/src/central_freelist.h',
103 '<(tcmalloc_dir)/src/common.cc',
104 '<(tcmalloc_dir)/src/common.h',
105 '<(tcmalloc_dir)/src/debugallocation.cc',
106 '<(tcmalloc_dir)/src/deep-heap-profile.cc',
107 '<(tcmalloc_dir)/src/deep-heap-profile.h',
108 '<(tcmalloc_dir)/src/free_list.cc',
109 '<(tcmalloc_dir)/src/free_list.h',
110 '<(tcmalloc_dir)/src/getpc.h',
111 '<(tcmalloc_dir)/src/gperftools/heap-checker.h',
112 '<(tcmalloc_dir)/src/gperftools/heap-profiler.h',
113 '<(tcmalloc_dir)/src/gperftools/malloc_extension.h',
114 '<(tcmalloc_dir)/src/gperftools/malloc_extension_c.h',
115 '<(tcmalloc_dir)/src/gperftools/malloc_hook.h',
116 '<(tcmalloc_dir)/src/gperftools/malloc_hook_c.h',
117 '<(tcmalloc_dir)/src/gperftools/profiler.h',
118 '<(tcmalloc_dir)/src/gperftools/stacktrace.h',
119 '<(tcmalloc_dir)/src/gperftools/tcmalloc.h',
120 '<(tcmalloc_dir)/src/heap-checker-bcad.cc',
121 '<(tcmalloc_dir)/src/heap-checker.cc',
122 '<(tcmalloc_dir)/src/heap-profile-table.cc',
123 '<(tcmalloc_dir)/src/heap-profile-table.h',
124 '<(tcmalloc_dir)/src/heap-profiler.cc',
125 '<(tcmalloc_dir)/src/internal_logging.cc',
126 '<(tcmalloc_dir)/src/internal_logging.h',
127 '<(tcmalloc_dir)/src/libc_override.h',
128 '<(tcmalloc_dir)/src/libc_override_gcc_and_weak.h',
129 '<(tcmalloc_dir)/src/libc_override_glibc.h',
130 '<(tcmalloc_dir)/src/libc_override_osx.h',
131 '<(tcmalloc_dir)/src/libc_override_redefine.h',
132 '<(tcmalloc_dir)/src/linked_list.h',
133 '<(tcmalloc_dir)/src/malloc_extension.cc',
134 '<(tcmalloc_dir)/src/malloc_hook-inl.h',
135 '<(tcmalloc_dir)/src/malloc_hook.cc',
136 '<(tcmalloc_dir)/src/malloc_hook_mmap_freebsd.h',
137 '<(tcmalloc_dir)/src/malloc_hook_mmap_linux.h',
138 '<(tcmalloc_dir)/src/maybe_threads.cc',
139 '<(tcmalloc_dir)/src/maybe_threads.h',
140 '<(tcmalloc_dir)/src/memfs_malloc.cc',
141 '<(tcmalloc_dir)/src/memory_region_map.cc',
142 '<(tcmalloc_dir)/src/memory_region_map.h',
143 '<(tcmalloc_dir)/src/packed-cache-inl.h',
144 '<(tcmalloc_dir)/src/page_heap.cc',
145 '<(tcmalloc_dir)/src/page_heap.h',
146 '<(tcmalloc_dir)/src/page_heap_allocator.h',
147 '<(tcmalloc_dir)/src/pagemap.h',
148 '<(tcmalloc_dir)/src/profile-handler.cc',
149 '<(tcmalloc_dir)/src/profile-handler.h',
150 '<(tcmalloc_dir)/src/profiledata.cc',
151 '<(tcmalloc_dir)/src/profiledata.h',
152 '<(tcmalloc_dir)/src/profiler.cc',
153 '<(tcmalloc_dir)/src/raw_printer.cc',
154 '<(tcmalloc_dir)/src/raw_printer.h',
155 '<(tcmalloc_dir)/src/sampler.cc',
156 '<(tcmalloc_dir)/src/sampler.h',
157 '<(tcmalloc_dir)/src/span.cc',
158 '<(tcmalloc_dir)/src/span.h',
159 '<(tcmalloc_dir)/src/stack_trace_table.cc',
160 '<(tcmalloc_dir)/src/stack_trace_table.h',
161 '<(tcmalloc_dir)/src/stacktrace.cc',
162 '<(tcmalloc_dir)/src/stacktrace_arm-inl.h',
163 '<(tcmalloc_dir)/src/stacktrace_config.h',
164 '<(tcmalloc_dir)/src/stacktrace_generic-inl.h',
165 '<(tcmalloc_dir)/src/stacktrace_libunwind-inl.h',
166 '<(tcmalloc_dir)/src/stacktrace_powerpc-inl.h',
167 '<(tcmalloc_dir)/src/stacktrace_win32-inl.h',
168 '<(tcmalloc_dir)/src/stacktrace_with_context.cc',
169 '<(tcmalloc_dir)/src/stacktrace_x86-inl.h',
170 '<(tcmalloc_dir)/src/static_vars.cc',
171 '<(tcmalloc_dir)/src/static_vars.h',
172 '<(tcmalloc_dir)/src/symbolize.cc',
173 '<(tcmalloc_dir)/src/symbolize.h',
174 '<(tcmalloc_dir)/src/system-alloc.cc',
175 '<(tcmalloc_dir)/src/system-alloc.h',
176 '<(tcmalloc_dir)/src/tcmalloc.cc',
177 '<(tcmalloc_dir)/src/tcmalloc_guard.h',
178 '<(tcmalloc_dir)/src/thread_cache.cc',
179 '<(tcmalloc_dir)/src/thread_cache.h',
180 '<(tcmalloc_dir)/src/windows/config.h',
181 '<(tcmalloc_dir)/src/windows/get_mangled_names.cc',
182 '<(tcmalloc_dir)/src/windows/gperftools/tcmalloc.h',
183 '<(tcmalloc_dir)/src/windows/ia32_modrm_map.cc',
184 '<(tcmalloc_dir)/src/windows/ia32_opcode_map.cc',
185 '<(tcmalloc_dir)/src/windows/mingw.h',
186 '<(tcmalloc_dir)/src/windows/mini_disassembler.cc',
187 '<(tcmalloc_dir)/src/windows/mini_disassembler.h',
188 '<(tcmalloc_dir)/src/windows/mini_disassembler_types.h',
189 '<(tcmalloc_dir)/src/windows/override_functions.cc',
190 '<(tcmalloc_dir)/src/windows/patch_functions.cc',
191 '<(tcmalloc_dir)/src/windows/port.cc',
192 '<(tcmalloc_dir)/src/windows/port.h',
193 '<(tcmalloc_dir)/src/windows/preamble_patcher.cc',
194 '<(tcmalloc_dir)/src/windows/preamble_patcher.h',
195 '<(tcmalloc_dir)/src/windows/preamble_patcher_with_stub.cc',
198 '<(jemalloc_dir)/jemalloc.c',
199 '<(jemalloc_dir)/jemalloc.h',
200 '<(jemalloc_dir)/ql.h',
201 '<(jemalloc_dir)/qr.h',
202 '<(jemalloc_dir)/rb.h',
206 'generic_allocators.cc',
209 # sources! means that these are not compiled directly.
211 # Included by allocator_shim.cc for maximal inlining.
212 'generic_allocators.cc',
215 # We simply don't use these, but list them above so that IDE
216 # users can view the full available source for reference, etc.
217 '<(tcmalloc_dir)/src/addressmap-inl.h',
218 '<(tcmalloc_dir)/src/base/atomicops-internals-linuxppc.h',
219 '<(tcmalloc_dir)/src/base/atomicops-internals-macosx.h',
220 '<(tcmalloc_dir)/src/base/atomicops-internals-x86-msvc.h',
221 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.cc',
222 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.h',
223 '<(tcmalloc_dir)/src/base/atomicops.h',
224 '<(tcmalloc_dir)/src/base/basictypes.h',
225 '<(tcmalloc_dir)/src/base/commandlineflags.h',
226 '<(tcmalloc_dir)/src/base/cycleclock.h',
227 '<(tcmalloc_dir)/src/base/elf_mem_image.h',
228 '<(tcmalloc_dir)/src/base/elfcore.h',
229 '<(tcmalloc_dir)/src/base/googleinit.h',
230 '<(tcmalloc_dir)/src/base/linux_syscall_support.h',
231 '<(tcmalloc_dir)/src/base/simple_mutex.h',
232 '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h',
233 '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h',
234 '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h',
235 '<(tcmalloc_dir)/src/base/stl_allocator.h',
236 '<(tcmalloc_dir)/src/base/thread_annotations.h',
237 '<(tcmalloc_dir)/src/getpc.h',
238 '<(tcmalloc_dir)/src/gperftools/heap-checker.h',
239 '<(tcmalloc_dir)/src/gperftools/heap-profiler.h',
240 '<(tcmalloc_dir)/src/gperftools/malloc_extension.h',
241 '<(tcmalloc_dir)/src/gperftools/malloc_extension_c.h',
242 '<(tcmalloc_dir)/src/gperftools/malloc_hook.h',
243 '<(tcmalloc_dir)/src/gperftools/malloc_hook_c.h',
244 '<(tcmalloc_dir)/src/gperftools/profiler.h',
245 '<(tcmalloc_dir)/src/gperftools/stacktrace.h',
246 '<(tcmalloc_dir)/src/gperftools/tcmalloc.h',
247 '<(tcmalloc_dir)/src/libc_override.h',
248 '<(tcmalloc_dir)/src/libc_override_gcc_and_weak.h',
249 '<(tcmalloc_dir)/src/libc_override_glibc.h',
250 '<(tcmalloc_dir)/src/libc_override_osx.h',
251 '<(tcmalloc_dir)/src/libc_override_redefine.h',
252 '<(tcmalloc_dir)/src/malloc_hook_mmap_freebsd.h',
253 '<(tcmalloc_dir)/src/malloc_hook_mmap_linux.h',
254 '<(tcmalloc_dir)/src/memfs_malloc.cc',
255 '<(tcmalloc_dir)/src/packed-cache-inl.h',
256 '<(tcmalloc_dir)/src/page_heap_allocator.h',
257 '<(tcmalloc_dir)/src/pagemap.h',
258 '<(tcmalloc_dir)/src/stacktrace_arm-inl.h',
259 '<(tcmalloc_dir)/src/stacktrace_config.h',
260 '<(tcmalloc_dir)/src/stacktrace_generic-inl.h',
261 '<(tcmalloc_dir)/src/stacktrace_libunwind-inl.h',
262 '<(tcmalloc_dir)/src/stacktrace_powerpc-inl.h',
263 '<(tcmalloc_dir)/src/stacktrace_win32-inl.h',
264 '<(tcmalloc_dir)/src/stacktrace_with_context.cc',
265 '<(tcmalloc_dir)/src/stacktrace_x86-inl.h',
266 '<(tcmalloc_dir)/src/tcmalloc_guard.h',
267 '<(tcmalloc_dir)/src/windows/config.h',
268 '<(tcmalloc_dir)/src/windows/gperftools/tcmalloc.h',
269 '<(tcmalloc_dir)/src/windows/get_mangled_names.cc',
270 '<(tcmalloc_dir)/src/windows/ia32_modrm_map.cc',
271 '<(tcmalloc_dir)/src/windows/ia32_opcode_map.cc',
272 '<(tcmalloc_dir)/src/windows/mingw.h',
273 '<(tcmalloc_dir)/src/windows/mini_disassembler.cc',
274 '<(tcmalloc_dir)/src/windows/mini_disassembler.h',
275 '<(tcmalloc_dir)/src/windows/mini_disassembler_types.h',
276 '<(tcmalloc_dir)/src/windows/override_functions.cc',
277 '<(tcmalloc_dir)/src/windows/patch_functions.cc',
278 '<(tcmalloc_dir)/src/windows/preamble_patcher.cc',
279 '<(tcmalloc_dir)/src/windows/preamble_patcher.h',
280 '<(tcmalloc_dir)/src/windows/preamble_patcher_with_stub.cc',
283 '../third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations',
286 # TODO(sgk): merge this with build/common.gypi settings
288 'AdditionalOptions': ['/ignore:4006,4221'],
289 'AdditionalLibraryDirectories':
290 ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'],
293 'AdditionalOptions': ['/ignore:4006'],
299 'VCCLCompilerTool': {
300 'RuntimeLibrary': '0',
308 'PERFTOOLS_DLL_DECL=',
311 # tcmalloc source files unconditionally define this, remove it from
312 # the list of defines that common.gypi defines globally.
320 '<(tcmalloc_dir)/src/windows',
323 '<(tcmalloc_dir)/src/base/elf_mem_image.cc',
324 '<(tcmalloc_dir)/src/base/elf_mem_image.h',
325 '<(tcmalloc_dir)/src/base/linuxthreads.cc',
326 '<(tcmalloc_dir)/src/base/linuxthreads.h',
327 '<(tcmalloc_dir)/src/base/vdso_support.cc',
328 '<(tcmalloc_dir)/src/base/vdso_support.h',
329 '<(tcmalloc_dir)/src/maybe_threads.cc',
330 '<(tcmalloc_dir)/src/maybe_threads.h',
331 '<(tcmalloc_dir)/src/symbolize.h',
332 '<(tcmalloc_dir)/src/system-alloc.cc',
333 '<(tcmalloc_dir)/src/system-alloc.h',
335 # included by allocator_shim.cc
336 '<(tcmalloc_dir)/src/tcmalloc.cc',
338 # heap-profiler/checker/cpuprofiler
339 '<(tcmalloc_dir)/src/base/thread_lister.c',
340 '<(tcmalloc_dir)/src/base/thread_lister.h',
341 '<(tcmalloc_dir)/src/deep-heap-profile.cc',
342 '<(tcmalloc_dir)/src/deep-heap-profile.h',
343 '<(tcmalloc_dir)/src/heap-checker-bcad.cc',
344 '<(tcmalloc_dir)/src/heap-checker.cc',
345 '<(tcmalloc_dir)/src/heap-profiler.cc',
346 '<(tcmalloc_dir)/src/heap-profile-table.cc',
347 '<(tcmalloc_dir)/src/heap-profile-table.h',
348 '<(tcmalloc_dir)/src/memory_region_map.cc',
349 '<(tcmalloc_dir)/src/memory_region_map.h',
350 '<(tcmalloc_dir)/src/profiledata.cc',
351 '<(tcmalloc_dir)/src/profiledata.h',
352 '<(tcmalloc_dir)/src/profile-handler.cc',
353 '<(tcmalloc_dir)/src/profile-handler.h',
354 '<(tcmalloc_dir)/src/profiler.cc',
357 '<(tcmalloc_dir)/src/debugallocation.cc',
360 ['OS=="linux" or OS=="freebsd" or OS=="solaris"', {
362 '<(tcmalloc_dir)/src/system-alloc.h',
363 '<(tcmalloc_dir)/src/windows/port.cc',
364 '<(tcmalloc_dir)/src/windows/port.h',
366 # TODO(willchan): Support allocator shim later on.
369 # TODO(willchan): support jemalloc on other platforms
371 '<(jemalloc_dir)/jemalloc.c',
372 '<(jemalloc_dir)/jemalloc.h',
373 '<(jemalloc_dir)/ql.h',
374 '<(jemalloc_dir)/qr.h',
375 '<(jemalloc_dir)/rb.h',
378 # We enable all warnings by default, but upstream disables a few.
379 # Keep "-Wno-*" flags in sync with upstream by comparing against:
380 # http://code.google.com/p/google-perftools/source/browse/trunk/Makefile.am
383 '-Wno-unused-result',
386 '-fvisibility=hidden',
390 # Don't let linker rip this symbol out, otherwise the heap&cpu
391 # profilers will not initialize properly on startup.
392 '-Wl,-uIsHeapProfilerRunning,-uProfilerStart',
393 # Do the same for heap leak checker.
394 '-Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi',
395 '-Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl',
396 '-Wl,-u_ZN15HeapLeakChecker12IgnoreObjectEPKv,-u_ZN15HeapLeakChecker14UnIgnoreObjectEPKv',
399 [ 'use_vtable_verify==1', {
401 '-fvtable-verify=preinit',
404 [ 'linux_use_debugallocation==1', {
406 # debugallocation.cc #includes tcmalloc.cc,
407 # so only one of them should be used.
408 '<(tcmalloc_dir)/src/tcmalloc.cc',
411 'TCMALLOC_FOR_DEBUGALLOCATION',
413 }, { # linux_use_debugallocation != 1
415 '<(tcmalloc_dir)/src/debugallocation.cc',
418 [ 'linux_keep_shadow_stacks==1', {
420 '<(tcmalloc_dir)/src/linux_shadow_stacks.cc',
421 '<(tcmalloc_dir)/src/linux_shadow_stacks.h',
422 '<(tcmalloc_dir)/src/stacktrace_shadow-inl.h',
425 '-finstrument-functions',
428 'KEEP_SHADOW_STACKS',
431 [ 'linux_use_heapchecker==0', {
432 # Do not compile and link the heapchecker source.
434 '<(tcmalloc_dir)/src/heap-checker-bcad.cc',
435 '<(tcmalloc_dir)/src/heap-checker.cc',
437 # Disable the heap checker in tcmalloc.
444 '-Wno-non-literal-null-conversion',
447 ['order_profiling != 0', {
448 'target_conditions' : [
449 ['_toolset=="target"', {
450 'cflags!': [ '-finstrument-functions' ],
457 # This library is linked in to src/base.gypi:base and allocator_unittests
458 # It can't depend on either and nothing else should depend on it - all
459 # other code should use the interfaced provided by base.
460 'target_name': 'allocator_extension_thunks',
461 'type': 'static_library',
463 'allocator_extension_thunks.cc',
464 'allocator_extension_thunks.h',
466 'toolsets': ['host', 'target'],
476 'target_name': 'libcmt',
480 'action_name': 'libcmt',
485 '<(SHARED_INTERMEDIATE_DIR)/allocator/libcmt.lib',
490 '$(VCInstallDir)lib',
491 '<(SHARED_INTERMEDIATE_DIR)/allocator',
497 'target_name': 'allocator_unittests',
498 'type': 'executable',
501 'allocator_extension_thunks',
502 '../../testing/gtest.gyp:gtest',
506 '<(tcmalloc_dir)/src/base',
507 '<(tcmalloc_dir)/src',
511 'allocator_unittests.cc',
512 '../profiler/alternate_timer.cc',
513 '../profiler/alternate_timer.h',
517 'target_name': 'allocator_extension_thunks_win64',
518 'type': 'static_library',
520 'allocator_extension_thunks.cc',
521 'allocator_extension_thunks.h',
523 'toolsets': ['host', 'target'],
529 'msvs_target_platform': 'x64',
534 'target_name': 'tcmalloc_unittest',
535 'type': 'executable',
537 'tcmalloc_unittest.cc',
541 # For constants of TCMalloc.
542 '<(tcmalloc_dir)/src',
545 '../../testing/gtest.gyp:gtest',