• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2014 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
5import("//build/config/sanitizers/sanitizers.gni")
6
7# Temporarily disable tcmalloc on arm64 linux to get rid of compilation errors.
8if (is_ohos || is_mac || is_asan || is_lsan || is_tsan || is_msan || is_win ||
9    (is_linux && target_cpu == "arm64")) {
10  _default_allocator = "none"
11} else {
12  _default_allocator = "tcmalloc"
13}
14
15# The debug CRT on Windows has some debug features that are incompatible with
16# the shim. NaCl in particular does seem to link some binaries statically
17# against the debug CRT with "is_nacl=false".
18if ((is_linux || is_ohos || is_mac ||
19     (is_win && !is_component_build && !is_debug)) && !is_asan && !is_lsan &&
20    !is_tsan && !is_msan) {
21  _default_use_allocator_shim = true
22} else {
23  _default_use_allocator_shim = false
24}
25
26declare_args() {
27  # Memory allocator to use. Set to "none" to use default allocator.
28  use_allocator = _default_allocator
29
30  # Causes all the allocations to be routed via allocator_shim.cc.
31  use_allocator_shim = _default_use_allocator_shim
32
33  # Partition alloc is included by default except iOS.
34  use_partition_alloc = true
35
36  # Use the new tcmalloc. It's relevant only when use_allocator == "tcmalloc".
37  use_new_tcmalloc = false
38}
39
40if (is_nacl) {
41  # Turn off the build flag for NaCL builds to minimize confusion, as NaCL
42  # doesn't support the heap shim.
43  use_allocator_shim = false
44}
45
46assert(use_allocator == "none" || use_allocator == "tcmalloc")
47
48assert(!is_win || use_allocator == "none", "Tcmalloc doesn't work on Windows.")
49assert(!is_mac || use_allocator == "none", "Tcmalloc doesn't work on macOS.")
50
51assert(
52    !use_allocator_shim || is_linux || is_ohos || is_win || is_mac,
53    "use_allocator_shim is supported only on Linux, Windows and macOS targets")
54
55if (is_win && use_allocator_shim) {
56  assert(!is_component_build,
57         "The allocator shim doesn't work for the component build on Windows.")
58}
59