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 '<(tcmalloc_dir)/src/base/dynamic_annotations.cc', 61 '<(tcmalloc_dir)/src/base/dynamic_annotations.h', 62 '<(tcmalloc_dir)/src/base/elfcore.h', 63 '<(tcmalloc_dir)/src/base/googleinit.h', 64 '<(tcmalloc_dir)/src/base/linux_syscall_support.h', 65 '<(tcmalloc_dir)/src/base/linuxthreads.cc', 66 '<(tcmalloc_dir)/src/base/linuxthreads.h', 67 '<(tcmalloc_dir)/src/base/logging.cc', 68 '<(tcmalloc_dir)/src/base/logging.h', 69 '<(tcmalloc_dir)/src/base/low_level_alloc.cc', 70 '<(tcmalloc_dir)/src/base/low_level_alloc.h', 71 '<(tcmalloc_dir)/src/base/simple_mutex.h', 72 '<(tcmalloc_dir)/src/base/spinlock.cc', 73 '<(tcmalloc_dir)/src/base/spinlock.h', 74 '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h', 75 '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h', 76 '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h', 77 '<(tcmalloc_dir)/src/base/stl_allocator.h', 78 '<(tcmalloc_dir)/src/base/sysinfo.cc', 79 '<(tcmalloc_dir)/src/base/sysinfo.h', 80 '<(tcmalloc_dir)/src/base/thread_annotations.h', 81 '<(tcmalloc_dir)/src/base/thread_lister.c', 82 '<(tcmalloc_dir)/src/base/thread_lister.h', 83 '<(tcmalloc_dir)/src/base/vdso_support.cc', 84 '<(tcmalloc_dir)/src/base/vdso_support.h', 85 '<(tcmalloc_dir)/src/central_freelist.cc', 86 '<(tcmalloc_dir)/src/central_freelist.h', 87 '<(tcmalloc_dir)/src/common.cc', 88 '<(tcmalloc_dir)/src/common.h', 89 '<(tcmalloc_dir)/src/debugallocation.cc', 90 '<(tcmalloc_dir)/src/getpc.h', 91 '<(tcmalloc_dir)/src/google/heap-checker.h', 92 '<(tcmalloc_dir)/src/google/heap-profiler.h', 93 '<(tcmalloc_dir)/src/google/malloc_extension.h', 94 '<(tcmalloc_dir)/src/google/malloc_extension_c.h', 95 '<(tcmalloc_dir)/src/google/malloc_hook.h', 96 '<(tcmalloc_dir)/src/google/malloc_hook_c.h', 97 '<(tcmalloc_dir)/src/google/profiler.h', 98 '<(tcmalloc_dir)/src/google/stacktrace.h', 99 '<(tcmalloc_dir)/src/google/tcmalloc.h', 100 '<(tcmalloc_dir)/src/heap-checker-bcad.cc', 101 '<(tcmalloc_dir)/src/heap-checker.cc', 102 '<(tcmalloc_dir)/src/heap-profile-table.cc', 103 '<(tcmalloc_dir)/src/heap-profile-table.h', 104 '<(tcmalloc_dir)/src/heap-profiler.cc', 105 '<(tcmalloc_dir)/src/internal_logging.cc', 106 '<(tcmalloc_dir)/src/internal_logging.h', 107 '<(tcmalloc_dir)/src/linked_list.h', 108 '<(tcmalloc_dir)/src/malloc_extension.cc', 109 '<(tcmalloc_dir)/src/malloc_hook-inl.h', 110 '<(tcmalloc_dir)/src/malloc_hook.cc', 111 '<(tcmalloc_dir)/src/maybe_threads.cc', 112 '<(tcmalloc_dir)/src/maybe_threads.h', 113 '<(tcmalloc_dir)/src/memfs_malloc.cc', 114 '<(tcmalloc_dir)/src/memory_region_map.cc', 115 '<(tcmalloc_dir)/src/memory_region_map.h', 116 '<(tcmalloc_dir)/src/packed-cache-inl.h', 117 '<(tcmalloc_dir)/src/page_heap.cc', 118 '<(tcmalloc_dir)/src/page_heap.h', 119 '<(tcmalloc_dir)/src/page_heap_allocator.h', 120 '<(tcmalloc_dir)/src/pagemap.h', 121 '<(tcmalloc_dir)/src/profile-handler.cc', 122 '<(tcmalloc_dir)/src/profile-handler.h', 123 '<(tcmalloc_dir)/src/profiledata.cc', 124 '<(tcmalloc_dir)/src/profiledata.h', 125 '<(tcmalloc_dir)/src/profiler.cc', 126 '<(tcmalloc_dir)/src/raw_printer.cc', 127 '<(tcmalloc_dir)/src/raw_printer.h', 128 '<(tcmalloc_dir)/src/sampler.cc', 129 '<(tcmalloc_dir)/src/sampler.h', 130 '<(tcmalloc_dir)/src/span.cc', 131 '<(tcmalloc_dir)/src/span.h', 132 '<(tcmalloc_dir)/src/stack_trace_table.cc', 133 '<(tcmalloc_dir)/src/stack_trace_table.h', 134 '<(tcmalloc_dir)/src/stacktrace.cc', 135 '<(tcmalloc_dir)/src/stacktrace.h', 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/symbolize_linux.cc', 149 '<(tcmalloc_dir)/src/system-alloc.cc', 150 '<(tcmalloc_dir)/src/system-alloc.h', 151 '<(tcmalloc_dir)/src/tcmalloc.cc', 152 '<(tcmalloc_dir)/src/tcmalloc_guard.h', 153 '<(tcmalloc_dir)/src/tcmalloc_linux.cc', 154 '<(tcmalloc_dir)/src/thread_cache.cc', 155 '<(tcmalloc_dir)/src/thread_cache.h', 156 '<(tcmalloc_dir)/src/windows/config.h', 157 '<(tcmalloc_dir)/src/windows/get_mangled_names.cc', 158 '<(tcmalloc_dir)/src/windows/google/tcmalloc.h', 159 '<(tcmalloc_dir)/src/windows/ia32_modrm_map.cc', 160 '<(tcmalloc_dir)/src/windows/ia32_opcode_map.cc', 161 '<(tcmalloc_dir)/src/windows/mingw.h', 162 '<(tcmalloc_dir)/src/windows/mini_disassembler.cc', 163 '<(tcmalloc_dir)/src/windows/mini_disassembler.h', 164 '<(tcmalloc_dir)/src/windows/mini_disassembler_types.h', 165 '<(tcmalloc_dir)/src/windows/override_functions.cc', 166 '<(tcmalloc_dir)/src/windows/patch_functions.cc', 167 '<(tcmalloc_dir)/src/windows/port.cc', 168 '<(tcmalloc_dir)/src/windows/port.h', 169 '<(tcmalloc_dir)/src/windows/preamble_patcher.cc', 170 '<(tcmalloc_dir)/src/windows/preamble_patcher.h', 171 '<(tcmalloc_dir)/src/windows/preamble_patcher_with_stub.cc', 172 173 # jemalloc files 174 '<(jemalloc_dir)/jemalloc.c', 175 '<(jemalloc_dir)/jemalloc.h', 176 '<(jemalloc_dir)/ql.h', 177 '<(jemalloc_dir)/qr.h', 178 '<(jemalloc_dir)/rb.h', 179 180 'allocator_shim.cc', 181 'generic_allocators.cc', 182 'win_allocator.cc', 183 ], 184 # sources! means that these are not compiled directly. 185 'sources!': [ 186 # Included by allocator_shim.cc for maximal inlining. 187 'generic_allocators.cc', 188 'win_allocator.cc', 189 '<(tcmalloc_dir)/src/tcmalloc.cc', 190 191 # Unneeded on Windows, symbolize_linux.cc used there instead. 192 '<(tcmalloc_dir)/src/symbolize.cc', 193 194 # We simply don't use these, but list them above so that IDE 195 # users can view the full available source for reference, etc. 196 '<(tcmalloc_dir)/src/addressmap-inl.h', 197 '<(tcmalloc_dir)/src/base/atomicops-internals-linuxppc.h', 198 '<(tcmalloc_dir)/src/base/atomicops-internals-macosx.h', 199 '<(tcmalloc_dir)/src/base/atomicops-internals-x86-msvc.h', 200 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.cc', 201 '<(tcmalloc_dir)/src/base/atomicops-internals-x86.h', 202 '<(tcmalloc_dir)/src/base/atomicops.h', 203 '<(tcmalloc_dir)/src/base/basictypes.h', 204 '<(tcmalloc_dir)/src/base/commandlineflags.h', 205 '<(tcmalloc_dir)/src/base/cycleclock.h', 206 '<(tcmalloc_dir)/src/base/elfcore.h', 207 '<(tcmalloc_dir)/src/base/googleinit.h', 208 '<(tcmalloc_dir)/src/base/linux_syscall_support.h', 209 '<(tcmalloc_dir)/src/base/simple_mutex.h', 210 '<(tcmalloc_dir)/src/base/spinlock_linux-inl.h', 211 '<(tcmalloc_dir)/src/base/spinlock_posix-inl.h', 212 '<(tcmalloc_dir)/src/base/spinlock_win32-inl.h', 213 '<(tcmalloc_dir)/src/base/stl_allocator.h', 214 '<(tcmalloc_dir)/src/base/thread_annotations.h', 215 '<(tcmalloc_dir)/src/debugallocation.cc', 216 '<(tcmalloc_dir)/src/getpc.h', 217 '<(tcmalloc_dir)/src/google/heap-checker.h', 218 '<(tcmalloc_dir)/src/google/heap-profiler.h', 219 '<(tcmalloc_dir)/src/google/malloc_extension_c.h', 220 '<(tcmalloc_dir)/src/google/malloc_hook.h', 221 '<(tcmalloc_dir)/src/google/malloc_hook_c.h', 222 '<(tcmalloc_dir)/src/google/profiler.h', 223 '<(tcmalloc_dir)/src/google/stacktrace.h', 224 '<(tcmalloc_dir)/src/memfs_malloc.cc', 225 '<(tcmalloc_dir)/src/packed-cache-inl.h', 226 '<(tcmalloc_dir)/src/page_heap_allocator.h', 227 '<(tcmalloc_dir)/src/pagemap.h', 228 '<(tcmalloc_dir)/src/stacktrace_config.h', 229 '<(tcmalloc_dir)/src/stacktrace_generic-inl.h', 230 '<(tcmalloc_dir)/src/stacktrace_libunwind-inl.h', 231 '<(tcmalloc_dir)/src/stacktrace_powerpc-inl.h', 232 '<(tcmalloc_dir)/src/stacktrace_win32-inl.h', 233 '<(tcmalloc_dir)/src/stacktrace_with_context.cc', 234 '<(tcmalloc_dir)/src/stacktrace_x86-inl.h', 235 '<(tcmalloc_dir)/src/stacktrace_x86_64-inl.h', 236 '<(tcmalloc_dir)/src/tcmalloc_guard.h', 237 '<(tcmalloc_dir)/src/windows/config.h', 238 '<(tcmalloc_dir)/src/windows/google/tcmalloc.h', 239 '<(tcmalloc_dir)/src/windows/get_mangled_names.cc', 240 '<(tcmalloc_dir)/src/windows/ia32_modrm_map.cc', 241 '<(tcmalloc_dir)/src/windows/ia32_opcode_map.cc', 242 '<(tcmalloc_dir)/src/windows/mingw.h', 243 '<(tcmalloc_dir)/src/windows/mini_disassembler.cc', 244 '<(tcmalloc_dir)/src/windows/mini_disassembler.h', 245 '<(tcmalloc_dir)/src/windows/mini_disassembler_types.h', 246 '<(tcmalloc_dir)/src/windows/override_functions.cc', 247 '<(tcmalloc_dir)/src/windows/patch_functions.cc', 248 '<(tcmalloc_dir)/src/windows/preamble_patcher.cc', 249 '<(tcmalloc_dir)/src/windows/preamble_patcher.h', 250 '<(tcmalloc_dir)/src/windows/preamble_patcher_with_stub.cc', 251 ], 252 'msvs_settings': { 253 # TODO(sgk): merge this with build/common.gypi settings 254 'VCLibrarianTool=': { 255 'AdditionalOptions': ['/ignore:4006,4221'], 256 'AdditionalLibraryDirectories': 257 ['<(DEPTH)/third_party/platformsdk_win2008_6_1/files/Lib'], 258 }, 259 'VCLinkerTool': { 260 'AdditionalOptions': ['/ignore:4006'], 261 }, 262 }, 263 'configurations': { 264 'Debug_Base': { 265 'msvs_settings': { 266 'VCCLCompilerTool': { 267 'RuntimeLibrary': '0', 268 }, 269 }, 270 }, 271 }, 272 'conditions': [ 273 ['OS=="win"', { 274 'defines': [ 275 ['PERFTOOLS_DLL_DECL', ''] 276 ], 277 'dependencies': [ 278 'libcmt', 279 ], 280 'include_dirs': [ 281 '<(tcmalloc_dir)/src/windows', 282 ], 283 'sources!': [ 284 '<(tcmalloc_dir)/src/base/linuxthreads.cc', 285 '<(tcmalloc_dir)/src/base/linuxthreads.h', 286 '<(tcmalloc_dir)/src/base/vdso_support.cc', 287 '<(tcmalloc_dir)/src/base/vdso_support.h', 288 '<(tcmalloc_dir)/src/maybe_threads.cc', 289 '<(tcmalloc_dir)/src/maybe_threads.h', 290 '<(tcmalloc_dir)/src/symbolize.h', 291 '<(tcmalloc_dir)/src/system-alloc.cc', 292 '<(tcmalloc_dir)/src/system-alloc.h', 293 294 # don't use linux forked version 295 '<(tcmalloc_dir)/src/tcmalloc_linux.cc', 296 '<(tcmalloc_dir)/src/symbolize_linux.cc', 297 298 # heap-profiler/checker/cpuprofiler 299 '<(tcmalloc_dir)/src/base/thread_lister.c', 300 '<(tcmalloc_dir)/src/base/thread_lister.h', 301 '<(tcmalloc_dir)/src/heap-checker-bcad.cc', 302 '<(tcmalloc_dir)/src/heap-checker.cc', 303 '<(tcmalloc_dir)/src/heap-profiler.cc', 304 '<(tcmalloc_dir)/src/memory_region_map.cc', 305 '<(tcmalloc_dir)/src/memory_region_map.h', 306 '<(tcmalloc_dir)/src/profiledata.cc', 307 '<(tcmalloc_dir)/src/profiledata.h', 308 '<(tcmalloc_dir)/src/profile-handler.cc', 309 '<(tcmalloc_dir)/src/profile-handler.h', 310 '<(tcmalloc_dir)/src/profiler.cc', 311 ], 312 }], 313 ['OS=="linux" or OS=="freebsd" or OS=="openbsd"', { 314 'sources!': [ 315 '<(tcmalloc_dir)/src/system-alloc.h', 316 '<(tcmalloc_dir)/src/windows/port.cc', 317 '<(tcmalloc_dir)/src/windows/port.h', 318 319 # TODO(willchan): Support allocator shim later on. 320 'allocator_shim.cc', 321 322 # TODO(willchan): support jemalloc on other platforms 323 # jemalloc files 324 '<(jemalloc_dir)/jemalloc.c', 325 '<(jemalloc_dir)/jemalloc.h', 326 '<(jemalloc_dir)/ql.h', 327 '<(jemalloc_dir)/qr.h', 328 '<(jemalloc_dir)/rb.h', 329 330 # TODO(willchan): Return to using this when page_heap_linux.cc 331 # becomes unnecessary. 332 '<(tcmalloc_dir)/src/page_heap.cc', 333 ], 334 # TODO(willchan): This is actually just a branched copy of the 335 # vanilla upstream page_heap.cc. The current forked copy of 336 # page_heap.cc has Windows-specific code in it so Linux can't 337 # use it. These need to be refactored so we can track changes 338 # to the upstream page_heap.cc without duplication. 339 'sources': [ 340 '<(tcmalloc_dir)/src/page_heap_linux.cc', 341 ], 342 'cflags!': [ 343 '-fvisibility=hidden', 344 ], 345 'link_settings': { 346 'ldflags': [ 347 # Don't let linker rip this symbol out, otherwise the heap&cpu 348 # profilers will not initialize properly on startup. 349 '-Wl,-uIsHeapProfilerRunning,-uProfilerStart', 350 # Do the same for heap leak checker. 351 '-Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jiiix,-u_Z22InitialMallocHook_SbrkPKvi', 352 '-Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_miiil,-u_Z22InitialMallocHook_SbrkPKvl', 353 ], 354 }, 355 }], 356 ], 357 }, 358 { 359 'target_name': 'allocator_unittests', 360 'type': 'executable', 361 'dependencies': [ 362 'allocator', 363 '../../testing/gtest.gyp:gtest', 364 ], 365 'include_dirs': [ 366 '.', 367 '<(tcmalloc_dir)/src/base', 368 '<(tcmalloc_dir)/src', 369 '../..', 370 ], 371 'msvs_guid': 'E99DA267-BE90-4F45-1294-6919DB2C9999', 372 'sources': [ 373 'unittest_utils.cc', 374 'allocator_unittests.cc', 375 ], 376 }, 377 ], 378 'conditions': [ 379 ['OS=="win"', { 380 'targets': [ 381 { 382 'target_name': 'libcmt', 383 'type': 'none', 384 'actions': [ 385 { 386 'action_name': 'libcmt', 387 'inputs': [ 388 'prep_libc.sh', 389 ], 390 'outputs': [ 391 '<(SHARED_INTERMEDIATE_DIR)/allocator/libcmt.lib', 392 ], 393 'action': [ 394 './prep_libc.sh', 395 '$(VCInstallDir)lib', 396 '<(SHARED_INTERMEDIATE_DIR)/allocator', 397 ], 398 }, 399 ], 400 }, 401 ], 402 }], 403 ], 404 } 405 406 # Local Variables: 407 # tab-width:2 408 # indent-tabs-mode:nil 409 # End: 410 # vim: set expandtab tabstop=2 shiftwidth=2: 411