1# Copyright 2014 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 5import("//build/config/sanitizers/sanitizers.gni") 6 7_default_allocator = "none" 8 9# The debug CRT on Windows has some debug features that are incompatible with 10# the shim. NaCl in particular does seem to link some binaries statically 11# against the debug CRT with "is_nacl=false". 12if ((is_linux || is_ohos || is_mac || 13 (is_win && !is_component_build && !is_debug)) && !is_asan && !is_lsan && 14 !is_tsan && !is_msan) { 15 _default_use_allocator_shim = true 16} else { 17 _default_use_allocator_shim = false 18} 19 20declare_args() { 21 # Memory allocator to use. Set to "none" to use default allocator. 22 use_allocator = _default_allocator 23 24 # Causes all the allocations to be routed via allocator_shim.cc. 25 use_allocator_shim = _default_use_allocator_shim 26 27 # Partition alloc is included by default except iOS. 28 use_partition_alloc = true 29} 30 31if (is_nacl) { 32 # Turn off the build flag for NaCL builds to minimize confusion, as NaCL 33 # doesn't support the heap shim. 34 use_allocator_shim = false 35} 36 37assert(use_allocator == "none") 38 39assert( 40 !use_allocator_shim || is_linux || is_ohos || is_win || is_mac, 41 "use_allocator_shim is supported only on Linux, Windows and macOS targets") 42 43if (is_win && use_allocator_shim) { 44 assert(!is_component_build, 45 "The allocator shim doesn't work for the component build on Windows.") 46} 47