blob: 9d91b175f1a32453fe0ac3450314e26860e7f559 [file] [log] [blame]
Nico Weberb80b0852019-08-01 22:03:011# Copyright 2019 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
Rob Hueber336a5ae2019-09-10 21:43:055import("//build/config/chromecast_build.gni")
Nico Weberb80b0852019-08-01 22:03:016import("//build/config/sanitizers/sanitizers.gni")
7
8# Temporarily disable tcmalloc on arm64 linux to get rid of compilation errors.
Sylvain Defresnefafffe82020-07-27 14:16:509if (is_android || is_apple || is_asan || is_lsan || is_tsan || is_msan ||
Yuki Shiino24622fa2020-08-26 12:01:0210 is_win || is_fuchsia ||
11 ((is_linux || is_chromeos) && target_cpu == "arm64") ||
Rob Hueber336a5ae2019-09-10 21:43:0512 (is_cast_audio_only && target_cpu == "arm")) {
Nico Weberb80b0852019-08-01 22:03:0113 _default_allocator = "none"
14} else {
15 _default_allocator = "tcmalloc"
16}
17
18# The debug CRT on Windows has some debug features that are incompatible with
19# the shim. NaCl in particular does seem to link some binaries statically
20# against the debug CRT with "is_nacl=false".
Sean McAllisterdeaa7402020-07-31 04:42:5421if ((is_linux || is_chromeos || is_android || is_apple ||
Nico Weberb80b0852019-08-01 22:03:0122 (is_win && !is_component_build && !is_debug)) && !is_asan && !is_hwasan &&
23 !is_lsan && !is_tsan && !is_msan) {
24 _default_use_allocator_shim = true
25} else {
26 _default_use_allocator_shim = false
27}
28
29declare_args() {
30 # Memory allocator to use. Set to "none" to use default allocator.
31 use_allocator = _default_allocator
32
33 # Causes all the allocations to be routed via allocator_shim.cc.
34 use_allocator_shim = _default_use_allocator_shim
Yuki Shiino24622fa2020-08-26 12:01:0235
Yuki Shiino90d5fe682020-09-02 11:03:5136 # Whether PartitionAlloc should be available for use or not.
37 # true makes PartitionAlloc linked to the executable or shared library and
38 # makes it available for use, but it doesn't mean that the default allocator
39 # is PartitionAlloc. PartitionAlloc may or may not be the default allocator.
40 #
41 # |use_allocator = "partition"| makes PartitionAlloc the default allocator
42 # but it's effective only when |use_partition_alloc = true|.
43 #
44 # TODO(lizeb, yukishiino): Determine if |use_partition_alloc| is necessary or
45 # not, and redesign or remove the flag accordingly. We may want to assert a
46 # possible conflict between |use_allocator = "partition"| and
47 # |use_partition_alloc = true| rather than prioritizing use_partition_alloc.
48 use_partition_alloc = !is_ios # Never use PartitionAlloc on iOS.
49}
50
51if (!use_partition_alloc && use_allocator == "partition") {
52 # If there is a conflict, prioritize |use_partition_alloc| over
53 # |use_allocator|.
54 use_allocator = "none"
Nico Weberb80b0852019-08-01 22:03:0155}
56
Benoit Lizea27feee2020-06-10 12:48:5257assert(use_allocator == "none" || use_allocator == "tcmalloc" ||
58 use_allocator == "partition")
59
60# Don't ship this configuration, not ready yet.
61assert(!(use_allocator == "partition" && is_official_build))
Nico Weberb80b0852019-08-01 22:03:0162
Benoit Lize6111210832020-08-26 13:38:0863assert(!is_win || use_allocator != "tcmalloc",
64 "Tcmalloc doesn't work on Windows.")
65assert(!is_mac || use_allocator != "tcmalloc",
66 "Tcmalloc doesn't work on macOS.")
67assert(!is_ios || use_allocator != "tcmalloc", "Tcmalloc doesn't work on iOS.")
Nico Weberb80b0852019-08-01 22:03:0168
Rohit Rao849b4262020-05-01 19:10:3469assert(
Yuki Shiino24622fa2020-08-26 12:01:0270 !use_allocator_shim || is_linux || is_chromeos || is_android || is_win ||
71 is_apple,
Rohit Rao849b4262020-05-01 19:10:3472 "use_allocator_shim works only on Android, iOS, Linux, macOS, and Windows.")
Nico Weberb80b0852019-08-01 22:03:0173
74if (is_win && use_allocator_shim) {
75 assert(!is_component_build,
76 "The allocator shim doesn't work for the component build on Windows.")
77}