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