blob: 148e37d91063b70a244a6b5dc626b36b1c969025 [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.
9if (is_android || is_mac || is_ios || is_asan || is_lsan || is_tsan ||
Rob Hueber336a5ae2019-09-10 21:43:0510 is_msan || is_win || is_fuchsia || (is_linux && target_cpu == "arm64") ||
11 (is_cast_audio_only && target_cpu == "arm")) {
Nico Weberb80b0852019-08-01 22:03:0112 _default_allocator = "none"
13} else {
14 _default_allocator = "tcmalloc"
15}
16
17# The debug CRT on Windows has some debug features that are incompatible with
18# the shim. NaCl in particular does seem to link some binaries statically
19# against the debug CRT with "is_nacl=false".
Rohit Rao849b4262020-05-01 19:10:3420if ((is_linux || is_android || is_mac || is_ios ||
Nico Weberb80b0852019-08-01 22:03:0121 (is_win && !is_component_build && !is_debug)) && !is_asan && !is_hwasan &&
22 !is_lsan && !is_tsan && !is_msan) {
23 _default_use_allocator_shim = true
24} else {
25 _default_use_allocator_shim = false
26}
27
28declare_args() {
29 # Memory allocator to use. Set to "none" to use default allocator.
30 use_allocator = _default_allocator
31
32 # Causes all the allocations to be routed via allocator_shim.cc.
33 use_allocator_shim = _default_use_allocator_shim
34}
35
36assert(use_allocator == "none" || use_allocator == "tcmalloc")
37
38assert(!is_win || use_allocator == "none", "Tcmalloc doesn't work on Windows.")
39assert(!is_mac || use_allocator == "none", "Tcmalloc doesn't work on macOS.")
Rohit Rao9d0b15a2020-04-28 19:06:2740assert(!is_ios || use_allocator == "none", "Tcmalloc doesn't work on iOS.")
Nico Weberb80b0852019-08-01 22:03:0141
Rohit Rao849b4262020-05-01 19:10:3442assert(
43 !use_allocator_shim || is_linux || is_android || is_win || is_mac || is_ios,
44 "use_allocator_shim works only on Android, iOS, Linux, macOS, and Windows.")
Nico Weberb80b0852019-08-01 22:03:0145
46if (is_win && use_allocator_shim) {
47 assert(!is_component_build,
48 "The allocator shim doesn't work for the component build on Windows.")
49}