blob: d7637679a664c0f1806e80f0c52bc2739e8ccab3 [file] [log] [blame]
Christopher Ferriscbfcc162019-09-24 12:28:10 -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
Peter Collingbourne1c182602019-11-19 16:07:42 -080017cc_defaults {
18 name: "libscudo_defaults",
Christopher Ferriscbfcc162019-09-24 12:28:10 -070019 native_coverage: false,
Yifan Hongdc883f12020-01-21 17:12:16 -080020 ramdisk_available: true,
Christopher Ferriscbfcc162019-09-24 12:28:10 -070021 recovery_available: true,
22 host_supported: true,
23 native_bridge_supported: true,
24
25 rtti: false,
26 stl: "none",
27
28 cflags: [
29 "-O3",
30 "-fno-rtti",
Christopher Ferris7435ef72019-09-25 17:43:02 -070031 // This option speeds up alloc/free code paths by about 5% to 7%.
32 "-fno-stack-protector",
Peter Collingbourne1c182602019-11-19 16:07:42 -080033 "-fno-emulated-tls",
Christopher Ferriscbfcc162019-09-24 12:28:10 -070034
35 "-Wall",
36 "-Wextra",
37 "-Wunused",
38 "-Wno-unused-result",
39
40 "-Werror=pointer-to-int-cast",
41 "-Werror=int-to-pointer-cast",
42 "-Werror=type-limits",
43 "-Werror",
Christopher Ferrisdf4af6d2020-01-14 13:48:30 -080044
45 // Always force alignment to 16 bytes even on 32 bit.
46 // Android assumes that allocations of multiples of 16 bytes
47 // will be aligned to at least 16 bytes.
48 "-DSCUDO_MIN_ALIGNMENT_LOG=4",
Peter Collingbournedf9219e2020-04-23 13:29:34 -070049
50 // Allow scudo to use android_unsafe_frame_pointer_chase(), which is
51 // normally a private function.
52 "-DHAVE_ANDROID_UNSAFE_FRAME_POINTER_CHASE",
Christopher Ferriscbfcc162019-09-24 12:28:10 -070053 ],
54 cppflags: [
55 "-nostdinc++",
56 "-fno-exceptions",
57 ],
58
Dynamic Tools Team26615592020-03-23 16:08:18 -070059 include_dirs: [
60 "external/scudo/standalone/include",
61 ],
62
Christopher Ferriscbfcc162019-09-24 12:28:10 -070063 system_shared_libs: [],
64
65 srcs: [
66 "standalone/checksum.cpp",
67 "standalone/common.cpp",
68 "standalone/flags.cpp",
69 "standalone/flags_parser.cpp",
70 "standalone/linux.cpp",
Christopher Ferris4998f8c2020-02-18 10:51:54 -080071 "standalone/release.cpp",
Christopher Ferriscbfcc162019-09-24 12:28:10 -070072 "standalone/report.cpp",
Christopher Ferriscbfcc162019-09-24 12:28:10 -070073 "standalone/string_utils.cpp",
74 "standalone/wrappers_c_bionic.cpp"
75 ],
76 arch: {
77 arm: {
78 cflags: ["-mcrc"],
79 srcs: ["standalone/crc32_hw.cpp"],
80 },
81 arm64: {
82 cflags: ["-mcrc"],
83 srcs: ["standalone/crc32_hw.cpp"],
84 },
85 x86_64: {
86 cflags: ["-msse4.2"],
87 srcs: ["standalone/crc32_hw.cpp"],
88 },
89 x86: {
90 cflags: ["-msse4.2"],
91 srcs: ["standalone/crc32_hw.cpp"],
92 },
93 },
94
95 target: {
96 linux_glibc: {
97 enabled: true,
98 },
Martin Stjernholm2ad96b12020-04-23 16:48:50 +010099 android: {
100 header_libs: ["bionic_libc_platform_headers"],
101 product_variables: {
102 experimental_mte: {
103 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
104 },
105 },
106 },
107 linux_bionic: {
108 header_libs: ["bionic_libc_platform_headers"],
109 product_variables: {
110 experimental_mte: {
111 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
112 },
113 },
Peter Collingbourne65006932019-11-26 20:02:40 -0800114 },
115 },
Christopher Ferriscbfcc162019-09-24 12:28:10 -0700116}
Peter Collingbourne1c182602019-11-19 16:07:42 -0800117
118cc_library_static {
119 name: "libscudo",
120 defaults: ["libscudo_defaults"],
121 cflags: ["-D_BIONIC=1"],
122}
123
124cc_library_static {
125 name: "libscudo_for_testing",
126 defaults: ["libscudo_defaults"],
127}
128
129cc_test {
130 name: "scudo_unit_tests",
Christopher Ferrisdadba4c2019-11-21 14:34:40 -0800131 host_supported: true,
Peter Collingbourne1c182602019-11-19 16:07:42 -0800132 srcs: [
133 "standalone/tests/atomic_test.cpp",
134 "standalone/tests/bytemap_test.cpp",
135 "standalone/tests/checksum_test.cpp",
136 "standalone/tests/chunk_test.cpp",
137 "standalone/tests/combined_test.cpp",
138 "standalone/tests/flags_test.cpp",
139 "standalone/tests/list_test.cpp",
140 "standalone/tests/map_test.cpp",
141 "standalone/tests/mutex_test.cpp",
142 "standalone/tests/primary_test.cpp",
143 "standalone/tests/quarantine_test.cpp",
144 "standalone/tests/release_test.cpp",
145 "standalone/tests/report_test.cpp",
146 "standalone/tests/scudo_unit_test_main.cpp",
147 "standalone/tests/secondary_test.cpp",
148 "standalone/tests/size_class_map_test.cpp",
149 "standalone/tests/stats_test.cpp",
150 "standalone/tests/strings_test.cpp",
151 "standalone/tests/tsd_test.cpp",
152 "standalone/tests/vector_test.cpp",
153 ],
154 static_libs: ["libscudo_for_testing"],
155 include_dirs: [
Peter Collingbourne1c182602019-11-19 16:07:42 -0800156 "external/scudo/standalone",
Dynamic Tools Team26615592020-03-23 16:08:18 -0700157 "external/scudo/standalone/include",
Peter Collingbourne1c182602019-11-19 16:07:42 -0800158 ],
159 cflags: [
160 "-Wno-unused-parameter",
161 "-fno-emulated-tls",
162 ],
Martin Stjernholm2ad96b12020-04-23 16:48:50 +0100163 target: {
164 android: {
165 header_libs: ["bionic_libc_platform_headers"],
166 product_variables: {
167 experimental_mte: {
168 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
169 },
170 },
171 },
172 linux_bionic: {
173 header_libs: ["bionic_libc_platform_headers"],
174 product_variables: {
175 experimental_mte: {
176 cflags: ["-DANDROID_EXPERIMENTAL_MTE"],
177 },
178 },
Peter Collingbourne65006932019-11-26 20:02:40 -0800179 },
180 },
Christopher Ferrisdadba4c2019-11-21 14:34:40 -0800181 test_suites: ["general-tests"],
Peter Collingbourneaf40e252020-04-23 13:26:14 -0700182 bootstrap: true,
Peter Collingbourne1c182602019-11-19 16:07:42 -0800183}