• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2022 The PDFium Authors
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/android/config.gni")
6import("//build/config/c++/c++.gni")
7import("//build/config/cast.gni")
8import("//build/config/chromeos/ui_mode.gni")
9import("//build/config/compiler/compiler.gni")
10import("//build/config/cronet/config.gni")
11import("//build/config/dcheck_always_on.gni")
12import("//build/config/logging.gni")
13import("//build/config/sanitizers/sanitizers.gni")
14
15partition_alloc_enable_arc_config = "//build/config/compiler:enable_arc"
16
17# partition_alloc is performance critical and it should generally be optimized
18# for speed so that pdfium developers aren't slowed down, even in Debug mode.
19partition_alloc_remove_configs =
20    [ "//build/config/compiler:default_optimization" ]
21partition_alloc_add_configs = [ "//build/config/compiler:optimize_speed" ]
22
23# Sanitizers replace the allocator, don't use our own allocator.
24_is_using_sanitizers = is_asan || is_hwasan || is_lsan || is_tsan || is_msan
25
26# - Component build support is disabled on all platforms except Linux. It is
27#   known to cause issues on some (e.g. Windows with shims, Android with
28#   non-universal symbol wrapping), and has not been validated on others.
29# - Windows: debug CRT is not compatible, see below.
30_disable_partition_alloc_everywhere =
31    (!is_linux && is_component_build) || (is_win && is_debug)
32
33# Under Windows debug build, the allocator shim is not compatible with CRT.
34# For all other platforms & configurations, the shim is required, to replace
35#     the default system allocators, e.g. with Partition Alloc.
36
37# Additionally:
38# - The allocator shim does not work with macOS with use_custom_libcxx=false.
39# - The allocator shim isn't working standalone on Windows at the moment.
40#   See crbug.com/pdfium/2068.
41if ((is_linux || is_chromeos || is_android || is_apple ||
42     (is_win && !is_component_build && !is_debug)) && !_is_using_sanitizers &&
43    (!is_mac || use_custom_libcxx) && !is_win) {
44  _use_shim = true
45} else {
46  _use_shim = false
47}
48
49if (_use_shim && !_disable_partition_alloc_everywhere) {
50  _default_allocator = "partition"
51} else {
52  _default_allocator = "none"
53}
54
55# See base/allocator/partition_allocator/external_builds.md
56use_allocator_shim_default = _use_shim
57use_partition_alloc_as_malloc_default = _default_allocator == "partition"
58
59_is_brp_supported = (is_win || is_android || is_linux || is_mac ||
60                     is_chromeos) && use_partition_alloc_as_malloc_default
61
62enable_backup_ref_ptr_support_default = _is_brp_supported
63
64enable_mte_checked_ptr_support_default = false
65put_ref_count_in_previous_slot_default = true
66enable_backup_ref_ptr_slow_checks_default = false
67enable_dangling_raw_ptr_checks_default = false
68raw_ptr_zero_on_construct_default = true
69raw_ptr_zero_on_move_default = true
70raw_ptr_zero_on_destruct_default = false
71
72# Allow embedders to opt-out of C++20 build which is set as default.
73# Set to true to use C++20 by default.
74assert_cpp20_default = true
75