blob: fd14aea57a3dad532488361229e10aa8fa1ce382 [file] [log] [blame]
Dan Willemsen208ae172015-09-16 16:33:27 -07001// Define the common source files for all the libc instances
2// =========================================================
Bob Badouraa7d8352021-02-19 13:06:22 -08003package {
4 default_applicable_licenses: ["bionic_libc_license"],
5}
6
7license {
8 name: "bionic_libc_license",
9 visibility: [":__subpackages__"],
10 license_kinds: [
11 "SPDX-license-identifier-Apache-2.0",
12 "SPDX-license-identifier-BSD",
13 "SPDX-license-identifier-ISC",
14 "SPDX-license-identifier-MIT",
15 "legacy_notice",
16 "legacy_unencumbered",
17 ],
18 license_text: [
19 "NOTICE",
20 ],
21}
22
Elliott Hughes53cf3482016-08-09 13:06:41 -070023libc_common_flags = [
24 "-D_LIBC=1",
Elliott Hughes25f17e42018-02-12 15:48:01 -080025 "-D__BIONIC_LP32_USE_STAT64",
Elliott Hughes53cf3482016-08-09 13:06:41 -070026 "-Wall",
27 "-Wextra",
28 "-Wunused",
Elliott Hughes3048a362018-01-19 17:58:07 -080029 "-Wno-char-subscripts",
Elliott Hughes53cf3482016-08-09 13:06:41 -070030 "-Wno-deprecated-declarations",
Elliott Hughesb348d5c2017-07-24 16:53:11 -070031 "-Wno-gcc-compat",
Elliott Hughes8e547bd2016-08-16 15:57:47 -070032 "-Wframe-larger-than=2048",
Christopher Ferris1de7a482023-09-12 11:06:29 -070033 "-Wno-reorder-init-list",
Elliott Hughes53cf3482016-08-09 13:06:41 -070034
35 // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
36 "-Werror=pointer-to-int-cast",
37 "-Werror=int-to-pointer-cast",
38 "-Werror=type-limits",
39 "-Werror",
Ryan Prichard8f419572018-02-20 17:09:05 -080040
41 // Clang's exit-time destructor registration hides __dso_handle, but
42 // __dso_handle needs to have default visibility on ARM32. See b/73485611.
43 "-Wexit-time-destructors",
Mitch Phillipsf3968e82020-01-31 19:57:04 -080044
Elliott Hughesa13d0662021-12-02 14:42:16 -080045 // We know clang does a lot of harm by rewriting what we've said, and sadly
46 // never see any good it does, so let's just ask it to do what we say...
47 // (The specific motivating example was clang turning a loop that would only
48 // ever touch 0, 1, or 2 bytes into a call to memset, which was never going
49 // to amortize.)
50 "-fno-builtin",
Elliott Hughes53cf3482016-08-09 13:06:41 -070051]
52
Dan Willemsen208ae172015-09-16 16:33:27 -070053// Define some common cflags
54// ========================================================
Colin Cross50c21ab2015-10-31 23:03:05 -070055cc_defaults {
56 name: "libc_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -080057 defaults: ["linux_bionic_supported"],
Elliott Hughes53cf3482016-08-09 13:06:41 -070058 cflags: libc_common_flags,
59 asflags: libc_common_flags,
Colin Cross50c21ab2015-10-31 23:03:05 -070060 conlyflags: ["-std=gnu99"],
61 cppflags: [],
Christopher Ferris7a3681e2017-04-24 17:48:32 -070062 include_dirs: [
63 "bionic/libc/async_safe/include",
Peter Collingbourne5d3aa862020-09-11 15:05:17 -070064 "bionic/libc/platform",
Tom Cherry379ed1e2020-09-17 09:36:25 -070065 // For android_filesystem_config.h.
66 "system/core/libcutils/include",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070067 ],
Colin Cross50c21ab2015-10-31 23:03:05 -070068
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010069 header_libs: [
70 "libc_headers",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +000071 "liblog_headers", // needed by bionic/libc/async_safe/include
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010072 ],
73 export_header_lib_headers: [
74 "libc_headers",
75 ],
Mitch Phillipsf3968e82020-01-31 19:57:04 -080076
Colin Cross50c21ab2015-10-31 23:03:05 -070077 stl: "none",
78 system_shared_libs: [],
Colin Cross27c43c52016-04-07 13:27:24 -070079 sanitize: {
Evgenii Stepanovbe551f52018-08-13 16:46:15 -070080 address: false,
81 integer_overflow: false,
Mitch Phillipsdfde0ee2019-05-01 14:26:13 -070082 // TODO(b/132640749): Fix broken fuzzer support.
83 fuzzer: false,
Colin Cross27c43c52016-04-07 13:27:24 -070084 },
Yifan Hong5a39cee2020-01-21 16:43:56 -080085 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -070086 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +090087 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +020088 native_bridge_supported: true,
Ivan Lozanof17fd1d2018-11-27 07:56:17 -080089
Yi Konge3d90de2019-02-20 14:28:56 -080090 // lld complains about duplicate symbols in libcrt and libgcc. Suppress the
91 // warning since this is intended right now.
92 ldflags: ["-Wl,-z,muldefs"],
Peter Collingbournee99912f2019-11-01 15:37:00 -070093
Quallenauge6c66f942020-10-20 21:19:01 +020094 multilib: {
95 lib64: {
96 product_variables: {
97 malloc_zero_contents: {
98 cflags: ["-DSCUDO_ZERO_CONTENTS"],
99 },
100 malloc_pattern_fill_contents: {
101 cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
102 },
103 malloc_not_svelte: {
104 cflags: ["-DUSE_SCUDO"],
105 },
106 },
Evgenii Stepanov5a73e032020-04-29 14:59:44 -0700107 },
Quallenauge6c66f942020-10-20 21:19:01 +0200108 lib32: {
109 product_variables: {
110 malloc_zero_contents: {
111 cflags: ["-DSCUDO_ZERO_CONTENTS"],
112 },
113 malloc_pattern_fill_contents: {
114 cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
115 },
116 malloc_not_svelte_libc32: {
117 cflags: ["-DUSE_SCUDO"],
118 },
119 },
Steven Morelandfb65ee42020-07-31 00:18:38 +0000120 },
Peter Collingbournee99912f2019-11-01 15:37:00 -0700121 },
Yi Kong9e33b762021-10-29 02:43:22 +0800122
123 lto: {
124 never: true,
125 },
Elliott Hughesc2043342023-07-20 20:24:09 +0000126
127 apex_available: ["com.android.runtime"],
Elliott Hughes7d136662023-10-27 15:40:32 -0700128
129 tidy_disabled_srcs: ["upstream-*/**/*.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700130}
131
Christopher Ferris4df29ed2020-01-24 18:06:42 -0800132libc_scudo_product_variables = {
133 malloc_not_svelte: {
134 cflags: ["-DUSE_SCUDO"],
135 whole_static_libs: ["libscudo"],
136 exclude_static_libs: [
137 "libjemalloc5",
138 "libc_jemalloc_wrapper",
139 ],
140 },
141}
142
Quallenauge6c66f942020-10-20 21:19:01 +0200143libc32_scudo_product_variables = {
144 malloc_not_svelte_libc32: {
145 cflags: ["-DUSE_SCUDO"],
146 whole_static_libs: ["libscudo"],
147 exclude_static_libs: [
148 "libjemalloc5",
149 "libc_jemalloc_wrapper",
150 ],
151 },
152}
153
154
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700155// Defaults for native allocator libs/includes to make it
156// easier to change.
Christopher Ferris062eba22020-01-31 22:40:45 -0800157// To disable scudo for the non-svelte config remove the line:
Christopher Ferris4df29ed2020-01-24 18:06:42 -0800158// product_variables: libc_scudo_product_variables,
Christopher Ferris062eba22020-01-31 22:40:45 -0800159// in the cc_defaults below.
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700160// ========================================================
161cc_defaults {
162 name: "libc_native_allocator_defaults",
163
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700164 whole_static_libs: [
165 "libjemalloc5",
166 "libc_jemalloc_wrapper",
167 ],
Mitch Phillipsf3968e82020-01-31 19:57:04 -0800168 header_libs: ["gwp_asan_headers"],
Quallenauge6c66f942020-10-20 21:19:01 +0200169 multilib: {
170 lib64: {
171 product_variables: libc_scudo_product_variables,
172 },
173 lib32: {
174 product_variables: libc32_scudo_product_variables,
175 }
176 },
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700177}
178
179// Functions not implemented by jemalloc directly, or that need to
180// be modified for Android.
181cc_library_static {
182 name: "libc_jemalloc_wrapper",
183 defaults: ["libc_defaults"],
184 srcs: ["bionic/jemalloc_wrapper.cpp"],
185 cflags: ["-fvisibility=hidden"],
186
Christopher Ferris4df29ed2020-01-24 18:06:42 -0800187 // Used to pull in the jemalloc include directory so that if the
188 // library is removed, the include directory is also removed.
189 static_libs: ["libjemalloc5"],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700190}
191
Dan Willemsen208ae172015-09-16 16:33:27 -0700192// ========================================================
Ryan Prichard249757b2019-11-01 17:18:28 -0700193// libc_bootstrap.a - -fno-stack-protector and -ffreestanding
Dan Willemsen208ae172015-09-16 16:33:27 -0700194// ========================================================
195//
Ryan Prichard249757b2019-11-01 17:18:28 -0700196// Code that implements the stack protector (or that runs before TLS has been set up) needs to be
197// compiled with -fno-stack-protector, since it accesses the stack canary TLS slot. In the linker,
198// some of this code runs before ifunc resolvers have made string.h functions work, so compile with
199// -ffreestanding.
Dan Willemsen208ae172015-09-16 16:33:27 -0700200
201cc_library_static {
202
Colin Crossa3f9fca2016-01-11 13:20:55 -0800203 srcs: [
204 "bionic/__libc_init_main_thread.cpp",
205 "bionic/__stack_chk_fail.cpp",
Ryan Prichard249757b2019-11-01 17:18:28 -0700206 "bionic/bionic_call_ifunc_resolver.cpp",
207 "bionic/getauxval.cpp",
Colin Crossa3f9fca2016-01-11 13:20:55 -0800208 ],
209 arch: {
210 arm64: {
211 srcs: ["arch-arm64/bionic/__set_tls.c"],
212 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000213 riscv64: {
214 srcs: ["arch-riscv64/bionic/__set_tls.c"],
215 },
Colin Crossa3f9fca2016-01-11 13:20:55 -0800216 x86: {
Ryan Prichard27475b52018-05-17 17:14:18 -0700217 srcs: [
218 "arch-x86/bionic/__libc_init_sysinfo.cpp",
Pirama Arumuga Nainar7b89be72021-02-12 15:09:49 -0800219 "arch-x86/bionic/__libc_int0x80.S",
Ryan Prichard27475b52018-05-17 17:14:18 -0700220 "arch-x86/bionic/__set_tls.cpp",
221 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800222 },
223 x86_64: {
224 srcs: ["arch-x86_64/bionic/__set_tls.c"],
225 },
226 },
227
Colin Cross50c21ab2015-10-31 23:03:05 -0700228 defaults: ["libc_defaults"],
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000229 cflags: [
230 "-fno-stack-protector",
231 "-ffreestanding",
232 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700233 name: "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -0700234}
235
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800236filegroup {
237 name: "elf_note_sources",
238 srcs: ["bionic/elf_note.cpp"],
239}
240
Ryan Prichard249757b2019-11-01 17:18:28 -0700241// libc_init_static.cpp and libc_init_dynamic.cpp need to be built without stack protector.
242// libc_init_static.cpp sets up TLS for static executables, and libc_init_dynamic.cpp initializes
243// the stack protector global variable.
Colin Crossa3f9fca2016-01-11 13:20:55 -0800244
245cc_library_static {
246 name: "libc_init_static",
247 defaults: ["libc_defaults"],
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800248 srcs: [
249 "bionic/libc_init_static.cpp",
250 ":elf_note_sources",
251 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700252 cflags: [
253 "-fno-stack-protector",
254
255 // Compile libc_init_static.cpp with -ffreestanding, because some of its code is called
256 // from the linker before ifunc resolvers have made string.h functions available.
257 "-ffreestanding",
258 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800259}
260
Stephen Cranef4b1cbd2017-05-09 14:27:43 -0700261cc_library_static {
262 name: "libc_init_dynamic",
263 defaults: ["libc_defaults"],
264 srcs: ["bionic/libc_init_dynamic.cpp"],
265 cflags: ["-fno-stack-protector"],
266}
Colin Crossa3f9fca2016-01-11 13:20:55 -0800267
Dan Willemsen208ae172015-09-16 16:33:27 -0700268// ========================================================
269// libc_tzcode.a - upstream 'tzcode' code
270// ========================================================
271
272cc_library_static {
273
Colin Cross50c21ab2015-10-31 23:03:05 -0700274 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700275 srcs: [
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800276 "tzcode/**/*.c",
Elliott Hughes0e8616a2017-04-11 14:44:51 -0700277 "tzcode/bionic.cpp",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700278 // tzcode doesn't include strptime, so we use a fork of the
279 // OpenBSD code which needs this global data.
Elliott Hughesd3627a42022-12-06 22:24:27 +0000280 "upstream-openbsd/lib/libc/locale/_def_time.c",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700281 // tzcode doesn't include wcsftime, so we use the FreeBSD code.
282 "upstream-freebsd/lib/libc/locale/wcsftime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700283 ],
284
Colin Cross50c21ab2015-10-31 23:03:05 -0700285 cflags: [
Dan Willemsen268a6732015-10-15 14:49:45 -0700286 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700287 // Don't use ridiculous amounts of stack.
288 "-DALL_STATE",
289 // Include tzsetwall, timelocal, timegm, time2posix, and posix2time.
290 "-DSTD_INSPIRED",
Colin Crossa35d23d2015-11-19 13:32:49 -0800291 // Obviously, we want to be thread-safe.
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000292 "-DTHREAD_SAFE=1",
Dan Willemsen208ae172015-09-16 16:33:27 -0700293 // The name of the tm_gmtoff field in our struct tm.
294 "-DTM_GMTOFF=tm_gmtoff",
Elliott Hughes31fc69f2023-06-20 15:36:11 -0700295 // Android uses a system property instead of /etc/localtime, so make callers crash.
Almaz Mingaleeva52a0da2022-02-28 16:55:50 +0000296 "-DTZDEFAULT=NULL",
Dan Willemsen208ae172015-09-16 16:33:27 -0700297 // Where we store our tzdata.
Colin Cross7b294952016-09-29 14:08:13 -0700298 "-DTZDIR=\"/system/usr/share/zoneinfo\"",
Elliott Hughes0a610d02016-07-29 14:04:17 -0700299 // Include `tzname`, `timezone`, and `daylight` globals.
300 "-DHAVE_POSIX_DECLS=0",
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000301 "-DUSG_COMPAT=2",
302 "-DHAVE_TZNAME=2",
303 // stdbool.h is available
304 "-DHAVE_STDBOOL_H",
Colin Crossa35d23d2015-11-19 13:32:49 -0800305 // Use the empty string (instead of " ") as the timezone abbreviation
306 // fallback.
Colin Cross7b294952016-09-29 14:08:13 -0700307 "-DWILDABBR=\"\"",
Dan Willemsen208ae172015-09-16 16:33:27 -0700308 "-Dlint",
309 ],
310
Elliott Hughes2bd43162023-06-15 13:17:08 -0700311 local_include_dirs: [
312 "tzcode/",
313 "upstream-freebsd/android/include",
314 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700315 name: "libc_tzcode",
Dan Willemsen208ae172015-09-16 16:33:27 -0700316}
317
318// ========================================================
319// libc_dns.a - modified NetBSD DNS code
320// ========================================================
321
322cc_library_static {
323
Colin Cross50c21ab2015-10-31 23:03:05 -0700324 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700325 srcs: [
Elliott Hughesd0bbfa82021-04-08 11:58:51 -0700326 "dns/**/*.c*",
Dan Willemsen208ae172015-09-16 16:33:27 -0700327
328 "upstream-netbsd/lib/libc/isc/ev_streams.c",
329 "upstream-netbsd/lib/libc/isc/ev_timers.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700330 ],
331
Colin Cross50c21ab2015-10-31 23:03:05 -0700332 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700333 "-DANDROID_CHANGES",
334 "-DINET6",
Dan Willemsen208ae172015-09-16 16:33:27 -0700335 "-Wno-unused-parameter",
336 "-include netbsd-compat.h",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700337 "-Wframe-larger-than=66000",
Elliott Hughese1dc4f62021-01-11 11:51:29 -0800338 "-include private/bsd_sys_param.h",
Dan Willemsen208ae172015-09-16 16:33:27 -0700339 ],
340
Dan Willemsen208ae172015-09-16 16:33:27 -0700341 local_include_dirs: [
342 "dns/include",
343 "private",
344 "upstream-netbsd/lib/libc/include",
345 "upstream-netbsd/android/include",
346 ],
347
348 name: "libc_dns",
Dan Willemsen208ae172015-09-16 16:33:27 -0700349}
350
351// ========================================================
352// libc_freebsd.a - upstream FreeBSD C library code
353// ========================================================
354//
355// These files are built with the freebsd-compat.h header file
356// automatically included.
357
358cc_library_static {
Elliott Hughesc2043342023-07-20 20:24:09 +0000359 name: "libc_freebsd_ldexp",
360 defaults: ["libc_defaults"],
361 cflags: ["-Dscalbn=ldexp"],
362 srcs: [":libc_ldexp_srcs"],
363}
364
365cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700366 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700367 srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700368 "upstream-freebsd/lib/libc/stdlib/getopt_long.c",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700369 "upstream-freebsd/lib/libc/stdlib/hcreate.c",
370 "upstream-freebsd/lib/libc/stdlib/hcreate_r.c",
371 "upstream-freebsd/lib/libc/stdlib/hdestroy_r.c",
372 "upstream-freebsd/lib/libc/stdlib/hsearch_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700373 "upstream-freebsd/lib/libc/stdlib/qsort.c",
374 "upstream-freebsd/lib/libc/stdlib/quick_exit.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700375 "upstream-freebsd/lib/libc/string/wcpcpy.c",
376 "upstream-freebsd/lib/libc/string/wcpncpy.c",
377 "upstream-freebsd/lib/libc/string/wcscasecmp.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700378 "upstream-freebsd/lib/libc/string/wcscat.c",
379 "upstream-freebsd/lib/libc/string/wcschr.c",
380 "upstream-freebsd/lib/libc/string/wcscmp.c",
381 "upstream-freebsd/lib/libc/string/wcscpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700382 "upstream-freebsd/lib/libc/string/wcscspn.c",
383 "upstream-freebsd/lib/libc/string/wcsdup.c",
384 "upstream-freebsd/lib/libc/string/wcslcat.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700385 "upstream-freebsd/lib/libc/string/wcslen.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700386 "upstream-freebsd/lib/libc/string/wcsncasecmp.c",
387 "upstream-freebsd/lib/libc/string/wcsncat.c",
388 "upstream-freebsd/lib/libc/string/wcsncmp.c",
389 "upstream-freebsd/lib/libc/string/wcsncpy.c",
390 "upstream-freebsd/lib/libc/string/wcsnlen.c",
391 "upstream-freebsd/lib/libc/string/wcspbrk.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700392 "upstream-freebsd/lib/libc/string/wcsrchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700393 "upstream-freebsd/lib/libc/string/wcsspn.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700394 "upstream-freebsd/lib/libc/string/wcsstr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700395 "upstream-freebsd/lib/libc/string/wcstok.c",
396 "upstream-freebsd/lib/libc/string/wmemchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700397 "upstream-freebsd/lib/libc/string/wmemcmp.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700398 "upstream-freebsd/lib/libc/string/wmemcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700399 "upstream-freebsd/lib/libc/string/wmemmove.c",
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800400 "upstream-freebsd/lib/libc/string/wmemset.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700401 ],
402 arch: {
Dan Willemsen208ae172015-09-16 16:33:27 -0700403 x86: {
404 exclude_srcs: [
405 "upstream-freebsd/lib/libc/string/wcschr.c",
406 "upstream-freebsd/lib/libc/string/wcscmp.c",
407 "upstream-freebsd/lib/libc/string/wcslen.c",
408 "upstream-freebsd/lib/libc/string/wcsrchr.c",
Haibo Huangb9244ff2018-08-11 10:12:13 -0700409 "upstream-freebsd/lib/libc/string/wmemcmp.c",
410 "upstream-freebsd/lib/libc/string/wcscat.c",
411 "upstream-freebsd/lib/libc/string/wcscpy.c",
412 "upstream-freebsd/lib/libc/string/wmemcmp.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700413 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700414 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700415 },
416
Colin Cross50c21ab2015-10-31 23:03:05 -0700417 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700418 "-Wno-sign-compare",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700419 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700420 "-include freebsd-compat.h",
421 ],
422
Dan Willemsen208ae172015-09-16 16:33:27 -0700423 local_include_dirs: [
424 "upstream-freebsd/android/include",
425 ],
426
427 name: "libc_freebsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700428}
429
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700430cc_library_static {
431 defaults: ["libc_defaults"],
432 srcs: [
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700433 "upstream-freebsd/lib/libc/gen/glob.c",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700434 ],
435
436 cflags: [
437 "-Wno-sign-compare",
438 "-include freebsd-compat.h",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700439 "-Wframe-larger-than=66000",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700440 ],
441
442 local_include_dirs: [
443 "upstream-freebsd/android/include",
444 ],
445
446 name: "libc_freebsd_large_stack",
447}
448
Dan Willemsen208ae172015-09-16 16:33:27 -0700449// ========================================================
450// libc_netbsd.a - upstream NetBSD C library code
451// ========================================================
452//
453// These files are built with the netbsd-compat.h header file
454// automatically included.
455
456cc_library_static {
457
Colin Cross50c21ab2015-10-31 23:03:05 -0700458 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700459 srcs: [
460 "upstream-netbsd/common/lib/libc/stdlib/random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700461 "upstream-netbsd/lib/libc/gen/nice.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700462 "upstream-netbsd/lib/libc/gen/psignal.c",
463 "upstream-netbsd/lib/libc/gen/utime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700464 "upstream-netbsd/lib/libc/inet/nsap_addr.c",
465 "upstream-netbsd/lib/libc/regex/regcomp.c",
466 "upstream-netbsd/lib/libc/regex/regerror.c",
467 "upstream-netbsd/lib/libc/regex/regexec.c",
468 "upstream-netbsd/lib/libc/regex/regfree.c",
469 "upstream-netbsd/lib/libc/stdlib/bsearch.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700470 "upstream-netbsd/lib/libc/stdlib/drand48.c",
471 "upstream-netbsd/lib/libc/stdlib/erand48.c",
472 "upstream-netbsd/lib/libc/stdlib/jrand48.c",
473 "upstream-netbsd/lib/libc/stdlib/lcong48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700474 "upstream-netbsd/lib/libc/stdlib/lrand48.c",
475 "upstream-netbsd/lib/libc/stdlib/mrand48.c",
476 "upstream-netbsd/lib/libc/stdlib/nrand48.c",
477 "upstream-netbsd/lib/libc/stdlib/_rand48.c",
478 "upstream-netbsd/lib/libc/stdlib/rand_r.c",
479 "upstream-netbsd/lib/libc/stdlib/reallocarr.c",
480 "upstream-netbsd/lib/libc/stdlib/seed48.c",
481 "upstream-netbsd/lib/libc/stdlib/srand48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700482 ],
483 multilib: {
484 lib32: {
485 // LP32 cruft
486 srcs: ["upstream-netbsd/common/lib/libc/hash/sha1/sha1.c"],
487 },
488 },
Colin Cross50c21ab2015-10-31 23:03:05 -0700489 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700490 "-Wno-sign-compare",
Dan Willemsen879cec22016-02-29 10:37:56 -0800491 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700492 "-DPOSIX_MISTAKE",
493 "-include netbsd-compat.h",
494 ],
495
Dan Willemsen208ae172015-09-16 16:33:27 -0700496 local_include_dirs: [
497 "upstream-netbsd/android/include",
498 "upstream-netbsd/lib/libc/include",
499 ],
500
501 name: "libc_netbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700502}
503
504// ========================================================
Elliott Hughes968adf92024-02-08 13:15:53 -0800505// libc_openbsd.a - upstream OpenBSD C library code
Dan Willemsen208ae172015-09-16 16:33:27 -0700506// ========================================================
507//
508// These files are built with the openbsd-compat.h header file
509// automatically included.
Dan Willemsen208ae172015-09-16 16:33:27 -0700510cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700511 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700512 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800513 "upstream-openbsd/lib/libc/crypt/arc4random.c",
514 "upstream-openbsd/lib/libc/crypt/arc4random_uniform.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700515 "upstream-openbsd/lib/libc/gen/alarm.c",
516 "upstream-openbsd/lib/libc/gen/ctype_.c",
517 "upstream-openbsd/lib/libc/gen/daemon.c",
518 "upstream-openbsd/lib/libc/gen/err.c",
519 "upstream-openbsd/lib/libc/gen/errx.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700520 "upstream-openbsd/lib/libc/gen/fnmatch.c",
521 "upstream-openbsd/lib/libc/gen/ftok.c",
522 "upstream-openbsd/lib/libc/gen/getprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700523 "upstream-openbsd/lib/libc/gen/setprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700524 "upstream-openbsd/lib/libc/gen/verr.c",
525 "upstream-openbsd/lib/libc/gen/verrx.c",
526 "upstream-openbsd/lib/libc/gen/vwarn.c",
527 "upstream-openbsd/lib/libc/gen/vwarnx.c",
528 "upstream-openbsd/lib/libc/gen/warn.c",
529 "upstream-openbsd/lib/libc/gen/warnx.c",
530 "upstream-openbsd/lib/libc/locale/btowc.c",
531 "upstream-openbsd/lib/libc/locale/mbrlen.c",
532 "upstream-openbsd/lib/libc/locale/mbstowcs.c",
533 "upstream-openbsd/lib/libc/locale/mbtowc.c",
534 "upstream-openbsd/lib/libc/locale/wcscoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700535 "upstream-openbsd/lib/libc/locale/wcstombs.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700536 "upstream-openbsd/lib/libc/locale/wcsxfrm.c",
537 "upstream-openbsd/lib/libc/locale/wctob.c",
538 "upstream-openbsd/lib/libc/locale/wctomb.c",
Elliott Hughes26fda772016-04-06 11:56:41 -0700539 "upstream-openbsd/lib/libc/net/base64.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700540 "upstream-openbsd/lib/libc/net/htonl.c",
541 "upstream-openbsd/lib/libc/net/htons.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700542 "upstream-openbsd/lib/libc/net/inet_lnaof.c",
543 "upstream-openbsd/lib/libc/net/inet_makeaddr.c",
544 "upstream-openbsd/lib/libc/net/inet_netof.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700545 "upstream-openbsd/lib/libc/net/inet_ntoa.c",
546 "upstream-openbsd/lib/libc/net/inet_ntop.c",
547 "upstream-openbsd/lib/libc/net/inet_pton.c",
548 "upstream-openbsd/lib/libc/net/ntohl.c",
549 "upstream-openbsd/lib/libc/net/ntohs.c",
Colin Cross8ce38af2016-01-19 12:50:20 -0800550 "upstream-openbsd/lib/libc/net/res_random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700551 "upstream-openbsd/lib/libc/stdio/fgetln.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700552 "upstream-openbsd/lib/libc/stdio/fgetwc.c",
553 "upstream-openbsd/lib/libc/stdio/fgetws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700554 "upstream-openbsd/lib/libc/stdio/flags.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700555 "upstream-openbsd/lib/libc/stdio/fpurge.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700556 "upstream-openbsd/lib/libc/stdio/fputwc.c",
557 "upstream-openbsd/lib/libc/stdio/fputws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700558 "upstream-openbsd/lib/libc/stdio/fvwrite.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700559 "upstream-openbsd/lib/libc/stdio/fwide.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700560 "upstream-openbsd/lib/libc/stdio/getdelim.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700561 "upstream-openbsd/lib/libc/stdio/gets.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700562 "upstream-openbsd/lib/libc/stdio/makebuf.c",
563 "upstream-openbsd/lib/libc/stdio/mktemp.c",
564 "upstream-openbsd/lib/libc/stdio/open_memstream.c",
565 "upstream-openbsd/lib/libc/stdio/open_wmemstream.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700566 "upstream-openbsd/lib/libc/stdio/rget.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700567 "upstream-openbsd/lib/libc/stdio/setvbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700568 "upstream-openbsd/lib/libc/stdio/ungetc.c",
569 "upstream-openbsd/lib/libc/stdio/ungetwc.c",
570 "upstream-openbsd/lib/libc/stdio/vasprintf.c",
571 "upstream-openbsd/lib/libc/stdio/vdprintf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700572 "upstream-openbsd/lib/libc/stdio/vsscanf.c",
573 "upstream-openbsd/lib/libc/stdio/vswprintf.c",
574 "upstream-openbsd/lib/libc/stdio/vswscanf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700575 "upstream-openbsd/lib/libc/stdio/wbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700576 "upstream-openbsd/lib/libc/stdio/wsetup.c",
577 "upstream-openbsd/lib/libc/stdlib/abs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800578 "upstream-openbsd/lib/libc/stdlib/div.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700579 "upstream-openbsd/lib/libc/stdlib/getenv.c",
Colin Crossb8396102016-04-07 13:24:50 -0700580 "upstream-openbsd/lib/libc/stdlib/getsubopt.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700581 "upstream-openbsd/lib/libc/stdlib/insque.c",
582 "upstream-openbsd/lib/libc/stdlib/imaxabs.c",
583 "upstream-openbsd/lib/libc/stdlib/imaxdiv.c",
584 "upstream-openbsd/lib/libc/stdlib/labs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800585 "upstream-openbsd/lib/libc/stdlib/ldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700586 "upstream-openbsd/lib/libc/stdlib/llabs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800587 "upstream-openbsd/lib/libc/stdlib/lldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700588 "upstream-openbsd/lib/libc/stdlib/lsearch.c",
Elliott Hughes26b06072020-07-31 11:00:10 -0700589 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700590 "upstream-openbsd/lib/libc/stdlib/remque.c",
591 "upstream-openbsd/lib/libc/stdlib/setenv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700592 "upstream-openbsd/lib/libc/stdlib/tfind.c",
593 "upstream-openbsd/lib/libc/stdlib/tsearch.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800594 "upstream-openbsd/lib/libc/string/memccpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700595 "upstream-openbsd/lib/libc/string/strcasecmp.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800596 "upstream-openbsd/lib/libc/string/strcasestr.c",
597 "upstream-openbsd/lib/libc/string/strcoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700598 "upstream-openbsd/lib/libc/string/strcspn.c",
599 "upstream-openbsd/lib/libc/string/strdup.c",
600 "upstream-openbsd/lib/libc/string/strndup.c",
601 "upstream-openbsd/lib/libc/string/strpbrk.c",
602 "upstream-openbsd/lib/libc/string/strsep.c",
603 "upstream-openbsd/lib/libc/string/strspn.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700604 "upstream-openbsd/lib/libc/string/strtok.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800605 "upstream-openbsd/lib/libc/string/strxfrm.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700606 "upstream-openbsd/lib/libc/string/wcslcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700607 "upstream-openbsd/lib/libc/string/wcswidth.c",
Colin Cross69bcb8b2021-09-08 13:24:16 -0700608
609 // This file is originally from OpenBSD, and benefits from
610 // being compiled with openbsd-compat.h.
Elliott Hughes968adf92024-02-08 13:15:53 -0800611 // TODO: clean this up instead.
Colin Cross69bcb8b2021-09-08 13:24:16 -0700612 "bionic/fts.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700613 ],
614
Elliott Hughes7d136662023-10-27 15:40:32 -0700615 // Each architecture has optimized versions of some routines,
616 // and only includes the portable C versions of ones it's missing.
Dan Willemsen208ae172015-09-16 16:33:27 -0700617 arch: {
618 arm: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700619 srcs: [
620 "upstream-openbsd/lib/libc/string/memchr.c",
621 "upstream-openbsd/lib/libc/string/memrchr.c",
622 "upstream-openbsd/lib/libc/string/stpncpy.c",
623 "upstream-openbsd/lib/libc/string/strlcat.c",
624 "upstream-openbsd/lib/libc/string/strlcpy.c",
625 "upstream-openbsd/lib/libc/string/strncat.c",
626 "upstream-openbsd/lib/libc/string/strncmp.c",
627 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700628 ],
629 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700630 arm64: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700631 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700632 "upstream-openbsd/lib/libc/string/strcat.c",
Elliott Hughesaefe9992023-11-08 12:04:41 -0800633 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700634 "upstream-openbsd/lib/libc/string/strlcat.c",
635 "upstream-openbsd/lib/libc/string/strlcpy.c",
636 "upstream-openbsd/lib/libc/string/strncat.c",
637 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700638 ],
639 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000640 riscv64: {
641 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700642 "upstream-openbsd/lib/libc/string/memrchr.c",
643 "upstream-openbsd/lib/libc/string/stpncpy.c",
644 "upstream-openbsd/lib/libc/string/strlcat.c",
645 "upstream-openbsd/lib/libc/string/strlcpy.c",
Elliott Hughesebc19a92022-10-14 23:25:36 +0000646 ],
647 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700648 x86: {
Elliott Hughesaefe9992023-11-08 12:04:41 -0800649 srcs: [
650 // x86 has custom implementations of all of these.
651 ],
Elliott Hughes7d136662023-10-27 15:40:32 -0700652 },
653 x86_64: {
654 srcs: [
Colin Cross6ab8f892015-11-23 14:12:15 -0800655 "upstream-openbsd/lib/libc/string/memchr.c",
Colin Cross6ab8f892015-11-23 14:12:15 -0800656 "upstream-openbsd/lib/libc/string/memrchr.c",
Haibo Huangb9244ff2018-08-11 10:12:13 -0700657 "upstream-openbsd/lib/libc/string/strlcat.c",
658 "upstream-openbsd/lib/libc/string/strlcpy.c",
Colin Cross6ab8f892015-11-23 14:12:15 -0800659 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700660 },
661 },
662
Colin Cross50c21ab2015-10-31 23:03:05 -0700663 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700664 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700665 "-Wno-unused-parameter",
666 "-include openbsd-compat.h",
667 ],
668
Dan Willemsen208ae172015-09-16 16:33:27 -0700669 local_include_dirs: [
670 "private",
Dan Willemsen208ae172015-09-16 16:33:27 -0700671 "upstream-openbsd/android/include",
Elliott Hughes968adf92024-02-08 13:15:53 -0800672 "stdio",
673 "upstream-openbsd/lib/libc/include",
Dan Willemsen208ae172015-09-16 16:33:27 -0700674 ],
675
676 name: "libc_openbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700677}
678
Elliott Hughes968adf92024-02-08 13:15:53 -0800679cc_library_static {
680 name: "libc_openbsd_large_stack",
681 defaults: ["libc_defaults"],
682 srcs: [
683 "stdio/vfprintf.cpp",
684 "stdio/vfwprintf.cpp",
685 "upstream-openbsd/lib/libc/string/memmem.c",
686 "upstream-openbsd/lib/libc/string/strstr.c",
687 ],
688 cflags: [
689 "-include openbsd-compat.h",
690 "-Wno-sign-compare",
691 "-Wframe-larger-than=5000",
692 ],
693
694 local_include_dirs: [
695 "private",
696 "upstream-openbsd/android/include/",
697 "upstream-openbsd/lib/libc/gdtoa/",
698 "upstream-openbsd/lib/libc/include/",
699 "upstream-openbsd/lib/libc/stdio/",
700 ],
701}
702
Dan Willemsen208ae172015-09-16 16:33:27 -0700703// ========================================================
704// libc_gdtoa.a - upstream OpenBSD C library gdtoa code
705// ========================================================
706//
707// These files are built with the openbsd-compat.h header file
708// automatically included.
709
710cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700711 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700712 srcs: [
713 "upstream-openbsd/android/gdtoa_support.cpp",
714 "upstream-openbsd/lib/libc/gdtoa/dmisc.c",
715 "upstream-openbsd/lib/libc/gdtoa/dtoa.c",
716 "upstream-openbsd/lib/libc/gdtoa/gdtoa.c",
717 "upstream-openbsd/lib/libc/gdtoa/gethex.c",
718 "upstream-openbsd/lib/libc/gdtoa/gmisc.c",
719 "upstream-openbsd/lib/libc/gdtoa/hd_init.c",
720 "upstream-openbsd/lib/libc/gdtoa/hdtoa.c",
721 "upstream-openbsd/lib/libc/gdtoa/hexnan.c",
722 "upstream-openbsd/lib/libc/gdtoa/ldtoa.c",
723 "upstream-openbsd/lib/libc/gdtoa/misc.c",
724 "upstream-openbsd/lib/libc/gdtoa/smisc.c",
725 "upstream-openbsd/lib/libc/gdtoa/strtod.c",
726 "upstream-openbsd/lib/libc/gdtoa/strtodg.c",
727 "upstream-openbsd/lib/libc/gdtoa/strtof.c",
728 "upstream-openbsd/lib/libc/gdtoa/strtord.c",
729 "upstream-openbsd/lib/libc/gdtoa/sum.c",
730 "upstream-openbsd/lib/libc/gdtoa/ulp.c",
731 ],
732 multilib: {
733 lib64: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800734 srcs: ["upstream-openbsd/lib/libc/gdtoa/strtorQ.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700735 },
736 },
737
Colin Cross50c21ab2015-10-31 23:03:05 -0700738 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700739 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700740 "-include openbsd-compat.h",
741 ],
742
Dan Willemsen208ae172015-09-16 16:33:27 -0700743 local_include_dirs: [
744 "private",
745 "upstream-openbsd/android/include",
746 "upstream-openbsd/lib/libc/include",
747 ],
748
749 name: "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -0700750}
751
752// ========================================================
Pierre-Clément Tosi467e58e2023-02-01 13:44:43 +0000753// libc_fortify.a - container for our FORTIFY
George Burgess IV6cb06872017-07-21 13:28:42 -0700754// implementation details
755// ========================================================
756cc_library_static {
757 defaults: ["libc_defaults"],
George Burgess IVd34b0a92017-07-25 11:43:39 -0700758 srcs: ["bionic/fortify.cpp"],
George Burgess IV6cb06872017-07-21 13:28:42 -0700759
760 name: "libc_fortify",
761
762 // Disable FORTIFY for the compilation of these, so we don't end up having
763 // FORTIFY silently call itself.
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800764 cflags: [
765 "-U_FORTIFY_SOURCE",
766 "-D__BIONIC_DECLARE_FORTIFY_HELPERS",
767 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700768
769 arch: {
770 arm: {
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800771 cflags: [
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800772 "-DRENAME___STRCAT_CHK",
773 "-DRENAME___STRCPY_CHK",
774 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700775 srcs: [
776 "arch-arm/generic/bionic/__memcpy_chk.S",
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800777
778 "arch-arm/cortex-a15/bionic/__strcat_chk.S",
779 "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
780
781 "arch-arm/cortex-a7/bionic/__strcat_chk.S",
782 "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
783
784 "arch-arm/cortex-a9/bionic/__strcat_chk.S",
785 "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
786
787 "arch-arm/krait/bionic/__strcat_chk.S",
788 "arch-arm/krait/bionic/__strcpy_chk.S",
789
790 "arch-arm/cortex-a53/bionic/__strcat_chk.S",
791 "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
792
Haibo Huang01bfd892018-12-03 15:05:16 -0800793 "arch-arm/cortex-a55/bionic/__strcat_chk.S",
794 "arch-arm/cortex-a55/bionic/__strcpy_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700795 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700796 },
797 arm64: {
798 srcs: [
Elliott Hughes023e4e72022-11-17 19:27:02 +0000799 "arch-arm64/string/__memcpy_chk.S",
800 "arch-arm64/string/__memset_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700801 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700802 },
caowenchengab457f92023-03-06 14:57:55 +0800803 riscv64: {
804 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000805 "arch-riscv64/string/__memset_chk.S",
806 "arch-riscv64/string/__memcpy_chk.S",
caowenchengab457f92023-03-06 14:57:55 +0800807 ],
808 },
George Burgess IV6cb06872017-07-21 13:28:42 -0700809 },
810}
811
812// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -0700813// libc_bionic.a - home-grown C library code
814// ========================================================
815
816cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700817 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700818 srcs: [
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800819 "bionic/NetdClientDispatch.cpp",
820 "bionic/__bionic_get_shell_path.cpp",
821 "bionic/__cmsg_nxthdr.cpp",
822 "bionic/__cxa_thread_atexit_impl.cpp",
823 "bionic/__errno.cpp",
824 "bionic/__gnu_basename.cpp",
825 "bionic/__libc_current_sigrtmax.cpp",
826 "bionic/__libc_current_sigrtmin.cpp",
827 "bionic/abort.cpp",
828 "bionic/accept.cpp",
829 "bionic/access.cpp",
Florian Mayerca4749a2024-02-14 12:55:46 -0800830 "bionic/android_crash_detail.cpp",
Josh Gao10ec9282017-04-03 15:13:29 -0700831 "bionic/android_set_abort_message.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000832 "bionic/android_unsafe_frame_pointer_chase.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800833 "bionic/arpa_inet.cpp",
834 "bionic/assert.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000835 "bionic/atexit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800836 "bionic/atof.cpp",
837 "bionic/bionic_allocator.cpp",
838 "bionic/bionic_arc4random.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000839 "bionic/bionic_elf_tls.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800840 "bionic/bionic_futex.cpp",
841 "bionic/bionic_netlink.cpp",
842 "bionic/bionic_systrace.cpp",
843 "bionic/bionic_time_conversions.cpp",
844 "bionic/brk.cpp",
845 "bionic/c16rtomb.cpp",
846 "bionic/c32rtomb.cpp",
847 "bionic/chmod.cpp",
848 "bionic/chown.cpp",
849 "bionic/clearenv.cpp",
850 "bionic/clock.cpp",
851 "bionic/clock_getcpuclockid.cpp",
852 "bionic/clock_nanosleep.cpp",
853 "bionic/clone.cpp",
854 "bionic/ctype.cpp",
855 "bionic/dirent.cpp",
856 "bionic/dup.cpp",
857 "bionic/environ.cpp",
858 "bionic/error.cpp",
859 "bionic/eventfd.cpp",
860 "bionic/exec.cpp",
861 "bionic/execinfo.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800862 "bionic/exit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800863 "bionic/faccessat.cpp",
864 "bionic/fchmod.cpp",
865 "bionic/fchmodat.cpp",
866 "bionic/fcntl.cpp",
867 "bionic/fdsan.cpp",
868 "bionic/fdtrack.cpp",
869 "bionic/ffs.cpp",
870 "bionic/fgetxattr.cpp",
871 "bionic/flistxattr.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000872 "bionic/fork.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800873 "bionic/fpclassify.cpp",
874 "bionic/fsetxattr.cpp",
875 "bionic/ftruncate.cpp",
876 "bionic/ftw.cpp",
877 "bionic/futimens.cpp",
878 "bionic/getcwd.cpp",
879 "bionic/getdomainname.cpp",
880 "bionic/getentropy.cpp",
881 "bionic/gethostname.cpp",
882 "bionic/getloadavg.cpp",
883 "bionic/getpagesize.cpp",
884 "bionic/getpgrp.cpp",
885 "bionic/getpid.cpp",
886 "bionic/getpriority.cpp",
887 "bionic/gettid.cpp",
888 "bionic/get_device_api_level.cpp",
889 "bionic/grp_pwd.cpp",
890 "bionic/grp_pwd_file.cpp",
891 "bionic/heap_zero_init.cpp",
892 "bionic/iconv.cpp",
893 "bionic/icu_wrappers.cpp",
894 "bionic/ifaddrs.cpp",
895 "bionic/inotify_init.cpp",
896 "bionic/ioctl.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800897 "bionic/isatty.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800898 "bionic/killpg.cpp",
899 "bionic/langinfo.cpp",
900 "bionic/lchown.cpp",
901 "bionic/lfs64_support.cpp",
902 "bionic/libc_init_common.cpp",
903 "bionic/libgen.cpp",
904 "bionic/link.cpp",
905 "bionic/locale.cpp",
906 "bionic/lockf.cpp",
907 "bionic/lstat.cpp",
908 "bionic/mblen.cpp",
909 "bionic/mbrtoc16.cpp",
910 "bionic/mbrtoc32.cpp",
911 "bionic/mempcpy.cpp",
912 "bionic/memset_explicit.cpp",
913 "bionic/mkdir.cpp",
914 "bionic/mkfifo.cpp",
915 "bionic/mknod.cpp",
916 "bionic/mntent.cpp",
917 "bionic/mremap.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800918 "bionic/netdb.cpp",
Elliott Hughes3ed6e722024-02-16 01:18:01 +0000919 "bionic/net_if.cpp",
920 "bionic/netinet_ether.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800921 "bionic/netinet_in.cpp",
922 "bionic/nl_types.cpp",
923 "bionic/open.cpp",
924 "bionic/pathconf.cpp",
925 "bionic/pause.cpp",
926 "bionic/pidfd.cpp",
927 "bionic/pipe.cpp",
928 "bionic/poll.cpp",
929 "bionic/posix_fadvise.cpp",
930 "bionic/posix_fallocate.cpp",
931 "bionic/posix_madvise.cpp",
932 "bionic/posix_timers.cpp",
933 "bionic/preadv_pwritev.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000934 "bionic/pthread_atfork.cpp",
935 "bionic/pthread_attr.cpp",
936 "bionic/pthread_barrier.cpp",
937 "bionic/pthread_cond.cpp",
938 "bionic/pthread_create.cpp",
939 "bionic/pthread_detach.cpp",
940 "bionic/pthread_equal.cpp",
941 "bionic/pthread_exit.cpp",
942 "bionic/pthread_getcpuclockid.cpp",
943 "bionic/pthread_getschedparam.cpp",
944 "bionic/pthread_gettid_np.cpp",
945 "bionic/pthread_internal.cpp",
946 "bionic/pthread_join.cpp",
947 "bionic/pthread_key.cpp",
948 "bionic/pthread_kill.cpp",
949 "bionic/pthread_mutex.cpp",
950 "bionic/pthread_once.cpp",
951 "bionic/pthread_rwlock.cpp",
952 "bionic/pthread_sigqueue.cpp",
953 "bionic/pthread_self.cpp",
954 "bionic/pthread_setname_np.cpp",
955 "bionic/pthread_setschedparam.cpp",
956 "bionic/pthread_spinlock.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800957 "bionic/ptrace.cpp",
958 "bionic/pty.cpp",
959 "bionic/raise.cpp",
960 "bionic/rand.cpp",
961 "bionic/readlink.cpp",
962 "bionic/realpath.cpp",
963 "bionic/reboot.cpp",
964 "bionic/recv.cpp",
965 "bionic/recvmsg.cpp",
966 "bionic/rename.cpp",
967 "bionic/rmdir.cpp",
968 "bionic/scandir.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800969 "bionic/sched_cpualloc.cpp",
970 "bionic/sched_cpucount.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800971 "bionic/sched_getaffinity.cpp",
972 "bionic/sched_getcpu.cpp",
973 "bionic/semaphore.cpp",
974 "bionic/send.cpp",
975 "bionic/setegid.cpp",
976 "bionic/seteuid.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000977 "bionic/setjmp_cookie.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800978 "bionic/setpgrp.cpp",
979 "bionic/sigaction.cpp",
980 "bionic/signal.cpp",
981 "bionic/sigprocmask.cpp",
982 "bionic/sleep.cpp",
983 "bionic/socketpair.cpp",
984 "bionic/spawn.cpp",
985 "bionic/stat.cpp",
986 "bionic/stdlib_l.cpp",
987 "bionic/strerror.cpp",
988 "bionic/string_l.cpp",
989 "bionic/strings_l.cpp",
990 "bionic/strsignal.cpp",
991 "bionic/strtol.cpp",
992 "bionic/strtold.cpp",
993 "bionic/swab.cpp",
994 "bionic/symlink.cpp",
995 "bionic/sync_file_range.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000996 "bionic/sysconf.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800997 "bionic/sys_epoll.cpp",
998 "bionic/sys_msg.cpp",
999 "bionic/sys_sem.cpp",
1000 "bionic/sys_shm.cpp",
1001 "bionic/sys_signalfd.cpp",
1002 "bionic/sys_statfs.cpp",
1003 "bionic/sys_statvfs.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001004 "bionic/sys_thread_properties.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001005 "bionic/sys_time.cpp",
1006 "bionic/sysinfo.cpp",
1007 "bionic/syslog.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001008 "bionic/sysprop_helpers.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001009 "bionic/system.cpp",
1010 "bionic/system_property_api.cpp",
1011 "bionic/system_property_set.cpp",
1012 "bionic/tdestroy.cpp",
1013 "bionic/termios.cpp",
1014 "bionic/thread_private.cpp",
1015 "bionic/threads.cpp",
1016 "bionic/time.cpp",
1017 "bionic/time_l.cpp",
1018 "bionic/tmpfile.cpp",
1019 "bionic/umount.cpp",
1020 "bionic/unlink.cpp",
1021 "bionic/usleep.cpp",
1022 "bionic/utmp.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001023 "bionic/vdso.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001024 "bionic/wait.cpp",
1025 "bionic/wchar.cpp",
1026 "bionic/wchar_l.cpp",
1027 "bionic/wcstod.cpp",
1028 "bionic/wctype.cpp",
1029 "bionic/wcwidth.cpp",
1030 "bionic/wmempcpy.cpp",
1031
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001032 // Forked but not yet cleaned up/rewritten stdio code.
1033 // TODO: finish cleanup.
1034 "stdio/fmemopen.cpp",
1035 "stdio/parsefloat.c",
1036 "stdio/refill.c",
1037 "stdio/stdio.cpp",
1038 "stdio/stdio_ext.cpp",
1039 "stdio/vfscanf.cpp",
1040 "stdio/vfwscanf.cpp",
1041
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001042 // TODO: why isn't this in a static-libc-only module?
1043 // This contains a weak stub implementation of __find_icu_symbol for wctype.cpp,
1044 // which will be overridden by the actual one in libc.so.
1045 "bionic/icu_static.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001046 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001047
1048 arch: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001049 arm: {
Elliott Hughes1b61d782019-06-04 10:38:34 -07001050 asflags: libc_common_flags + ["-mno-restrict-it"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001051 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -08001052 "arch-arm/bionic/__aeabi_read_tp.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001053 "arch-arm/bionic/__bionic_clone.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001054 "arch-arm/bionic/__restore.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001055 "arch-arm/bionic/_exit_with_stack_teardown.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001056 "arch-arm/bionic/atomics_arm.c",
1057 "arch-arm/bionic/bpabi.c",
Yi Kong165b1cf2019-02-13 14:10:10 -08001058 "arch-arm/bionic/libcrt_compat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001059 "arch-arm/bionic/popcount_tab.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001060 "arch-arm/bionic/setjmp.S",
1061 "arch-arm/bionic/syscall.S",
1062 "arch-arm/bionic/vfork.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001063
Haibo Huangea9957a2018-11-19 11:00:32 -08001064 "arch-arm/cortex-a7/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001065 "arch-arm/cortex-a7/bionic/memset.S",
1066
1067 "arch-arm/cortex-a9/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001068 "arch-arm/cortex-a9/bionic/memset.S",
1069 "arch-arm/cortex-a9/bionic/stpcpy.S",
1070 "arch-arm/cortex-a9/bionic/strcat.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001071 "arch-arm/cortex-a9/bionic/strcpy.S",
1072 "arch-arm/cortex-a9/bionic/strlen.S",
1073
Elliott Hughesaefe9992023-11-08 12:04:41 -08001074 "arch-arm/cortex-a15/bionic/memcpy.S",
1075 "arch-arm/cortex-a15/bionic/memmove.S",
1076 "arch-arm/cortex-a15/bionic/memset.S",
1077 "arch-arm/cortex-a15/bionic/stpcpy.S",
1078 "arch-arm/cortex-a15/bionic/strcat.S",
1079 "arch-arm/cortex-a15/bionic/strcmp.S",
1080 "arch-arm/cortex-a15/bionic/strcpy.S",
1081 "arch-arm/cortex-a15/bionic/strlen.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001082
1083 "arch-arm/cortex-a53/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001084
Haibo Huang01bfd892018-12-03 15:05:16 -08001085 "arch-arm/cortex-a55/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001086
Elliott Hughesaefe9992023-11-08 12:04:41 -08001087 "arch-arm/generic/bionic/memcmp.S",
1088 "arch-arm/generic/bionic/memmove.S",
1089 "arch-arm/generic/bionic/memset.S",
1090 "arch-arm/generic/bionic/stpcpy.c",
1091 "arch-arm/generic/bionic/strcat.c",
1092 "arch-arm/generic/bionic/strcmp.S",
1093 "arch-arm/generic/bionic/strcpy.S",
1094 "arch-arm/generic/bionic/strlen.c",
1095
1096 "arch-arm/krait/bionic/memcpy.S",
1097 "arch-arm/krait/bionic/memset.S",
1098
Haibo Huangea9957a2018-11-19 11:00:32 -08001099 "arch-arm/kryo/bionic/memcpy.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001100
1101 "bionic/strchr.cpp",
1102 "bionic/strchrnul.cpp",
1103 "bionic/strnlen.cpp",
1104 "bionic/strrchr.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001105 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001106 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001107 arm64: {
1108 srcs: [
Dan Willemsen3e621712016-02-03 21:48:08 -08001109 "arch-arm64/bionic/__bionic_clone.S",
1110 "arch-arm64/bionic/_exit_with_stack_teardown.S",
1111 "arch-arm64/bionic/setjmp.S",
1112 "arch-arm64/bionic/syscall.S",
1113 "arch-arm64/bionic/vfork.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001114 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001115 },
1116
Elliott Hughesebc19a92022-10-14 23:25:36 +00001117 riscv64: {
1118 srcs: [
1119 "arch-riscv64/bionic/__bionic_clone.S",
1120 "arch-riscv64/bionic/_exit_with_stack_teardown.S",
Elliott Hughese1905ed2022-10-17 23:23:36 +00001121 "arch-riscv64/bionic/setjmp.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001122 "arch-riscv64/bionic/syscall.S",
1123 "arch-riscv64/bionic/vfork.S",
Yun Hsiang40a82d02023-05-26 10:10:40 +08001124
Elliott Hughesaefe9992023-11-08 12:04:41 -08001125 "arch-riscv64/string/memchr_v.S",
1126 "arch-riscv64/string/memcmp_v.S",
1127 "arch-riscv64/string/memcpy_v.S",
1128 "arch-riscv64/string/memmove_v.S",
1129 "arch-riscv64/string/memset_v.S",
1130 "arch-riscv64/string/stpcpy_v.S",
1131 "arch-riscv64/string/strcat_v.S",
1132 "arch-riscv64/string/strchr_v.S",
1133 "arch-riscv64/string/strcmp_v.S",
1134 "arch-riscv64/string/strcpy_v.S",
1135 "arch-riscv64/string/strlen_v.S",
1136 "arch-riscv64/string/strncat_v.S",
1137 "arch-riscv64/string/strncmp_v.S",
1138 "arch-riscv64/string/strncpy_v.S",
1139 "arch-riscv64/string/strnlen_v.S",
1140
1141 "arch-riscv64/string/memchr.c",
1142 "arch-riscv64/string/memcmp.c",
1143 "arch-riscv64/string/memcpy.c",
1144 "arch-riscv64/string/memmove.c",
1145 "arch-riscv64/string/memset.c",
1146 "arch-riscv64/string/stpcpy.c",
1147 "arch-riscv64/string/strcat.c",
1148 "arch-riscv64/string/strchr.c",
1149 "arch-riscv64/string/strcmp.c",
1150 "arch-riscv64/string/strcpy.c",
1151 "arch-riscv64/string/strlen.c",
1152 "arch-riscv64/string/strncat.c",
1153 "arch-riscv64/string/strncmp.c",
1154 "arch-riscv64/string/strncpy.c",
1155 "arch-riscv64/string/strnlen.c",
Prashanth Swaminathana4d71022023-10-30 17:35:19 -07001156
Elliott Hughes7d136662023-10-27 15:40:32 -07001157 "bionic/strchrnul.cpp",
1158 "bionic/strrchr.cpp",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001159 ],
1160 },
1161
Dan Willemsen208ae172015-09-16 16:33:27 -07001162 x86: {
1163 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001164 "arch-x86/bionic/__bionic_clone.S",
1165 "arch-x86/bionic/_exit_with_stack_teardown.S",
1166 "arch-x86/bionic/libcrt_compat.c",
Elliott Hughes7d136662023-10-27 15:40:32 -07001167 "arch-x86/bionic/setjmp.S",
1168 "arch-x86/bionic/syscall.S",
1169 "arch-x86/bionic/vfork.S",
1170 "arch-x86/bionic/__x86.get_pc_thunk.S",
1171
Dan Willemsen208ae172015-09-16 16:33:27 -07001172 "arch-x86/generic/string/memcmp.S",
1173 "arch-x86/generic/string/strcmp.S",
1174 "arch-x86/generic/string/strncmp.S",
1175 "arch-x86/generic/string/strcat.S",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001176
1177 "arch-x86/generic/string/strlcat.c",
1178 "arch-x86/generic/string/strlcpy.c",
1179 "arch-x86/generic/string/strncat.c",
1180 "arch-x86/generic/string/wcscat.c",
1181 "arch-x86/generic/string/wcscpy.c",
1182 "arch-x86/generic/string/wmemcmp.c",
1183
Elliott Hughesed777142022-07-25 16:25:11 +00001184 "arch-x86/string/sse2-memchr-atom.S",
1185 "arch-x86/string/sse2-memmove-slm.S",
1186 "arch-x86/string/sse2-memrchr-atom.S",
1187 "arch-x86/string/sse2-memset-atom.S",
1188 "arch-x86/string/sse2-memset-slm.S",
1189 "arch-x86/string/sse2-stpcpy-slm.S",
1190 "arch-x86/string/sse2-stpncpy-slm.S",
1191 "arch-x86/string/sse2-strchr-atom.S",
1192 "arch-x86/string/sse2-strcpy-slm.S",
1193 "arch-x86/string/sse2-strlen-slm.S",
1194 "arch-x86/string/sse2-strncpy-slm.S",
1195 "arch-x86/string/sse2-strnlen-atom.S",
1196 "arch-x86/string/sse2-strrchr-atom.S",
1197 "arch-x86/string/sse2-wcschr-atom.S",
1198 "arch-x86/string/sse2-wcsrchr-atom.S",
1199 "arch-x86/string/sse2-wcslen-atom.S",
1200 "arch-x86/string/sse2-wcscmp-atom.S",
1201 "arch-x86/string/sse2-strlen-atom.S",
1202
1203 "arch-x86/string/ssse3-memcmp-atom.S",
1204 "arch-x86/string/ssse3-memmove-atom.S",
1205 "arch-x86/string/ssse3-strcat-atom.S",
1206 "arch-x86/string/ssse3-strcmp-atom.S",
1207 "arch-x86/string/ssse3-strcpy-atom.S",
1208 "arch-x86/string/ssse3-strlcat-atom.S",
1209 "arch-x86/string/ssse3-strlcpy-atom.S",
1210 "arch-x86/string/ssse3-strncat-atom.S",
1211 "arch-x86/string/ssse3-strncmp-atom.S",
1212 "arch-x86/string/ssse3-strncpy-atom.S",
1213 "arch-x86/string/ssse3-wcscat-atom.S",
1214 "arch-x86/string/ssse3-wcscpy-atom.S",
1215 "arch-x86/string/ssse3-wmemcmp-atom.S",
1216
1217 "arch-x86/string/sse4-memcmp-slm.S",
1218 "arch-x86/string/sse4-wmemcmp-slm.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001219
1220 "bionic/strchrnul.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001221 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001222 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001223 x86_64: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001224 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001225 "arch-x86_64/bionic/__bionic_clone.S",
1226 "arch-x86_64/bionic/_exit_with_stack_teardown.S",
1227 "arch-x86_64/bionic/__restore_rt.S",
1228 "arch-x86_64/bionic/setjmp.S",
1229 "arch-x86_64/bionic/syscall.S",
1230 "arch-x86_64/bionic/vfork.S",
1231
ahs919fb7f2022-06-10 07:11:14 +05301232 "arch-x86_64/string/avx2-memset-kbl.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001233 "arch-x86_64/string/sse2-memmove-slm.S",
1234 "arch-x86_64/string/sse2-memset-slm.S",
1235 "arch-x86_64/string/sse2-stpcpy-slm.S",
1236 "arch-x86_64/string/sse2-stpncpy-slm.S",
1237 "arch-x86_64/string/sse2-strcat-slm.S",
1238 "arch-x86_64/string/sse2-strcpy-slm.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001239 "arch-x86_64/string/sse2-strlen-slm.S",
1240 "arch-x86_64/string/sse2-strncat-slm.S",
1241 "arch-x86_64/string/sse2-strncpy-slm.S",
1242 "arch-x86_64/string/sse4-memcmp-slm.S",
1243 "arch-x86_64/string/ssse3-strcmp-slm.S",
1244 "arch-x86_64/string/ssse3-strncmp-slm.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001245
1246 "bionic/strchr.cpp",
1247 "bionic/strchrnul.cpp",
1248 "bionic/strnlen.cpp",
1249 "bionic/strrchr.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001250 ],
1251 },
Dan Willemsen268a6732015-10-15 14:49:45 -07001252 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001253
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001254 multilib: {
1255 lib32: {
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001256 srcs: [
1257 // off64_t/time64_t support on LP32.
1258 "bionic/legacy_32_bit_support.cpp",
1259 "bionic/time64.c",
1260
1261 // TODO: move to libc/bionic/legacy_32_bit_support.cpp or #if __LP64__ instead.
1262 "bionic/mmap.cpp",
1263 ],
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001264 },
1265 },
1266
1267 local_include_dirs: ["stdio"],
1268 generated_headers: ["generated_android_ids"],
1269
1270 whole_static_libs: [
1271 "libsystemproperties",
1272 ],
1273
Colin Cross50c21ab2015-10-31 23:03:05 -07001274 cppflags: ["-Wold-style-cast"],
Dan Willemsen268a6732015-10-15 14:49:45 -07001275 include_dirs: ["bionic/libstdc++/include"],
1276 name: "libc_bionic",
Dan Willemsen268a6732015-10-15 14:49:45 -07001277}
1278
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001279genrule {
1280 name: "generated_android_ids",
Colin Cross35bbed82017-01-17 18:16:07 -08001281 out: ["generated_android_ids.h"],
1282 srcs: [":android_filesystem_config_header"],
Cole Faustb1a0a9d2023-11-28 17:51:16 -08001283 tools: ["fs_config_generator"],
1284 cmd: "$(location fs_config_generator) aidarray $(in) > $(out)",
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001285}
1286
Dan Willemsen268a6732015-10-15 14:49:45 -07001287// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001288// libc_syscalls.a
1289// ========================================================
1290
Elliott Hughes782c4852019-04-16 12:31:00 -07001291genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001292 name: "syscalls-arm",
Elliott Hughes782c4852019-04-16 12:31:00 -07001293 out: ["syscalls-arm.S"],
1294 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001295 tools: ["gensyscalls"],
1296 cmd: "$(location gensyscalls) arm $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001297}
1298
1299genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001300 name: "syscalls-arm64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001301 out: ["syscalls-arm64.S"],
1302 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001303 tools: ["gensyscalls"],
1304 cmd: "$(location gensyscalls) arm64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001305}
1306
1307genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001308 name: "syscalls-riscv64",
Elliott Hughes704772b2022-10-10 17:06:43 +00001309 out: ["syscalls-riscv64.S"],
1310 srcs: ["SYSCALLS.TXT"],
1311 tools: ["gensyscalls"],
1312 cmd: "$(location gensyscalls) riscv64 $(in) > $(out)",
1313}
1314
1315genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001316 name: "syscalls-x86",
Elliott Hughes782c4852019-04-16 12:31:00 -07001317 out: ["syscalls-x86.S"],
1318 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001319 tools: ["gensyscalls"],
1320 cmd: "$(location gensyscalls) x86 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001321}
1322
1323genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001324 name: "syscalls-x86_64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001325 out: ["syscalls-x86_64.S"],
1326 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001327 tools: ["gensyscalls"],
1328 cmd: "$(location gensyscalls) x86_64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001329}
1330
Dan Willemsen208ae172015-09-16 16:33:27 -07001331cc_library_static {
Colin Cross27c43c52016-04-07 13:27:24 -07001332 defaults: ["libc_defaults"],
Josh Gao0e0e3702017-10-12 13:34:42 -07001333 srcs: ["bionic/__set_errno.cpp"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001334 arch: {
1335 arm: {
Cole Faustf5968d82023-04-11 15:20:19 -07001336 srcs: [":syscalls-arm"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001337 },
1338 arm64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001339 srcs: [":syscalls-arm64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001340 },
Elliott Hughes704772b2022-10-10 17:06:43 +00001341 riscv64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001342 srcs: [":syscalls-riscv64"],
Elliott Hughes704772b2022-10-10 17:06:43 +00001343 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001344 x86: {
Cole Faustf5968d82023-04-11 15:20:19 -07001345 srcs: [":syscalls-x86"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001346 },
1347 x86_64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001348 srcs: [":syscalls-x86_64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001349 },
1350 },
1351 name: "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001352}
1353
1354// ========================================================
1355// libc_aeabi.a
1356// This is an LP32 ARM-only library that needs to be built with -fno-builtin
1357// to avoid infinite recursion. For the other architectures we just build an
1358// empty library to keep this makefile simple.
1359// ========================================================
1360
1361cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001362 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001363 arch: {
1364 arm: {
1365 srcs: ["arch-arm/bionic/__aeabi.c"],
1366 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001367 },
1368 name: "libc_aeabi",
Colin Cross50c21ab2015-10-31 23:03:05 -07001369 cflags: ["-fno-builtin"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001370}
1371
1372// ========================================================
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001373// libc_common.a --- everything shared by libc.a and libc.so
Dan Willemsen208ae172015-09-16 16:33:27 -07001374// ========================================================
Elliott Hughesb0948922024-01-26 00:28:12 +00001375
Dan Willemsen208ae172015-09-16 16:33:27 -07001376cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001377 defaults: ["libc_defaults"],
Elliott Hughesb0948922024-01-26 00:28:12 +00001378 name: "libc_common",
1379
Dan Willemsen208ae172015-09-16 16:33:27 -07001380 whole_static_libs: [
Peter Collingbourne337a5b32020-02-21 12:11:02 -08001381 "libarm-optimized-routines-string",
Rupert Shuttleworth78f48a52021-03-16 06:39:19 +00001382 "libasync_safe",
Dan Willemsen208ae172015-09-16 16:33:27 -07001383 "libc_bionic",
Ryan Prichard249757b2019-11-01 17:18:28 -07001384 "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -07001385 "libc_dns",
George Burgess IV6cb06872017-07-21 13:28:42 -07001386 "libc_fortify",
Dan Willemsen208ae172015-09-16 16:33:27 -07001387 "libc_freebsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001388 "libc_freebsd_large_stack",
Elliott Hughesc2043342023-07-20 20:24:09 +00001389 "libc_freebsd_ldexp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001390 "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -07001391 "libc_netbsd",
1392 "libc_openbsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001393 "libc_openbsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001394 "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001395 "libc_tzcode",
Elliott Hughes816fab92016-05-27 17:57:46 -07001396 "libstdc++",
Dan Willemsen208ae172015-09-16 16:33:27 -07001397 ],
1398
1399 arch: {
1400 arm: {
1401 whole_static_libs: ["libc_aeabi"],
1402 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001403 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001404}
1405
1406// ========================================================
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001407// libc_static_dispatch.a --- libc.a ifuncs
Haibo Huangf71edfa2018-11-12 10:06:56 -08001408// ========================================================
1409cc_library_static {
1410 defaults: ["libc_defaults"],
Ryan Prichard249757b2019-11-01 17:18:28 -07001411 name: "libc_static_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001412
Haibo Huangb9244ff2018-08-11 10:12:13 -07001413 arch: {
ahs919fb7f2022-06-10 07:11:14 +05301414 x86_64: {
1415 srcs: ["arch-x86_64/static_function_dispatch.S"],
1416 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001417 x86: {
1418 srcs: ["arch-x86/static_function_dispatch.S"],
1419 },
Haibo Huangea9957a2018-11-19 11:00:32 -08001420 arm: {
1421 srcs: ["arch-arm/static_function_dispatch.S"],
1422 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001423 arm64: {
1424 srcs: ["arch-arm64/static_function_dispatch.S"],
1425 },
Elliott Hughesaefe9992023-11-08 12:04:41 -08001426 riscv64: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001427 srcs: ["arch-riscv64/static_function_dispatch.S"],
Elliott Hughesaefe9992023-11-08 12:04:41 -08001428 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001429 },
Haibo Huangf71edfa2018-11-12 10:06:56 -08001430}
1431
1432// ========================================================
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001433// libc_dynamic_dispatch.a --- libc.so ifuncs
Haibo Huangf71edfa2018-11-12 10:06:56 -08001434// ========================================================
1435cc_library_static {
1436 defaults: ["libc_defaults"],
Ryan Prichard249757b2019-11-01 17:18:28 -07001437 name: "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001438
Haibo Huangb9244ff2018-08-11 10:12:13 -07001439 cflags: [
Peter Collingbourne36a56442019-10-31 17:11:54 -07001440 "-ffreestanding",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001441 "-fno-stack-protector",
1442 "-fno-jump-tables",
1443 ],
1444 arch: {
ahs919fb7f2022-06-10 07:11:14 +05301445 x86_64: {
1446 srcs: ["arch-x86_64/dynamic_function_dispatch.cpp"],
1447 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001448 x86: {
1449 srcs: ["arch-x86/dynamic_function_dispatch.cpp"],
1450 },
Haibo Huangea9957a2018-11-19 11:00:32 -08001451 arm: {
Elliott Hughes927fe992019-01-31 22:29:22 +00001452 srcs: ["arch-arm/dynamic_function_dispatch.cpp"],
Haibo Huangea9957a2018-11-19 11:00:32 -08001453 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001454 arm64: {
1455 srcs: ["arch-arm64/dynamic_function_dispatch.cpp"],
1456 },
Elliott Hughesaefe9992023-11-08 12:04:41 -08001457 riscv64: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001458 srcs: ["arch-riscv64/dynamic_function_dispatch.cpp"],
Elliott Hughesaefe9992023-11-08 12:04:41 -08001459 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001460 },
Ryan Prichard249757b2019-11-01 17:18:28 -07001461}
1462
1463// ========================================================
1464// libc_common_static.a For static binaries.
1465// ========================================================
1466cc_library_static {
1467 defaults: ["libc_defaults"],
1468 name: "libc_common_static",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001469
Haibo Huangf71edfa2018-11-12 10:06:56 -08001470 whole_static_libs: [
1471 "libc_common",
Ryan Prichard249757b2019-11-01 17:18:28 -07001472 "libc_static_dispatch",
1473 ],
1474}
1475
1476// ========================================================
1477// libc_common_shared.a For shared libraries.
1478// ========================================================
1479cc_library_static {
1480 defaults: ["libc_defaults"],
1481 name: "libc_common_shared",
1482
1483 whole_static_libs: [
1484 "libc_common",
1485 "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001486 ],
1487}
1488
Ryan Prichard22a6a052019-10-10 23:59:30 -07001489// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static
1490// executable.
1491cc_library_static {
1492 name: "libc_unwind_static",
1493 defaults: ["libc_defaults"],
1494 cflags: ["-DLIBC_STATIC"],
1495
1496 srcs: ["bionic/dl_iterate_phdr_static.cpp"],
1497 arch: {
1498 // arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs
1499 arm: {
1500 srcs: ["arch-arm/bionic/exidx_static.c"],
1501 },
1502 },
1503}
1504
Haibo Huangf71edfa2018-11-12 10:06:56 -08001505// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001506// libc_nomalloc.a
1507// ========================================================
1508//
Ryan Prichard249757b2019-11-01 17:18:28 -07001509// This is a version of the static C library used by the dynamic linker that exclude malloc. It also
1510// excludes functions selected using ifunc's (e.g. for string.h). Link in either
1511// libc_static_dispatch or libc_dynamic_dispatch to provide those functions.
Dan Willemsen208ae172015-09-16 16:33:27 -07001512
1513cc_library_static {
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -08001514 name: "libc_nomalloc",
Colin Cross50c21ab2015-10-31 23:03:05 -07001515 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001516
Colin Crossa3f9fca2016-01-11 13:20:55 -08001517 whole_static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -07001518 "libc_common",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001519 "libc_init_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001520 "libc_unwind_static",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001521 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001522}
1523
dimitryc0c0ef62018-12-05 16:33:52 +01001524filegroup {
1525 name: "libc_sources_shared",
1526 srcs: [
1527 "arch-common/bionic/crtbegin_so.c",
1528 "arch-common/bionic/crtbrand.S",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001529 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001530 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001531 "bionic/icu.cpp",
1532 "bionic/malloc_common.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001533 "bionic/malloc_common_dynamic.cpp",
Ryan Savitski175c8862020-01-02 19:54:57 +00001534 "bionic/android_profiling_dynamic.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001535 "bionic/malloc_heapprofd.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001536 "bionic/malloc_limit.cpp",
Peter Collingbourne570de332019-12-11 10:00:58 -08001537 "bionic/ndk_cruft.cpp",
1538 "bionic/ndk_cruft_data.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001539 "bionic/NetdClient.cpp",
1540 "arch-common/bionic/crtend_so.S",
1541 ],
1542}
1543
1544filegroup {
1545 name: "libc_sources_static",
1546 srcs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001547 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001548 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001549 "bionic/malloc_common.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001550 "bionic/malloc_limit.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001551 ],
1552}
1553
1554filegroup {
1555 name: "libc_sources_shared_arm",
1556 srcs: [
1557 "arch-arm/bionic/exidx_dynamic.c",
1558 "arch-arm/bionic/atexit_legacy.c",
1559 ],
1560}
1561
Dan Willemsen208ae172015-09-16 16:33:27 -07001562// ========================================================
1563// libc.a + libc.so
1564// ========================================================
Florian Mayerc10d0642023-03-22 16:12:49 -07001565cc_defaults {
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001566 defaults: [
1567 "libc_defaults",
1568 "libc_native_allocator_defaults",
1569 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001570 name: "libc_library_defaults",
Colin Cross50c21ab2015-10-31 23:03:05 -07001571 product_variables: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001572 platform_sdk_version: {
1573 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1574 },
1575 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001576 static: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001577 srcs: [":libc_sources_static"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001578 cflags: ["-DLIBC_STATIC"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001579 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001580 "gwp_asan",
Mitch Phillipsa493fe42023-01-19 12:47:22 -08001581 "gwp_asan_crash_handler",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001582 "libc_init_static",
1583 "libc_common_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001584 "libc_unwind_static",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001585 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001586 },
1587 shared: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001588 srcs: [":libc_sources_shared"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001589 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001590 "gwp_asan",
Mitch Phillipsa493fe42023-01-19 12:47:22 -08001591 "gwp_asan_crash_handler",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001592 "libc_init_dynamic",
1593 "libc_common_shared",
Ryan Prichardcdf71752020-12-16 03:37:22 -08001594 "libunwind-exported",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001595 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001596 },
1597
Neil Fullera7db90f2019-04-25 09:28:27 +01001598 required: [
MarkDacekd88d7ea2022-06-28 20:14:58 +00001599 "tzdata_prebuilt",
1600 "tz_version_prebuilt", // Version metadata for tzdata to help debugging.
Neil Fullera7db90f2019-04-25 09:28:27 +01001601 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001602
Colin Cross4ce94d22016-11-15 13:15:43 -08001603 // Do not pack libc.so relocations; see http://b/20645321 for details.
1604 pack_relocations: false,
1605
dimitry06016f22018-01-05 11:39:28 +01001606 // WARNING: The only libraries libc.so should depend on are libdl.so and ld-android.so!
1607 // If you add other libraries, make sure to add -Wl,--exclude-libs=libgcc.a to the
1608 // LOCAL_LDFLAGS for those libraries. This ensures that symbols that are pulled into
1609 // those new libraries from libgcc.a are not declared external; if that were the case,
1610 // then libc would not pull those symbols from libgcc.a as it should, instead relying
1611 // on the external symbols from the dependent libraries. That would create a "cloaked"
1612 // dependency on libgcc.a in libc though the libraries, which is not what you wanted!
Dan Willemsen208ae172015-09-16 16:33:27 -07001613
dimitry06016f22018-01-05 11:39:28 +01001614 shared_libs: [
1615 "ld-android",
1616 "libdl",
1617 ],
Jiyong Park3ff116a2019-04-02 23:04:52 +09001618 static_libs: [
1619 "libdl_android",
1620 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001621
1622 nocrt: true,
1623
Dan Willemsen208ae172015-09-16 16:33:27 -07001624 arch: {
1625 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001626 // TODO: This is to work around b/24465209. Remove after root cause is fixed.
Chih-Hung Hsiehecbff832018-05-23 18:45:53 -07001627 pack_relocations: false,
Christopher Ferris9d03a162023-11-10 11:19:11 -08001628 ldflags: [
1629 "-Wl,--hash-style=both",
1630 // Since we are preserving the debug_frame, do not compress
1631 // in this case to make unwinds as fast as possible.
1632 "-Wl,--compress-debug-sections=none",
1633 ],
Ian Pedowitzb6310c22018-01-18 16:26:19 -08001634
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001635 version_script: ":libc.arm.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001636 no_libcrt: true,
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001637
Dan Willemsen208ae172015-09-16 16:33:27 -07001638 shared: {
dimitryc0c0ef62018-12-05 16:33:52 +01001639 srcs: [":libc_sources_shared_arm"],
Dan Willemsen0c657082016-05-12 01:43:07 -07001640 // special for arm
1641 cflags: ["-DCRT_LEGACY_WORKAROUND"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001642 // For backwards-compatibility, some arm32 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001643 static_libs: ["libclang_rt.builtins-exported"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001644 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001645
1646 // Arm 32 bit does not produce complete exidx unwind information
1647 // so keep the .debug_frame which is relatively small and does
1648 // include needed unwind information.
1649 // See b/132992102 for details.
1650 strip: {
1651 keep_symbols_and_debug_frame: true,
1652 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001653 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001654 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001655 version_script: ":libc.arm64.map",
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001656
1657 // Leave the symbols in the shared library so that stack unwinders can produce
1658 // meaningful name resolution.
1659 strip: {
1660 keep_symbols: true,
1661 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001662 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001663 riscv64: {
1664 version_script: ":libc.riscv64.map",
1665
1666 // Leave the symbols in the shared library so that stack unwinders can produce
1667 // meaningful name resolution.
1668 strip: {
1669 keep_symbols: true,
1670 },
1671 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001672 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001673 // TODO: This is to work around b/24465209. Remove after root cause is fixed.
Chih-Hung Hsiehecbff832018-05-23 18:45:53 -07001674 pack_relocations: false,
Ian Pedowitzb6310c22018-01-18 16:26:19 -08001675 ldflags: ["-Wl,--hash-style=both"],
1676
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001677 version_script: ":libc.x86.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001678 no_libcrt: true,
1679
1680 shared: {
1681 // For backwards-compatibility, some x86 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001682 static_libs: ["libclang_rt.builtins-exported"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001683 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001684
1685 // Leave the symbols in the shared library so that stack unwinders can produce
1686 // meaningful name resolution.
1687 strip: {
1688 keep_symbols: true,
1689 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001690 },
1691 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001692 version_script: ":libc.x86_64.map",
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001693
1694 // Leave the symbols in the shared library so that stack unwinders can produce
1695 // meaningful name resolution.
1696 strip: {
1697 keep_symbols: true,
1698 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001699 },
1700 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +09001701
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001702 apex_available: [
1703 "//apex_available:platform",
1704 "com.android.runtime",
1705 ],
1706
Colin Cross7edd0082021-10-28 13:20:35 -07001707 target: {
1708 native_bridge: {
1709 shared: {
1710 installable: false,
1711 },
1712 },
1713 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001714}
1715
Florian Mayerc10d0642023-03-22 16:12:49 -07001716cc_library {
1717 name: "libc",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001718 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001719 "libc_library_defaults",
1720 ],
1721 stubs: {
1722 symbol_file: "libc.map.txt",
1723 versions: [
1724 "29",
1725 "R",
1726 "current",
1727 ],
1728 },
1729 static_ndk_lib: true,
1730 llndk: {
1731 symbol_file: "libc.map.txt",
1732 export_headers_as_system: true,
1733 export_preprocessed_headers: ["include"],
1734 export_llndk_headers: ["libc_llndk_headers"],
1735 },
1736}
1737
1738cc_library {
1739 name: "libc_hwasan",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001740 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001741 "libc_library_defaults",
1742 ],
1743 sanitize: {
1744 hwaddress: true,
1745 },
1746 enabled: false,
Florian Mayerff116ed2023-04-14 17:38:53 -07001747 target: {
1748 android_arm64: {
Florian Mayerc10d0642023-03-22 16:12:49 -07001749 enabled: true,
1750 },
1751 },
1752 stem: "libc",
1753 relative_install_path: "hwasan",
1754 // We don't really need the stubs, but this needs to stay to trigger the
1755 // symlink logic in soong.
1756 stubs: {
1757 symbol_file: "libc.map.txt",
1758 },
1759 native_bridge_supported: false,
1760 // It is never correct to depend on this directly. This is only
1761 // needed for the runtime apex, and in base_system.mk.
1762 visibility: ["//bionic/apex"],
1763}
1764
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001765genrule {
1766 name: "libc.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001767 out: ["libc.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001768 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001769 tools: ["generate-version-script"],
1770 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001771}
1772
1773genrule {
1774 name: "libc.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001775 out: ["libc.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001776 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001777 tools: ["generate-version-script"],
1778 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001779}
1780
1781genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001782 name: "libc.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001783 out: ["libc.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001784 srcs: ["libc.map.txt"],
1785 tools: ["generate-version-script"],
1786 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1787}
1788
1789genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001790 name: "libc.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001791 out: ["libc.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001792 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001793 tools: ["generate-version-script"],
1794 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001795}
1796
1797genrule {
1798 name: "libc.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001799 out: ["libc.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001800 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001801 tools: ["generate-version-script"],
1802 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001803}
1804
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001805// Headers that only other parts of the platform can include.
1806cc_library_headers {
1807 name: "bionic_libc_platform_headers",
Martin Stjernholma2763432020-04-23 16:47:19 +01001808 defaults: ["linux_bionic_supported"],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001809 visibility: [
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001810 "//art:__subpackages__",
Josh Gao97271922019-11-06 13:15:00 -08001811 "//bionic:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001812 "//frameworks:__subpackages__",
Roman Kiryanov067f5182020-05-07 14:58:30 -07001813 "//device/generic/goldfish-opengl:__subpackages__",
Mitch Phillips3309b3d2020-03-25 15:05:48 -07001814 "//external/gwp_asan:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001815 "//external/perfetto:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001816 "//external/scudo:__subpackages__",
Josh Gao5074e7d2019-12-13 13:55:53 -08001817 "//system/core/debuggerd:__subpackages__",
Florian Mayerf5d70ce2022-09-13 13:58:30 -07001818 "//system/core/init:__subpackages__",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001819 "//system/core/libcutils:__subpackages__",
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001820 "//system/memory/libmemunreachable:__subpackages__",
Baligh Uddindb0c6de2020-10-15 04:49:00 +00001821 "//system/unwinding/libunwindstack:__subpackages__",
Peter Collingbourne15418002020-05-12 16:02:50 -07001822 "//tools/security/sanitizer-status:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001823 ],
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001824 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001825 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001826 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001827 vendor_ramdisk_available: true,
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001828 recovery_available: true,
1829 native_bridge_supported: true,
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001830 export_include_dirs: [
1831 "platform",
1832 ],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001833 system_shared_libs: [],
1834 stl: "none",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001835 sdk_version: "current",
Jiyong Park4ede1602020-04-28 18:21:08 +09001836
Steven Moreland0cdf1322020-10-05 21:55:26 +00001837 min_sdk_version: "29",
Jiyong Park4ede1602020-04-28 18:21:08 +09001838 apex_available: [
1839 "//apex_available:platform",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001840 "//apex_available:anyapex",
Jiyong Park4ede1602020-04-28 18:21:08 +09001841 ],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001842}
1843
Logan Chien17af91b2019-01-15 21:19:56 +08001844cc_library_headers {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001845 name: "libc_llndk_headers",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001846 visibility: [
1847 "//external/musl",
1848 ],
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001849 llndk: {
1850 llndk_headers: true,
1851 },
Logan Chien17af91b2019-01-15 21:19:56 +08001852 host_supported: true,
1853 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001854 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001855 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001856 vendor_ramdisk_available: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001857 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001858 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001859 apex_available: [
1860 "//apex_available:platform",
Jiyong Parkad9946c2020-03-30 18:36:07 +09001861 "//apex_available:anyapex",
1862 ],
Jooyung Han15c32a82020-04-16 18:26:45 +09001863 // used by most APEXes indirectly via libunwind_llvm
1864 min_sdk_version: "apex_inherit",
Logan Chien17af91b2019-01-15 21:19:56 +08001865
1866 no_libcrt: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001867 stl: "none",
1868 system_shared_libs: [],
1869
Peter Collingbournef2b1e032019-12-10 17:41:16 -08001870 // The build system generally requires that any dependencies of a target
1871 // with an sdk_version must have a lower sdk_version. By setting sdk_version
1872 // to 1 we let targets with an sdk_version that need to depend on the libc
1873 // headers but cannot depend on libc itself due to circular dependencies
1874 // (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
1875 // is correct because the headers can support any sdk_version.
1876 sdk_version: "1",
1877
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001878 export_system_include_dirs: [
Logan Chien17af91b2019-01-15 21:19:56 +08001879 "kernel/uapi",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001880 "kernel/android/scsi",
Logan Chien17af91b2019-01-15 21:19:56 +08001881 "kernel/android/uapi",
1882 ],
1883
1884 arch: {
1885 arm: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001886 export_system_include_dirs: ["kernel/uapi/asm-arm"],
Logan Chien17af91b2019-01-15 21:19:56 +08001887 },
1888 arm64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001889 export_system_include_dirs: ["kernel/uapi/asm-arm64"],
Logan Chien17af91b2019-01-15 21:19:56 +08001890 },
Elliott Hughes48e53332022-10-07 20:39:25 +00001891 riscv64: {
1892 export_system_include_dirs: ["kernel/uapi/asm-riscv"],
1893 },
Logan Chien17af91b2019-01-15 21:19:56 +08001894 x86: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001895 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001896 },
1897 x86_64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001898 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001899 },
1900 },
1901}
1902
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001903cc_library_headers {
1904 name: "libc_headers",
1905 host_supported: true,
1906 native_bridge_supported: true,
1907 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001908 product_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001909 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001910 vendor_ramdisk_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001911 recovery_available: true,
1912 sdk_version: "1",
1913
1914 apex_available: [
1915 "//apex_available:platform",
1916 "//apex_available:anyapex",
1917 ],
1918 // used by most APEXes indirectly via libunwind_llvm
1919 min_sdk_version: "apex_inherit",
1920 visibility: [
1921 "//bionic:__subpackages__", // visible to bionic
1922 // ... and only to these places (b/152668052)
1923 "//external/arm-optimized-routines",
1924 "//external/gwp_asan",
1925 "//external/jemalloc_new",
1926 "//external/libunwind_llvm",
Nick Desaulniers942ae552024-02-12 10:26:19 -08001927 "//external/llvm-libc",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001928 "//external/scudo",
1929 "//system/core/property_service/libpropertyinfoparser",
1930 "//system/extras/toolchain-extras",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001931 ],
1932
1933 stl: "none",
1934 no_libcrt: true,
1935 system_shared_libs: [],
1936
1937 target: {
1938 android: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001939 export_system_include_dirs: ["include"],
1940 header_libs: ["libc_llndk_headers"],
1941 export_header_lib_headers: ["libc_llndk_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001942 },
1943 linux_bionic: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001944 export_system_include_dirs: ["include"],
1945 header_libs: ["libc_llndk_headers"],
1946 export_header_lib_headers: ["libc_llndk_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001947 },
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001948 },
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001949}
1950
Dan Willemsen208ae172015-09-16 16:33:27 -07001951// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001952// libstdc++.so and libstdc++.a.
Dan Willemsen208ae172015-09-16 16:33:27 -07001953// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001954
me-cafebabee0d06f52023-10-05 19:38:27 +00001955cc_defaults {
Colin Cross50c21ab2015-10-31 23:03:05 -07001956 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001957 include_dirs: ["bionic/libstdc++/include"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001958 srcs: [
1959 "bionic/__cxa_guard.cpp",
1960 "bionic/__cxa_pure_virtual.cpp",
1961 "bionic/new.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001962 ],
me-cafebabee0d06f52023-10-05 19:38:27 +00001963 name: "libstdc++_defaults",
Dan Albert40f15ec2017-10-27 11:21:20 -07001964 static_ndk_lib: true,
Isaac Chen5e7c90b2017-09-20 14:44:42 +08001965 static_libs: ["libasync_safe"],
Elliott Hughesc2043342023-07-20 20:24:09 +00001966 apex_available: [
1967 "//apex_available:platform",
1968 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001969
Dan Willemsen6b3be172018-12-03 13:57:20 -08001970 static: {
1971 system_shared_libs: [],
1972 },
Colin Crossb5bfe0b2021-07-13 16:26:28 -07001973 target: {
1974 bionic: {
1975 shared: {
1976 system_shared_libs: ["libc"],
1977 },
1978 },
Dan Willemsen6b3be172018-12-03 13:57:20 -08001979 },
1980
Ian Pedowitzb6310c22018-01-18 16:26:19 -08001981 //TODO (dimitry): This is to work around b/24465209. Remove after root cause is fixed
Dan Willemsen208ae172015-09-16 16:33:27 -07001982 arch: {
1983 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001984 // TODO: This is to work around b/24465209. Remove after root cause is fixed.
Chih-Hung Hsiehecbff832018-05-23 18:45:53 -07001985 pack_relocations: false,
Ian Pedowitzb6310c22018-01-18 16:26:19 -08001986 ldflags: ["-Wl,--hash-style=both"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001987 version_script: ":libstdc++.arm.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001988 },
1989 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001990 version_script: ":libstdc++.arm64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001991 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001992 riscv64: {
1993 version_script: ":libstdc++.riscv64.map",
1994 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001995 x86: {
Chih-Hung Hsiehecbff832018-05-23 18:45:53 -07001996 pack_relocations: false,
Ian Pedowitzb6310c22018-01-18 16:26:19 -08001997 ldflags: ["-Wl,--hash-style=both"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001998 version_script: ":libstdc++.x86.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001999 },
2000 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002001 version_script: ":libstdc++.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07002002 },
2003 },
2004}
2005
me-cafebabee0d06f52023-10-05 19:38:27 +00002006cc_library {
2007 name: "libstdc++",
2008 defaults: ["libstdc++_defaults"],
2009}
2010
2011cc_library_shared {
2012 name: "libstdc++_vendor",
2013 defaults: ["libstdc++_defaults"],
2014 vendor: true,
2015}
2016
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002017genrule {
2018 name: "libstdc++.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07002019 out: ["libstdc++.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002020 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00002021 tools: ["generate-version-script"],
2022 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002023}
2024
2025genrule {
2026 name: "libstdc++.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07002027 out: ["libstdc++.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002028 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00002029 tools: ["generate-version-script"],
2030 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002031}
2032
2033genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00002034 name: "libstdc++.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07002035 out: ["libstdc++.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00002036 srcs: ["libstdc++.map.txt"],
2037 tools: ["generate-version-script"],
2038 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
2039}
2040
2041genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002042 name: "libstdc++.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07002043 out: ["libstdc++.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002044 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00002045 tools: ["generate-version-script"],
2046 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002047}
2048
2049genrule {
2050 name: "libstdc++.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07002051 out: ["libstdc++.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002052 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00002053 tools: ["generate-version-script"],
2054 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002055}
2056
2057// ========================================================
2058// crt object files.
2059// ========================================================
2060
Colin Cross50c21ab2015-10-31 23:03:05 -07002061cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07002062 name: "crt_and_memtag_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -08002063 defaults: ["linux_bionic_supported"],
Dan Willemsen230a7a42017-04-07 14:09:05 -07002064 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09002065 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08002066 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07002067 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +09002068 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02002069 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09002070 apex_available: [
2071 "//apex_available:platform",
2072 "//apex_available:anyapex",
2073 ],
Dan Albertdc503f62020-07-15 17:22:18 -07002074 // Generate NDK variants of the CRT objects for every supported API level.
2075 min_sdk_version: "16",
2076 stl: "none",
2077 crt: true,
Elliott Hughesd50a1de2018-02-05 17:30:57 -08002078 cflags: [
2079 "-Wno-gcc-compat",
2080 "-Wall",
2081 "-Werror",
2082 ],
Peter Collingbourne7eb851c2019-09-26 12:16:06 -07002083 sanitize: {
2084 never: true,
2085 },
Dan Willemsen208ae172015-09-16 16:33:27 -07002086}
2087
Colin Cross50c21ab2015-10-31 23:03:05 -07002088cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07002089 name: "crt_defaults",
2090 defaults: ["crt_and_memtag_defaults"],
Colin Cross02f81372021-07-22 12:02:10 -07002091 system_shared_libs: [],
Colin Cross10d92682021-06-22 13:25:46 -07002092}
2093
2094cc_defaults {
Colin Cross50c21ab2015-10-31 23:03:05 -07002095 name: "crt_so_defaults",
Colin Cross7d7b3682017-11-03 13:38:40 -07002096 defaults: ["crt_defaults"],
Colin Cross50c21ab2015-10-31 23:03:05 -07002097
2098 arch: {
Colin Cross50c21ab2015-10-31 23:03:05 -07002099 x86: {
2100 cflags: ["-fPIC"],
2101 },
2102 x86_64: {
2103 cflags: ["-fPIC"],
2104 },
Dan Willemsen208ae172015-09-16 16:33:27 -07002105 },
Colin Crossab179442018-09-27 11:03:22 -07002106 stl: "none",
Dan Willemsen208ae172015-09-16 16:33:27 -07002107}
2108
Dan Willemsen208ae172015-09-16 16:33:27 -07002109cc_object {
2110 name: "crtbrand",
Dan Willemsena3ed9012017-04-04 15:51:26 -07002111 // crtbrand.c needs <stdint.h> and a #define for the platform SDK version.
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002112 local_include_dirs: [
2113 "include",
2114 "private", // crtbrand.S depends on private/bionic_asm_note.h
2115 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002116 product_variables: {
2117 platform_sdk_version: {
2118 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
2119 },
2120 },
2121 srcs: ["arch-common/bionic/crtbrand.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002122
Colin Cross7d7b3682017-11-03 13:38:40 -07002123 defaults: ["crt_so_defaults"],
Dan Alberteee46dc2023-04-04 23:27:52 +00002124 // crtbrand is an intermediate artifact, not a final CRT object.
2125 exclude_from_ndk_sysroot: true,
Dan Willemsen208ae172015-09-16 16:33:27 -07002126}
2127
Dan Willemsen208ae172015-09-16 16:33:27 -07002128cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002129 name: "crtbegin_so",
Dan Willemsen208ae172015-09-16 16:33:27 -07002130 local_include_dirs: ["include"],
2131 srcs: ["arch-common/bionic/crtbegin_so.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002132
Colin Cross7d7b3682017-11-03 13:38:40 -07002133 defaults: ["crt_so_defaults"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002134 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002135 "crtbrand",
2136 ],
2137}
2138
Dan Willemsen208ae172015-09-16 16:33:27 -07002139cc_object {
2140 name: "crtend_so",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002141 local_include_dirs: [
2142 "include",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002143 "private", // crtend_so.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002144 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002145 srcs: ["arch-common/bionic/crtend_so.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002146
Colin Cross7d7b3682017-11-03 13:38:40 -07002147 defaults: ["crt_so_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002148}
2149
Dan Willemsen208ae172015-09-16 16:33:27 -07002150cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002151 name: "crtbegin_static",
2152
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002153 local_include_dirs: [
2154 "include",
2155 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2156 ],
Liz Kammere718dd72021-03-09 15:00:06 -05002157
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002158 cflags: ["-DCRTBEGIN_STATIC"],
Yabin Cui744cfd32023-08-24 13:20:23 -07002159
Dan Willemsen208ae172015-09-16 16:33:27 -07002160 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002161 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002162 "crtbrand",
2163 ],
Colin Cross50c21ab2015-10-31 23:03:05 -07002164 defaults: ["crt_defaults"],
Jiyong Park268a6002021-01-12 23:14:37 +09002165 // When using libc.a, we're using the latest library regardless of target API level.
2166 min_sdk_version: "current",
Dan Willemsen208ae172015-09-16 16:33:27 -07002167}
2168
Dan Willemsen208ae172015-09-16 16:33:27 -07002169cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002170 name: "crtbegin_dynamic",
2171
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002172 local_include_dirs: [
2173 "include",
2174 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2175 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002176 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002177 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002178 "crtbrand",
2179 ],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -07002180 target: {
2181 linux_bionic: {
2182 generated_sources: ["host_bionic_linker_asm"],
2183 objs: [
2184 "linker_wrapper",
2185 ],
2186 },
2187 },
Colin Cross50c21ab2015-10-31 23:03:05 -07002188 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002189}
2190
Dan Willemsen208ae172015-09-16 16:33:27 -07002191cc_object {
2192 // We rename crtend.o to crtend_android.o to avoid a
2193 // name clash between gcc and bionic.
2194 name: "crtend_android",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002195 local_include_dirs: [
2196 "include",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002197 "private", // crtend.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002198 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002199 srcs: ["arch-common/bionic/crtend.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002200
Colin Cross50c21ab2015-10-31 23:03:05 -07002201 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002202}
Colin Crossbaa48992016-07-13 11:15:21 -07002203
Kalesh Singh862a23d2024-01-09 13:13:50 -08002204cc_object {
2205 name: "crt_pad_segment",
2206 local_include_dirs: [
2207 "include",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002208 "private", // crt_pad_segment.S depends on private/bionic_asm_note.h
Kalesh Singh862a23d2024-01-09 13:13:50 -08002209 ],
2210 srcs: ["arch-common/bionic/crt_pad_segment.S"],
2211
2212 defaults: ["crt_defaults"],
2213}
2214
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002215cc_library_static {
2216 name: "note_memtag_heap_async",
2217 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002218 arm64: {
2219 srcs: ["arch-arm64/bionic/note_memtag_heap_async.S"],
2220 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002221 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002222 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002223
Colin Cross10d92682021-06-22 13:25:46 -07002224 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002225}
2226
2227cc_library_static {
2228 name: "note_memtag_heap_sync",
2229 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002230 arm64: {
2231 srcs: ["arch-arm64/bionic/note_memtag_heap_sync.S"],
2232 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002233 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002234 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002235
Colin Cross10d92682021-06-22 13:25:46 -07002236 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002237}
2238
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002239// ========================================================
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002240// libc dependencies for baremetal Rust projects.
2241// ========================================================
2242
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002243// This library contains the following unresolved symbols:
2244// __errno
2245// abort
2246// async_safe_fatal_va_list
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002247cc_library_static {
2248 name: "librust_baremetal",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002249 header_libs: ["libc_headers"],
2250 include_dirs: [
2251 "bionic/libc/async_safe/include",
2252 "bionic/libc/platform",
2253 ],
2254 cflags: [
2255 "-Wall",
2256 "-Werror",
2257 ],
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002258 srcs: [
2259 "bionic/fortify.cpp",
Pierre-Clément Tosi816176c2022-11-30 14:33:41 +00002260 "bionic/strtol.cpp",
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002261 ],
2262 arch: {
2263 arm64: {
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002264 srcs: [
2265 "arch-arm64/string/__memcpy_chk.S",
2266 ],
2267 },
caowencheng9a39eb32023-03-20 16:24:41 +08002268 riscv64: {
2269 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002270 "arch-riscv64/string/__memcpy_chk.S",
caowencheng9a39eb32023-03-20 16:24:41 +08002271 ],
2272 },
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002273 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002274 whole_static_libs: [
2275 "libarm-optimized-routines-mem",
Pierre-Clément Tosieb46ac92023-02-01 13:44:57 +00002276 "libc_netbsd",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002277 ],
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002278 system_shared_libs: [],
2279 nocrt: true,
2280 stl: "none",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002281 visibility: [
2282 "//packages/modules/Virtualization/vmbase",
2283 ],
2284}
2285
2286// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002287// NDK headers.
2288// ========================================================
2289
Dan Albert26e1c412018-05-24 14:56:46 -07002290versioned_ndk_headers {
Dan Albert22805ea2017-03-22 15:28:05 -07002291 name: "common_libc",
2292 from: "include",
2293 to: "",
2294 license: "NOTICE",
2295}
Dan Albert4238a352016-06-28 11:18:05 -07002296
2297ndk_headers {
Dan Albert063e86a2016-11-29 11:09:12 -08002298 name: "libc_uapi",
2299 from: "kernel/uapi",
2300 to: "",
2301 srcs: [
2302 "kernel/uapi/asm-generic/**/*.h",
2303 "kernel/uapi/drm/**/*.h",
2304 "kernel/uapi/linux/**/*.h",
2305 "kernel/uapi/misc/**/*.h",
2306 "kernel/uapi/mtd/**/*.h",
2307 "kernel/uapi/rdma/**/*.h",
2308 "kernel/uapi/scsi/**/*.h",
2309 "kernel/uapi/sound/**/*.h",
2310 "kernel/uapi/video/**/*.h",
2311 "kernel/uapi/xen/**/*.h",
2312 ],
Dan Albert92592652016-10-20 01:42:54 -07002313 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002314}
2315
2316ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002317 name: "libc_kernel_android_uapi_linux",
Dan Albertbae16ef2016-09-14 17:15:48 -07002318 from: "kernel/android/uapi/linux",
2319 to: "linux",
2320 srcs: ["kernel/android/uapi/linux/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002321 license: "NOTICE",
Dan Albertbae16ef2016-09-14 17:15:48 -07002322}
2323
2324ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002325 name: "libc_kernel_android_scsi",
Elliott Hughes50599392017-05-25 17:13:32 -07002326 from: "kernel/android/scsi/scsi",
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002327 to: "scsi",
2328 srcs: ["kernel/android/scsi/**/*.h"],
2329 license: "NOTICE",
2330}
2331
2332ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002333 name: "libc_asm_arm",
2334 from: "kernel/uapi/asm-arm",
2335 to: "arm-linux-androideabi",
2336 srcs: ["kernel/uapi/asm-arm/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002337 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002338}
2339
2340ndk_headers {
2341 name: "libc_asm_arm64",
2342 from: "kernel/uapi/asm-arm64",
2343 to: "aarch64-linux-android",
2344 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002345 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002346}
2347
Lazar Trsic790d2f72017-11-27 11:54:11 +01002348ndk_headers {
Colin Crossbd26e0f2022-10-19 15:03:14 -07002349 name: "libc_asm_riscv64",
2350 from: "kernel/uapi/asm-riscv",
2351 to: "riscv64-linux-android",
2352 srcs: ["kernel/uapi/asm-riscv/**/*.h"],
2353 license: "NOTICE",
2354}
2355
2356ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002357 name: "libc_asm_x86",
2358 from: "kernel/uapi/asm-x86",
2359 to: "i686-linux-android",
2360 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002361 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002362}
2363
2364ndk_headers {
2365 name: "libc_asm_x86_64",
2366 from: "kernel/uapi/asm-x86",
2367 to: "x86_64-linux-android",
2368 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002369 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002370}
2371
Dan Albert4238a352016-06-28 11:18:05 -07002372ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002373 name: "libc",
Dan Albert4238a352016-06-28 11:18:05 -07002374 symbol_file: "libc.map.txt",
2375 first_version: "9",
Spandan Das6feb2cc2022-09-08 23:41:42 +00002376 export_header_libs: [
2377 "common_libc",
2378 "libc_uapi",
2379 "libc_kernel_android_uapi_linux",
2380 "libc_kernel_android_scsi",
2381 "libc_asm_arm",
2382 "libc_asm_arm64",
Colin Crossbd26e0f2022-10-19 15:03:14 -07002383 "libc_asm_riscv64",
Spandan Das6feb2cc2022-09-08 23:41:42 +00002384 "libc_asm_x86",
2385 "libc_asm_x86_64",
2386 ],
Dan Albert4238a352016-06-28 11:18:05 -07002387}
2388
Dan Albertdf31aff2016-10-06 15:50:41 -07002389ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002390 name: "libstdc++",
Dan Albertdf31aff2016-10-06 15:50:41 -07002391 symbol_file: "libstdc++.map.txt",
2392 first_version: "9",
2393}
2394
Dan Willemsenca056d72018-01-08 14:00:24 -08002395// Export these headers for toolbox to process
2396filegroup {
2397 name: "kernel_input_headers",
2398 srcs: [
2399 "kernel/uapi/linux/input.h",
2400 "kernel/uapi/linux/input-event-codes.h",
2401 ],
2402}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002403
2404// Generate a syscall name / number mapping. These objects are text files
2405// (thanks to the -dD -E flags) and not binary files. They will then be
2406// consumed by the genseccomp.py script and converted into C++ code.
2407cc_defaults {
2408 name: "libseccomp_gen_syscall_nrs_defaults",
2409 recovery_available: true,
2410 srcs: ["seccomp/gen_syscall_nrs.cpp"],
2411 cflags: [
2412 "-dD",
2413 "-E",
2414 "-Wall",
2415 "-Werror",
2416 "-nostdinc",
2417 ],
2418}
2419
2420cc_object {
2421 name: "libseccomp_gen_syscall_nrs_arm",
2422 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2423 local_include_dirs: [
2424 "kernel/uapi/asm-arm",
2425 "kernel/uapi",
2426 ],
2427}
2428
2429cc_object {
2430 name: "libseccomp_gen_syscall_nrs_arm64",
2431 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2432 local_include_dirs: [
2433 "kernel/uapi/asm-arm64",
2434 "kernel/uapi",
2435 ],
2436}
2437
2438cc_object {
Elliott Hughes704772b2022-10-10 17:06:43 +00002439 name: "libseccomp_gen_syscall_nrs_riscv64",
2440 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2441 local_include_dirs: [
2442 "kernel/uapi/asm-riscv",
2443 "kernel/uapi",
2444 ],
2445}
2446
2447cc_object {
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002448 name: "libseccomp_gen_syscall_nrs_x86",
2449 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2450 srcs: ["seccomp/gen_syscall_nrs_x86.cpp"],
2451 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2452 local_include_dirs: [
2453 "kernel/uapi/asm-x86",
2454 "kernel/uapi",
2455 ],
2456}
2457
2458cc_object {
2459 name: "libseccomp_gen_syscall_nrs_x86_64",
2460 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2461 srcs: ["seccomp/gen_syscall_nrs_x86_64.cpp"],
2462 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2463 local_include_dirs: [
2464 "kernel/uapi/asm-x86",
2465 "kernel/uapi",
2466 ],
2467}
2468
Jingwen Chenca366332021-01-29 05:16:32 -05002469filegroup {
2470 name: "all_kernel_uapi_headers",
2471 srcs: ["kernel/uapi/**/*.h"],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002472}
2473
Martijn Coenen0c6de752019-01-02 12:52:51 +01002474cc_genrule {
2475 name: "func_to_syscall_nrs",
2476 recovery_available: true,
2477 cmd: "$(location genfunctosyscallnrs) --out-dir=$(genDir) $(in)",
2478
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002479 tools: ["genfunctosyscallnrs"],
Martijn Coenen0c6de752019-01-02 12:52:51 +01002480
2481 srcs: [
2482 "SYSCALLS.TXT",
Martijn Coenen0c6de752019-01-02 12:52:51 +01002483 ],
2484
Elliott Hughes704772b2022-10-10 17:06:43 +00002485 arch: {
2486 arm: {
2487 srcs: [
2488 ":libseccomp_gen_syscall_nrs_arm",
2489 ":libseccomp_gen_syscall_nrs_arm64",
2490 ],
2491 },
2492 arm64: {
2493 srcs: [
2494 ":libseccomp_gen_syscall_nrs_arm",
2495 ":libseccomp_gen_syscall_nrs_arm64",
2496 ],
2497 },
2498 riscv64: {
2499 srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
2500 },
2501 x86: {
2502 srcs: [
2503 ":libseccomp_gen_syscall_nrs_x86",
2504 ":libseccomp_gen_syscall_nrs_x86_64",
2505 ],
2506 },
2507 x86_64: {
2508 srcs: [
2509 ":libseccomp_gen_syscall_nrs_x86",
2510 ":libseccomp_gen_syscall_nrs_x86_64",
2511 ],
2512 },
2513 },
2514
Martijn Coenen0c6de752019-01-02 12:52:51 +01002515 out: [
2516 "func_to_syscall_nrs.h",
2517 ],
2518}
2519
Victor Hsiehdbb86702020-06-15 09:29:07 -07002520// SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT = SECCOMP_BLOCKLIST_APP.txt - setresgid*
Martijn Coenenc3752be2019-01-09 16:19:57 +01002521genrule {
Victor Hsiehdbb86702020-06-15 09:29:07 -07002522 name: "generate_app_zygote_blocklist",
2523 out: ["SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT"],
2524 srcs: ["SECCOMP_BLOCKLIST_APP.TXT"],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002525 cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)",
2526}
2527
Yu Liu938ec9b2022-10-17 16:36:30 -07002528filegroup {
2529 name: "seccomp_syscalls_sources_zygote",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002530 srcs: [
2531 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002532 "SECCOMP_ALLOWLIST_COMMON.TXT",
2533 "SECCOMP_ALLOWLIST_APP.TXT",
2534 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002535 "SECCOMP_PRIORITY.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002536 ":generate_app_zygote_blocklist",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002537 ],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002538}
2539
Yu Liu938ec9b2022-10-17 16:36:30 -07002540filegroup {
2541 name: "seccomp_syscalls_sources_app",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002542 srcs: [
2543 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002544 "SECCOMP_ALLOWLIST_COMMON.TXT",
2545 "SECCOMP_ALLOWLIST_APP.TXT",
2546 "SECCOMP_BLOCKLIST_COMMON.TXT",
2547 "SECCOMP_BLOCKLIST_APP.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002548 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002549 ],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002550}
2551
Yu Liu938ec9b2022-10-17 16:36:30 -07002552filegroup {
2553 name: "seccomp_syscalls_sources_system",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002554 srcs: [
2555 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002556 "SECCOMP_ALLOWLIST_COMMON.TXT",
2557 "SECCOMP_ALLOWLIST_SYSTEM.TXT",
2558 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002559 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002560 ],
Yu Liu938ec9b2022-10-17 16:36:30 -07002561}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002562
Yu Liu938ec9b2022-10-17 16:36:30 -07002563cc_genrule {
2564 name: "libseccomp_policy_app_zygote_sources_x86",
2565 recovery_available: true,
2566 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002567 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002568 srcs: [
2569 ":seccomp_syscalls_sources_zygote",
2570 ":libseccomp_gen_syscall_nrs_x86",
2571 ":libseccomp_gen_syscall_nrs_x86_64",
2572 ],
2573 out: [
2574 "x86_app_zygote_policy.cpp",
2575 "x86_64_app_zygote_policy.cpp",
2576 ],
2577 enabled: false,
Yu Liu3a579692022-10-18 03:02:32 +00002578 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002579 x86: {
2580 enabled: true,
2581 },
2582 x86_64: {
2583 enabled: true,
2584 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002585 },
2586}
2587
2588cc_genrule {
2589 name: "libseccomp_policy_app_zygote_sources_arm",
2590 recovery_available: true,
2591 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002592 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002593 srcs: [
2594 ":seccomp_syscalls_sources_zygote",
2595 ":libseccomp_gen_syscall_nrs_arm",
2596 ":libseccomp_gen_syscall_nrs_arm64",
2597 ],
2598 out: [
2599 "arm_app_zygote_policy.cpp",
2600 "arm64_app_zygote_policy.cpp",
2601 ],
2602 enabled: false,
2603 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002604 arm: {
2605 enabled: true,
2606 },
2607 arm64: {
2608 enabled: true,
2609 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002610 },
2611}
2612
2613cc_genrule {
2614 name: "libseccomp_policy_app_zygote_sources_riscv64",
2615 recovery_available: true,
2616 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002617 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002618 srcs: [
2619 ":seccomp_syscalls_sources_zygote",
2620 ":libseccomp_gen_syscall_nrs_riscv64",
2621 ],
2622 out: [
2623 "riscv64_app_zygote_policy.cpp",
2624 ],
2625 enabled: false,
2626 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002627 riscv64: {
2628 enabled: true,
2629 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002630 },
2631}
2632
2633cc_genrule {
2634 name: "libseccomp_policy_app_sources_x86",
2635 recovery_available: true,
2636 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002637 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002638 srcs: [
2639 ":seccomp_syscalls_sources_app",
2640 ":libseccomp_gen_syscall_nrs_x86",
2641 ":libseccomp_gen_syscall_nrs_x86_64",
2642 ],
2643 out: [
2644 "x86_app_policy.cpp",
2645 "x86_64_app_policy.cpp",
2646 ],
2647 enabled: false,
2648 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002649 x86: {
2650 enabled: true,
2651 },
2652 x86_64: {
2653 enabled: true,
2654 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002655 },
2656}
2657
2658cc_genrule {
2659 name: "libseccomp_policy_app_sources_arm",
2660 recovery_available: true,
2661 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002662 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002663 srcs: [
2664 ":seccomp_syscalls_sources_app",
2665 ":libseccomp_gen_syscall_nrs_arm",
2666 ":libseccomp_gen_syscall_nrs_arm64",
2667 ],
2668 out: [
2669 "arm_app_policy.cpp",
2670 "arm64_app_policy.cpp",
2671 ],
2672 enabled: false,
2673 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002674 arm: {
2675 enabled: true,
2676 },
2677 arm64: {
2678 enabled: true,
2679 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002680 },
2681}
2682
2683cc_genrule {
2684 name: "libseccomp_policy_app_sources_riscv64",
2685 recovery_available: true,
2686 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002687 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002688 srcs: [
2689 ":seccomp_syscalls_sources_app",
2690 ":libseccomp_gen_syscall_nrs_riscv64",
2691 ],
2692 out: [
2693 "riscv64_app_policy.cpp",
2694 ],
2695 enabled: false,
2696 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002697 riscv64: {
2698 enabled: true,
2699 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002700 },
2701}
2702
2703cc_genrule {
2704 name: "libseccomp_policy_system_sources_x86",
2705 recovery_available: true,
2706 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002707 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002708 srcs: [
2709 ":seccomp_syscalls_sources_system",
2710 ":libseccomp_gen_syscall_nrs_x86",
2711 ":libseccomp_gen_syscall_nrs_x86_64",
2712 ],
2713 out: [
2714 "x86_system_policy.cpp",
2715 "x86_64_system_policy.cpp",
2716 ],
2717 enabled: false,
2718 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002719 x86: {
2720 enabled: true,
2721 },
2722 x86_64: {
2723 enabled: true,
2724 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002725 },
2726}
2727
2728cc_genrule {
2729 name: "libseccomp_policy_system_sources_arm",
2730 recovery_available: true,
2731 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002732 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002733 srcs: [
2734 ":seccomp_syscalls_sources_system",
2735 ":libseccomp_gen_syscall_nrs_arm",
2736 ":libseccomp_gen_syscall_nrs_arm64",
2737 ],
2738 out: [
2739 "arm_system_policy.cpp",
2740 "arm64_system_policy.cpp",
2741 ],
2742 enabled: false,
2743 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002744 arm: {
2745 enabled: true,
2746 },
2747 arm64: {
2748 enabled: true,
2749 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002750 },
2751}
2752
2753cc_genrule {
2754 name: "libseccomp_policy_system_sources_riscv64",
2755 recovery_available: true,
2756 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002757 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002758 srcs: [
2759 ":seccomp_syscalls_sources_system",
2760 ":libseccomp_gen_syscall_nrs_riscv64",
2761 ],
2762 out: [
2763 "riscv64_system_policy.cpp",
2764 ],
2765 enabled: false,
2766 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002767 riscv64: {
2768 enabled: true,
2769 },
Yu Liu3a579692022-10-18 03:02:32 +00002770 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002771}
2772
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002773cc_library {
2774 name: "libseccomp_policy",
2775 recovery_available: true,
Martijn Coenend269d9b2018-11-08 16:41:42 +01002776 generated_headers: ["func_to_syscall_nrs"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002777
2778 arch: {
2779 arm: {
2780 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002781 "libseccomp_policy_app_sources_arm",
2782 "libseccomp_policy_app_zygote_sources_arm",
2783 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002784 ],
2785 },
2786 arm64: {
2787 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002788 "libseccomp_policy_app_sources_arm",
2789 "libseccomp_policy_app_zygote_sources_arm",
2790 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002791 ],
2792 },
2793 riscv64: {
2794 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002795 "libseccomp_policy_app_sources_riscv64",
2796 "libseccomp_policy_app_zygote_sources_riscv64",
2797 "libseccomp_policy_system_sources_riscv64",
Yu Liu938ec9b2022-10-17 16:36:30 -07002798 ],
2799 },
2800 x86: {
2801 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002802 "libseccomp_policy_app_sources_x86",
2803 "libseccomp_policy_app_zygote_sources_x86",
2804 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002805 ],
2806 },
2807 x86_64: {
2808 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002809 "libseccomp_policy_app_sources_x86",
2810 "libseccomp_policy_app_zygote_sources_x86",
2811 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002812 ],
2813 },
2814 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002815
2816 srcs: [
2817 "seccomp/seccomp_policy.cpp",
2818 ],
2819
2820 export_include_dirs: ["seccomp/include"],
2821 cflags: [
2822 "-Wall",
2823 "-Werror",
2824 ],
2825 shared: {
2826 shared_libs: ["libbase"],
2827 },
2828 static: {
2829 static_libs: ["libbase"],
2830 },
2831}
Christopher Ferrisfc26d712019-02-27 18:07:55 -08002832
Colin Cross048f24e2021-09-01 17:26:00 -07002833cc_library_host_static {
2834 name: "libfts",
2835 srcs: [
2836 "bionic/fts.c",
2837 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
2838 ],
2839 export_include_dirs: ["fts/include"],
2840 local_include_dirs: [
2841 "private",
2842 "upstream-openbsd/android/include",
2843 ],
2844 cflags: [
2845 "-include openbsd-compat.h",
2846 "-Wno-unused-parameter",
2847 ],
2848 enabled: false,
2849 target: {
2850 musl: {
2851 enabled: true,
2852 },
2853 },
Colin Cross2a9843f2022-01-13 12:26:30 -08002854 stl: "none",
2855}
2856
2857cc_library_host_static {
2858 name: "libexecinfo",
2859 visibility: ["//external/musl"],
2860 srcs: ["bionic/execinfo.cpp"],
2861 export_include_dirs: ["execinfo/include"],
2862 local_include_dirs: ["private"],
2863 enabled: false,
2864 target: {
2865 musl: {
2866 enabled: true,
2867 system_shared_libs: [],
2868 header_libs: ["libc_musl_headers"],
2869 },
2870 },
2871 stl: "none",
Colin Cross048f24e2021-09-01 17:26:00 -07002872}
2873
Colin Cross9da85fa2022-01-24 18:20:05 -08002874cc_library_host_static {
2875 name: "libb64",
2876 visibility: ["//external/musl"],
2877 srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
2878 export_include_dirs: ["b64/include"],
2879 local_include_dirs: [
2880 "private",
2881 "upstream-openbsd/android/include",
2882 ],
2883 cflags: [
2884 "-include openbsd-compat.h",
2885 ],
2886 enabled: false,
2887 target: {
2888 musl: {
2889 enabled: true,
2890 system_shared_libs: [],
2891 header_libs: ["libc_musl_headers"],
2892 },
2893 },
2894 stl: "none",
2895}
2896
Colin Cross9d4a56e2022-02-03 10:20:32 -08002897// Export kernel uapi headers to be used in the musl sysroot.
2898// Also include the execinfo headers for the libexecinfo and the
2899// b64 headers for libb64 embedded in musl libc.
2900cc_genrule {
2901 name: "libc_musl_sysroot_bionic_headers",
2902 visibility: ["//external/musl"],
2903 host_supported: true,
2904 device_supported: false,
2905 enabled: false,
2906 target: {
2907 musl: {
2908 enabled: true,
2909 },
2910 },
2911 srcs: [
2912 "kernel/uapi/**/*.h",
2913 "kernel/android/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002914 "execinfo/include/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002915 "b64/include/**/*.h",
Colin Crossaeef9f02022-02-07 21:01:26 -08002916
Colin Crossaeef9f02022-02-07 21:01:26 -08002917 "NOTICE",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002918
2919 ":libc_musl_sysroot_bionic_arch_headers",
2920 ],
2921 out: ["libc_musl_sysroot_bionic_headers.zip"],
2922 tools: [
2923 "soong_zip",
2924 "merge_zips",
2925 "zip2zip",
2926 ],
Colin Crossaeef9f02022-02-07 21:01:26 -08002927 cmd: "BIONIC_LIBC_DIR=$$(dirname $(location NOTICE)) && " +
2928 "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
Colin Crossad33d022022-02-25 18:27:04 -08002929 // NOTICE
2930 " -j -f $(location NOTICE) " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002931 // headers
2932 " -P include " +
Colin Crossaeef9f02022-02-07 21:01:26 -08002933 " -C $${BIONIC_LIBC_DIR}/kernel/uapi " +
2934 " -D $${BIONIC_LIBC_DIR}/kernel/uapi " +
2935 " -C $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2936 " -D $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2937 " -C $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2938 " -D $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2939 " -C $${BIONIC_LIBC_DIR}/execinfo/include " +
2940 " -D $${BIONIC_LIBC_DIR}/execinfo/include " +
2941 " -C $${BIONIC_LIBC_DIR}/b64/include " +
2942 " -D $${BIONIC_LIBC_DIR}/b64/include " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002943 " && " +
Colin Crossad33d022022-02-25 18:27:04 -08002944 "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(genDir)/sysroot-renamed.zip " +
Colin Cross1c0a7a02022-08-11 12:22:26 -07002945 " -x **/BUILD " +
Colin Crossad33d022022-02-25 18:27:04 -08002946 " include/**/*:include/ " +
2947 " NOTICE:NOTICE.bionic " +
2948 " && " +
2949 "$(location merge_zips) $(out) $(location :libc_musl_sysroot_bionic_arch_headers) $(genDir)/sysroot-renamed.zip",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002950}
2951
2952// The architecture-specific bits have to be handled separately because the label varies based
2953// on architecture, which prevents using $(locations) to find them and requires using $(in)
2954// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
2955// genrule.
2956cc_genrule {
2957 name: "libc_musl_sysroot_bionic_arch_headers",
2958 visibility: ["//visibility:private"],
2959 host_supported: true,
2960 device_supported: false,
2961 enabled: false,
2962 target: {
2963 musl: {
2964 enabled: true,
2965 },
2966 },
2967 arch: {
2968 arm: {
2969 srcs: ["kernel/uapi/asm-arm/**/*.h"],
2970 },
2971 arm64: {
2972 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
2973 },
2974 x86: {
2975 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2976 },
2977 x86_64: {
2978 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2979 },
2980 },
2981 out: ["libc_musl_sysroot_bionic_arch_headers.zip"],
2982 tools: ["soong_zip"],
2983 cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/asm -j -D $$(dirname $${includes[0]})",
2984}
Colin Cross290c4952022-10-13 12:51:13 -07002985
2986cc_genrule {
2987 name: "bionic_sysroot_crt_objects",
2988 visibility: ["//visibility:private"],
2989 out: ["bionic_sysroot_crt_objects.zip"],
2990 tools: ["soong_zip"],
2991 srcs: [
2992 ":crtbegin_dynamic",
2993 ":crtbegin_so",
2994 ":crtbegin_static",
2995 ":crtend_android",
2996 ":crtend_so",
2997 ],
2998 cmd: "$(location soong_zip) -o $(out) -j " +
2999 "-f $(location :crtbegin_dynamic) " +
3000 "-f $(location :crtbegin_so) " +
3001 "-f $(location :crtbegin_static) " +
3002 "-f $(location :crtend_android) " +
3003 "-f $(location :crtend_so)",
3004 dist: {
3005 targets: ["bionic_sysroot_crt_objects"],
3006 },
3007 arch: {
3008 arm: {
3009 dist: {
3010 suffix: "_arm",
3011 },
3012 },
3013 arm64: {
3014 dist: {
3015 suffix: "_arm64",
3016 },
3017 },
3018 riscv64: {
3019 dist: {
3020 suffix: "_riscv64",
3021 },
3022 },
3023 x86: {
3024 dist: {
3025 suffix: "_x86",
3026 },
3027 },
3028 x86_64: {
3029 dist: {
3030 suffix: "_x86_64",
3031 },
3032 },
3033 },
3034}
Spandan Das8fce52a2023-09-28 18:00:12 +00003035
3036// headers that will be placed on the include path when running versioner in bazel
3037// this module should be a no-op in soong
3038filegroup {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00003039 name: "versioner-dependencies",
3040 srcs: ["versioner-dependencies/**/*"],
Spandan Das8fce52a2023-09-28 18:00:12 +00003041}