xref: /build/config/allocator.gni (revision 5f9996aa)
15f9996aaSopenharmony_ci# Copyright 2014 The Chromium Authors. All rights reserved.
25f9996aaSopenharmony_ci# Use of this source code is governed by a BSD-style license that can be
35f9996aaSopenharmony_ci# found in the LICENSE file.
45f9996aaSopenharmony_ci
55f9996aaSopenharmony_ciimport("//build/config/sanitizers/sanitizers.gni")
65f9996aaSopenharmony_ci
75f9996aaSopenharmony_ci_default_allocator = "none"
85f9996aaSopenharmony_ci
95f9996aaSopenharmony_ci# The debug CRT on Windows has some debug features that are incompatible with
105f9996aaSopenharmony_ci# the shim. NaCl in particular does seem to link some binaries statically
115f9996aaSopenharmony_ci# against the debug CRT with "is_nacl=false".
125f9996aaSopenharmony_ciif ((is_linux || is_ohos || is_mac ||
135f9996aaSopenharmony_ci     (is_win && !is_component_build && !is_debug)) && !is_asan && !is_lsan &&
145f9996aaSopenharmony_ci    !is_tsan && !is_msan) {
155f9996aaSopenharmony_ci  _default_use_allocator_shim = true
165f9996aaSopenharmony_ci} else {
175f9996aaSopenharmony_ci  _default_use_allocator_shim = false
185f9996aaSopenharmony_ci}
195f9996aaSopenharmony_ci
205f9996aaSopenharmony_cideclare_args() {
215f9996aaSopenharmony_ci  # Memory allocator to use. Set to "none" to use default allocator.
225f9996aaSopenharmony_ci  use_allocator = _default_allocator
235f9996aaSopenharmony_ci
245f9996aaSopenharmony_ci  # Causes all the allocations to be routed via allocator_shim.cc.
255f9996aaSopenharmony_ci  use_allocator_shim = _default_use_allocator_shim
265f9996aaSopenharmony_ci
275f9996aaSopenharmony_ci  # Partition alloc is included by default except iOS.
285f9996aaSopenharmony_ci  use_partition_alloc = true
295f9996aaSopenharmony_ci}
305f9996aaSopenharmony_ci
315f9996aaSopenharmony_ciif (is_nacl) {
325f9996aaSopenharmony_ci  # Turn off the build flag for NaCL builds to minimize confusion, as NaCL
335f9996aaSopenharmony_ci  # doesn't support the heap shim.
345f9996aaSopenharmony_ci  use_allocator_shim = false
355f9996aaSopenharmony_ci}
365f9996aaSopenharmony_ci
375f9996aaSopenharmony_ciassert(use_allocator == "none")
385f9996aaSopenharmony_ci
395f9996aaSopenharmony_ciassert(
405f9996aaSopenharmony_ci    !use_allocator_shim || is_linux || is_ohos || is_win || is_mac,
415f9996aaSopenharmony_ci    "use_allocator_shim is supported only on Linux, Windows and macOS targets")
425f9996aaSopenharmony_ci
435f9996aaSopenharmony_ciif (is_win && use_allocator_shim) {
445f9996aaSopenharmony_ci  assert(!is_component_build,
455f9996aaSopenharmony_ci         "The allocator shim doesn't work for the component build on Windows.")
465f9996aaSopenharmony_ci}
47