xref: /aosp_15_r20/bionic/libc/malloc_debug/Android.bp (revision 8d67ca893c1523eb926b9080dbe4e2ffd2a27ba1)
1// ==============================================================
2// libc_malloc_debug_backtrace.a
3// ==============================================================
4// Used by libmemunreachable
5package {
6    default_team: "trendy_team_native_tools_libraries",
7    // See: http://go/android-license-faq
8    // A large-scale-change added 'default_applicable_licenses' to import
9    // all of the 'license_kinds' from "bionic_libc_license"
10    // to get the below license kinds:
11    //   SPDX-license-identifier-Apache-2.0
12    //   SPDX-license-identifier-BSD
13    default_applicable_licenses: ["bionic_libc_license"],
14}
15
16cc_library_static {
17    name: "libc_malloc_debug_backtrace",
18    vendor_available: true,
19
20    srcs: [
21        "backtrace.cpp",
22        "MapData.cpp",
23    ],
24
25    stl: "libc++_static",
26
27    whole_static_libs: [
28        "libbase",
29        "libasync_safe",
30    ],
31
32    include_dirs: ["bionic/libc"],
33
34    export_include_dirs: ["."],
35
36    sanitize: {
37        never: true,
38    },
39    native_coverage: false,
40
41    // -Wno-error=format-zero-length needed for gcc to compile.
42    cflags: [
43        "-Wall",
44        "-Werror",
45        "-Wno-error=format-zero-length",
46    ],
47
48    apex_available: [
49        "//apex_available:platform",
50        "com.android.runtime",
51    ],
52}
53
54// ==============================================================
55// libc_malloc_debug.so
56// ==============================================================
57cc_library {
58    name: "libc_malloc_debug",
59
60    srcs: [
61        "Config.cpp",
62        "DebugData.cpp",
63        "debug_disable.cpp",
64        "GuardData.cpp",
65        "LogAllocatorStats.cpp",
66        "malloc_debug.cpp",
67        "PointerData.cpp",
68        "RecordData.cpp",
69        "Unreachable.cpp",
70        "UnwindBacktrace.cpp",
71    ],
72
73    stl: "libc++_static",
74
75    static_libs: [
76        "libasync_safe",
77        "libbase",
78        "libc_malloc_debug_backtrace",
79        "libmemunreachable",
80    ],
81
82    whole_static_libs: [
83        "libmemory_trace",
84    ],
85
86    shared_libs: [
87        "libunwindstack",
88    ],
89
90    multilib: {
91        lib32: {
92            version_script: "exported32.map",
93        },
94        lib64: {
95            version_script: "exported64.map",
96        },
97    },
98    allow_undefined_symbols: true,
99    include_dirs: ["bionic/libc"],
100
101    sanitize: {
102        never: true,
103    },
104    native_coverage: false,
105
106    // -Wno-error=format-zero-length needed for gcc to compile.
107    cflags: [
108        "-Wall",
109        "-Werror",
110        "-fno-stack-protector",
111        "-Wno-error=format-zero-length",
112        "-Wthread-safety",
113    ],
114
115    apex_available: [
116        "com.android.runtime",
117    ],
118    static: {
119        apex_available: [
120            "//apex_available:platform",
121        ],
122    },
123}
124
125// ==============================================================
126// Unit Tests
127// ==============================================================
128cc_test {
129    name: "malloc_debug_unit_tests",
130    test_suites: ["device-tests"],
131    isolated: true,
132
133    srcs: [
134        "tests/backtrace_fake.cpp",
135        "tests/log_fake.cpp",
136        "tests/libc_fake.cpp",
137        "tests/malloc_debug_config_tests.cpp",
138        "tests/malloc_debug_unit_tests.cpp",
139    ],
140
141    local_include_dirs: ["tests"],
142    include_dirs: [
143        "bionic/libc",
144        "bionic/libc/async_safe/include",
145    ],
146
147    header_libs: [
148        "bionic_libc_platform_headers",
149    ],
150
151    static_libs: [
152        "libc_malloc_debug",
153        "libtinyxml2",
154    ],
155
156    shared_libs: [
157        "libbase",
158        "libunwindstack",
159    ],
160
161    cflags: [
162        "-Wall",
163        "-Werror",
164        "-Wno-error=format-zero-length",
165        "-O0",
166    ],
167}
168
169// ==============================================================
170// System Tests
171// ==============================================================
172cc_test {
173    name: "malloc_debug_system_tests",
174    isolated: true,
175
176    include_dirs: [
177        "bionic/libc",
178        "bionic", // For SKIP_WITH_HWASAN.
179    ],
180
181    header_libs: [
182        "bionic_libc_platform_headers",
183    ],
184
185    // The clang-analyzer-unix.Malloc and other warnings in these
186    // unit tests are either false positive or in
187    // negative tests that can be ignored.
188    tidy: false,
189
190    srcs: [
191        "tests/malloc_debug_system_tests.cpp",
192    ],
193
194    shared_libs: [
195        "libbase",
196        "liblog",
197        "libunwindstack",
198    ],
199
200    cflags: [
201        "-Wall",
202        "-Werror",
203        "-O0",
204    ],
205    test_suites: ["general-tests"],
206    test_config: "tests/AndroidTest.xml",
207}
208