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 if (is_win) { | |
10 import("//build/config/win/visual_studio_version.gni") | |
11 } | |
12 | |
13 declare_args() { | 9 declare_args() { |
14 # Provide a way to force disable debugallocation in Debug builds, | 10 # Provide a way to force disable debugallocation in Debug builds, |
15 # 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, |
16 # but people sometimes need to do that). | 12 # but people sometimes need to do that). |
17 enable_debugallocation = is_debug | 13 enable_debugallocation = is_debug |
18 } | 14 } |
19 | 15 |
| 16 # Allocator shim is only enabled for Release static builds. |
| 17 win_use_allocator_shim = is_win && !is_component_build && !is_debug |
| 18 |
20 # This "allocator" meta-target will forward to the default allocator according | 19 # This "allocator" meta-target will forward to the default allocator according |
21 # to the build settings. | 20 # to the build settings. |
22 group("allocator") { | 21 group("allocator") { |
| 22 public_deps = [] |
23 deps = [] | 23 deps = [] |
24 | 24 |
25 if (use_allocator == "tcmalloc") { | 25 if (use_allocator == "tcmalloc") { |
26 deps += [ ":tcmalloc" ] | 26 deps += [ ":tcmalloc" ] |
27 } | 27 } |
28 | 28 |
29 # This condition expresses the win_use_allocator_shim in the GYP build. | 29 if (win_use_allocator_shim) { |
30 if (is_win && !is_component_build && visual_studio_version != "2015") { | 30 public_deps += [ ":allocator_shim" ] |
31 deps += [ ":allocator_shim" ] | |
32 all_dependent_configs = [ ":nocmt" ] | |
33 } | 31 } |
34 } | 32 } |
35 | 33 |
36 # This config defines ALLOCATOR_SHIM in the same conditions that the allocator | 34 # This config defines ALLOCATOR_SHIM in the same conditions that the allocator |
37 # shim will be used by the allocator target. | 35 # shim will be used by the allocator target. |
38 # | 36 # |
39 # TODO(brettw) this is only used in one place and is kind of mess, because it | 37 # 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 | 38 # assumes that the library using it will eventually be linked with |
41 # //base/allocator in the default way. Clean this up and delete this. | 39 # //base/allocator in the default way. Clean this up and delete this. |
42 config("allocator_shim_define") { | 40 config("allocator_shim_define") { |
43 if (is_win && !is_component_build && visual_studio_version != "2015") { | 41 if (win_use_allocator_shim) { |
44 defines = [ "ALLOCATOR_SHIM" ] | 42 defines = [ "ALLOCATOR_SHIM" ] |
45 } | 43 } |
46 } | 44 } |
47 | 45 |
48 config("tcmalloc_flags") { | 46 config("tcmalloc_flags") { |
49 defines = [] | 47 defines = [] |
50 if (enable_debugallocation) { | 48 if (enable_debugallocation) { |
51 defines += [ | 49 defines += [ |
52 # Use debugallocation for Debug builds to catch problems early | 50 # Use debugallocation for Debug builds to catch problems early |
53 # and cleanly, http://crbug.com/30715 . | 51 # and cleanly, http://crbug.com/30715 . |
(...skipping 15 matching lines...) Expand all Loading... |
69 # typedefs. | 67 # typedefs. |
70 "-Wno-unused-local-typedefs", | 68 "-Wno-unused-local-typedefs", |
71 | 69 |
72 # for magic2_ in debugallocation.cc (only built in Debug builds) | 70 # for magic2_ in debugallocation.cc (only built in Debug builds) |
73 # typedefs. | 71 # typedefs. |
74 "-Wno-unused-private-field", | 72 "-Wno-unused-private-field", |
75 ] | 73 ] |
76 } | 74 } |
77 } | 75 } |
78 | 76 |
79 # This config and libc modification are only used on Windows. | 77 # This config is only used on Windows static release builds for the |
80 if (is_win) { | 78 # allocator shim. |
81 config("nocmt") { | 79 if (win_use_allocator_shim) { |
82 ldflags = [ | 80 source_set("allocator_shim") { |
83 "/NODEFAULTLIB:libcmt", | 81 sources = [ |
84 "/NODEFAULTLIB:libcmtd", | 82 "allocator_shim_win.cc", |
| 83 "allocator_shim_win.h", |
85 ] | 84 ] |
86 libs = [ rebase_path("$target_gen_dir/allocator/libcmt.lib") ] | 85 configs += [ ":allocator_shim_define" ] |
87 } | |
88 | |
89 if (!is_component_build && visual_studio_version != "2015") { | |
90 action("prep_libc") { | |
91 script = "prep_libc.py" | |
92 outputs = [ | |
93 "$target_gen_dir/allocator/libcmt.lib", | |
94 ] | |
95 args = [ | |
96 visual_studio_path + "/vc/lib", | |
97 rebase_path("$target_gen_dir/allocator"), | |
98 current_cpu, | |
99 | |
100 # The environment file in the build directory. This is required because | |
101 # the Windows toolchain setup saves the VC paths and such so that | |
102 # running "mc.exe" will work with the configured toolchain. This file | |
103 # is in the root build dir. | |
104 "environment.$current_cpu", | |
105 ] | |
106 } | |
107 | |
108 source_set("allocator_shim") { | |
109 sources = [ | |
110 "allocator_shim_win.cc", | |
111 ] | |
112 configs -= [ "//build/config/compiler:chromium_code" ] | |
113 configs += [ "//build/config/compiler:no_chromium_code" ] | |
114 | |
115 deps = [ | |
116 ":prep_libc", | |
117 ] | |
118 } | |
119 } | 86 } |
120 } | 87 } |
121 | 88 |
122 if (use_allocator == "tcmalloc") { | 89 if (use_allocator == "tcmalloc") { |
123 # tcmalloc currently won't compile on Android. | 90 # tcmalloc currently won't compile on Android. |
124 source_set("tcmalloc") { | 91 source_set("tcmalloc") { |
125 tcmalloc_dir = "//third_party/tcmalloc/chromium" | 92 tcmalloc_dir = "//third_party/tcmalloc/chromium" |
126 | 93 |
127 # Don't check tcmalloc's includes. These files include various files like | 94 # Don't check tcmalloc's includes. These files include various files like |
128 # base/foo.h and they actually refer to tcmalloc's forked copy of base | 95 # base/foo.h and they actually refer to tcmalloc's forked copy of base |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 "allocator_shim_override_glibc_weak_symbols.h", | 285 "allocator_shim_override_glibc_weak_symbols.h", |
319 ] | 286 ] |
320 deps = [ | 287 deps = [ |
321 ":tcmalloc", | 288 ":tcmalloc", |
322 ] | 289 ] |
323 } else if (is_linux && use_allocator == "none") { | 290 } else if (is_linux && use_allocator == "none") { |
324 sources += [ "allocator_shim_default_dispatch_to_glibc.cc" ] | 291 sources += [ "allocator_shim_default_dispatch_to_glibc.cc" ] |
325 } | 292 } |
326 } | 293 } |
327 } | 294 } |
OLD | NEW |