xref: /aosp_15_r20/external/skia/build_overrides/partition_alloc.gni (revision c8dee2aa9b3f27cf6c858bd81872bdeb2c07ed17)
1# Copyright 2024 Google Inc.
2#
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5
6# PartitionAlloc is still depending on a couple of "common" `is_xxx` variables
7# shared by Chromium / Dawn / Pdfium / etc... Only Skia is really independent.
8#
9# While waiting for partition_alloc to do the same, they need to be set:
10is_asan = sanitize == "address"
11is_cast_android = false
12is_castos = false
13is_cronet_build = false
14is_nacl = false
15is_posix = !is_win && !is_fuchsia
16
17# Skia standalone isn't built as part of chromium.
18build_with_chromium = false
19
20# Skia still need to supports C++17 for quite some time.
21assert_cpp20_default = false
22
23# Contrary to Skia, Chrome/PartitionAlloc do not enforce strict aliasing rules.
24# Contrary to Clang, GCC is aggressively relying on the strict aliasing rule for
25# optimization and this breaks PartitionAlloc.
26# See https://crbug.com/379844655 for more details.
27partition_alloc_remove_configs = [ "//gn/skia:strict_aliasing" ]
28partition_alloc_add_configs = [ "//gn/skia:no_strict_aliasing" ]
29
30# partition_alloc is performance critical and it should generally be optimized
31# for speed, even in debug mode.
32if (is_debug) {
33  partition_alloc_add_configs += [
34    "//gn/skia:optimize",
35    "//gn/skia:NDEBUG",
36  ]
37}
38
39# MSVC's cl.exe compiler is not supported.
40_supported_compiler = is_clang || !is_win
41
42# Windows: debug CRT is not yet compatible with the allocator shim.
43# https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/free-dbg
44_supported_build_type = !is_win || (!is_component_build && !is_debug)
45
46# TODO(351867706): Resolve compile assertions issues on Mac, and add `is_mac`
47# here.
48_supported_platform =
49    is_android || is_chromeos || is_fuchsia || is_linux || is_win
50
51# Sanitizers replace the allocator, don't replace it ourselves with
52# partition_alloc.
53_is_using_sanitizers = sanitize != ""
54
55_supported = _supported_compiler && _supported_build_type &&
56             _supported_platform && !_is_using_sanitizers
57
58use_partition_alloc_as_malloc_default = _supported
59use_allocator_shim_default = _supported
60enable_backup_ref_ptr_support_default = _supported
61put_ref_count_in_previous_slot_default = true
62enable_backup_ref_ptr_slow_checks_default = false
63enable_dangling_raw_ptr_checks_default = _supported
64
65# This is the default build configuration for pointers/raw_ptr*.
66raw_ptr_zero_on_construct_default = true
67raw_ptr_zero_on_move_default = true
68raw_ptr_zero_on_destruct_default = false
69
70# For now, don't check for additional costly memory safety errors in Skia.
71# Some will be enforced in the future.
72can_unwind_with_frame_pointers = false
73dcheck_always_on = false
74dcheck_is_configurable = false
75enable_expensive_dchecks = false
76