forked from youtube/cobalt
-
Notifications
You must be signed in to change notification settings - Fork 0
/
partition_alloc.gni
88 lines (77 loc) · 3.57 KB
/
partition_alloc.gni
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
# Copyright 2022 The Chromium Authors
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
# This defines PartitionAlloc's default build configuration for chromium.
# If building PartitionAlloc as a part of chromium,
# //build_overrides/partition_alloc.gni points out this file.
# //base/allocator/partition_allocator/partition_alloc.gni will import
# this file and will use the defined values as default build configuration.
#
# partition_alloc.gni declares the following variables:
# - use_allocator_shim
# - use_partition_alloc_as_malloc
# - enable_backup_ref_ptr_support
# - put_ref_count_in_previous_slot
# - enable_backup_ref_ptr_slow_checks
# - enable_dangling_raw_ptr_checks
# - backup_ref_ptr_poison_oob_ptr
#
# Temporarily defines use_allocator_shim here. After deciding what
# allocator_shim should be (e.g. a part of PartitionAlloc, a new component:
# allocator_shim, and so on), move use_allocator_shim_default to the place.
# - use_allocator_shim
#
# {variable}_default works as the default value of {variable}.
import("//build/config/chromecast_build.gni")
import("//build/config/sanitizers/sanitizers.gni")
if (is_ios) {
import("//build/config/ios/ios_sdk.gni")
import("//ios/features.gni")
}
# Sanitizers replace the allocator, don't use our own.
_is_using_sanitizers = is_asan || is_hwasan || is_lsan || is_tsan || is_msan
# - Component build support is disabled on all platforms except Linux. It is
# known to cause issues on some (e.g. Windows with shims, Android with
# non-universal symbol wrapping), and has not been validated on others.
# - Disable on Linux when component and debug build are used together, because
# PA-E caused lots of timeouts on Linux Tests(dbg).
# TODO(crbug.com/1429450): fix the timeout issue and enable on linux debug
# and component build.
# - Windows: debug CRT is not compatible, see below.
_disable_partition_alloc_everywhere =
(is_linux && is_component_build && is_debug) ||
(!is_linux && is_component_build) || (is_win && is_debug)
# - NaCl: No plans to support it.
# - iOS: Depends on ios_partition_alloc_enabled.
if (is_ios) {
_is_partition_alloc_everywhere_platform = ios_partition_alloc_enabled
} else {
_is_partition_alloc_everywhere_platform = !is_nacl
}
# Under Windows debug build, the allocator shim is not compatible with CRT.
# NaCl in particular does seem to link some binaries statically
# against the debug CRT with "is_nacl=false".
# Under Fuchsia, the allocator shim is only required for PA-E.
# For all other platforms & configurations, the shim is required, to replace
# the default system allocators, e.g. with Partition Alloc.
if ((is_linux || is_chromeos || is_android || is_apple ||
(is_fuchsia && !_disable_partition_alloc_everywhere) ||
(is_win && !is_component_build && !is_debug)) && !_is_using_sanitizers) {
_default_use_allocator_shim = true
} else {
_default_use_allocator_shim = false
}
if (_default_use_allocator_shim && _is_partition_alloc_everywhere_platform &&
!_disable_partition_alloc_everywhere) {
_default_allocator = "partition"
} else {
_default_allocator = "none"
}
use_partition_alloc_as_malloc_default = _default_allocator == "partition"
use_allocator_shim_default = _default_use_allocator_shim
_is_brp_supported = (is_win || is_android || is_linux || is_mac ||
is_chromeos) && use_partition_alloc_as_malloc_default
enable_backup_ref_ptr_support_default = _is_brp_supported
put_ref_count_in_previous_slot_default = true
enable_backup_ref_ptr_slow_checks_default = false
enable_dangling_raw_ptr_checks_default = false