blob: 5f8c925ee551a3d7d71ba441232fe083414b2e0b [file] [log] [blame]
Mitch Phillipsb7ff4302019-08-23 18:40:12 -07001//
2// Copyright (C) 2019 The Android Open Source Project
3//
4// Licensed under the Apache License, Version 2.0 (the "License");
5// you may not use this file except in compliance with the License.
6// You may obtain a copy of the License at
7//
8// http://www.apache.org/licenses/LICENSE-2.0
9//
10// Unless required by applicable law or agreed to in writing, software
11// distributed under the License is distributed on an "AS IS" BASIS,
12// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13// See the License for the specific language governing permissions and
14// limitations under the License.
15//
16
Bob Badourebb07f02021-02-12 17:53:38 -080017package {
18 default_applicable_licenses: ["external_gwp_asan_license"],
19}
20
21// Added automatically by a large-scale-change that took the approach of
22// 'apply every license found to every target'. While this makes sure we respect
23// every license restriction, it may not be entirely correct.
24//
25// e.g. GPL in an MIT project might only apply to the contrib/ directory.
26//
27// Please consider splitting the single license below into multiple licenses,
28// taking care not to lose any license_kind information, and overriding the
29// default license using the 'licenses: [...]' property on targets as needed.
30//
31// For unused files, consider creating a 'fileGroup' with "//visibility:private"
32// to attach the license to, and including a comment whether the files may be
33// used in the current project.
34// See: http://go/android-license-faq
35license {
36 name: "external_gwp_asan_license",
37 visibility: [":__subpackages__"],
38 license_kinds: [
39 "SPDX-license-identifier-Apache-2.0",
40 "SPDX-license-identifier-BSD",
41 "SPDX-license-identifier-MIT",
42 "SPDX-license-identifier-NCSA",
43 ],
44 license_text: [
45 "LICENSE.TXT",
46 ],
47}
48
Mitch Phillipsb7ff4302019-08-23 18:40:12 -070049cc_defaults {
50 name: "gwp_asan_defaults",
51 host_supported: true,
Mitch Phillips1e0dfc22019-11-14 15:36:46 -080052 vendor_available: true,
Justin Yun930d6a72020-11-11 16:21:59 +090053 product_available: true,
Mitch Phillips1e0dfc22019-11-14 15:36:46 -080054 recovery_available: true,
55 native_bridge_supported: true,
Mitch Phillips9127a822020-01-28 10:44:34 -080056 ramdisk_available: true,
Yifan Hongf03616c2020-10-21 18:40:51 -070057 vendor_ramdisk_available: true,
Mitch Phillips1e0dfc22019-11-14 15:36:46 -080058
Mitch Phillips1e0dfc22019-11-14 15:36:46 -080059 // GWP-ASan currently has no support for darwin.
Elliott Hughes15d441c2019-09-09 18:43:39 -070060 target: {
61 darwin: {
62 enabled: false,
63 },
64 },
Nicolas Geoffraya35f1ae2021-03-03 22:05:25 +000065 min_sdk_version: "S",
Mitch Phillipsb7ff4302019-08-23 18:40:12 -070066}
67
Mitch Phillips554cba62020-02-05 16:39:26 -080068cc_defaults {
69 name: "gwp_asan_no_libs_defaults",
70 defaults: ["gwp_asan_defaults"],
71
72 // GWP-ASan is used by bionic libc, and should have no libc/libc++
73 // dependencies.
Colin Cross0b40b332021-12-15 14:51:30 -080074 target: {
75 bionic: {
76 system_shared_libs: [],
77 header_libs: ["libc_headers"],
78 },
79 },
Mitch Phillips554cba62020-02-05 16:39:26 -080080 stl: "none",
81}
82
Mitch Phillipsb7ff4302019-08-23 18:40:12 -070083cc_library_headers {
84 name: "gwp_asan_headers",
Mitch Phillips554cba62020-02-05 16:39:26 -080085 defaults: [
86 "gwp_asan_defaults",
87 "gwp_asan_no_libs_defaults",
88 ],
Mitch Phillipsb7ff4302019-08-23 18:40:12 -070089 export_include_dirs: [
Mitch Phillips4f635e22019-12-09 13:08:57 -080090 ".",
Mitch Phillipsb7ff4302019-08-23 18:40:12 -070091 ],
Mitch Phillipsec4fe322020-02-07 13:35:17 -080092 apex_available: [
Jiyong Parkc5f489c2020-04-27 16:00:57 +090093 // This header lib is compiled also as part of the platform due to libasync_safe
94 // and others that are compiled with this header and are statically included
95 // in the platform side.
Jiyong Parke32bc112020-04-07 16:35:19 +090096 "//apex_available:platform",
Jiyong Parkc5f489c2020-04-27 16:00:57 +090097 "com.android.runtime",
98 // GWP-ASan headers are currently referenced by the following additional APEXes
Martin Stjernholmeb139a42020-10-12 15:11:11 +010099 "com.android.art",
Jiyong Parkc5f489c2020-04-27 16:00:57 +0900100 "com.android.art.debug",
Jiyong Parkc5f489c2020-04-27 16:00:57 +0900101 "com.android.media",
102 "com.android.media.swcodec",
Shikha Panwar25b5f932022-03-25 17:56:36 +0000103 "com.android.virt",
Mitch Phillipsec4fe322020-02-07 13:35:17 -0800104 ],
Mitch Phillipsb7ff4302019-08-23 18:40:12 -0700105}
106
107// Only static linkage is provided for performance reasons.
108cc_library_static {
109 name: "gwp_asan",
Mitch Phillips554cba62020-02-05 16:39:26 -0800110 defaults: ["gwp_asan_no_libs_defaults"],
Mitch Phillips1e0dfc22019-11-14 15:36:46 -0800111 header_libs: [
112 "gwp_asan_headers",
Mitch Phillips1e0dfc22019-11-14 15:36:46 -0800113 ],
Mitch Phillipsb7ff4302019-08-23 18:40:12 -0700114 srcs: [
Mitch Phillips554cba62020-02-05 16:39:26 -0800115 "gwp_asan/common.cpp",
Mitch Phillipsb7ff4302019-08-23 18:40:12 -0700116 "gwp_asan/guarded_pool_allocator.cpp",
Mitch Phillips554cba62020-02-05 16:39:26 -0800117 "gwp_asan/platform_specific/common_posix.cpp",
Mitch Phillipsb7ff4302019-08-23 18:40:12 -0700118 "gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp",
119 "gwp_asan/platform_specific/mutex_posix.cpp",
Mitch Phillips554cba62020-02-05 16:39:26 -0800120 "gwp_asan/platform_specific/utilities_posix.cpp",
Mitch Phillipsb7ff4302019-08-23 18:40:12 -0700121 "gwp_asan/stack_trace_compressor.cpp",
122 ],
Mitch Phillips554cba62020-02-05 16:39:26 -0800123 // GWP-ASan requires platform (non-emulated) TLS. We use thread local
124 // variables in the core, inlined interface to GWP-ASan.
125 cflags: [
126 "-fno-emulated-tls",
127 ],
Mitch Phillipsec4fe322020-02-07 13:35:17 -0800128 apex_available: [
129 // Required to not occlude the default platform variation from being
130 // skipped by the apex mutator. If this happens - the license file for
131 // the static GWP-ASan library won't be generated, and you'll get errors
132 // at build time.
133 "//apex_available:platform",
134
135 "com.android.runtime", // GWP-ASan is used in libc.
136 "com.android.media.swcodec", // libc_scudo (from media) uses GWP-ASan.
137 ],
Mitch Phillips554cba62020-02-05 16:39:26 -0800138}
139
140// GWP-ASan crash handler API. Provides all the tools you need to symbolize a
141// GWP-ASan crash.
142cc_library {
143 name: "gwp_asan_crash_handler",
144 defaults: ["gwp_asan_defaults"],
145 header_libs: [
146 "gwp_asan_headers",
Mitch Phillips554cba62020-02-05 16:39:26 -0800147 ],
148 srcs: [
149 "gwp_asan/common.cpp",
150 "gwp_asan/crash_handler.cpp",
151 "gwp_asan/platform_specific/common_posix.cpp",
152 "gwp_asan/platform_specific/utilities_posix.cpp",
153 "gwp_asan/stack_trace_compressor.cpp",
154 ],
Mitch Phillips83de3222020-02-14 14:52:48 -0800155 apex_available: [
156 "//apex_available:platform",
157 "com.android.runtime",
158 ],
Mitch Phillipsb7ff4302019-08-23 18:40:12 -0700159}
160
161cc_fuzz {
162 name: "stack_trace_compressor_fuzzer",
Mitch Phillips1e0dfc22019-11-14 15:36:46 -0800163 host_supported: true,
Mitch Phillipsdb8fe862019-08-27 16:09:44 -0700164 srcs: ["tools/stack_trace_compressor_fuzzer.cpp"],
Mitch Phillipsb7ff4302019-08-23 18:40:12 -0700165 static_libs: ["gwp_asan"],
166}
Mitch Phillips4f635e22019-12-09 13:08:57 -0800167
Mitch Phillipsbfaecde2021-02-09 14:58:39 -0800168cc_fuzz {
169 name: "options_parser_fuzzer",
170 host_supported: true,
171 srcs: [
172 "tools/options_parser_fuzzer.cpp",
173 "gwp_asan/optional/options_parser.cpp",
174 ],
175 static_libs: ["gwp_asan"],
176}
177
Mitch Phillips4f635e22019-12-09 13:08:57 -0800178// These unit tests are also continuously run upstream in LLVM's buildbots.
179cc_test {
180 name: "gwp_asan_unittest",
181 defaults: ["linux_bionic_supported"],
182 static_libs: [
183 "gwp_asan",
Mitch Phillips554cba62020-02-05 16:39:26 -0800184 "gwp_asan_crash_handler",
Mitch Phillips4f635e22019-12-09 13:08:57 -0800185 "libasync_safe",
Mitch Phillips3d8aa4c2020-03-24 18:16:04 -0700186 "liblog",
Christopher Ferris4e633f92020-09-24 18:47:03 -0700187 "libunwindstack_no_dex",
Mitch Phillipsadefa142020-03-25 15:13:07 -0700188 "liblzma", // Dependency from libunwindstack.
189 ],
David Srbecky4f2cfac2020-05-12 15:14:41 +0100190 shared_libs: [
191 "libbase",
192 ],
Mitch Phillipsadefa142020-03-25 15:13:07 -0700193
194 ldflags: [
195 // Ensure that ICF doesn't clobber DeallocateMemory2 into
196 // DeallocateMemory in tests/backtrace.cpp. This is done in the linker,
197 // so `optnone` in the function declaration doesn't help.
198 "-Wl,--icf=none",
Mitch Phillips4f635e22019-12-09 13:08:57 -0800199 ],
200 srcs: [
Mitch Phillipsadefa142020-03-25 15:13:07 -0700201 "android/test_backtrace.cpp",
Mitch Phillips4f635e22019-12-09 13:08:57 -0800202 "android/test_printf.cpp",
Mitch Phillipsbfaecde2021-02-09 14:58:39 -0800203 "gwp_asan/optional/options_parser.cpp",
Mitch Phillipsadefa142020-03-25 15:13:07 -0700204 "gwp_asan/optional/segv_handler_posix.cpp",
Mitch Phillips4f635e22019-12-09 13:08:57 -0800205 "gwp_asan/tests/alignment.cpp",
Mitch Phillipsadefa142020-03-25 15:13:07 -0700206 "gwp_asan/tests/backtrace.cpp",
Mitch Phillips4f635e22019-12-09 13:08:57 -0800207 "gwp_asan/tests/basic.cpp",
208 "gwp_asan/tests/compression.cpp",
Mitch Phillips554cba62020-02-05 16:39:26 -0800209 "gwp_asan/tests/crash_handler_api.cpp",
Mitch Phillipsadefa142020-03-25 15:13:07 -0700210 "gwp_asan/tests/enable_disable.cpp",
Evgenii Stepanovca8e2c12020-01-10 16:01:01 -0800211 "gwp_asan/tests/harness.cpp",
Mitch Phillipsadefa142020-03-25 15:13:07 -0700212 "gwp_asan/tests/iterate.cpp",
Mitch Phillipsb1652f32020-02-03 12:50:30 -0800213 "gwp_asan/tests/late_init.cpp",
Mitch Phillips4f635e22019-12-09 13:08:57 -0800214 "gwp_asan/tests/mutex_test.cpp",
Mitch Phillipsbfaecde2021-02-09 14:58:39 -0800215 "gwp_asan/tests/options.cpp",
Mitch Phillips4f635e22019-12-09 13:08:57 -0800216 "gwp_asan/tests/slot_reuse.cpp",
217 "gwp_asan/tests/thread_contention.cpp",
218 ],
219 include_dirs: ["bionic/libc/async_safe/include"],
Mitch Phillips6f8ad462019-12-10 14:15:31 -0800220 test_suites: ["general-tests"],
Mitch Phillipsadefa142020-03-25 15:13:07 -0700221 cflags: [
222 // GWP-ASan requires anything that uses GuardedPoolAllocator headers to
223 // use platform (ELF) TLS.
224 "-fno-emulated-tls",
225
226 // Ensure that the helper functions in test/backtrace.cpp don't get
227 // tail-call optimised, as this breaks the unwind chain.
228 "-fno-optimize-sibling-calls",
Mitch Phillipsadefa142020-03-25 15:13:07 -0700229 ],
Mitch Phillips4f635e22019-12-09 13:08:57 -0800230}