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 | |
17 # is mutually exclusive with the generalized shim. | |
18 win_use_allocator_shim = is_win && !is_component_build && !is_debug && | |
19 !use_allocator_shim && !is_asan | |
20 | |
21 # This "allocator" meta-target will forward to the default allocator according | 16 # This "allocator" meta-target will forward to the default allocator according |
22 # to the build settings. | 17 # to the build settings. |
23 group("allocator") { | 18 group("allocator") { |
24 public_deps = [] | 19 public_deps = [] |
25 deps = [] | 20 deps = [] |
26 | 21 |
27 if (use_allocator == "tcmalloc") { | 22 if (use_allocator == "tcmalloc") { |
28 deps += [ ":tcmalloc" ] | 23 deps += [ ":tcmalloc" ] |
29 } | 24 } |
30 | |
31 if (win_use_allocator_shim) { | |
32 public_deps += [ ":allocator_shim" ] | |
33 } | |
34 } | |
35 | |
36 # This config defines ALLOCATOR_SHIM in the same conditions that the allocator | |
37 # shim will be used by the allocator target. | |
38 # | |
39 # TODO(brettw) this is only used in one place and is kind of mess, because it | |
40 # assumes that the library using it will eventually be linked with | |
41 # //base/allocator in the default way. Clean this up and delete this. | |
42 config("allocator_shim_define") { | |
43 if (win_use_allocator_shim) { | |
44 defines = [ "ALLOCATOR_SHIM" ] | |
45 } | |
46 } | 25 } |
47 | 26 |
48 config("tcmalloc_flags") { | 27 config("tcmalloc_flags") { |
49 defines = [] | 28 defines = [] |
50 if (enable_debugallocation) { | 29 if (enable_debugallocation) { |
51 defines += [ | 30 defines += [ |
52 # Use debugallocation for Debug builds to catch problems early | 31 # Use debugallocation for Debug builds to catch problems early |
53 # and cleanly, http://crbug.com/30715 . | 32 # and cleanly, http://crbug.com/30715 . |
54 "TCMALLOC_FOR_DEBUGALLOCATION", | 33 "TCMALLOC_FOR_DEBUGALLOCATION", |
55 ] | 34 ] |
(...skipping 23 matching lines...) Expand all Loading... |
79 # We enable all warnings by default, but upstream disables a few. | 58 # We enable all warnings by default, but upstream disables a few. |
80 # Keep "-Wno-*" flags in sync with upstream by comparing against: | 59 # Keep "-Wno-*" flags in sync with upstream by comparing against: |
81 # http://code.google.com/p/google-perftools/source/browse/trunk/Makefile.am | 60 # http://code.google.com/p/google-perftools/source/browse/trunk/Makefile.am |
82 cflags += [ | 61 cflags += [ |
83 "-Wno-sign-compare", | 62 "-Wno-sign-compare", |
84 "-Wno-unused-result", | 63 "-Wno-unused-result", |
85 ] | 64 ] |
86 } | 65 } |
87 } | 66 } |
88 | 67 |
89 # This config is only used on Windows static release builds for the | |
90 # allocator shim. | |
91 if (win_use_allocator_shim) { | |
92 source_set("allocator_shim") { | |
93 sources = [ | |
94 "allocator_shim_win.cc", | |
95 "allocator_shim_win.h", | |
96 "winheap_stubs_win.cc", | |
97 "winheap_stubs_win.h", | |
98 ] | |
99 configs += [ ":allocator_shim_define" ] | |
100 } | |
101 } | |
102 | |
103 if (use_allocator == "tcmalloc") { | 68 if (use_allocator == "tcmalloc") { |
104 # tcmalloc currently won't compile on Android. | 69 # tcmalloc currently won't compile on Android. |
105 source_set("tcmalloc") { | 70 source_set("tcmalloc") { |
106 tcmalloc_dir = "//third_party/tcmalloc/chromium" | 71 tcmalloc_dir = "//third_party/tcmalloc/chromium" |
107 | 72 |
108 # Don't check tcmalloc's includes. These files include various files like | 73 # Don't check tcmalloc's includes. These files include various files like |
109 # base/foo.h and they actually refer to tcmalloc's forked copy of base | 74 # base/foo.h and they actually refer to tcmalloc's forked copy of base |
110 # rather than the regular one, which confuses the header checker. | 75 # rather than the regular one, which confuses the header checker. |
111 check_includes = false | 76 check_includes = false |
112 | 77 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 configs -= [ "//build/config/compiler:default_optimization" ] | 249 configs -= [ "//build/config/compiler:default_optimization" ] |
285 configs += [ "//build/config/compiler:optimize_max" ] | 250 configs += [ "//build/config/compiler:optimize_max" ] |
286 } | 251 } |
287 | 252 |
288 deps += [ "//base/third_party/dynamic_annotations" ] | 253 deps += [ "//base/third_party/dynamic_annotations" ] |
289 } | 254 } |
290 } # use_allocator == "tcmalloc" | 255 } # use_allocator == "tcmalloc" |
291 | 256 |
292 buildflag_header("features") { | 257 buildflag_header("features") { |
293 header = "features.h" | 258 header = "features.h" |
294 flags = [ | 259 flags = [ "USE_ALLOCATOR_SHIM=$use_allocator_shim" ] |
295 "USE_ALLOCATOR_SHIM=$use_allocator_shim", | |
296 "ENABLE_WIN_ALLOCATOR_SHIM_TESTS=($use_allocator_shim || $win_use_allocator_
shim)", | |
297 ] | |
298 } | 260 } |
299 | 261 |
300 # Used to shim malloc symbols on Android. see //base/allocator/README.md. | 262 # Used to shim malloc symbols on Android. see //base/allocator/README.md. |
301 config("wrap_malloc_symbols") { | 263 config("wrap_malloc_symbols") { |
302 ldflags = [ | 264 ldflags = [ |
303 "-Wl,-wrap,calloc", | 265 "-Wl,-wrap,calloc", |
304 "-Wl,-wrap,free", | 266 "-Wl,-wrap,free", |
305 "-Wl,-wrap,malloc", | 267 "-Wl,-wrap,malloc", |
306 "-Wl,-wrap,memalign", | 268 "-Wl,-wrap,memalign", |
307 "-Wl,-wrap,posix_memalign", | 269 "-Wl,-wrap,posix_memalign", |
308 "-Wl,-wrap,pvalloc", | 270 "-Wl,-wrap,pvalloc", |
309 "-Wl,-wrap,realloc", | 271 "-Wl,-wrap,realloc", |
310 "-Wl,-wrap,valloc", | 272 "-Wl,-wrap,valloc", |
311 ] | 273 ] |
312 } | 274 } |
OLD | NEW |