Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 1 | # 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 Hueber | 336a5ae | 2019-09-10 21:43:05 | [diff] [blame] | 5 | import("//build/config/chromecast_build.gni") |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 6 | import("//build/config/sanitizers/sanitizers.gni") |
| 7 | |
| 8 | # Temporarily disable tcmalloc on arm64 linux to get rid of compilation errors. |
| 9 | if (is_android || is_mac || is_ios || is_asan || is_lsan || is_tsan || |
Rob Hueber | 336a5ae | 2019-09-10 21:43:05 | [diff] [blame] | 10 | is_msan || is_win || is_fuchsia || (is_linux && target_cpu == "arm64") || |
| 11 | (is_cast_audio_only && target_cpu == "arm")) { |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 12 | _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 Rao | 849b426 | 2020-05-01 19:10:34 | [diff] [blame^] | 20 | if ((is_linux || is_android || is_mac || is_ios || |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 21 | (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 | |
| 28 | declare_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 | |
| 36 | assert(use_allocator == "none" || use_allocator == "tcmalloc") |
| 37 | |
| 38 | assert(!is_win || use_allocator == "none", "Tcmalloc doesn't work on Windows.") |
| 39 | assert(!is_mac || use_allocator == "none", "Tcmalloc doesn't work on macOS.") |
Rohit Rao | 9d0b15a | 2020-04-28 19:06:27 | [diff] [blame] | 40 | assert(!is_ios || use_allocator == "none", "Tcmalloc doesn't work on iOS.") |
Nico Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 41 | |
Rohit Rao | 849b426 | 2020-05-01 19:10:34 | [diff] [blame^] | 42 | assert( |
| 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 Weber | b80b085 | 2019-08-01 22:03:01 | [diff] [blame] | 45 | |
| 46 | if (is_win && use_allocator_shim) { |
| 47 | assert(!is_component_build, |
| 48 | "The allocator shim doesn't work for the component build on Windows.") |
| 49 | } |