OLD | NEW |
1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
4 | 4 |
5 static_library("allocator_extension_thunks") { | 5 import("//build/config/allocator.gni") |
| 6 |
| 7 # Only executables and not libraries should depend on the allocator target; |
| 8 # only the application (the final executable) knows what allocator makes sense. |
| 9 # This "allocator" meta-target will forward to the default allocator according |
| 10 # to the build settings. |
| 11 group("allocator") { |
| 12 if (use_allocator == "tcmalloc") { |
| 13 deps = [ ":tcmalloc" ] |
| 14 } |
| 15 } |
| 16 |
| 17 source_set("tcmalloc") { |
| 18 tcmalloc_dir = "//third_party/tcmalloc/chromium" |
| 19 |
| 20 sources = [ |
| 21 # Generated for our configuration from tcmalloc"s build |
| 22 # and checked in. |
| 23 "$tcmalloc_dir/src/config.h", |
| 24 "$tcmalloc_dir/src/config_android.h", |
| 25 "$tcmalloc_dir/src/config_linux.h", |
| 26 "$tcmalloc_dir/src/config_win.h", |
| 27 |
| 28 # tcmalloc native and forked files. |
| 29 "$tcmalloc_dir/src/base/abort.cc", |
| 30 "$tcmalloc_dir/src/base/abort.h", |
| 31 "$tcmalloc_dir/src/base/arm_instruction_set_select.h", |
| 32 # We don"t list dynamic_annotations.c since its copy is already |
| 33 # present in the dynamic_annotations target. |
| 34 "$tcmalloc_dir/src/base/elf_mem_image.cc", |
| 35 "$tcmalloc_dir/src/base/linuxthreads.cc", |
| 36 "$tcmalloc_dir/src/base/linuxthreads.h", |
| 37 "$tcmalloc_dir/src/base/logging.cc", |
| 38 "$tcmalloc_dir/src/base/logging.h", |
| 39 "$tcmalloc_dir/src/base/low_level_alloc.cc", |
| 40 "$tcmalloc_dir/src/base/low_level_alloc.h", |
| 41 "$tcmalloc_dir/src/base/spinlock.cc", |
| 42 "$tcmalloc_dir/src/base/spinlock.h", |
| 43 "$tcmalloc_dir/src/base/spinlock_internal.cc", |
| 44 "$tcmalloc_dir/src/base/spinlock_internal.h", |
| 45 "$tcmalloc_dir/src/base/synchronization_profiling.h", |
| 46 "$tcmalloc_dir/src/base/sysinfo.cc", |
| 47 "$tcmalloc_dir/src/base/sysinfo.h", |
| 48 "$tcmalloc_dir/src/base/thread_lister.c", |
| 49 "$tcmalloc_dir/src/base/thread_lister.h", |
| 50 "$tcmalloc_dir/src/base/vdso_support.cc", |
| 51 "$tcmalloc_dir/src/base/vdso_support.h", |
| 52 "$tcmalloc_dir/src/central_freelist.cc", |
| 53 "$tcmalloc_dir/src/central_freelist.h", |
| 54 "$tcmalloc_dir/src/common.cc", |
| 55 "$tcmalloc_dir/src/common.h", |
| 56 # #included by debugallocation_shim.cc |
| 57 #"$tcmalloc_dir/src/debugallocation.cc", |
| 58 "$tcmalloc_dir/src/deep-heap-profile.cc", |
| 59 "$tcmalloc_dir/src/deep-heap-profile.h", |
| 60 "$tcmalloc_dir/src/free_list.cc", |
| 61 "$tcmalloc_dir/src/free_list.h", |
| 62 "$tcmalloc_dir/src/heap-profile-table.cc", |
| 63 "$tcmalloc_dir/src/heap-profile-table.h", |
| 64 "$tcmalloc_dir/src/heap-profiler.cc", |
| 65 "$tcmalloc_dir/src/internal_logging.cc", |
| 66 "$tcmalloc_dir/src/internal_logging.h", |
| 67 "$tcmalloc_dir/src/linked_list.h", |
| 68 "$tcmalloc_dir/src/malloc_extension.cc", |
| 69 "$tcmalloc_dir/src/malloc_hook-inl.h", |
| 70 "$tcmalloc_dir/src/malloc_hook.cc", |
| 71 "$tcmalloc_dir/src/maybe_threads.cc", |
| 72 "$tcmalloc_dir/src/maybe_threads.h", |
| 73 "$tcmalloc_dir/src/memory_region_map.cc", |
| 74 "$tcmalloc_dir/src/memory_region_map.h", |
| 75 "$tcmalloc_dir/src/page_heap.cc", |
| 76 "$tcmalloc_dir/src/page_heap.h", |
| 77 "$tcmalloc_dir/src/profile-handler.cc", |
| 78 "$tcmalloc_dir/src/profile-handler.h", |
| 79 "$tcmalloc_dir/src/profiledata.cc", |
| 80 "$tcmalloc_dir/src/profiledata.h", |
| 81 "$tcmalloc_dir/src/profiler.cc", |
| 82 "$tcmalloc_dir/src/raw_printer.cc", |
| 83 "$tcmalloc_dir/src/raw_printer.h", |
| 84 "$tcmalloc_dir/src/sampler.cc", |
| 85 "$tcmalloc_dir/src/sampler.h", |
| 86 "$tcmalloc_dir/src/span.cc", |
| 87 "$tcmalloc_dir/src/span.h", |
| 88 "$tcmalloc_dir/src/stack_trace_table.cc", |
| 89 "$tcmalloc_dir/src/stack_trace_table.h", |
| 90 "$tcmalloc_dir/src/stacktrace.cc", |
| 91 "$tcmalloc_dir/src/static_vars.cc", |
| 92 "$tcmalloc_dir/src/static_vars.h", |
| 93 "$tcmalloc_dir/src/symbolize.cc", |
| 94 "$tcmalloc_dir/src/symbolize.h", |
| 95 "$tcmalloc_dir/src/system-alloc.cc", |
| 96 "$tcmalloc_dir/src/system-alloc.h", |
| 97 # #included by debugallocation_shim.cc |
| 98 #"$tcmalloc_dir/src/tcmalloc.cc", |
| 99 "$tcmalloc_dir/src/thread_cache.cc", |
| 100 "$tcmalloc_dir/src/thread_cache.h", |
| 101 "$tcmalloc_dir/src/windows/port.cc", |
| 102 "$tcmalloc_dir/src/windows/port.h", |
| 103 |
| 104 "allocator_shim.cc", |
| 105 "allocator_shim.h", |
| 106 "debugallocation_shim.cc", |
| 107 |
| 108 # These are both #included by allocator_shim for maximal linking. |
| 109 #"generic_allocators.cc", |
| 110 #"win_allocator.cc", |
| 111 ] |
| 112 |
| 113 # Disable the heap checker in tcmalloc. |
| 114 defines = [ "NO_HEAP_CHECK" ] |
| 115 |
| 116 include_dirs = [ |
| 117 ".", |
| 118 "$tcmalloc_dir/src/base", |
| 119 "$tcmalloc_dir/src", |
| 120 ] |
| 121 |
| 122 configs -= [ "//build/config/compiler:chromium_code" ] |
| 123 configs += [ "//build/config/compiler:no_chromium_code" ] |
| 124 |
| 125 if (is_win) { |
| 126 sources -= [ |
| 127 "$tcmalloc_dir/src/base/elf_mem_image.cc", |
| 128 "$tcmalloc_dir/src/base/elf_mem_image.h", |
| 129 "$tcmalloc_dir/src/base/linuxthreads.cc", |
| 130 "$tcmalloc_dir/src/base/linuxthreads.h", |
| 131 "$tcmalloc_dir/src/base/vdso_support.cc", |
| 132 "$tcmalloc_dir/src/base/vdso_support.h", |
| 133 "$tcmalloc_dir/src/maybe_threads.cc", |
| 134 "$tcmalloc_dir/src/maybe_threads.h", |
| 135 "$tcmalloc_dir/src/symbolize.h", |
| 136 "$tcmalloc_dir/src/system-alloc.cc", |
| 137 "$tcmalloc_dir/src/system-alloc.h", |
| 138 |
| 139 # included by allocator_shim.cc |
| 140 "debugallocation_shim.cc", |
| 141 |
| 142 # cpuprofiler |
| 143 "$tcmalloc_dir/src/base/thread_lister.c", |
| 144 "$tcmalloc_dir/src/base/thread_lister.h", |
| 145 "$tcmalloc_dir/src/profiledata.cc", |
| 146 "$tcmalloc_dir/src/profiledata.h", |
| 147 "$tcmalloc_dir/src/profile-handler.cc", |
| 148 "$tcmalloc_dir/src/profile-handler.h", |
| 149 "$tcmalloc_dir/src/profiler.cc", |
| 150 ] |
| 151 defines = [ "PERFTOOLS_DLL_DECL=" ] |
| 152 } |
| 153 if (is_linux || is_android) { |
| 154 sources -= [ |
| 155 "$tcmalloc_dir/src/system-alloc.h", |
| 156 "$tcmalloc_dir/src/windows/port.cc", |
| 157 "$tcmalloc_dir/src/windows/port.h", |
| 158 |
| 159 # TODO(willchan): Support allocator shim later on. |
| 160 "allocator_shim.cc", |
| 161 ] |
| 162 |
| 163 # We enable all warnings by default, but upstream disables a few. |
| 164 # Keep "-Wno-*" flags in sync with upstream by comparing against: |
| 165 # http://code.google.com/p/google-perftools/source/browse/trunk/Makefile.am |
| 166 cflags = [ |
| 167 "-Wno-sign-compare", |
| 168 "-Wno-unused-result", |
| 169 ] |
| 170 |
| 171 configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] |
| 172 |
| 173 ldflags = [ |
| 174 # Don"t let linker rip this symbol out, otherwise the heap&cpu |
| 175 # profilers will not initialize properly on startup. |
| 176 "-Wl,-uIsHeapProfilerRunning,-uProfilerStart", |
| 177 # Do the same for heap leak checker. |
| 178 "-Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_jii
ix,-u_Z22InitialMallocHook_SbrkPKvi", |
| 179 "-Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_mii
il,-u_Z22InitialMallocHook_SbrkPKvl", |
| 180 "-Wl,-u_ZN15HeapLeakChecker12IgnoreObjectEPKv,-u_ZN15HeapLeakChecker14UnIg
noreObjectEPKv", |
| 181 ] |
| 182 } |
| 183 |
| 184 # Make sure the allocation library is optimized as much as possible when |
| 185 # we"re in release mode. |
| 186 if (!is_debug) { |
| 187 configs -= [ "//build/config/compiler:optimize" ] |
| 188 configs += [ "//build/config/compiler:optimize_max" ] |
| 189 } |
| 190 |
| 191 deps = [ |
| 192 "//base/third_party/dynamic_annotations", |
| 193 ] |
| 194 |
| 195 if (is_win) { |
| 196 ldflags = [ "/ignore:4006:4221" ] |
| 197 } |
| 198 } |
| 199 |
| 200 source_set("allocator_extension_thunks") { |
6 visibility = "//base/*" | 201 visibility = "//base/*" |
7 sources = [ | 202 sources = [ |
8 "allocator_extension_thunks.cc", | 203 "allocator_extension_thunks.cc", |
9 "allocator_extension_thunks.h", | 204 "allocator_extension_thunks.h", |
10 ] | 205 ] |
11 } | 206 } |
OLD | NEW |