| OLD | NEW |
| (Empty) |
| 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 | |
| 3 # found in the LICENSE file. | |
| 4 | |
| 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 = [ | |
| 14 ":tcmalloc", | |
| 15 ] | |
| 16 } | |
| 17 } | |
| 18 | |
| 19 # This config and libc modification are only used on Windows. | |
| 20 if (is_win) { | |
| 21 import("//build/config/win/visual_studio_version.gni") | |
| 22 | |
| 23 config("nocmt") { | |
| 24 ldflags = [ | |
| 25 "/NODEFAULTLIB:libcmt", | |
| 26 "/NODEFAULTLIB:libcmtd", | |
| 27 ] | |
| 28 libs = [ rebase_path("$target_gen_dir/allocator/libcmt.lib") ] | |
| 29 } | |
| 30 | |
| 31 action("prep_libc") { | |
| 32 script = "prep_libc.py" | |
| 33 outputs = [ | |
| 34 "$target_gen_dir/allocator/libcmt.lib", | |
| 35 ] | |
| 36 args = [ | |
| 37 visual_studio_path + "/vc/lib", | |
| 38 rebase_path("$target_gen_dir/allocator"), | |
| 39 current_cpu, | |
| 40 ] | |
| 41 } | |
| 42 } | |
| 43 | |
| 44 if (use_allocator == "tcmalloc") { | |
| 45 # tcmalloc currently won't compile on Android. | |
| 46 source_set("tcmalloc") { | |
| 47 tcmalloc_dir = "//third_party/tcmalloc/chromium" | |
| 48 | |
| 49 # Don't check tcmalloc's includes. These files include various files like | |
| 50 # base/foo.h and they actually refer to tcmalloc's forked copy of base | |
| 51 # rather than the regular one, which confuses the header checker. | |
| 52 check_includes = false | |
| 53 | |
| 54 sources = [ | |
| 55 # Generated for our configuration from tcmalloc"s build | |
| 56 # and checked in. | |
| 57 "$tcmalloc_dir/src/config.h", | |
| 58 "$tcmalloc_dir/src/config_android.h", | |
| 59 "$tcmalloc_dir/src/config_linux.h", | |
| 60 "$tcmalloc_dir/src/config_win.h", | |
| 61 | |
| 62 # tcmalloc native and forked files. | |
| 63 "$tcmalloc_dir/src/base/abort.cc", | |
| 64 "$tcmalloc_dir/src/base/abort.h", | |
| 65 "$tcmalloc_dir/src/base/arm_instruction_set_select.h", | |
| 66 "$tcmalloc_dir/src/base/atomicops-internals-arm-generic.h", | |
| 67 "$tcmalloc_dir/src/base/atomicops-internals-arm-v6plus.h", | |
| 68 "$tcmalloc_dir/src/base/atomicops-internals-linuxppc.h", | |
| 69 "$tcmalloc_dir/src/base/atomicops-internals-macosx.h", | |
| 70 "$tcmalloc_dir/src/base/atomicops-internals-windows.h", | |
| 71 "$tcmalloc_dir/src/base/atomicops-internals-x86.cc", | |
| 72 "$tcmalloc_dir/src/base/atomicops-internals-x86.h", | |
| 73 "$tcmalloc_dir/src/base/atomicops.h", | |
| 74 "$tcmalloc_dir/src/base/basictypes.h", | |
| 75 "$tcmalloc_dir/src/base/commandlineflags.h", | |
| 76 "$tcmalloc_dir/src/base/cycleclock.h", | |
| 77 | |
| 78 # We don't list dynamic_annotations.c since its copy is already | |
| 79 # present in the dynamic_annotations target. | |
| 80 "$tcmalloc_dir/src/base/elf_mem_image.cc", | |
| 81 "$tcmalloc_dir/src/base/elf_mem_image.h", | |
| 82 "$tcmalloc_dir/src/base/linuxthreads.cc", | |
| 83 "$tcmalloc_dir/src/base/linuxthreads.h", | |
| 84 "$tcmalloc_dir/src/base/logging.cc", | |
| 85 "$tcmalloc_dir/src/base/logging.h", | |
| 86 "$tcmalloc_dir/src/base/low_level_alloc.cc", | |
| 87 "$tcmalloc_dir/src/base/low_level_alloc.h", | |
| 88 "$tcmalloc_dir/src/base/spinlock.cc", | |
| 89 "$tcmalloc_dir/src/base/spinlock.h", | |
| 90 "$tcmalloc_dir/src/base/spinlock_internal.cc", | |
| 91 "$tcmalloc_dir/src/base/spinlock_internal.h", | |
| 92 "$tcmalloc_dir/src/base/synchronization_profiling.h", | |
| 93 "$tcmalloc_dir/src/base/sysinfo.cc", | |
| 94 "$tcmalloc_dir/src/base/sysinfo.h", | |
| 95 "$tcmalloc_dir/src/base/thread_lister.c", | |
| 96 "$tcmalloc_dir/src/base/thread_lister.h", | |
| 97 "$tcmalloc_dir/src/base/vdso_support.cc", | |
| 98 "$tcmalloc_dir/src/base/vdso_support.h", | |
| 99 "$tcmalloc_dir/src/central_freelist.cc", | |
| 100 "$tcmalloc_dir/src/central_freelist.h", | |
| 101 "$tcmalloc_dir/src/common.cc", | |
| 102 "$tcmalloc_dir/src/common.h", | |
| 103 | |
| 104 # #included by debugallocation_shim.cc | |
| 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/heap-profile-table.cc", | |
| 111 "$tcmalloc_dir/src/heap-profile-table.h", | |
| 112 "$tcmalloc_dir/src/heap-profiler.cc", | |
| 113 "$tcmalloc_dir/src/internal_logging.cc", | |
| 114 "$tcmalloc_dir/src/internal_logging.h", | |
| 115 "$tcmalloc_dir/src/linked_list.h", | |
| 116 "$tcmalloc_dir/src/malloc_extension.cc", | |
| 117 "$tcmalloc_dir/src/malloc_hook-inl.h", | |
| 118 "$tcmalloc_dir/src/malloc_hook.cc", | |
| 119 "$tcmalloc_dir/src/maybe_threads.cc", | |
| 120 "$tcmalloc_dir/src/maybe_threads.h", | |
| 121 "$tcmalloc_dir/src/memory_region_map.cc", | |
| 122 "$tcmalloc_dir/src/memory_region_map.h", | |
| 123 "$tcmalloc_dir/src/page_heap.cc", | |
| 124 "$tcmalloc_dir/src/page_heap.h", | |
| 125 "$tcmalloc_dir/src/profile-handler.cc", | |
| 126 "$tcmalloc_dir/src/profile-handler.h", | |
| 127 "$tcmalloc_dir/src/profiledata.cc", | |
| 128 "$tcmalloc_dir/src/profiledata.h", | |
| 129 "$tcmalloc_dir/src/profiler.cc", | |
| 130 "$tcmalloc_dir/src/raw_printer.cc", | |
| 131 "$tcmalloc_dir/src/raw_printer.h", | |
| 132 "$tcmalloc_dir/src/sampler.cc", | |
| 133 "$tcmalloc_dir/src/sampler.h", | |
| 134 "$tcmalloc_dir/src/span.cc", | |
| 135 "$tcmalloc_dir/src/span.h", | |
| 136 "$tcmalloc_dir/src/stack_trace_table.cc", | |
| 137 "$tcmalloc_dir/src/stack_trace_table.h", | |
| 138 "$tcmalloc_dir/src/stacktrace.cc", | |
| 139 "$tcmalloc_dir/src/static_vars.cc", | |
| 140 "$tcmalloc_dir/src/static_vars.h", | |
| 141 "$tcmalloc_dir/src/symbolize.cc", | |
| 142 "$tcmalloc_dir/src/symbolize.h", | |
| 143 "$tcmalloc_dir/src/system-alloc.cc", | |
| 144 "$tcmalloc_dir/src/system-alloc.h", | |
| 145 | |
| 146 # #included by debugallocation_shim.cc | |
| 147 #"$tcmalloc_dir/src/tcmalloc.cc", | |
| 148 "$tcmalloc_dir/src/thread_cache.cc", | |
| 149 "$tcmalloc_dir/src/thread_cache.h", | |
| 150 "$tcmalloc_dir/src/windows/port.cc", | |
| 151 "$tcmalloc_dir/src/windows/port.h", | |
| 152 "allocator_shim.cc", | |
| 153 "debugallocation_shim.cc", | |
| 154 | |
| 155 # These are both #included by allocator_shim for maximal linking. | |
| 156 #"generic_allocators.cc", | |
| 157 #"win_allocator.cc", | |
| 158 ] | |
| 159 | |
| 160 # Disable the heap checker in tcmalloc. | |
| 161 defines = [ "NO_HEAP_CHECK" ] | |
| 162 | |
| 163 include_dirs = [ | |
| 164 ".", | |
| 165 "$tcmalloc_dir/src/base", | |
| 166 "$tcmalloc_dir/src", | |
| 167 ] | |
| 168 | |
| 169 configs -= [ "//build/config/compiler:chromium_code" ] | |
| 170 configs += [ "//build/config/compiler:no_chromium_code" ] | |
| 171 | |
| 172 deps = [] | |
| 173 | |
| 174 if (is_win) { | |
| 175 sources -= [ | |
| 176 "$tcmalloc_dir/src/base/elf_mem_image.cc", | |
| 177 "$tcmalloc_dir/src/base/elf_mem_image.h", | |
| 178 "$tcmalloc_dir/src/base/linuxthreads.cc", | |
| 179 "$tcmalloc_dir/src/base/linuxthreads.h", | |
| 180 "$tcmalloc_dir/src/base/vdso_support.cc", | |
| 181 "$tcmalloc_dir/src/base/vdso_support.h", | |
| 182 "$tcmalloc_dir/src/maybe_threads.cc", | |
| 183 "$tcmalloc_dir/src/maybe_threads.h", | |
| 184 "$tcmalloc_dir/src/symbolize.h", | |
| 185 "$tcmalloc_dir/src/system-alloc.cc", | |
| 186 "$tcmalloc_dir/src/system-alloc.h", | |
| 187 | |
| 188 # included by allocator_shim.cc | |
| 189 "debugallocation_shim.cc", | |
| 190 | |
| 191 # cpuprofiler | |
| 192 "$tcmalloc_dir/src/base/thread_lister.c", | |
| 193 "$tcmalloc_dir/src/base/thread_lister.h", | |
| 194 "$tcmalloc_dir/src/profile-handler.cc", | |
| 195 "$tcmalloc_dir/src/profile-handler.h", | |
| 196 "$tcmalloc_dir/src/profiledata.cc", | |
| 197 "$tcmalloc_dir/src/profiledata.h", | |
| 198 "$tcmalloc_dir/src/profiler.cc", | |
| 199 ] | |
| 200 defines += [ "PERFTOOLS_DLL_DECL=" ] | |
| 201 | |
| 202 configs -= [ | |
| 203 # Tcmalloc defines this itself, and we don't want duplicate definition | |
| 204 # warnings. | |
| 205 "//build/config/win:nominmax", | |
| 206 ] | |
| 207 | |
| 208 public_configs = [ ":nocmt" ] | |
| 209 | |
| 210 deps += [ ":prep_libc" ] | |
| 211 } | |
| 212 | |
| 213 if (is_linux || is_android) { | |
| 214 sources -= [ | |
| 215 "$tcmalloc_dir/src/system-alloc.h", | |
| 216 "$tcmalloc_dir/src/windows/port.cc", | |
| 217 "$tcmalloc_dir/src/windows/port.h", | |
| 218 | |
| 219 # TODO(willchan): Support allocator shim later on. | |
| 220 "allocator_shim.cc", | |
| 221 ] | |
| 222 | |
| 223 # We enable all warnings by default, but upstream disables a few. | |
| 224 # Keep "-Wno-*" flags in sync with upstream by comparing against: | |
| 225 # http://code.google.com/p/google-perftools/source/browse/trunk/Makefile.a
m | |
| 226 cflags = [ | |
| 227 "-Wno-sign-compare", | |
| 228 "-Wno-unused-result", | |
| 229 ] | |
| 230 | |
| 231 configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] | |
| 232 | |
| 233 ldflags = [ | |
| 234 # Don't let linker rip this symbol out, otherwise the heap&cpu | |
| 235 # profilers will not initialize properly on startup. | |
| 236 "-Wl,-uIsHeapProfilerRunning,-uProfilerStart", | |
| 237 | |
| 238 # Do the same for heap leak checker. | |
| 239 "-Wl,-u_Z21InitialMallocHook_NewPKvj,-u_Z22InitialMallocHook_MMapPKvS0_j
iiix,-u_Z22InitialMallocHook_SbrkPKvi", | |
| 240 "-Wl,-u_Z21InitialMallocHook_NewPKvm,-u_Z22InitialMallocHook_MMapPKvS0_m
iiil,-u_Z22InitialMallocHook_SbrkPKvl", | |
| 241 "-Wl,-u_ZN15HeapLeakChecker12IgnoreObjectEPKv,-u_ZN15HeapLeakChecker14Un
IgnoreObjectEPKv", | |
| 242 ] | |
| 243 } | |
| 244 | |
| 245 # Make sure the allocation library is optimized as much as possible when | |
| 246 # we"re in release mode. | |
| 247 if (!is_debug) { | |
| 248 configs -= [ "//build/config/compiler:optimize" ] | |
| 249 configs += [ "//build/config/compiler:optimize_max" ] | |
| 250 } | |
| 251 | |
| 252 deps += [ "//base/third_party/dynamic_annotations" ] | |
| 253 | |
| 254 if (is_win) { | |
| 255 ldflags = [ "/ignore:4006:4221" ] | |
| 256 } | |
| 257 } | |
| 258 } # !is_android | |
| 259 | |
| 260 source_set("allocator_extension_thunks") { | |
| 261 visibility = [ "//base/*" ] | |
| 262 sources = [ | |
| 263 "allocator_extension_thunks.cc", | |
| 264 "allocator_extension_thunks.h", | |
| 265 ] | |
| 266 if (is_android && !is_debug) { | |
| 267 configs -= [ "//build/config/compiler:optimize" ] | |
| 268 configs += [ "//build/config/compiler:optimize_max" ] | |
| 269 } | |
| 270 } | |
| OLD | NEW |