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 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157
|
# 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
# - 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}.
# TODO(crbug.com/41481467) Document what are the required and optional GN
# variable embedders can provide to partition_alloc. For the least common,
# consider wrapping them into some partition_alloc specific names.
import("//build/config/android/config.gni")
import("//build/config/cast.gni")
import("//build/config/chromeos/ui_mode.gni")
import("//build/config/compiler/compiler.gni")
import("//build/config/cronet/config.gni")
import("//build/config/dcheck_always_on.gni")
import("//build/config/logging.gni")
import("//build/config/sanitizers/sanitizers.gni")
if (is_ios) {
import("//ios/features.gni")
}
partition_alloc_enable_arc_config = "//build/config/compiler:enable_arc"
declare_args() {
# Turns on compiler optimizations in PartitionAlloc in Debug build. If
# enabling PartitionAlloc-Everywhere in Debug build for tests in Debug build,
# since all memory allocations and deallocations are executed by non-optimized
# PartitionAlloc, chrome (including tests) will be much slower. This will
# cause debug trybots' timeouts. If we want to debug PartitionAlloc itself,
# use partition_alloc_optimized_debug=false. Otherwise, use
# partition_alloc_optimized_debug=true to enable optimized PartitionAlloc.
partition_alloc_optimized_debug = true
}
if (!is_debug || partition_alloc_optimized_debug) {
# In chrome, partition_alloc is relatively hot (>1% of cycles for users of
# CrOS). Use speed-focused optimizations for it.
partition_alloc_remove_configs =
[ "//build/config/compiler:default_optimization" ]
partition_alloc_add_configs = [ "//build/config/compiler:optimize_speed" ]
} else {
partition_alloc_remove_configs =
[ "//build/config/compiler:default_optimization" ]
partition_alloc_add_configs = [ "//build/config/compiler:no_optimize" ]
}
# llvm_profile_set_target() generated by -fgenerate-profile invokes malloc()
# internally. Since allocator_shim and PartitionAlloc are not reenterant,
# the code will cause crashes. See crbug.com/338094768.
partition_alloc_remove_configs +=
[ "//build/config/compiler/pgo:default_pgo_flags" ]
# - 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.
# - Windows: debug CRT is not compatible, see below.
_disable_partition_alloc_everywhere =
(!is_linux && is_component_build) || (is_win && is_debug)
# - NaCl: No plans to support it.
# - iOS: Depends on ios_partition_alloc_enabled.
_is_partition_alloc_everywhere_platform =
!is_nacl && (!is_ios || ios_partition_alloc_enabled)
use_allocator_shim_default = true # Updated below:
# Sanitizers replace the allocator, don't use our own.
if (is_asan || is_hwasan || is_lsan || is_tsan || is_msan) {
use_allocator_shim_default = false
}
# NaCl will never support the allocator shim.
if (is_nacl) {
use_allocator_shim_default = false
}
# Under Fuchsia, the allocator shim is only required for PA-E.
if (is_fuchsia && _disable_partition_alloc_everywhere) {
use_allocator_shim_default = false
}
# 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".
if (is_win && is_debug) {
use_allocator_shim_default = false
}
if (is_win && is_component_build && (!use_custom_libcxx || libcxx_is_shared)) {
use_allocator_shim_default = false
}
shim_supports_sized_dealloc_default = use_sized_deallocation
use_partition_alloc_as_malloc_default =
use_allocator_shim_default && _is_partition_alloc_everywhere_platform &&
!_disable_partition_alloc_everywhere
enable_backup_ref_ptr_support_default = use_partition_alloc_as_malloc_default
enable_backup_ref_ptr_slow_checks_default = false
enable_dangling_raw_ptr_checks_default =
# The DanglingPointerDetector relies on BackupRefPtr:
enable_backup_ref_ptr_support_default &&
# DanglingPointerDetector is not yet enabled for official builds.
# Enabling it would require:
# - Metric-monitored dry-runs to assess real-world impact.
# - Performance re-evaluation, although past impact was neutral.
# - Additional considerations (etc.).
#
# It's also unclear if potential security issues warrant crash reports,
# as this could burden developers. Non-crashing metrics might help assess
# the value.
!is_official_build &&
# In unofficial builds, enable only for developers interested in
# DCHECKd/Debug builds. In the future, given its neutral performance impact,
# we could consider removing this restriction.
(is_debug || dcheck_always_on) &&
# Fuchsia and iOS have never been tested against DanglingPointerDetector at
# the moment.
!is_ios && !is_fuchsia &&
# Only the `android-rel` CQ bot has enforced DanglingPointerDetector checks
# at the moment. The other Android bots are not ready for it yet.
!is_android
enable_ios_corruption_hardening_default =
is_ios && ios_partition_alloc_corruption_hardening_enabled
raw_ptr_zero_on_construct_default = true
raw_ptr_zero_on_move_default = true
raw_ptr_zero_on_destruct_default = false
# Allow embedders to opt-out of C++20 build which is set as default.
# Kindly notify PartitionAlloc owners of change to false.
assert_cpp20_default = true
|