| 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 import("//build/buildflag_header.gni") | 5 import("//build/buildflag_header.gni") |
| 6 import("//build/config/allocator.gni") | 6 import("//build/config/allocator.gni") |
| 7 import("//build/config/compiler/compiler.gni") | 7 import("//build/config/compiler/compiler.gni") |
| 8 | 8 |
| 9 declare_args() { | 9 declare_args() { |
| 10 # Provide a way to force disable debugallocation in Debug builds, | 10 # Provide a way to force disable debugallocation in Debug builds, |
| 11 # e.g. for profiling (it's more rare to profile Debug builds, | 11 # e.g. for profiling (it's more rare to profile Debug builds, |
| 12 # but people sometimes need to do that). | 12 # but people sometimes need to do that). |
| 13 enable_debugallocation = is_debug | 13 enable_debugallocation = is_debug |
| 14 } | 14 } |
| 15 | 15 |
| 16 # The Windows-only allocator shim is only enabled for Release static builds, and | 16 # The Windows-only allocator shim is only enabled for Release static builds, and |
| 17 # is mutually exclusive with the generalized shim. | 17 # is mutually exclusive with the generalized shim. |
| 18 win_use_allocator_shim = is_win && !is_component_build && !is_debug && | 18 win_use_allocator_shim = is_win && !is_component_build && !is_debug && |
| 19 !use_experimental_allocator_shim && !is_asan | 19 !use_allocator_shim && !is_asan |
| 20 | 20 |
| 21 # This "allocator" meta-target will forward to the default allocator according | 21 # This "allocator" meta-target will forward to the default allocator according |
| 22 # to the build settings. | 22 # to the build settings. |
| 23 group("allocator") { | 23 group("allocator") { |
| 24 public_deps = [] | 24 public_deps = [] |
| 25 deps = [] | 25 deps = [] |
| 26 | 26 |
| 27 if (use_allocator == "tcmalloc") { | 27 if (use_allocator == "tcmalloc") { |
| 28 deps += [ ":tcmalloc" ] | 28 deps += [ ":tcmalloc" ] |
| 29 } | 29 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 47 | 47 |
| 48 config("tcmalloc_flags") { | 48 config("tcmalloc_flags") { |
| 49 defines = [] | 49 defines = [] |
| 50 if (enable_debugallocation) { | 50 if (enable_debugallocation) { |
| 51 defines += [ | 51 defines += [ |
| 52 # Use debugallocation for Debug builds to catch problems early | 52 # Use debugallocation for Debug builds to catch problems early |
| 53 # and cleanly, http://crbug.com/30715 . | 53 # and cleanly, http://crbug.com/30715 . |
| 54 "TCMALLOC_FOR_DEBUGALLOCATION", | 54 "TCMALLOC_FOR_DEBUGALLOCATION", |
| 55 ] | 55 ] |
| 56 } | 56 } |
| 57 if (use_experimental_allocator_shim) { | 57 if (use_allocator_shim) { |
| 58 defines += [ "TCMALLOC_DONT_REPLACE_SYSTEM_ALLOC" ] | 58 defines += [ "TCMALLOC_DONT_REPLACE_SYSTEM_ALLOC" ] |
| 59 } | 59 } |
| 60 if (is_clang) { | 60 if (is_clang) { |
| 61 cflags = [ | 61 cflags = [ |
| 62 # tcmalloc initializes some fields in the wrong order. | 62 # tcmalloc initializes some fields in the wrong order. |
| 63 "-Wno-reorder", | 63 "-Wno-reorder", |
| 64 | 64 |
| 65 # tcmalloc contains some unused local template specializations. | 65 # tcmalloc contains some unused local template specializations. |
| 66 "-Wno-unused-function", | 66 "-Wno-unused-function", |
| 67 | 67 |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 "$tcmalloc_dir/src/windows/port.cc", | 254 "$tcmalloc_dir/src/windows/port.cc", |
| 255 "$tcmalloc_dir/src/windows/port.h", | 255 "$tcmalloc_dir/src/windows/port.h", |
| 256 ] | 256 ] |
| 257 | 257 |
| 258 # Compiling tcmalloc with -fvisibility=default is only necessary when | 258 # Compiling tcmalloc with -fvisibility=default is only necessary when |
| 259 # not using the allocator shim, which provides the correct visibility | 259 # not using the allocator shim, which provides the correct visibility |
| 260 # annotations for those symbols which need to be exported (see | 260 # annotations for those symbols which need to be exported (see |
| 261 # //base/allocator/allocator_shim_override_glibc_weak_symbols.h and | 261 # //base/allocator/allocator_shim_override_glibc_weak_symbols.h and |
| 262 # //base/allocator/allocator_shim_internals.h for the definition of | 262 # //base/allocator/allocator_shim_internals.h for the definition of |
| 263 # SHIM_ALWAYS_EXPORT). | 263 # SHIM_ALWAYS_EXPORT). |
| 264 if (!use_experimental_allocator_shim) { | 264 if (!use_allocator_shim) { |
| 265 configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] | 265 configs -= [ "//build/config/gcc:symbol_visibility_hidden" ] |
| 266 configs += [ "//build/config/gcc:symbol_visibility_default" ] | 266 configs += [ "//build/config/gcc:symbol_visibility_default" ] |
| 267 } | 267 } |
| 268 | 268 |
| 269 ldflags = [ | 269 ldflags = [ |
| 270 # Don't let linker rip this symbol out, otherwise the heap&cpu | 270 # Don't let linker rip this symbol out, otherwise the heap&cpu |
| 271 # profilers will not initialize properly on startup. | 271 # profilers will not initialize properly on startup. |
| 272 "-Wl,-uIsHeapProfilerRunning,-uProfilerStart", | 272 "-Wl,-uIsHeapProfilerRunning,-uProfilerStart", |
| 273 | 273 |
| 274 # Do the same for heap leak checker. | 274 # Do the same for heap leak checker. |
| (...skipping 10 matching lines...) Expand all Loading... |
| 285 configs += [ "//build/config/compiler:optimize_max" ] | 285 configs += [ "//build/config/compiler:optimize_max" ] |
| 286 } | 286 } |
| 287 | 287 |
| 288 deps += [ "//base/third_party/dynamic_annotations" ] | 288 deps += [ "//base/third_party/dynamic_annotations" ] |
| 289 } | 289 } |
| 290 } # use_allocator == "tcmalloc" | 290 } # use_allocator == "tcmalloc" |
| 291 | 291 |
| 292 buildflag_header("features") { | 292 buildflag_header("features") { |
| 293 header = "features.h" | 293 header = "features.h" |
| 294 flags = [ | 294 flags = [ |
| 295 "USE_EXPERIMENTAL_ALLOCATOR_SHIM=$use_experimental_allocator_shim", | 295 "USE_ALLOCATOR_SHIM=$use_allocator_shim", |
| 296 "ENABLE_WIN_ALLOCATOR_SHIM_TESTS=($use_experimental_allocator_shim || $win_u
se_allocator_shim)", | 296 "ENABLE_WIN_ALLOCATOR_SHIM_TESTS=($use_allocator_shim || $win_use_allocator_
shim)", |
| 297 ] | 297 ] |
| 298 } | 298 } |
| 299 | 299 |
| 300 # Used to shim malloc symbols on Android. see //base/allocator/README.md. | 300 # Used to shim malloc symbols on Android. see //base/allocator/README.md. |
| 301 config("wrap_malloc_symbols") { | 301 config("wrap_malloc_symbols") { |
| 302 ldflags = [ | 302 ldflags = [ |
| 303 "-Wl,-wrap,calloc", | 303 "-Wl,-wrap,calloc", |
| 304 "-Wl,-wrap,free", | 304 "-Wl,-wrap,free", |
| 305 "-Wl,-wrap,malloc", | 305 "-Wl,-wrap,malloc", |
| 306 "-Wl,-wrap,memalign", | 306 "-Wl,-wrap,memalign", |
| 307 "-Wl,-wrap,posix_memalign", | 307 "-Wl,-wrap,posix_memalign", |
| 308 "-Wl,-wrap,pvalloc", | 308 "-Wl,-wrap,pvalloc", |
| 309 "-Wl,-wrap,realloc", | 309 "-Wl,-wrap,realloc", |
| 310 "-Wl,-wrap,valloc", | 310 "-Wl,-wrap,valloc", |
| 311 ] | 311 ] |
| 312 } | 312 } |
| OLD | NEW |