Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 1 | // |
| 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 Badour | ebb07f0 | 2021-02-12 17:53:38 -0800 | [diff] [blame] | 17 | package { |
| 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 |
| 35 | license { |
| 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 Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 49 | cc_defaults { |
| 50 | name: "gwp_asan_defaults", |
| 51 | host_supported: true, |
Mitch Phillips | 1e0dfc2 | 2019-11-14 15:36:46 -0800 | [diff] [blame] | 52 | vendor_available: true, |
Justin Yun | 930d6a7 | 2020-11-11 16:21:59 +0900 | [diff] [blame] | 53 | product_available: true, |
Mitch Phillips | 1e0dfc2 | 2019-11-14 15:36:46 -0800 | [diff] [blame] | 54 | recovery_available: true, |
| 55 | native_bridge_supported: true, |
Mitch Phillips | 9127a82 | 2020-01-28 10:44:34 -0800 | [diff] [blame] | 56 | ramdisk_available: true, |
Yifan Hong | f03616c | 2020-10-21 18:40:51 -0700 | [diff] [blame] | 57 | vendor_ramdisk_available: true, |
Mitch Phillips | 1e0dfc2 | 2019-11-14 15:36:46 -0800 | [diff] [blame] | 58 | |
Mitch Phillips | 1e0dfc2 | 2019-11-14 15:36:46 -0800 | [diff] [blame] | 59 | // GWP-ASan currently has no support for darwin. |
Elliott Hughes | 15d441c | 2019-09-09 18:43:39 -0700 | [diff] [blame] | 60 | target: { |
| 61 | darwin: { |
| 62 | enabled: false, |
| 63 | }, |
| 64 | }, |
Nicolas Geoffray | a35f1ae | 2021-03-03 22:05:25 +0000 | [diff] [blame] | 65 | min_sdk_version: "S", |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 66 | } |
| 67 | |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 68 | cc_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 Cross | 0b40b33 | 2021-12-15 14:51:30 -0800 | [diff] [blame] | 74 | target: { |
| 75 | bionic: { |
| 76 | system_shared_libs: [], |
| 77 | header_libs: ["libc_headers"], |
| 78 | }, |
| 79 | }, |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 80 | stl: "none", |
| 81 | } |
| 82 | |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 83 | cc_library_headers { |
| 84 | name: "gwp_asan_headers", |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 85 | defaults: [ |
| 86 | "gwp_asan_defaults", |
| 87 | "gwp_asan_no_libs_defaults", |
| 88 | ], |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 89 | export_include_dirs: [ |
Mitch Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 90 | ".", |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 91 | ], |
Mitch Phillips | ec4fe32 | 2020-02-07 13:35:17 -0800 | [diff] [blame] | 92 | apex_available: [ |
Jiyong Park | c5f489c | 2020-04-27 16:00:57 +0900 | [diff] [blame] | 93 | // 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 Park | e32bc11 | 2020-04-07 16:35:19 +0900 | [diff] [blame] | 96 | "//apex_available:platform", |
Jiyong Park | c5f489c | 2020-04-27 16:00:57 +0900 | [diff] [blame] | 97 | "com.android.runtime", |
| 98 | // GWP-ASan headers are currently referenced by the following additional APEXes |
Martin Stjernholm | eb139a4 | 2020-10-12 15:11:11 +0100 | [diff] [blame] | 99 | "com.android.art", |
Jiyong Park | c5f489c | 2020-04-27 16:00:57 +0900 | [diff] [blame] | 100 | "com.android.art.debug", |
Jiyong Park | c5f489c | 2020-04-27 16:00:57 +0900 | [diff] [blame] | 101 | "com.android.media", |
| 102 | "com.android.media.swcodec", |
Shikha Panwar | 25b5f93 | 2022-03-25 17:56:36 +0000 | [diff] [blame] | 103 | "com.android.virt", |
Mitch Phillips | ec4fe32 | 2020-02-07 13:35:17 -0800 | [diff] [blame] | 104 | ], |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 105 | } |
| 106 | |
| 107 | // Only static linkage is provided for performance reasons. |
| 108 | cc_library_static { |
| 109 | name: "gwp_asan", |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 110 | defaults: ["gwp_asan_no_libs_defaults"], |
Mitch Phillips | 1e0dfc2 | 2019-11-14 15:36:46 -0800 | [diff] [blame] | 111 | header_libs: [ |
| 112 | "gwp_asan_headers", |
Mitch Phillips | 1e0dfc2 | 2019-11-14 15:36:46 -0800 | [diff] [blame] | 113 | ], |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 114 | srcs: [ |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 115 | "gwp_asan/common.cpp", |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 116 | "gwp_asan/guarded_pool_allocator.cpp", |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 117 | "gwp_asan/platform_specific/common_posix.cpp", |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 118 | "gwp_asan/platform_specific/guarded_pool_allocator_posix.cpp", |
| 119 | "gwp_asan/platform_specific/mutex_posix.cpp", |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 120 | "gwp_asan/platform_specific/utilities_posix.cpp", |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 121 | "gwp_asan/stack_trace_compressor.cpp", |
| 122 | ], |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 123 | // 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 Phillips | ec4fe32 | 2020-02-07 13:35:17 -0800 | [diff] [blame] | 128 | 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 Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 138 | } |
| 139 | |
| 140 | // GWP-ASan crash handler API. Provides all the tools you need to symbolize a |
| 141 | // GWP-ASan crash. |
| 142 | cc_library { |
| 143 | name: "gwp_asan_crash_handler", |
| 144 | defaults: ["gwp_asan_defaults"], |
| 145 | header_libs: [ |
| 146 | "gwp_asan_headers", |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 147 | ], |
| 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 Phillips | 83de322 | 2020-02-14 14:52:48 -0800 | [diff] [blame] | 155 | apex_available: [ |
| 156 | "//apex_available:platform", |
| 157 | "com.android.runtime", |
| 158 | ], |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | cc_fuzz { |
| 162 | name: "stack_trace_compressor_fuzzer", |
Mitch Phillips | 1e0dfc2 | 2019-11-14 15:36:46 -0800 | [diff] [blame] | 163 | host_supported: true, |
Mitch Phillips | db8fe86 | 2019-08-27 16:09:44 -0700 | [diff] [blame] | 164 | srcs: ["tools/stack_trace_compressor_fuzzer.cpp"], |
Mitch Phillips | b7ff430 | 2019-08-23 18:40:12 -0700 | [diff] [blame] | 165 | static_libs: ["gwp_asan"], |
| 166 | } |
Mitch Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 167 | |
Mitch Phillips | bfaecde | 2021-02-09 14:58:39 -0800 | [diff] [blame] | 168 | cc_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 Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 178 | // These unit tests are also continuously run upstream in LLVM's buildbots. |
| 179 | cc_test { |
| 180 | name: "gwp_asan_unittest", |
| 181 | defaults: ["linux_bionic_supported"], |
| 182 | static_libs: [ |
| 183 | "gwp_asan", |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 184 | "gwp_asan_crash_handler", |
Mitch Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 185 | "libasync_safe", |
Mitch Phillips | 3d8aa4c | 2020-03-24 18:16:04 -0700 | [diff] [blame] | 186 | "liblog", |
Christopher Ferris | 4e633f9 | 2020-09-24 18:47:03 -0700 | [diff] [blame] | 187 | "libunwindstack_no_dex", |
Mitch Phillips | adefa14 | 2020-03-25 15:13:07 -0700 | [diff] [blame] | 188 | "liblzma", // Dependency from libunwindstack. |
| 189 | ], |
David Srbecky | 4f2cfac | 2020-05-12 15:14:41 +0100 | [diff] [blame] | 190 | shared_libs: [ |
| 191 | "libbase", |
| 192 | ], |
Mitch Phillips | adefa14 | 2020-03-25 15:13:07 -0700 | [diff] [blame] | 193 | |
| 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 Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 199 | ], |
| 200 | srcs: [ |
Mitch Phillips | adefa14 | 2020-03-25 15:13:07 -0700 | [diff] [blame] | 201 | "android/test_backtrace.cpp", |
Mitch Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 202 | "android/test_printf.cpp", |
Mitch Phillips | bfaecde | 2021-02-09 14:58:39 -0800 | [diff] [blame] | 203 | "gwp_asan/optional/options_parser.cpp", |
Mitch Phillips | adefa14 | 2020-03-25 15:13:07 -0700 | [diff] [blame] | 204 | "gwp_asan/optional/segv_handler_posix.cpp", |
Mitch Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 205 | "gwp_asan/tests/alignment.cpp", |
Mitch Phillips | adefa14 | 2020-03-25 15:13:07 -0700 | [diff] [blame] | 206 | "gwp_asan/tests/backtrace.cpp", |
Mitch Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 207 | "gwp_asan/tests/basic.cpp", |
| 208 | "gwp_asan/tests/compression.cpp", |
Mitch Phillips | 554cba6 | 2020-02-05 16:39:26 -0800 | [diff] [blame] | 209 | "gwp_asan/tests/crash_handler_api.cpp", |
Mitch Phillips | adefa14 | 2020-03-25 15:13:07 -0700 | [diff] [blame] | 210 | "gwp_asan/tests/enable_disable.cpp", |
Evgenii Stepanov | ca8e2c1 | 2020-01-10 16:01:01 -0800 | [diff] [blame] | 211 | "gwp_asan/tests/harness.cpp", |
Mitch Phillips | adefa14 | 2020-03-25 15:13:07 -0700 | [diff] [blame] | 212 | "gwp_asan/tests/iterate.cpp", |
Mitch Phillips | b1652f3 | 2020-02-03 12:50:30 -0800 | [diff] [blame] | 213 | "gwp_asan/tests/late_init.cpp", |
Mitch Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 214 | "gwp_asan/tests/mutex_test.cpp", |
Mitch Phillips | bfaecde | 2021-02-09 14:58:39 -0800 | [diff] [blame] | 215 | "gwp_asan/tests/options.cpp", |
Mitch Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 216 | "gwp_asan/tests/slot_reuse.cpp", |
| 217 | "gwp_asan/tests/thread_contention.cpp", |
| 218 | ], |
| 219 | include_dirs: ["bionic/libc/async_safe/include"], |
Mitch Phillips | 6f8ad46 | 2019-12-10 14:15:31 -0800 | [diff] [blame] | 220 | test_suites: ["general-tests"], |
Mitch Phillips | adefa14 | 2020-03-25 15:13:07 -0700 | [diff] [blame] | 221 | 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 Phillips | adefa14 | 2020-03-25 15:13:07 -0700 | [diff] [blame] | 229 | ], |
Mitch Phillips | 4f635e2 | 2019-12-09 13:08:57 -0800 | [diff] [blame] | 230 | } |