1# Copyright (c) 2009 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. 4 5{ 6 'variables': { 7 'jemalloc_dir': '../../third_party/jemalloc/chromium', 8 'tcmalloc_dir': '../../third_party/tcmalloc/chromium', 9 }, 10 'targets': [ 11 { 12 'target_name': 'allocator', 13 'type': '<(library)', 14 'msvs_guid': 'C564F145-9172-42C3-BFCB-60FDEA124321', 15 'include_dirs': [ 16 '.', 17 '<(tcmalloc_dir)/src/base', 18 '<(tcmalloc_dir)/src', 19 '../..', 20 ], 21 'direct_dependent_settings': { 22 'configurations': { 23 'Common_Base': { 24 'msvs_settings': { 25 'VCLinkerTool': { 26 'IgnoreDefaultLibraryNames': ['libcmtd.lib', 'libcmt.lib'], 27 'AdditionalDependencies': [ 28 '<(SHARED_INTERMEDIATE_DIR)/allocator/libcmt.lib' 29 ], 30 }, 31 }, 32 }, 33 }, 34 'conditions': [ 35 ['OS=="win"', { 36 'defines': [ 37 ['PERFTOOLS_DLL_DECL', ''] 38 ], 39 }], 40 ], 41 }, 42 'sources': [ 43 # Generated for our configuration from tcmalloc's build 44 # and checked in. 45 '<(tcmalloc_dir)/src/config.h', 46 '<(tcmalloc_dir)/src/config_linux.h', 47 '<(tcmalloc_dir)/src/config_win.h', 48 49 # all tcmalloc native and forked files 50 '<(tcmalloc_dir)/src/addressmap-inl.h', 51 '<(tcmalloc_dir)/src/base/atomicops-internals-linuxppc.h', 52 '<(tcmalloc_dir)/src/base/atomicops-internals-macosx.h', 53 '<(tcmalloc_dir)/src/base/atomicops-internals-x86-msvc.h', 54 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.cc', 55 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.h', 56 '<(tcmalloc_dir)/src/base/atomicops.h', 57 '<(tcmalloc_dir)/src/base/basictypes.h', 58 '<(tcmalloc_dir)/src/base/commandlineflags.h', 59 '<(tcmalloc_dir)/src/base/cycleclock.h', 60 # We don't list dynamic_annotations.c since its copy is already 61 # present in the dynamic_annotations target. 62 '<(tcmalloc_dir)/src/base/dynamic_annotations.h', 63 '<(tcmalloc_dir)/src/base/elfcore.h', 64 '<(tcmalloc_dir)/src/base/googleinit.h', 65 '<(tcmalloc_dir)/src/base/linux_syscall_support.h', 66 '<(tcmalloc_dir)/src/base/linuxthreads.cc', 67 '<(tcmalloc_dir)/src/base/linuxthreads.h', 68 '<(tcmalloc_dir)/src/base/logging.cc', 69 '<(tcmalloc_dir)/src/base/logging.h', 70 '<(tcmalloc_dir)/src/base/low_level_alloc.cc', 71 '<(tcmalloc_dir)/src/base/low_level_alloc.h', 72 '<(tcmalloc_dir)/src/base/simple_mutex.h', 73 '<(tcmalloc_dir)/src/base/spinlock.cc', 74 '<(tcmalloc_dir)/src/base/spinlock.h', 75 '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h', 76 '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h', 77 '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h', 78 '<(tcmalloc_dir)/src/base/stl_allocator.h', 79 '<(tcmalloc_dir)/src/base/sysinfo.cc', 80 '<(tcmalloc_dir)/src/base/sysinfo.h', 81 '<(tcmalloc_dir)/src/base/thread_annotations.h', 82 '<(tcmalloc_dir)/src/base/thread_lister.c', 83 '<(tcmalloc_dir)/src/base/thread_lister.h', 84 '<(tcmalloc_dir)/src/base/vdso_support.cc', 85 '<(tcmalloc_dir)/src/base/vdso_support.h', 86 '<(tcmalloc_dir)/src/central_freelist.cc', 87 '<(tcmalloc_dir)/src/central_freelist.h', 88 '<(tcmalloc_dir)/src/common.cc', 89 '<(tcmalloc_dir)/src/common.h', 90 '<(tcmalloc_dir)/src/debugallocation.cc', 91 '<(tcmalloc_dir)/src/getpc.h', 92 '<(tcmalloc_dir)/src/google/heap-checker.h', 93 '<(tcmalloc_dir)/src/google/heap-profiler.h', 94 '<(tcmalloc_dir)/src/google/malloc_extension.h', 95 '<(tcmalloc_dir)/src/google/malloc_extension_c.h', 96 '<(tcmalloc_dir)/src/google/malloc_hook.h', 97 '<(tcmalloc_dir)/src/google/malloc_hook_c.h', 98 '<(tcmalloc_dir)/src/google/profiler.h', 99 '<(tcmalloc_dir)/src/google/stacktrace.h', 100 '<(tcmalloc_dir)/src/google/tcmalloc.h', 101 '<(tcmalloc_dir)/src/heap-checker-bcad.cc', 102 '<(tcmalloc_dir)/src/heap-checker.cc', 103 '<(tcmalloc_dir)/src/heap-profile-table.cc', 104 '<(tcmalloc_dir)/src/heap-profile-table.h', 105 '<(tcmalloc_dir)/src/heap-profiler.cc', 106 '<(tcmalloc_dir)/src/internal_logging.cc', 107 '<(tcmalloc_dir)/src/internal_logging.h', 108 '<(tcmalloc_dir)/src/linked_list.h', 109 '<(tcmalloc_dir)/src/malloc_extension.cc', 110 '<(tcmalloc_dir)/src/malloc_hook-inl.h', 111 '<(tcmalloc_dir)/src/malloc_hook.cc', 112 '<(tcmalloc_dir)/src/maybe_threads.cc', 113 '<(tcmalloc_dir)/src/maybe_threads.h', 114 '<(tcmalloc_dir)/src/memfs_malloc.cc', 115 '<(tcmalloc_dir)/src/memory_region_map.cc', 116 '<(tcmalloc_dir)/src/memory_region_map.h', 117 '<(tcmalloc_dir)/src/packed-cache-inl.h', 118 '<(tcmalloc_dir)/src/page_heap.cc', 119 '<(tcmalloc_dir)/src/page_heap.h', 120 '<(tcmalloc_dir)/src/page_heap_allocator.h', 121 '<(tcmalloc_dir)/src/pagemap.h', 122 '<(tcmalloc_dir)/src/profile-handler.cc', 123 '<(tcmalloc_dir)/src/profile-handler.h', 124 '<(tcmalloc_dir)/src/profiledata.cc', 125 '<(tcmalloc_dir)/src/profiledata.h', 126 '<(tcmalloc_dir)/src/profiler.cc', 127 '<(tcmalloc_dir)/src/raw_printer.cc', 128 '<(tcmalloc_dir)/src/raw_printer.h', 129 '<(tcmalloc_dir)/src/sampler.cc', 130 '<(tcmalloc_dir)/src/sampler.h', 131 '<(tcmalloc_dir)/src/span.cc', 132 '<(tcmalloc_dir)/src/span.h', 133 '<(tcmalloc_dir)/src/stack_trace_table.cc', 134 '<(tcmalloc_dir)/src/stack_trace_table.h', 135 '<(tcmalloc_dir)/src/stacktrace.cc', 136 '<(tcmalloc_dir)/src/stacktrace_config.h', 137 '<(tcmalloc_dir)/src/stacktrace_generic-inl.h', 138 '<(tcmalloc_dir)/src/stacktrace_libunwind-inl.h', 139 '<(tcmalloc_dir)/src/stacktrace_powerpc-inl.h', 140 '<(tcmalloc_dir)/src/stacktrace_win32-inl.h', 141 '<(tcmalloc_dir)/src/stacktrace_with_context.cc', 142 '<(tcmalloc_dir)/src/stacktrace_x86-inl.h', 143 '<(tcmalloc_dir)/src/stacktrace_x86_64-inl.h', 144 '<(tcmalloc_dir)/src/static_vars.cc', 145 '<(tcmalloc_dir)/src/static_vars.h', 146 '<(tcmalloc_dir)/src/symbolize.cc', 147 '<(tcmalloc_dir)/src/symbolize.h', 148 '<(tcmalloc_dir)/src/system-alloc.cc', 149 '<(tcmalloc_dir)/src/system-alloc.h', 150 '<(tcmalloc_dir)/src/tcmalloc.cc', 151 '<(tcmalloc_dir)/src/tcmalloc_guard.h', 152 '<(tcmalloc_dir)/src/thread_cache.cc', 153 '<(tcmalloc_dir)/src/thread_cache.h', 154 '<(tcmalloc_dir)/src/windows/config.h', 155 '<(tcmalloc_dir)/src/windows/get_mangled_names.cc', 156 '<(tcmalloc_dir)/src/windows/google/tcmalloc.h', 157 '<(tcmalloc_dir)/src/windows/ia32_modrm_map.cc', 158 '<(tcmalloc_dir)/src/windows/ia32_opcode_map.cc', 159 '<(tcmalloc_dir)/src/windows/mingw.h', 160 '<(tcmalloc_dir)/src/windows/mini_disassembler.cc', 161 '<(tcmalloc_dir)/src/windows/mini_disassembler.h', 162 '<(tcmalloc_dir)/src/windows/mini_disassembler_types.h', 163 '<(tcmalloc_dir)/src/windows/override_functions.cc', 164 '<(tcmalloc_dir)/src/windows/patch_functions.cc', 165 '<(tcmalloc_dir)/src/windows/port.cc', 166 '<(tcmalloc_dir)/src/windows/port.h', 167 '<(tcmalloc_dir)/src/windows/preamble_patcher.cc', 168 '<(tcmalloc_dir)/src/windows/preamble_patcher.h', 169 '<(tcmalloc_dir)/src/windows/preamble_patcher_with_stub.cc', 170 171 # jemalloc files 172 '<(jemalloc_dir)/jemalloc.c', 173 '<(jemalloc_dir)/jemalloc.h', 174 '<(jemalloc_dir)/ql.h', 175 '<(jemalloc_dir)/qr.h', 176 '<(jemalloc_dir)/rb.h', 177 178 'allocator_shim.cc', 179 'allocator_shim.h', 180 'generic_allocators.cc', 181 'win_allocator.cc', 182 ], 183 # sources! means that these are not compiled directly. 184 'sources!': [ 185 # Included by allocator_shim.cc for maximal inlining. 186 'generic_allocators.cc', 187 'win_allocator.cc', 188 189 # We simply don't use these, but list them above so that IDE 190 # users can view the full available source for reference, etc. 191 '<(tcmalloc_dir)/src/addressmap-inl.h', 192 '<(tcmalloc_dir)/src/base/atomicops-internals-linuxppc.h', 193 '<(tcmalloc_dir)/src/base/atomicops-internals-macosx.h', 194 '<(tcmalloc_dir)/src/base/atomicops-internals-x86-msvc.h', 195 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.cc', 196 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.h', 197 '<(tcmalloc_dir)/src/base/atomicops.h', 198 '<(tcmalloc_dir)/src/base/basictypes.h', 199 '<(tcmalloc_dir)/src/base/commandlineflags.h', 200 '<(tcmalloc_dir)/src/base/cycleclock.h', 201 '<(tcmalloc_dir)/src/base/elfcore.h', 202 '<(tcmalloc_dir)/src/base/googleinit.h', 203 '<(tcmalloc_dir)/src/base/linux_syscall_support.h', 204 '<(tcmalloc_dir)/src/base/simple_mutex.h', 205 '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h', 206 '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h', 207 '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h', 208 '<(tcmalloc_dir)/src/base/stl_allocator.h', 209 '<(tcmalloc_dir)/src/base/thread_annotations.h', 210 '<(tcmalloc_dir)/src/getpc.h', 211 '<(tcmalloc_dir)/src/google/heap-checker.h', 212 '<(tcmalloc_dir)/src/google/heap-profiler.h', 213 '<(tcmalloc_dir)/src/google/malloc_extension_c.h', 214 '<(tcmalloc_dir)/src/google/malloc_hook.h', 215 '<(tcmalloc_dir)/src/google/malloc_hook_c.h', 216 '<(tcmalloc_dir)/src/google/profiler.h', 217 '<(tcmalloc_dir)/src/google/stacktrace.h', 218 '<(tcmalloc_dir)/src/memfs_malloc.cc', 219 '<(tcmalloc_dir)/src/packed-cache-inl.h', 220 '<(tcmalloc_dir)/src/page_heap_allocator.h', 221 '<(tcmalloc_dir)/src/pagemap.h', 222 '<(tcmalloc_dir)/src/stacktrace_config.h', 223 '<(tcmalloc_dir)/src/stacktrace_generic-inl.h', 224 '<(tcmalloc_dir)/src/stacktrace_libunwind-inl.h', 225 '<(tcmalloc_dir)/src/stacktrace_powerpc-inl.h', 226 '<(tcmalloc_dir)/src/stacktrace_win32-inl.h', 227 '<(tcmalloc_dir)/src/stacktrace_with_context.cc', 228 '<(tcmalloc_dir)/src/stacktrace_x86-inl.h', 229 '<(tcmalloc_dir)/src/stacktrace_x86_64-inl.h', 230 '<(tcmalloc_dir)/src/tcmalloc_guard.h', 231 '<(tcmalloc_dir)/src/windows/config.h', 232 '<(tcmalloc_dir)/src/windows/google/tcmalloc.h', 233 '<(tcmalloc_dir)/src/windows/get_mangled_names.cc', 234 '<(tcmalloc_dir)/src/windows/ia32_modrm_map.cc', 235 '<(tcmalloc_dir)/src/windows/ia32_opcode_map.cc', 236 '<(tcmalloc_dir)/src/windows/mingw.h', 237 '<(tcmalloc_dir)/src/windows/mini_disassembler.cc', 238 '<(tcmalloc_dir)/src/windows/mini_disassembler.h', 239 '<(tcmalloc_dir)/src/windows/mini_disassembler_types.h', 240 '<(tcmalloc_dir)/src/windows/override_functions.cc', 241 '<(tcmalloc_dir)/src/windows/patch_functions.cc', 242 '<(tcmalloc_dir)/src/windows/preamble_patcher.cc', 243 '<(tcmalloc_dir)/src/windows/preamble_patcher.h', 244 '<(tcmalloc_dir)/src/windows/preamble_patcher_with_stub.cc', 245 ], 246 'dependencies': [ 247 '../third_party/dynamic_annotations/dynamic_annotations.gyp:dynamic_annotations', 248 ], 249 'msvs_settings': { 250 # TODO(sgk): merge this with build/common.gypi settings 251 'VCLibrarianTool': { 252 'AdditionalOptions': ['/ignore:4006,4221'], 253 'AdditionalLibraryDirectories': 254 ['<(DEPTH)/third_party/platformsdk_win7/files/Lib'], 255 }, 256 'VCLinkerTool': { 257 'AdditionalOptions': ['/ignore:4006'], 258 }, 259 }, 260 'configurations': { 261 'Debug_Base': { 262 'msvs_settings': { 263 'VCCLCompilerTool': { 264 'RuntimeLibrary': '0', 265 }, 266 }, 267 }, 268 }, 269 'conditions': [ 270 ['OS=="win"', { 271 'defines': [ 272 ['PERFTOOLS_DLL_DECL', ''] 273 ], 274 'dependencies': [ 275 'libcmt', 276 ], 277 'include_dirs': [ 278 '<(tcmalloc_dir)/src/windows', 279 ], 280 'sources!': [ 281 '<(tcmalloc_dir)/src/base/linuxthreads.cc', 282 '<(tcmalloc_dir)/src/base/linuxthreads.h', 283 '<(tcmalloc_dir)/src/base/vdso_support.cc', 284 '<(tcmalloc_dir)/src/base/vdso_support.h', 285 '<(tcmalloc_dir)/src/maybe_threads.cc', 286 '<(tcmalloc_dir)/src/maybe_threads.h', 287 '<(tcmalloc_dir)/src/symbolize.h', 288 '<(tcmalloc_dir)/src/system-alloc.cc', 289 '<(tcmalloc_dir)/src/system-alloc.h', 290 291 # included by allocator_shim.cc 292 '<(tcmalloc_dir)/src/tcmalloc.cc', 293 294 # heap-profiler/checker/cpuprofiler 295 '<(tcmalloc_dir)/src/base/thread_lister.c', 296 '<(tcmalloc_dir)/src/base/thread_lister.h', 297 '<(tcmalloc_dir)/src/heap-checker-bcad.cc', 298 '<(tcmalloc_dir)/src/heap-checker.cc', 299 '<(tcmalloc_dir)/src/heap-profiler.cc', 300 '<(tcmalloc_dir)/src/memory_region_map.cc', 301 '<(tcmalloc_dir)/src/memory_region_map.h', 302 '<(tcmalloc_dir)/src/profiledata.cc', 303 '<(tcmalloc_dir)/src/profiledata.h', 304 '<(tcmalloc_dir)/src/profile-handler.cc', 305 '<(tcmalloc_dir)/src/profile-handler.h', 306 '<(tcmalloc_dir)/src/profiler.cc', 307 308 # debugallocation 309 '<(tcmalloc_dir)/src/debugallocation.cc', 310 ], 311 }], 312 ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', { 313 'sources!': [ 314 '<(tcmalloc_dir)/src/system-alloc.h', 315 '<(tcmalloc_dir)/src/windows/port.cc', 316 '<(tcmalloc_dir)/src/windows/port.h', 317 318 # TODO(willchan): Support allocator shim later on. 319 'allocator_shim.cc', 320 321 # TODO(willchan): support jemalloc on other platforms 322 # jemalloc files 323 '<(jemalloc_dir)/jemalloc.c', 324 '<(jemalloc_dir)/jemalloc.h', 325 '<(jemalloc_dir)/ql.h', 326 '<(jemalloc_dir)/qr.h', 327 '<(jemalloc_dir)/rb.h', 328 329 ], 330 'cflags!': [ 331 '-fvisibility=hidden', 332 ], 333 'link_settings': { 334 'ldflags': [ 335 # Don't let linker rip this symbol out, otherwise the heap&cpu 336 # profilers will not initialize properly on startup. 337 '-Wl,-uIsHeapProfilerRunning,-uProfilerStart', 338 # Do the same for heap leak checker. 339 '-Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi', 340 '-Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl', 341 ]}, 342 }], 343 [ 'linux_use_debugallocation==1', { 344 'sources!': [ 345 # debugallocation.cc #includes tcmalloc.cc, 346 # so only one of them should be used. 347 '<(tcmalloc_dir)/src/tcmalloc.cc', 348 ], 349 'cflags': [ 350 '-DTCMALLOC_FOR_DEBUGALLOCATION', 351 ], 352 }, { # linux_use_debugallocation != 1 353 'sources!': [ 354 '<(tcmalloc_dir)/src/debugallocation.cc', 355 ], 356 }], 357 [ 'linux_keep_shadow_stacks==1', { 358 'sources': [ 359 '<(tcmalloc_dir)/src/linux_shadow_stacks.cc', 360 '<(tcmalloc_dir)/src/linux_shadow_stacks.h', 361 '<(tcmalloc_dir)/src/stacktrace_shadow-inl.h', 362 ], 363 'cflags': [ 364 '-finstrument-functions', 365 '-DKEEP_SHADOW_STACKS', 366 ], 367 }], 368 [ 'linux_use_heapchecker==0', { 369 # Do not compile and link the heapchecker source. 370 'sources!': [ 371 '<(tcmalloc_dir)/src/heap-checker-bcad.cc', 372 '<(tcmalloc_dir)/src/heap-checker.cc', 373 ], 374 # Disable the heap checker in tcmalloc. 375 'cflags': [ 376 '-DNO_HEAP_CHECK', 377 ], 378 }], 379 ], 380 }, 381 { 382 'target_name': 'allocator_unittests', 383 'type': 'executable', 384 'dependencies': [ 385 'allocator', 386 '../../testing/gtest.gyp:gtest', 387 ], 388 'include_dirs': [ 389 '.', 390 '<(tcmalloc_dir)/src/base', 391 '<(tcmalloc_dir)/src', 392 '../..', 393 ], 394 'msvs_guid': 'E99DA267-BE90-4F45-1294-6919DB2C9999', 395 'sources': [ 396 'unittest_utils.cc', 397 'allocator_unittests.cc', 398 ], 399 }, 400 ], 401 'conditions': [ 402 ['OS=="win"', { 403 'targets': [ 404 { 405 'target_name': 'libcmt', 406 'type': 'none', 407 'actions': [ 408 { 409 'action_name': 'libcmt', 410 'inputs': [ 411 'prep_libc.sh', 412 ], 413 'outputs': [ 414 '<(SHARED_INTERMEDIATE_DIR)/allocator/libcmt.lib', 415 ], 416 'action': [ 417 './prep_libc.sh', 418 '$(VCInstallDir)lib', 419 '<(SHARED_INTERMEDIATE_DIR)/allocator', 420 ], 421 }, 422 ], 423 }, 424 ], 425 }], 426 ], 427} 428 429# Local Variables: 430# tab-width:2 431# indent-tabs-mode:nil 432# End: 433# vim: set expandtab tabstop=2 shiftwidth=2: 434