• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Build Config
2
3PartitionAlloc's behavior and operation can be influenced by many
4different settings. Broadly, these are controlled at the top-level by
5[GN args][gn-declare-args], which propagate via
6[buildflags][buildflag-header] and `#defined` clauses.
7
8*** promo
9Most of what you'll want to know exists between
10
11* [`//base/allocator/partition_allocator/BUILD.gn`][pa-build-gn],
12* Everything else ending in `.gn` or `.gni` in
13  `//base/allocator/partition_allocator/src/partition_alloc/`,
14* [`allocator.gni`][allocator-gni],
15* [`//base/allocator/BUILD.gn`][base-allocator-build-gn], and
16* [`//base/BUILD.gn`][base-build-gn].
17***
18
19*** aside
20While Chromium promotes the `#if BUILDFLAG(FOO)` construct, some of
21PartitionAlloc's behavior is governed by compound conditions `#defined`
22in [`partition_alloc_config.h`][partition-alloc-config].
23***
24
25*** promo
26PartitionAlloc targets C++17. As the team develops standalone
27PartitionAlloc, this may diverge from what the rest of Chrome browser
28does, as we will be obligated to support external clients that
29may not yet support newer C++ standards.
30
31See [Chrome-External Builds](./external_builds.md) for more.
32***
33
34## Select GN Args
35
36### `use_partition_alloc`
37
38Defines whether PartitionAlloc is at all available.
39
40Setting this `false` will entirely remove PartitionAlloc from the
41Chromium build. _You probably do not want this._
42
43*** note
44Back when PartitionAlloc was the dedicated allocator in Blink, disabling
45it was logically identical to wholly disabling it in Chromium. This GN
46arg organically grew in scope with the advent of
47PartitionAlloc-Everywhere and must be `true` as a prerequisite for
48enabling PA-E.
49***
50
51### `use_partition_alloc_as_malloc`
52
53Does nothing special when value is `false`. Enables
54[PartitionAlloc-Everywhere (PA-E)][pae-public-doc] when value is `true`.
55
56*** note
57* While "everywhere" (in "PartitionAlloc-Everywhere") tautologically
58  includes Blink where PartitionAlloc originated, setting
59  `use_partition_alloc_as_malloc = false` does not disable PA usage in Blink,
60  which invokes PA explicitly (not via malloc).
61* `use_partition_alloc_as_malloc = true` must not be confused
62  with `use_partition_alloc` (see above).
63***
64
65## Notable Macros
66
67There is an ongoing effort
68[to break out PartitionAlloc into a standalone library][pa-ee-crbug].
69Once PartitionAlloc stands alone from the larger Chrome build apparatus,
70the code loses access to some macros. This is not an immediate concern,
71but the team needs to decide either
72
73* how to propagate these macros in place, or
74* how to remove them, replacing them with PA-specific build config.
75
76A non-exhaustive list of work items:
77
78* `OFFICIAL_BUILD` - influences crash macros and
79  `PA_THREAD_CACHE_ALLOC_STATS`. These are conceptually distinct enough
80  to be worth separating into dedicated build controls.
81* `IS_PARTITION_ALLOC_IMPL` - must be defined when PartitionAlloc is
82  built as a shared library. This is required to export symbols.
83* `COMPONENT_BUILD` - component builds (as per
84  `//docs/component_build.md`) must `#define COMPONENT_BUILD`.
85  Additionally, to build Win32, invoker must `#define WIN32`.
86* `MEMORY_TOOL_REPLACES_ALLOCATOR`
87* `*_SANITIZER` - mainly influences unit tests.
88
89*** note
90Over time, the above list should evolve into a list of macros / GN args
91that influence PartitionAlloc's behavior.
92***
93
94[gn-declare-args]: https://gn.googlesource.com/gn/+/refs/heads/main/docs/reference.md#func_declare_args
95[buildflag-header]: https://source.chromium.org/chromium/chromium/src/+/main:build/buildflag_header.gni
96[pa-build-gn]: https://source.chromium.org/chromium/chromium/src/+/main:base/allocator/partition_allocator/BUILD.gn
97[allocator-gni]: https://source.chromium.org/chromium/chromium/src/+/main:base/allocator/allocator.gni
98[base-allocator-build-gn]: https://source.chromium.org/chromium/chromium/src/+/main:base/allocator/BUILD.gn
99[base-build-gn]: https://source.chromium.org/chromium/chromium/src/+/main:base/BUILD.gn
100[partition-alloc-config]: https://source.chromium.org/chromium/chromium/src/+/main:base/allocator/partition_allocator/src/partition_alloc/partition_alloc_config.h
101[pae-public-doc]: https://docs.google.com/document/d/1R1H9z5IVUAnXJgDjnts3nTJVcRbufWWT9ByXLgecSUM/preview
102[miracleptr-doc]: https://docs.google.com/document/d/1pnnOAIz_DMWDI4oIOFoMAqLnf_MZ2GsrJNb_dbQ3ZBg/preview
103[pa-ee-crbug]: https://crbug.com/1151236
104