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 |
9 declare_args() { | 13 declare_args() { |
10 # Provide a way to force disable debugallocation in Debug builds, | 14 # Provide a way to force disable debugallocation in Debug builds, |
11 # e.g. for profiling (it's more rare to profile Debug builds, | 15 # e.g. for profiling (it's more rare to profile Debug builds, |
12 # but people sometimes need to do that). | 16 # but people sometimes need to do that). |
13 enable_debugallocation = is_debug | 17 enable_debugallocation = is_debug |
14 } | 18 } |
15 | 19 |
16 # Allocator shim is only enabled for Release static builds. | |
17 win_use_allocator_shim = is_win && !is_component_build && !is_debug | |
18 | |
19 # This "allocator" meta-target will forward to the default allocator according | 20 # This "allocator" meta-target will forward to the default allocator according |
20 # to the build settings. | 21 # to the build settings. |
21 group("allocator") { | 22 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 if (win_use_allocator_shim) { | 29 # This condition expresses the win_use_allocator_shim in the GYP build. |
30 public_deps += [ ":allocator_shim" ] | 30 if (is_win && !is_component_build && visual_studio_version != "2015") { |
| 31 deps += [ ":allocator_shim" ] |
| 32 all_dependent_configs = [ ":nocmt" ] |
31 } | 33 } |
32 } | 34 } |
33 | 35 |
34 # This config defines ALLOCATOR_SHIM in the same conditions that the allocator | 36 # This config defines ALLOCATOR_SHIM in the same conditions that the allocator |
35 # shim will be used by the allocator target. | 37 # shim will be used by the allocator target. |
36 # | 38 # |
37 # TODO(brettw) this is only used in one place and is kind of mess, because it | 39 # TODO(brettw) this is only used in one place and is kind of mess, because it |
38 # assumes that the library using it will eventually be linked with | 40 # assumes that the library using it will eventually be linked with |
39 # //base/allocator in the default way. Clean this up and delete this. | 41 # //base/allocator in the default way. Clean this up and delete this. |
40 config("allocator_shim_define") { | 42 config("allocator_shim_define") { |
41 if (win_use_allocator_shim) { | 43 if (is_win && !is_component_build && visual_studio_version != "2015") { |
42 defines = [ "ALLOCATOR_SHIM" ] | 44 defines = [ "ALLOCATOR_SHIM" ] |
43 } | 45 } |
44 } | 46 } |
45 | 47 |
46 config("tcmalloc_flags") { | 48 config("tcmalloc_flags") { |
47 defines = [] | 49 defines = [] |
48 if (enable_debugallocation) { | 50 if (enable_debugallocation) { |
49 defines += [ | 51 defines += [ |
50 # Use debugallocation for Debug builds to catch problems early | 52 # Use debugallocation for Debug builds to catch problems early |
51 # and cleanly, http://crbug.com/30715 . | 53 # and cleanly, http://crbug.com/30715 . |
(...skipping 15 matching lines...) Expand all Loading... |
67 # typedefs. | 69 # typedefs. |
68 "-Wno-unused-local-typedefs", | 70 "-Wno-unused-local-typedefs", |
69 | 71 |
70 # for magic2_ in debugallocation.cc (only built in Debug builds) | 72 # for magic2_ in debugallocation.cc (only built in Debug builds) |
71 # typedefs. | 73 # typedefs. |
72 "-Wno-unused-private-field", | 74 "-Wno-unused-private-field", |
73 ] | 75 ] |
74 } | 76 } |
75 } | 77 } |
76 | 78 |
77 # This config is only used on Windows static release builds for the | 79 # This config and libc modification are only used on Windows. |
78 # allocator shim. | 80 if (is_win) { |
79 if (win_use_allocator_shim) { | 81 config("nocmt") { |
80 source_set("allocator_shim") { | 82 ldflags = [ |
81 sources = [ | 83 "/NODEFAULTLIB:libcmt", |
82 "allocator_shim_win.cc", | 84 "/NODEFAULTLIB:libcmtd", |
83 "allocator_shim_win.h", | |
84 ] | 85 ] |
85 configs += [ ":allocator_shim_define" ] | 86 libs = [ rebase_path("$target_gen_dir/allocator/libcmt.lib") ] |
| 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 } |
86 } | 119 } |
87 } | 120 } |
88 | 121 |
89 if (use_allocator == "tcmalloc") { | 122 if (use_allocator == "tcmalloc") { |
90 # tcmalloc currently won't compile on Android. | 123 # tcmalloc currently won't compile on Android. |
91 source_set("tcmalloc") { | 124 source_set("tcmalloc") { |
92 tcmalloc_dir = "//third_party/tcmalloc/chromium" | 125 tcmalloc_dir = "//third_party/tcmalloc/chromium" |
93 | 126 |
94 # Don't check tcmalloc's includes. These files include various files like | 127 # Don't check tcmalloc's includes. These files include various files like |
95 # base/foo.h and they actually refer to tcmalloc's forked copy of base | 128 # 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... |
285 "allocator_shim_override_glibc_weak_symbols.h", | 318 "allocator_shim_override_glibc_weak_symbols.h", |
286 ] | 319 ] |
287 deps = [ | 320 deps = [ |
288 ":tcmalloc", | 321 ":tcmalloc", |
289 ] | 322 ] |
290 } else if (is_linux && use_allocator == "none") { | 323 } else if (is_linux && use_allocator == "none") { |
291 sources += [ "allocator_shim_default_dispatch_to_glibc.cc" ] | 324 sources += [ "allocator_shim_default_dispatch_to_glibc.cc" ] |
292 } | 325 } |
293 } | 326 } |
294 } | 327 } |
OLD | NEW |