blob: c8964b07ca7c3fc135940a986c65c2183f4b18eb [file] [log] [blame]
# Copyright 2019 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
import("//build/config/chromecast_build.gni")
import("//build/config/sanitizers/sanitizers.gni")
# The debug CRT on Windows has some debug features that are incompatible with
# the shim. NaCl in particular does seem to link some binaries statically
# against the debug CRT with "is_nacl=false".
if ((is_linux || is_chromeos || is_android || is_apple ||
(is_win && !is_component_build && !is_debug)) && !is_asan && !is_hwasan &&
!is_lsan && !is_tsan && !is_msan) {
_default_use_allocator_shim = true
} else {
_default_use_allocator_shim = false
}
# Temporarily disable tcmalloc on arm64 linux to get rid of compilation errors.
if (is_android || is_apple || is_asan || is_lsan || is_tsan || is_msan ||
is_win || is_fuchsia ||
((is_linux || is_chromeos) && target_cpu == "arm64") ||
(is_cast_audio_only && target_cpu == "arm")) {
_default_allocator = "none"
} else {
_default_allocator = "tcmalloc"
}
declare_args() {
# Don't ship this configuration, not ready yet.
assert(_default_allocator != "partition")
# Memory allocator to use. Set to "none" to use default allocator.
use_allocator = _default_allocator
# Causes all the allocations to be routed via allocator_shim.cc.
use_allocator_shim = _default_use_allocator_shim
# Whether PartitionAlloc should be available for use or not.
# true makes PartitionAlloc linked to the executable or shared library and
# makes it available for use, but it doesn't mean that the default allocator
# is PartitionAlloc. PartitionAlloc may or may not be the default allocator.
#
# |use_allocator = "partition"| makes PartitionAlloc the default allocator
# but it's effective only when |use_partition_alloc = true|.
#
# TODO(lizeb, yukishiino): Determine if |use_partition_alloc| is necessary or
# not, and redesign or remove the flag accordingly. We may want to assert a
# possible conflict between |use_allocator = "partition"| and
# |use_partition_alloc = true| rather than prioritizing use_partition_alloc.
use_partition_alloc = !is_ios # Never use PartitionAlloc on iOS.
}
if (!use_partition_alloc && use_allocator == "partition") {
# If there is a conflict, prioritize |use_partition_alloc| over
# |use_allocator|.
use_allocator = "none"
}
assert(use_allocator == "none" || use_allocator == "tcmalloc" ||
use_allocator == "partition")
assert(!is_win || use_allocator != "tcmalloc",
"Tcmalloc doesn't work on Windows.")
assert(!is_mac || use_allocator != "tcmalloc",
"Tcmalloc doesn't work on macOS.")
assert(!is_ios || use_allocator != "tcmalloc", "Tcmalloc doesn't work on iOS.")
assert(
!use_allocator_shim || is_linux || is_chromeos || is_android || is_win ||
is_apple,
"use_allocator_shim works only on Android, iOS, Linux, macOS, and Windows.")
if (is_win && use_allocator_shim) {
assert(!is_component_build,
"The allocator shim doesn't work for the component build on Windows.")
}