blob: e59fac20a0b75f74ea74172b1a6bbfaab7393dfb [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
Dan Willemsen208ae172015-09-16 16:33:27 -070023libc_common_src_files = [
Dan Willemsen208ae172015-09-16 16:33:27 -070024 "bionic/ether_aton.c",
25 "bionic/ether_ntoa.c",
Victor Khimenko8e0707d2020-06-09 21:57:05 +020026 "bionic/exit.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -070027 "bionic/initgroups.c",
Dan Willemsen208ae172015-09-16 16:33:27 -070028 "bionic/isatty.c",
Dan Willemsen208ae172015-09-16 16:33:27 -070029 "bionic/sched_cpualloc.c",
30 "bionic/sched_cpucount.c",
Mitch Phillipse6997d52020-11-30 15:04:14 -080031 "bionic/sysprop_helpers.cpp",
Elliott Hughes3a4c4542017-07-19 17:20:24 -070032 "stdio/fmemopen.cpp",
Elliott Hughes7f0849f2016-08-26 16:17:17 -070033 "stdio/parsefloat.c",
Dan Willemsen268a6732015-10-15 14:49:45 -070034 "stdio/refill.c",
Dan Willemsen3e621712016-02-03 21:48:08 -080035 "stdio/stdio.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -070036 "stdio/stdio_ext.cpp",
Elliott Hughes38e4aef2018-01-18 10:21:29 -080037 "stdio/vfscanf.cpp",
Elliott Hughes1f462de2022-08-05 22:51:05 +000038 "stdio/vfwscanf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -070039]
40
Peter Collingbourne570de332019-12-11 10:00:58 -080041// off64_t/time64_t support on LP32.
Dan Willemsen208ae172015-09-16 16:33:27 -070042// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -070043libc_common_src_files_32 = [
44 "bionic/legacy_32_bit_support.cpp",
45 "bionic/time64.c",
46]
47
Elliott Hughes53cf3482016-08-09 13:06:41 -070048libc_common_flags = [
49 "-D_LIBC=1",
Elliott Hughes25f17e42018-02-12 15:48:01 -080050 "-D__BIONIC_LP32_USE_STAT64",
Elliott Hughes53cf3482016-08-09 13:06:41 -070051 "-Wall",
52 "-Wextra",
53 "-Wunused",
Elliott Hughes3048a362018-01-19 17:58:07 -080054 "-Wno-char-subscripts",
Elliott Hughes53cf3482016-08-09 13:06:41 -070055 "-Wno-deprecated-declarations",
Elliott Hughesb348d5c2017-07-24 16:53:11 -070056 "-Wno-gcc-compat",
Elliott Hughes8e547bd2016-08-16 15:57:47 -070057 "-Wframe-larger-than=2048",
Elliott Hughes53cf3482016-08-09 13:06:41 -070058
59 // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
60 "-Werror=pointer-to-int-cast",
61 "-Werror=int-to-pointer-cast",
62 "-Werror=type-limits",
63 "-Werror",
Ryan Prichard8f419572018-02-20 17:09:05 -080064
65 // Clang's exit-time destructor registration hides __dso_handle, but
66 // __dso_handle needs to have default visibility on ARM32. See b/73485611.
67 "-Wexit-time-destructors",
Mitch Phillipsf3968e82020-01-31 19:57:04 -080068
69 // GWP-ASan requires platform TLS.
70 "-fno-emulated-tls",
Elliott Hughesa13d0662021-12-02 14:42:16 -080071
72 // We know clang does a lot of harm by rewriting what we've said, and sadly
73 // never see any good it does, so let's just ask it to do what we say...
74 // (The specific motivating example was clang turning a loop that would only
75 // ever touch 0, 1, or 2 bytes into a call to memset, which was never going
76 // to amortize.)
77 "-fno-builtin",
Elliott Hughes53cf3482016-08-09 13:06:41 -070078]
79
Dan Willemsen208ae172015-09-16 16:33:27 -070080// Define some common cflags
81// ========================================================
Colin Cross50c21ab2015-10-31 23:03:05 -070082cc_defaults {
83 name: "libc_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -080084 defaults: ["linux_bionic_supported"],
Elliott Hughes53cf3482016-08-09 13:06:41 -070085 cflags: libc_common_flags,
86 asflags: libc_common_flags,
Colin Cross50c21ab2015-10-31 23:03:05 -070087 conlyflags: ["-std=gnu99"],
88 cppflags: [],
Christopher Ferris7a3681e2017-04-24 17:48:32 -070089 include_dirs: [
90 "bionic/libc/async_safe/include",
Peter Collingbourne5d3aa862020-09-11 15:05:17 -070091 "bionic/libc/platform",
Tom Cherry379ed1e2020-09-17 09:36:25 -070092 // For android_filesystem_config.h.
93 "system/core/libcutils/include",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070094 ],
Colin Cross50c21ab2015-10-31 23:03:05 -070095
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010096 header_libs: [
97 "libc_headers",
Rupert Shuttleworthed80dcd2021-04-22 01:52:53 -040098 "liblog_headers", // needed by bionic/libc/async_safe/include
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010099 ],
100 export_header_lib_headers: [
101 "libc_headers",
102 ],
Mitch Phillipsf3968e82020-01-31 19:57:04 -0800103
Colin Cross50c21ab2015-10-31 23:03:05 -0700104 stl: "none",
105 system_shared_libs: [],
Colin Cross27c43c52016-04-07 13:27:24 -0700106 sanitize: {
Evgenii Stepanovbe551f52018-08-13 16:46:15 -0700107 address: false,
108 integer_overflow: false,
Mitch Phillipsdfde0ee2019-05-01 14:26:13 -0700109 // TODO(b/132640749): Fix broken fuzzer support.
110 fuzzer: false,
Colin Cross27c43c52016-04-07 13:27:24 -0700111 },
Yifan Hong5a39cee2020-01-21 16:43:56 -0800112 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -0700113 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +0900114 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +0200115 native_bridge_supported: true,
Ivan Lozanof17fd1d2018-11-27 07:56:17 -0800116
Yi Konge3d90de2019-02-20 14:28:56 -0800117 // lld complains about duplicate symbols in libcrt and libgcc. Suppress the
118 // warning since this is intended right now.
119 ldflags: ["-Wl,-z,muldefs"],
Peter Collingbournee99912f2019-11-01 15:37:00 -0700120
121 product_variables: {
Evgenii Stepanov5a73e032020-04-29 14:59:44 -0700122 malloc_zero_contents: {
123 cflags: ["-DSCUDO_ZERO_CONTENTS"],
124 },
125 malloc_pattern_fill_contents: {
126 cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
127 },
Steven Morelandfb65ee42020-07-31 00:18:38 +0000128 malloc_not_svelte: {
129 cflags: ["-DUSE_SCUDO"],
130 },
Peter Collingbournee99912f2019-11-01 15:37:00 -0700131 },
Yi Kong9e33b762021-10-29 02:43:22 +0800132
133 lto: {
134 never: true,
135 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700136}
137
Christopher Ferris4df29ed2020-01-24 18:06:42 -0800138libc_scudo_product_variables = {
139 malloc_not_svelte: {
140 cflags: ["-DUSE_SCUDO"],
141 whole_static_libs: ["libscudo"],
142 exclude_static_libs: [
143 "libjemalloc5",
144 "libc_jemalloc_wrapper",
145 ],
146 },
147}
148
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700149// Defaults for native allocator libs/includes to make it
150// easier to change.
Christopher Ferris062eba22020-01-31 22:40:45 -0800151// To disable scudo for the non-svelte config remove the line:
Christopher Ferris4df29ed2020-01-24 18:06:42 -0800152// product_variables: libc_scudo_product_variables,
Christopher Ferris062eba22020-01-31 22:40:45 -0800153// in the cc_defaults below.
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700154// ========================================================
155cc_defaults {
156 name: "libc_native_allocator_defaults",
157
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700158 whole_static_libs: [
159 "libjemalloc5",
160 "libc_jemalloc_wrapper",
161 ],
Mitch Phillipsf3968e82020-01-31 19:57:04 -0800162 header_libs: ["gwp_asan_headers"],
Christopher Ferris062eba22020-01-31 22:40:45 -0800163 product_variables: libc_scudo_product_variables,
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700164}
165
166// Functions not implemented by jemalloc directly, or that need to
167// be modified for Android.
168cc_library_static {
169 name: "libc_jemalloc_wrapper",
170 defaults: ["libc_defaults"],
171 srcs: ["bionic/jemalloc_wrapper.cpp"],
172 cflags: ["-fvisibility=hidden"],
173
Christopher Ferris4df29ed2020-01-24 18:06:42 -0800174 // Used to pull in the jemalloc include directory so that if the
175 // library is removed, the include directory is also removed.
176 static_libs: ["libjemalloc5"],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700177}
178
Dan Willemsen208ae172015-09-16 16:33:27 -0700179// ========================================================
Ryan Prichard249757b2019-11-01 17:18:28 -0700180// libc_bootstrap.a - -fno-stack-protector and -ffreestanding
Dan Willemsen208ae172015-09-16 16:33:27 -0700181// ========================================================
182//
Ryan Prichard249757b2019-11-01 17:18:28 -0700183// Code that implements the stack protector (or that runs before TLS has been set up) needs to be
184// compiled with -fno-stack-protector, since it accesses the stack canary TLS slot. In the linker,
185// some of this code runs before ifunc resolvers have made string.h functions work, so compile with
186// -ffreestanding.
Dan Willemsen208ae172015-09-16 16:33:27 -0700187
188cc_library_static {
189
Colin Crossa3f9fca2016-01-11 13:20:55 -0800190 srcs: [
191 "bionic/__libc_init_main_thread.cpp",
192 "bionic/__stack_chk_fail.cpp",
Ryan Prichard249757b2019-11-01 17:18:28 -0700193 "bionic/bionic_call_ifunc_resolver.cpp",
194 "bionic/getauxval.cpp",
Colin Crossa3f9fca2016-01-11 13:20:55 -0800195 ],
196 arch: {
197 arm64: {
198 srcs: ["arch-arm64/bionic/__set_tls.c"],
199 },
200 x86: {
Ryan Prichard27475b52018-05-17 17:14:18 -0700201 srcs: [
202 "arch-x86/bionic/__libc_init_sysinfo.cpp",
Pirama Arumuga Nainar7b89be72021-02-12 15:09:49 -0800203 "arch-x86/bionic/__libc_int0x80.S",
Ryan Prichard27475b52018-05-17 17:14:18 -0700204 "arch-x86/bionic/__set_tls.cpp",
205 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800206 },
207 x86_64: {
208 srcs: ["arch-x86_64/bionic/__set_tls.c"],
209 },
210 },
211
Colin Cross50c21ab2015-10-31 23:03:05 -0700212 defaults: ["libc_defaults"],
Ryan Prichard249757b2019-11-01 17:18:28 -0700213 cflags: ["-fno-stack-protector", "-ffreestanding"],
214 name: "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -0700215}
216
Ryan Prichard249757b2019-11-01 17:18:28 -0700217// libc_init_static.cpp and libc_init_dynamic.cpp need to be built without stack protector.
218// libc_init_static.cpp sets up TLS for static executables, and libc_init_dynamic.cpp initializes
219// the stack protector global variable.
Colin Crossa3f9fca2016-01-11 13:20:55 -0800220
221cc_library_static {
222 name: "libc_init_static",
223 defaults: ["libc_defaults"],
224 srcs: ["bionic/libc_init_static.cpp"],
Ryan Prichard249757b2019-11-01 17:18:28 -0700225 cflags: [
226 "-fno-stack-protector",
227
228 // Compile libc_init_static.cpp with -ffreestanding, because some of its code is called
229 // from the linker before ifunc resolvers have made string.h functions available.
230 "-ffreestanding",
231 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800232}
233
Stephen Cranef4b1cbd2017-05-09 14:27:43 -0700234cc_library_static {
235 name: "libc_init_dynamic",
236 defaults: ["libc_defaults"],
237 srcs: ["bionic/libc_init_dynamic.cpp"],
238 cflags: ["-fno-stack-protector"],
239}
Colin Crossa3f9fca2016-01-11 13:20:55 -0800240
Dan Willemsen208ae172015-09-16 16:33:27 -0700241// ========================================================
242// libc_tzcode.a - upstream 'tzcode' code
243// ========================================================
244
245cc_library_static {
246
Colin Cross50c21ab2015-10-31 23:03:05 -0700247 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700248 srcs: [
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800249 "tzcode/**/*.c",
Elliott Hughes0e8616a2017-04-11 14:44:51 -0700250 "tzcode/bionic.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700251 "upstream-openbsd/lib/libc/time/wcsftime.c", // tzcode doesn't include wcsftime, so we use the OpenBSD one.
252 ],
253
Colin Cross50c21ab2015-10-31 23:03:05 -0700254 cflags: [
Dan Willemsen268a6732015-10-15 14:49:45 -0700255 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700256 // Don't use ridiculous amounts of stack.
257 "-DALL_STATE",
258 // Include tzsetwall, timelocal, timegm, time2posix, and posix2time.
259 "-DSTD_INSPIRED",
Colin Crossa35d23d2015-11-19 13:32:49 -0800260 // Obviously, we want to be thread-safe.
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000261 "-DTHREAD_SAFE=1",
Dan Willemsen208ae172015-09-16 16:33:27 -0700262 // The name of the tm_gmtoff field in our struct tm.
263 "-DTM_GMTOFF=tm_gmtoff",
Almaz Mingaleeva52a0da2022-02-28 16:55:50 +0000264 // TZDEFAULT is not applicable to Android as there is no one file per time zone mapping
265 "-DTZDEFAULT=NULL",
Dan Willemsen208ae172015-09-16 16:33:27 -0700266 // Where we store our tzdata.
Colin Cross7b294952016-09-29 14:08:13 -0700267 "-DTZDIR=\"/system/usr/share/zoneinfo\"",
Elliott Hughes0a610d02016-07-29 14:04:17 -0700268 // Include `tzname`, `timezone`, and `daylight` globals.
269 "-DHAVE_POSIX_DECLS=0",
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000270 "-DUSG_COMPAT=2",
271 "-DHAVE_TZNAME=2",
272 // stdbool.h is available
273 "-DHAVE_STDBOOL_H",
Colin Crossa35d23d2015-11-19 13:32:49 -0800274 // Use the empty string (instead of " ") as the timezone abbreviation
275 // fallback.
Colin Cross7b294952016-09-29 14:08:13 -0700276 "-DWILDABBR=\"\"",
Dan Willemsen208ae172015-09-16 16:33:27 -0700277 "-Dlint",
278 ],
279
Dan Willemsen208ae172015-09-16 16:33:27 -0700280 local_include_dirs: ["tzcode/"],
281 name: "libc_tzcode",
Dan Willemsen208ae172015-09-16 16:33:27 -0700282}
283
284// ========================================================
285// libc_dns.a - modified NetBSD DNS code
286// ========================================================
287
288cc_library_static {
289
Colin Cross50c21ab2015-10-31 23:03:05 -0700290 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700291 srcs: [
Elliott Hughesd0bbfa82021-04-08 11:58:51 -0700292 "dns/**/*.c*",
Dan Willemsen208ae172015-09-16 16:33:27 -0700293
294 "upstream-netbsd/lib/libc/isc/ev_streams.c",
295 "upstream-netbsd/lib/libc/isc/ev_timers.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700296 ],
297
Colin Cross50c21ab2015-10-31 23:03:05 -0700298 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700299 "-DANDROID_CHANGES",
300 "-DINET6",
Dan Willemsen208ae172015-09-16 16:33:27 -0700301 "-Wno-unused-parameter",
302 "-include netbsd-compat.h",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700303 "-Wframe-larger-than=66000",
Elliott Hughese1dc4f62021-01-11 11:51:29 -0800304 "-include private/bsd_sys_param.h",
Dan Willemsen208ae172015-09-16 16:33:27 -0700305 ],
306
Dan Willemsen208ae172015-09-16 16:33:27 -0700307 local_include_dirs: [
308 "dns/include",
309 "private",
310 "upstream-netbsd/lib/libc/include",
311 "upstream-netbsd/android/include",
312 ],
313
314 name: "libc_dns",
Dan Willemsen208ae172015-09-16 16:33:27 -0700315}
316
317// ========================================================
318// libc_freebsd.a - upstream FreeBSD C library code
319// ========================================================
320//
321// These files are built with the freebsd-compat.h header file
322// automatically included.
323
324cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700325 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700326 srcs: [
327 "upstream-freebsd/lib/libc/gen/ldexp.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700328 "upstream-freebsd/lib/libc/stdlib/getopt_long.c",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700329 "upstream-freebsd/lib/libc/stdlib/hcreate.c",
330 "upstream-freebsd/lib/libc/stdlib/hcreate_r.c",
331 "upstream-freebsd/lib/libc/stdlib/hdestroy_r.c",
332 "upstream-freebsd/lib/libc/stdlib/hsearch_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700333 "upstream-freebsd/lib/libc/stdlib/qsort.c",
334 "upstream-freebsd/lib/libc/stdlib/quick_exit.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700335 "upstream-freebsd/lib/libc/string/wcpcpy.c",
336 "upstream-freebsd/lib/libc/string/wcpncpy.c",
337 "upstream-freebsd/lib/libc/string/wcscasecmp.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700338 "upstream-freebsd/lib/libc/string/wcscat.c",
339 "upstream-freebsd/lib/libc/string/wcschr.c",
340 "upstream-freebsd/lib/libc/string/wcscmp.c",
341 "upstream-freebsd/lib/libc/string/wcscpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700342 "upstream-freebsd/lib/libc/string/wcscspn.c",
343 "upstream-freebsd/lib/libc/string/wcsdup.c",
344 "upstream-freebsd/lib/libc/string/wcslcat.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700345 "upstream-freebsd/lib/libc/string/wcslen.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700346 "upstream-freebsd/lib/libc/string/wcsncasecmp.c",
347 "upstream-freebsd/lib/libc/string/wcsncat.c",
348 "upstream-freebsd/lib/libc/string/wcsncmp.c",
349 "upstream-freebsd/lib/libc/string/wcsncpy.c",
350 "upstream-freebsd/lib/libc/string/wcsnlen.c",
351 "upstream-freebsd/lib/libc/string/wcspbrk.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700352 "upstream-freebsd/lib/libc/string/wcsrchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700353 "upstream-freebsd/lib/libc/string/wcsspn.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700354 "upstream-freebsd/lib/libc/string/wcsstr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700355 "upstream-freebsd/lib/libc/string/wcstok.c",
356 "upstream-freebsd/lib/libc/string/wmemchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700357 "upstream-freebsd/lib/libc/string/wmemcmp.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700358 "upstream-freebsd/lib/libc/string/wmemcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700359 "upstream-freebsd/lib/libc/string/wmemmove.c",
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800360 "upstream-freebsd/lib/libc/string/wmemset.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700361 ],
362 arch: {
363 arm64: {
364 exclude_srcs: [
365 "upstream-freebsd/lib/libc/string/wmemmove.c",
366 ],
367 },
368 x86: {
369 exclude_srcs: [
370 "upstream-freebsd/lib/libc/string/wcschr.c",
371 "upstream-freebsd/lib/libc/string/wcscmp.c",
372 "upstream-freebsd/lib/libc/string/wcslen.c",
373 "upstream-freebsd/lib/libc/string/wcsrchr.c",
Haibo Huangb9244ff2018-08-11 10:12:13 -0700374 "upstream-freebsd/lib/libc/string/wmemcmp.c",
375 "upstream-freebsd/lib/libc/string/wcscat.c",
376 "upstream-freebsd/lib/libc/string/wcscpy.c",
377 "upstream-freebsd/lib/libc/string/wmemcmp.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700378 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700379 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700380 },
381
Colin Cross50c21ab2015-10-31 23:03:05 -0700382 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700383 "-Wno-sign-compare",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700384 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700385 "-include freebsd-compat.h",
386 ],
387
Dan Willemsen208ae172015-09-16 16:33:27 -0700388 local_include_dirs: [
389 "upstream-freebsd/android/include",
390 ],
391
392 name: "libc_freebsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700393}
394
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700395cc_library_static {
396 defaults: ["libc_defaults"],
397 srcs: [
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700398 "upstream-freebsd/lib/libc/gen/glob.c",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700399 ],
400
401 cflags: [
402 "-Wno-sign-compare",
403 "-include freebsd-compat.h",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700404 "-Wframe-larger-than=66000",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700405 ],
406
407 local_include_dirs: [
408 "upstream-freebsd/android/include",
409 ],
410
411 name: "libc_freebsd_large_stack",
412}
413
Dan Willemsen208ae172015-09-16 16:33:27 -0700414// ========================================================
415// libc_netbsd.a - upstream NetBSD C library code
416// ========================================================
417//
418// These files are built with the netbsd-compat.h header file
419// automatically included.
420
421cc_library_static {
422
Colin Cross50c21ab2015-10-31 23:03:05 -0700423 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700424 srcs: [
425 "upstream-netbsd/common/lib/libc/stdlib/random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700426 "upstream-netbsd/lib/libc/gen/nice.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700427 "upstream-netbsd/lib/libc/gen/psignal.c",
428 "upstream-netbsd/lib/libc/gen/utime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700429 "upstream-netbsd/lib/libc/inet/nsap_addr.c",
430 "upstream-netbsd/lib/libc/regex/regcomp.c",
431 "upstream-netbsd/lib/libc/regex/regerror.c",
432 "upstream-netbsd/lib/libc/regex/regexec.c",
433 "upstream-netbsd/lib/libc/regex/regfree.c",
434 "upstream-netbsd/lib/libc/stdlib/bsearch.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700435 "upstream-netbsd/lib/libc/stdlib/drand48.c",
436 "upstream-netbsd/lib/libc/stdlib/erand48.c",
437 "upstream-netbsd/lib/libc/stdlib/jrand48.c",
438 "upstream-netbsd/lib/libc/stdlib/lcong48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700439 "upstream-netbsd/lib/libc/stdlib/lrand48.c",
440 "upstream-netbsd/lib/libc/stdlib/mrand48.c",
441 "upstream-netbsd/lib/libc/stdlib/nrand48.c",
442 "upstream-netbsd/lib/libc/stdlib/_rand48.c",
443 "upstream-netbsd/lib/libc/stdlib/rand_r.c",
444 "upstream-netbsd/lib/libc/stdlib/reallocarr.c",
445 "upstream-netbsd/lib/libc/stdlib/seed48.c",
446 "upstream-netbsd/lib/libc/stdlib/srand48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700447 ],
448 multilib: {
449 lib32: {
450 // LP32 cruft
451 srcs: ["upstream-netbsd/common/lib/libc/hash/sha1/sha1.c"],
452 },
453 },
Colin Cross50c21ab2015-10-31 23:03:05 -0700454 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700455 "-Wno-sign-compare",
Dan Willemsen879cec22016-02-29 10:37:56 -0800456 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700457 "-DPOSIX_MISTAKE",
458 "-include netbsd-compat.h",
459 ],
460
Dan Willemsen208ae172015-09-16 16:33:27 -0700461 local_include_dirs: [
462 "upstream-netbsd/android/include",
463 "upstream-netbsd/lib/libc/include",
464 ],
465
466 name: "libc_netbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700467}
468
469// ========================================================
470// libc_openbsd_ndk.a - upstream OpenBSD C library code
471// that can be safely included in the libc_ndk.a (doesn't
472// contain any troublesome global data or constructors).
473// ========================================================
474//
475// These files are built with the openbsd-compat.h header file
476// automatically included.
477
478cc_library_static {
479 name: "libc_openbsd_ndk",
Colin Cross50c21ab2015-10-31 23:03:05 -0700480 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700481 srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700482 "upstream-openbsd/lib/libc/gen/alarm.c",
483 "upstream-openbsd/lib/libc/gen/ctype_.c",
484 "upstream-openbsd/lib/libc/gen/daemon.c",
485 "upstream-openbsd/lib/libc/gen/err.c",
486 "upstream-openbsd/lib/libc/gen/errx.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700487 "upstream-openbsd/lib/libc/gen/fnmatch.c",
488 "upstream-openbsd/lib/libc/gen/ftok.c",
489 "upstream-openbsd/lib/libc/gen/getprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700490 "upstream-openbsd/lib/libc/gen/setprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700491 "upstream-openbsd/lib/libc/gen/verr.c",
492 "upstream-openbsd/lib/libc/gen/verrx.c",
493 "upstream-openbsd/lib/libc/gen/vwarn.c",
494 "upstream-openbsd/lib/libc/gen/vwarnx.c",
495 "upstream-openbsd/lib/libc/gen/warn.c",
496 "upstream-openbsd/lib/libc/gen/warnx.c",
497 "upstream-openbsd/lib/libc/locale/btowc.c",
498 "upstream-openbsd/lib/libc/locale/mbrlen.c",
499 "upstream-openbsd/lib/libc/locale/mbstowcs.c",
500 "upstream-openbsd/lib/libc/locale/mbtowc.c",
501 "upstream-openbsd/lib/libc/locale/wcscoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700502 "upstream-openbsd/lib/libc/locale/wcstombs.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700503 "upstream-openbsd/lib/libc/locale/wcsxfrm.c",
504 "upstream-openbsd/lib/libc/locale/wctob.c",
505 "upstream-openbsd/lib/libc/locale/wctomb.c",
Elliott Hughes26fda772016-04-06 11:56:41 -0700506 "upstream-openbsd/lib/libc/net/base64.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700507 "upstream-openbsd/lib/libc/net/htonl.c",
508 "upstream-openbsd/lib/libc/net/htons.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700509 "upstream-openbsd/lib/libc/net/inet_lnaof.c",
510 "upstream-openbsd/lib/libc/net/inet_makeaddr.c",
511 "upstream-openbsd/lib/libc/net/inet_netof.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700512 "upstream-openbsd/lib/libc/net/inet_ntoa.c",
513 "upstream-openbsd/lib/libc/net/inet_ntop.c",
514 "upstream-openbsd/lib/libc/net/inet_pton.c",
515 "upstream-openbsd/lib/libc/net/ntohl.c",
516 "upstream-openbsd/lib/libc/net/ntohs.c",
Colin Cross8ce38af2016-01-19 12:50:20 -0800517 "upstream-openbsd/lib/libc/net/res_random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700518 "upstream-openbsd/lib/libc/stdio/fgetln.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700519 "upstream-openbsd/lib/libc/stdio/fgetwc.c",
520 "upstream-openbsd/lib/libc/stdio/fgetws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700521 "upstream-openbsd/lib/libc/stdio/flags.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700522 "upstream-openbsd/lib/libc/stdio/fpurge.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700523 "upstream-openbsd/lib/libc/stdio/fputwc.c",
524 "upstream-openbsd/lib/libc/stdio/fputws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700525 "upstream-openbsd/lib/libc/stdio/fvwrite.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700526 "upstream-openbsd/lib/libc/stdio/fwide.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700527 "upstream-openbsd/lib/libc/stdio/getdelim.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700528 "upstream-openbsd/lib/libc/stdio/gets.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700529 "upstream-openbsd/lib/libc/stdio/makebuf.c",
530 "upstream-openbsd/lib/libc/stdio/mktemp.c",
531 "upstream-openbsd/lib/libc/stdio/open_memstream.c",
532 "upstream-openbsd/lib/libc/stdio/open_wmemstream.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700533 "upstream-openbsd/lib/libc/stdio/rget.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700534 "upstream-openbsd/lib/libc/stdio/setvbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700535 "upstream-openbsd/lib/libc/stdio/ungetc.c",
536 "upstream-openbsd/lib/libc/stdio/ungetwc.c",
537 "upstream-openbsd/lib/libc/stdio/vasprintf.c",
538 "upstream-openbsd/lib/libc/stdio/vdprintf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700539 "upstream-openbsd/lib/libc/stdio/vsscanf.c",
540 "upstream-openbsd/lib/libc/stdio/vswprintf.c",
541 "upstream-openbsd/lib/libc/stdio/vswscanf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700542 "upstream-openbsd/lib/libc/stdio/wbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700543 "upstream-openbsd/lib/libc/stdio/wsetup.c",
544 "upstream-openbsd/lib/libc/stdlib/abs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800545 "upstream-openbsd/lib/libc/stdlib/div.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700546 "upstream-openbsd/lib/libc/stdlib/getenv.c",
Colin Crossb8396102016-04-07 13:24:50 -0700547 "upstream-openbsd/lib/libc/stdlib/getsubopt.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700548 "upstream-openbsd/lib/libc/stdlib/insque.c",
549 "upstream-openbsd/lib/libc/stdlib/imaxabs.c",
550 "upstream-openbsd/lib/libc/stdlib/imaxdiv.c",
551 "upstream-openbsd/lib/libc/stdlib/labs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800552 "upstream-openbsd/lib/libc/stdlib/ldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700553 "upstream-openbsd/lib/libc/stdlib/llabs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800554 "upstream-openbsd/lib/libc/stdlib/lldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700555 "upstream-openbsd/lib/libc/stdlib/lsearch.c",
Elliott Hughes26b06072020-07-31 11:00:10 -0700556 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700557 "upstream-openbsd/lib/libc/stdlib/remque.c",
558 "upstream-openbsd/lib/libc/stdlib/setenv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700559 "upstream-openbsd/lib/libc/stdlib/tfind.c",
560 "upstream-openbsd/lib/libc/stdlib/tsearch.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800561 "upstream-openbsd/lib/libc/string/memccpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700562 "upstream-openbsd/lib/libc/string/strcasecmp.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800563 "upstream-openbsd/lib/libc/string/strcasestr.c",
564 "upstream-openbsd/lib/libc/string/strcoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700565 "upstream-openbsd/lib/libc/string/strcspn.c",
566 "upstream-openbsd/lib/libc/string/strdup.c",
567 "upstream-openbsd/lib/libc/string/strndup.c",
568 "upstream-openbsd/lib/libc/string/strpbrk.c",
569 "upstream-openbsd/lib/libc/string/strsep.c",
570 "upstream-openbsd/lib/libc/string/strspn.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700571 "upstream-openbsd/lib/libc/string/strtok.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800572 "upstream-openbsd/lib/libc/string/strxfrm.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700573 "upstream-openbsd/lib/libc/string/wcslcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700574 "upstream-openbsd/lib/libc/string/wcswidth.c",
Colin Cross69bcb8b2021-09-08 13:24:16 -0700575
576 // This file is originally from OpenBSD, and benefits from
577 // being compiled with openbsd-compat.h.
578 "bionic/fts.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700579 ],
580
Colin Cross50c21ab2015-10-31 23:03:05 -0700581 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700582 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700583 "-Wno-unused-parameter",
584 "-include openbsd-compat.h",
585 ],
586
Dan Willemsen208ae172015-09-16 16:33:27 -0700587 local_include_dirs: [
588 "private",
589 "stdio",
590 "upstream-openbsd/android/include",
591 "upstream-openbsd/lib/libc/include",
592 "upstream-openbsd/lib/libc/gdtoa/",
593 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700594}
595
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700596cc_library_static {
597 name: "libc_openbsd_large_stack",
598 defaults: ["libc_defaults"],
599 srcs: [
Elliott Hughes2f9c8ce2017-11-01 13:54:47 -0700600 "stdio/vfprintf.cpp",
601 "stdio/vfwprintf.cpp",
Elliott Hughes5633caa2020-08-06 14:32:43 -0700602 "upstream-openbsd/lib/libc/string/memmem.c",
Elliott Hughesc6b38ae2019-11-22 11:15:42 -0800603 "upstream-openbsd/lib/libc/string/strstr.c",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700604 ],
605 cflags: [
606 "-include openbsd-compat.h",
607 "-Wno-sign-compare",
608 "-Wframe-larger-than=5000",
609 ],
610
611 local_include_dirs: [
Elliott Hughese1dc4f62021-01-11 11:51:29 -0800612 "private",
Elliott Hughes3a589c22017-10-30 11:43:58 -0700613 "upstream-openbsd/android/include/",
614 "upstream-openbsd/lib/libc/include/",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700615 "upstream-openbsd/lib/libc/gdtoa/",
Elliott Hughes3a589c22017-10-30 11:43:58 -0700616 "upstream-openbsd/lib/libc/stdio/",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700617 ],
618}
619
Dan Willemsen208ae172015-09-16 16:33:27 -0700620// ========================================================
621// libc_openbsd.a - upstream OpenBSD C library code
622// ========================================================
623//
624// These files are built with the openbsd-compat.h header file
625// automatically included.
626cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700627 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700628 srcs: [
Elliott Hughes211c4d32018-02-02 15:10:32 -0800629 // These two depend on getentropy, which isn't in libc_ndk.a.
Dan Willemsen208ae172015-09-16 16:33:27 -0700630 "upstream-openbsd/lib/libc/crypt/arc4random.c",
631 "upstream-openbsd/lib/libc/crypt/arc4random_uniform.c",
632
633 // May be overriden by per-arch optimized versions
634 "upstream-openbsd/lib/libc/string/memchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700635 "upstream-openbsd/lib/libc/string/memrchr.c",
636 "upstream-openbsd/lib/libc/string/stpcpy.c",
637 "upstream-openbsd/lib/libc/string/stpncpy.c",
638 "upstream-openbsd/lib/libc/string/strcat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700639 "upstream-openbsd/lib/libc/string/strcpy.c",
640 "upstream-openbsd/lib/libc/string/strlcat.c",
641 "upstream-openbsd/lib/libc/string/strlcpy.c",
642 "upstream-openbsd/lib/libc/string/strncat.c",
643 "upstream-openbsd/lib/libc/string/strncmp.c",
644 "upstream-openbsd/lib/libc/string/strncpy.c",
645 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700646
647 arch: {
648 arm: {
649 exclude_srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700650 "upstream-openbsd/lib/libc/string/strcpy.c",
Haibo Huangea9957a2018-11-19 11:00:32 -0800651 "upstream-openbsd/lib/libc/string/stpcpy.c",
652 "upstream-openbsd/lib/libc/string/strcat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700653 ],
654 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700655 arm64: {
656 exclude_srcs: [
657 "upstream-openbsd/lib/libc/string/memchr.c",
Peter Collingbourne2361d4e2020-06-03 16:55:37 -0700658 "upstream-openbsd/lib/libc/string/memrchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700659 "upstream-openbsd/lib/libc/string/stpcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700660 "upstream-openbsd/lib/libc/string/strcpy.c",
661 "upstream-openbsd/lib/libc/string/strncmp.c",
662 ],
663 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700664 x86: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800665 exclude_srcs: [
666 "upstream-openbsd/lib/libc/string/memchr.c",
Colin Cross6ab8f892015-11-23 14:12:15 -0800667 "upstream-openbsd/lib/libc/string/memrchr.c",
668 "upstream-openbsd/lib/libc/string/stpcpy.c",
669 "upstream-openbsd/lib/libc/string/stpncpy.c",
670 "upstream-openbsd/lib/libc/string/strcat.c",
671 "upstream-openbsd/lib/libc/string/strcpy.c",
672 "upstream-openbsd/lib/libc/string/strncmp.c",
673 "upstream-openbsd/lib/libc/string/strncpy.c",
Haibo Huangb9244ff2018-08-11 10:12:13 -0700674 "upstream-openbsd/lib/libc/string/strlcat.c",
675 "upstream-openbsd/lib/libc/string/strlcpy.c",
676 "upstream-openbsd/lib/libc/string/strncat.c",
Colin Cross6ab8f892015-11-23 14:12:15 -0800677 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700678 },
679
680 x86_64: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800681 exclude_srcs: [
Colin Cross6ab8f892015-11-23 14:12:15 -0800682 "upstream-openbsd/lib/libc/string/stpcpy.c",
683 "upstream-openbsd/lib/libc/string/stpncpy.c",
684 "upstream-openbsd/lib/libc/string/strcat.c",
685 "upstream-openbsd/lib/libc/string/strcpy.c",
Colin Cross6ab8f892015-11-23 14:12:15 -0800686 "upstream-openbsd/lib/libc/string/strncat.c",
687 "upstream-openbsd/lib/libc/string/strncmp.c",
688 "upstream-openbsd/lib/libc/string/strncpy.c",
689 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700690 },
691 },
692
Colin Cross50c21ab2015-10-31 23:03:05 -0700693 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700694 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700695 "-Wno-unused-parameter",
696 "-include openbsd-compat.h",
697 ],
698
Dan Willemsen208ae172015-09-16 16:33:27 -0700699 local_include_dirs: [
700 "private",
Dan Willemsen208ae172015-09-16 16:33:27 -0700701 "upstream-openbsd/android/include",
Dan Willemsen208ae172015-09-16 16:33:27 -0700702 ],
703
704 name: "libc_openbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700705}
706
707// ========================================================
708// libc_gdtoa.a - upstream OpenBSD C library gdtoa code
709// ========================================================
710//
711// These files are built with the openbsd-compat.h header file
712// automatically included.
713
714cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700715 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700716 srcs: [
717 "upstream-openbsd/android/gdtoa_support.cpp",
718 "upstream-openbsd/lib/libc/gdtoa/dmisc.c",
719 "upstream-openbsd/lib/libc/gdtoa/dtoa.c",
720 "upstream-openbsd/lib/libc/gdtoa/gdtoa.c",
721 "upstream-openbsd/lib/libc/gdtoa/gethex.c",
722 "upstream-openbsd/lib/libc/gdtoa/gmisc.c",
723 "upstream-openbsd/lib/libc/gdtoa/hd_init.c",
724 "upstream-openbsd/lib/libc/gdtoa/hdtoa.c",
725 "upstream-openbsd/lib/libc/gdtoa/hexnan.c",
726 "upstream-openbsd/lib/libc/gdtoa/ldtoa.c",
727 "upstream-openbsd/lib/libc/gdtoa/misc.c",
728 "upstream-openbsd/lib/libc/gdtoa/smisc.c",
729 "upstream-openbsd/lib/libc/gdtoa/strtod.c",
730 "upstream-openbsd/lib/libc/gdtoa/strtodg.c",
731 "upstream-openbsd/lib/libc/gdtoa/strtof.c",
732 "upstream-openbsd/lib/libc/gdtoa/strtord.c",
733 "upstream-openbsd/lib/libc/gdtoa/sum.c",
734 "upstream-openbsd/lib/libc/gdtoa/ulp.c",
735 ],
736 multilib: {
737 lib64: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800738 srcs: ["upstream-openbsd/lib/libc/gdtoa/strtorQ.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700739 },
740 },
741
Colin Cross50c21ab2015-10-31 23:03:05 -0700742 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700743 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700744 "-include openbsd-compat.h",
745 ],
746
Dan Willemsen208ae172015-09-16 16:33:27 -0700747 local_include_dirs: [
748 "private",
749 "upstream-openbsd/android/include",
750 "upstream-openbsd/lib/libc/include",
751 ],
752
753 name: "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -0700754}
755
756// ========================================================
George Burgess IV6cb06872017-07-21 13:28:42 -0700757// libc_fortify.a - container for our FORITFY
758// implementation details
759// ========================================================
760cc_library_static {
761 defaults: ["libc_defaults"],
George Burgess IVd34b0a92017-07-25 11:43:39 -0700762 srcs: ["bionic/fortify.cpp"],
George Burgess IV6cb06872017-07-21 13:28:42 -0700763
764 name: "libc_fortify",
765
766 // Disable FORTIFY for the compilation of these, so we don't end up having
767 // FORTIFY silently call itself.
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800768 cflags: [
769 "-U_FORTIFY_SOURCE",
770 "-D__BIONIC_DECLARE_FORTIFY_HELPERS",
771 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700772
773 arch: {
774 arm: {
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800775 cflags: [
776 "-DNO___MEMCPY_CHK",
777 "-DRENAME___STRCAT_CHK",
778 "-DRENAME___STRCPY_CHK",
779 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700780 srcs: [
781 "arch-arm/generic/bionic/__memcpy_chk.S",
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800782
783 "arch-arm/cortex-a15/bionic/__strcat_chk.S",
784 "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
785
786 "arch-arm/cortex-a7/bionic/__strcat_chk.S",
787 "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
788
789 "arch-arm/cortex-a9/bionic/__strcat_chk.S",
790 "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
791
792 "arch-arm/krait/bionic/__strcat_chk.S",
793 "arch-arm/krait/bionic/__strcpy_chk.S",
794
795 "arch-arm/cortex-a53/bionic/__strcat_chk.S",
796 "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
797
Haibo Huang01bfd892018-12-03 15:05:16 -0800798 "arch-arm/cortex-a55/bionic/__strcat_chk.S",
799 "arch-arm/cortex-a55/bionic/__strcpy_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700800 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700801 },
802 arm64: {
George Burgess IVd34b0a92017-07-25 11:43:39 -0700803 cflags: ["-DNO___MEMCPY_CHK"],
George Burgess IV6cb06872017-07-21 13:28:42 -0700804 srcs: [
805 "arch-arm64/generic/bionic/__memcpy_chk.S",
806 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700807 },
808 },
809}
810
811// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -0700812// libc_bionic.a - home-grown C library code
813// ========================================================
814
815cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700816 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700817 srcs: [
Elliott Hughes211c4d32018-02-02 15:10:32 -0800818 // These require getauxval, which isn't available on older platforms.
Dan Willemsen208ae172015-09-16 16:33:27 -0700819 "bionic/sysconf.cpp",
820 "bionic/vdso.cpp",
Dan Willemsen35e91a12015-09-17 15:28:45 -0700821 "bionic/setjmp_cookie.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700822
Josh Gao10ec9282017-04-03 15:13:29 -0700823 // The following must not be statically linked into libc_ndk.a, because
824 // debuggerd will look for the abort message in libc.so's copy.
825 "bionic/android_set_abort_message.cpp",
826
Dan Willemsen208ae172015-09-16 16:33:27 -0700827 "bionic/strchr.cpp",
Peter Collingbourne337a5b32020-02-21 12:11:02 -0800828 "bionic/strchrnul.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700829 "bionic/strnlen.c",
830 "bionic/strrchr.cpp",
831 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700832
833 arch: {
Dan Willemsen208ae172015-09-16 16:33:27 -0700834 arm: {
Elliott Hughes1b61d782019-06-04 10:38:34 -0700835 asflags: libc_common_flags + ["-mno-restrict-it"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700836 srcs: [
Dan Willemsen3e621712016-02-03 21:48:08 -0800837 "arch-arm/generic/bionic/memcmp.S",
Elliott Hughesda46cae2018-05-24 14:40:32 -0700838 "arch-arm/generic/bionic/memmove.S",
Dan Willemsen3e621712016-02-03 21:48:08 -0800839 "arch-arm/generic/bionic/memset.S",
Haibo Huangea9957a2018-11-19 11:00:32 -0800840 "arch-arm/generic/bionic/stpcpy.c",
841 "arch-arm/generic/bionic/strcat.c",
Dan Willemsen3e621712016-02-03 21:48:08 -0800842 "arch-arm/generic/bionic/strcmp.S",
843 "arch-arm/generic/bionic/strcpy.S",
844 "arch-arm/generic/bionic/strlen.c",
845
Ryan Prichard45024fe2018-12-30 21:10:26 -0800846 "arch-arm/bionic/__aeabi_read_tp.S",
Dan Willemsen208ae172015-09-16 16:33:27 -0700847 "arch-arm/bionic/__bionic_clone.S",
Yi Kongb410d0e2019-04-22 16:00:46 -0700848 "arch-arm/bionic/__restore.S",
Dan Willemsen208ae172015-09-16 16:33:27 -0700849 "arch-arm/bionic/_exit_with_stack_teardown.S",
Yi Kongb410d0e2019-04-22 16:00:46 -0700850 "arch-arm/bionic/atomics_arm.c",
851 "arch-arm/bionic/bpabi.c",
Yi Kong165b1cf2019-02-13 14:10:10 -0800852 "arch-arm/bionic/libcrt_compat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700853 "arch-arm/bionic/popcount_tab.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700854 "arch-arm/bionic/setjmp.S",
855 "arch-arm/bionic/syscall.S",
856 "arch-arm/bionic/vfork.S",
Haibo Huangea9957a2018-11-19 11:00:32 -0800857
858 "arch-arm/cortex-a15/bionic/memcpy.S",
859 "arch-arm/cortex-a15/bionic/memmove.S",
860 "arch-arm/cortex-a15/bionic/memset.S",
861 "arch-arm/cortex-a15/bionic/stpcpy.S",
862 "arch-arm/cortex-a15/bionic/strcat.S",
863 "arch-arm/cortex-a15/bionic/strcmp.S",
864 "arch-arm/cortex-a15/bionic/strcpy.S",
865 "arch-arm/cortex-a15/bionic/strlen.S",
866
867 "arch-arm/cortex-a7/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -0800868 "arch-arm/cortex-a7/bionic/memset.S",
869
870 "arch-arm/cortex-a9/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -0800871 "arch-arm/cortex-a9/bionic/memset.S",
872 "arch-arm/cortex-a9/bionic/stpcpy.S",
873 "arch-arm/cortex-a9/bionic/strcat.S",
Haibo Huangea9957a2018-11-19 11:00:32 -0800874 "arch-arm/cortex-a9/bionic/strcpy.S",
875 "arch-arm/cortex-a9/bionic/strlen.S",
876
877 "arch-arm/krait/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -0800878 "arch-arm/krait/bionic/memset.S",
Haibo Huangea9957a2018-11-19 11:00:32 -0800879
880 "arch-arm/cortex-a53/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -0800881
Haibo Huang01bfd892018-12-03 15:05:16 -0800882 "arch-arm/cortex-a55/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -0800883
884 "arch-arm/kryo/bionic/memcpy.S",
Dan Willemsen208ae172015-09-16 16:33:27 -0700885 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700886 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700887 arm64: {
888 srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700889 "arch-arm64/generic/bionic/memcpy.S",
890 "arch-arm64/generic/bionic/memmove.S",
891 "arch-arm64/generic/bionic/memset.S",
Dan Willemsen208ae172015-09-16 16:33:27 -0700892 "arch-arm64/generic/bionic/wmemmove.S",
Dan Willemsen3e621712016-02-03 21:48:08 -0800893
894 "arch-arm64/bionic/__bionic_clone.S",
895 "arch-arm64/bionic/_exit_with_stack_teardown.S",
896 "arch-arm64/bionic/setjmp.S",
897 "arch-arm64/bionic/syscall.S",
898 "arch-arm64/bionic/vfork.S",
Dan Willemsen208ae172015-09-16 16:33:27 -0700899 ],
900 exclude_srcs: [
901 "bionic/__memcpy_chk.cpp",
902 "bionic/strchr.cpp",
Peter Collingbourne337a5b32020-02-21 12:11:02 -0800903 "bionic/strchrnul.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700904 "bionic/strnlen.c",
Peter Collingbourne337a5b32020-02-21 12:11:02 -0800905 "bionic/strrchr.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700906 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700907 },
908
Dan Willemsen208ae172015-09-16 16:33:27 -0700909 x86: {
910 srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700911 "arch-x86/generic/string/memcmp.S",
912 "arch-x86/generic/string/strcmp.S",
913 "arch-x86/generic/string/strncmp.S",
914 "arch-x86/generic/string/strcat.S",
Haibo Huangb9244ff2018-08-11 10:12:13 -0700915
916 "arch-x86/generic/string/strlcat.c",
917 "arch-x86/generic/string/strlcpy.c",
918 "arch-x86/generic/string/strncat.c",
919 "arch-x86/generic/string/wcscat.c",
920 "arch-x86/generic/string/wcscpy.c",
921 "arch-x86/generic/string/wmemcmp.c",
922
Elliott Hughesed777142022-07-25 16:25:11 +0000923 "arch-x86/string/sse2-memchr-atom.S",
924 "arch-x86/string/sse2-memmove-slm.S",
925 "arch-x86/string/sse2-memrchr-atom.S",
926 "arch-x86/string/sse2-memset-atom.S",
927 "arch-x86/string/sse2-memset-slm.S",
928 "arch-x86/string/sse2-stpcpy-slm.S",
929 "arch-x86/string/sse2-stpncpy-slm.S",
930 "arch-x86/string/sse2-strchr-atom.S",
931 "arch-x86/string/sse2-strcpy-slm.S",
932 "arch-x86/string/sse2-strlen-slm.S",
933 "arch-x86/string/sse2-strncpy-slm.S",
934 "arch-x86/string/sse2-strnlen-atom.S",
935 "arch-x86/string/sse2-strrchr-atom.S",
936 "arch-x86/string/sse2-wcschr-atom.S",
937 "arch-x86/string/sse2-wcsrchr-atom.S",
938 "arch-x86/string/sse2-wcslen-atom.S",
939 "arch-x86/string/sse2-wcscmp-atom.S",
940 "arch-x86/string/sse2-strlen-atom.S",
941
942 "arch-x86/string/ssse3-memcmp-atom.S",
943 "arch-x86/string/ssse3-memmove-atom.S",
944 "arch-x86/string/ssse3-strcat-atom.S",
945 "arch-x86/string/ssse3-strcmp-atom.S",
946 "arch-x86/string/ssse3-strcpy-atom.S",
947 "arch-x86/string/ssse3-strlcat-atom.S",
948 "arch-x86/string/ssse3-strlcpy-atom.S",
949 "arch-x86/string/ssse3-strncat-atom.S",
950 "arch-x86/string/ssse3-strncmp-atom.S",
951 "arch-x86/string/ssse3-strncpy-atom.S",
952 "arch-x86/string/ssse3-wcscat-atom.S",
953 "arch-x86/string/ssse3-wcscpy-atom.S",
954 "arch-x86/string/ssse3-wmemcmp-atom.S",
955
956 "arch-x86/string/sse4-memcmp-slm.S",
957 "arch-x86/string/sse4-wmemcmp-slm.S",
Dan Willemsen3e621712016-02-03 21:48:08 -0800958
959 "arch-x86/bionic/__bionic_clone.S",
960 "arch-x86/bionic/_exit_with_stack_teardown.S",
Yi Kong165b1cf2019-02-13 14:10:10 -0800961 "arch-x86/bionic/libcrt_compat.c",
Dan Willemsen3e621712016-02-03 21:48:08 -0800962 "arch-x86/bionic/__restore.S",
963 "arch-x86/bionic/setjmp.S",
964 "arch-x86/bionic/syscall.S",
965 "arch-x86/bionic/vfork.S",
Ryan Pricharda992a062020-04-18 02:59:24 -0700966 "arch-x86/bionic/__x86.get_pc_thunk.S",
Dan Willemsen208ae172015-09-16 16:33:27 -0700967 ],
Dan Willemsen268a6732015-10-15 14:49:45 -0700968
969 exclude_srcs: [
970 "bionic/strchr.cpp",
971 "bionic/strnlen.c",
972 "bionic/strrchr.cpp",
973 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700974 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700975 x86_64: {
Dan Willemsen208ae172015-09-16 16:33:27 -0700976 srcs: [
ahs919fb7f2022-06-10 07:11:14 +0530977 "arch-x86_64/string/avx2-memset-kbl.S",
Dan Willemsen208ae172015-09-16 16:33:27 -0700978 "arch-x86_64/string/sse2-memmove-slm.S",
979 "arch-x86_64/string/sse2-memset-slm.S",
980 "arch-x86_64/string/sse2-stpcpy-slm.S",
981 "arch-x86_64/string/sse2-stpncpy-slm.S",
982 "arch-x86_64/string/sse2-strcat-slm.S",
983 "arch-x86_64/string/sse2-strcpy-slm.S",
Dan Willemsen208ae172015-09-16 16:33:27 -0700984 "arch-x86_64/string/sse2-strlen-slm.S",
985 "arch-x86_64/string/sse2-strncat-slm.S",
986 "arch-x86_64/string/sse2-strncpy-slm.S",
987 "arch-x86_64/string/sse4-memcmp-slm.S",
988 "arch-x86_64/string/ssse3-strcmp-slm.S",
989 "arch-x86_64/string/ssse3-strncmp-slm.S",
Dan Willemsen3e621712016-02-03 21:48:08 -0800990
991 "arch-x86_64/bionic/__bionic_clone.S",
992 "arch-x86_64/bionic/_exit_with_stack_teardown.S",
993 "arch-x86_64/bionic/__restore_rt.S",
994 "arch-x86_64/bionic/setjmp.S",
995 "arch-x86_64/bionic/syscall.S",
996 "arch-x86_64/bionic/vfork.S",
Dan Willemsen208ae172015-09-16 16:33:27 -0700997 ],
998 },
Dan Willemsen268a6732015-10-15 14:49:45 -0700999 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001000
Colin Cross50c21ab2015-10-31 23:03:05 -07001001 cppflags: ["-Wold-style-cast"],
Dan Willemsen268a6732015-10-15 14:49:45 -07001002 include_dirs: ["bionic/libstdc++/include"],
1003 name: "libc_bionic",
Dan Willemsen268a6732015-10-15 14:49:45 -07001004}
1005
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001006genrule {
1007 name: "generated_android_ids",
Colin Cross35bbed82017-01-17 18:16:07 -08001008 out: ["generated_android_ids.h"],
1009 srcs: [":android_filesystem_config_header"],
1010 tool_files: ["fs_config_generator.py"],
1011 cmd: "$(location fs_config_generator.py) aidarray $(in) > $(out)",
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001012}
1013
Dan Willemsen268a6732015-10-15 14:49:45 -07001014// ========================================================
1015// libc_bionic_ndk.a- The portions of libc_bionic that can
1016// be safely used in libc_ndk.a (no troublesome global data
1017// or constructors).
1018// ========================================================
1019cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001020 defaults: ["libc_defaults"],
Dan Willemsen268a6732015-10-15 14:49:45 -07001021 srcs: [
Dan Alberte2fd0102017-07-11 14:27:07 -07001022 "bionic/NetdClientDispatch.cpp",
Sandeep Patil9b1ca562017-08-21 12:17:19 -07001023 "bionic/__bionic_get_shell_path.cpp",
Dan Alberte2fd0102017-07-11 14:27:07 -07001024 "bionic/__cmsg_nxthdr.cpp",
1025 "bionic/__errno.cpp",
1026 "bionic/__gnu_basename.cpp",
1027 "bionic/__libc_current_sigrtmax.cpp",
1028 "bionic/__libc_current_sigrtmin.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001029 "bionic/abort.cpp",
1030 "bionic/accept.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001031 "bionic/access.cpp",
1032 "bionic/arpa_inet.cpp",
1033 "bionic/assert.cpp",
1034 "bionic/atof.cpp",
Ryan Prichard083d8502019-01-24 13:47:13 -08001035 "bionic/bionic_allocator.cpp",
Josh Gaoa170d9b2016-11-10 16:08:29 -08001036 "bionic/bionic_arc4random.cpp",
Tom Cherryac49ced2017-08-17 13:18:52 -07001037 "bionic/bionic_futex.cpp",
Colin Cross8ce38af2016-01-19 12:50:20 -08001038 "bionic/bionic_netlink.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001039 "bionic/bionic_time_conversions.cpp",
1040 "bionic/brk.cpp",
1041 "bionic/c16rtomb.cpp",
1042 "bionic/c32rtomb.cpp",
1043 "bionic/chmod.cpp",
1044 "bionic/chown.cpp",
1045 "bionic/clearenv.cpp",
1046 "bionic/clock.cpp",
1047 "bionic/clock_getcpuclockid.cpp",
1048 "bionic/clock_nanosleep.cpp",
1049 "bionic/clone.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001050 "bionic/ctype.cpp",
1051 "bionic/dirent.cpp",
Josh Gao97271922019-11-06 13:15:00 -08001052 "bionic/dup.cpp",
Victor Khimenko0a0743f2017-07-10 21:15:37 +02001053 "bionic/environ.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001054 "bionic/error.cpp",
Josh Gao7de41242020-04-29 17:08:46 -07001055 "bionic/eventfd.cpp",
Elliott Hughese19c6722016-08-26 16:15:57 +00001056 "bionic/exec.cpp",
Christopher Ferris11526e22021-10-14 22:44:47 +00001057 "bionic/execinfo.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001058 "bionic/faccessat.cpp",
1059 "bionic/fchmod.cpp",
1060 "bionic/fchmodat.cpp",
Josh Gao97271922019-11-06 13:15:00 -08001061 "bionic/fcntl.cpp",
Josh Gaof6e5b582018-06-01 15:30:54 -07001062 "bionic/fdsan.cpp",
Josh Gao97271922019-11-06 13:15:00 -08001063 "bionic/fdtrack.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001064 "bionic/ffs.cpp",
1065 "bionic/fgetxattr.cpp",
1066 "bionic/flistxattr.cpp",
1067 "bionic/flockfile.cpp",
1068 "bionic/fpclassify.cpp",
1069 "bionic/fsetxattr.cpp",
1070 "bionic/ftruncate.cpp",
Elliott Hughes13d79ab2016-04-15 17:40:33 -07001071 "bionic/ftw.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001072 "bionic/futimens.cpp",
1073 "bionic/getcwd.cpp",
Dan Willemsen23aae1c2016-03-29 15:21:38 -07001074 "bionic/getdomainname.cpp",
Elliott Hughes211c4d32018-02-02 15:10:32 -08001075 "bionic/getentropy.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001076 "bionic/gethostname.cpp",
Elliott Hughes2d0b28b2018-10-23 11:23:00 -07001077 "bionic/getloadavg.cpp",
Elliott Hughese4510a22016-04-06 08:34:58 -07001078 "bionic/getpagesize.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001079 "bionic/getpgrp.cpp",
1080 "bionic/getpid.cpp",
Elliott Hughes8f0e42f2016-11-29 15:10:29 -08001081 "bionic/getpriority.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001082 "bionic/gettid.cpp",
Elliott Hughesce934e32018-09-06 13:26:08 -07001083 "bionic/get_device_api_level.cpp",
Mark Salyzynb38347a2016-04-05 09:09:46 -07001084 "bionic/grp_pwd.cpp",
Tom Cherry6034ef82018-02-02 16:10:07 -08001085 "bionic/grp_pwd_file.cpp",
Mitch Phillips9cad8422021-01-20 16:03:27 -08001086 "bionic/heap_zero_init.cpp",
Elliott Hughesa6487332017-08-15 23:16:48 -07001087 "bionic/iconv.cpp",
Elliott Hughesc41b5602017-07-27 17:08:08 -07001088 "bionic/icu_wrappers.cpp",
Dan Willemsen9b59acc2016-01-05 14:32:06 -08001089 "bionic/ifaddrs.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001090 "bionic/inotify_init.cpp",
Dan Willemsendc6b0a72015-11-09 14:03:46 -08001091 "bionic/ioctl.cpp",
Elliott Hughes7532b322017-07-11 15:00:17 -07001092 "bionic/killpg.cpp",
Elliott Hughesfc8e6882016-11-18 16:27:29 -08001093 "bionic/langinfo.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001094 "bionic/lchown.cpp",
1095 "bionic/lfs64_support.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001096 "bionic/libc_init_common.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001097 "bionic/libgen.cpp",
1098 "bionic/link.cpp",
1099 "bionic/locale.cpp",
Dan Willemsen3e621712016-02-03 21:48:08 -08001100 "bionic/lockf.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001101 "bionic/lstat.cpp",
Colin Crossee847862016-04-29 14:06:07 -07001102 "bionic/mblen.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001103 "bionic/mbrtoc16.cpp",
1104 "bionic/mbrtoc32.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001105 "bionic/mempcpy.cpp",
Elliott Hughes0d642432022-08-10 23:35:03 +00001106 "bionic/memset_explicit.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001107 "bionic/mkdir.cpp",
1108 "bionic/mkfifo.cpp",
1109 "bionic/mknod.cpp",
1110 "bionic/mntent.cpp",
Dan Willemsendc6b0a72015-11-09 14:03:46 -08001111 "bionic/mremap.cpp",
Colin Cross8ce38af2016-01-19 12:50:20 -08001112 "bionic/net_if.cpp",
Dan Alberte2fd0102017-07-11 14:27:07 -07001113 "bionic/netdb.cpp",
Dan Willemsen3e621712016-02-03 21:48:08 -08001114 "bionic/netinet_in.cpp",
Elliott Hughes6cfb84b2016-04-06 17:14:45 -07001115 "bionic/nl_types.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001116 "bionic/open.cpp",
1117 "bionic/pathconf.cpp",
1118 "bionic/pause.cpp",
Josh Gao3de19152021-02-22 18:09:48 -08001119 "bionic/pidfd.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001120 "bionic/pipe.cpp",
1121 "bionic/poll.cpp",
1122 "bionic/posix_fadvise.cpp",
1123 "bionic/posix_fallocate.cpp",
1124 "bionic/posix_madvise.cpp",
1125 "bionic/posix_timers.cpp",
Elliott Hughescf59e192021-10-13 18:25:21 -07001126 "bionic/preadv_pwritev.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001127 "bionic/ptrace.cpp",
1128 "bionic/pty.cpp",
1129 "bionic/raise.cpp",
1130 "bionic/rand.cpp",
1131 "bionic/readlink.cpp",
Elliott Hughes22fb2672019-11-01 08:07:25 -07001132 "bionic/realpath.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001133 "bionic/reboot.cpp",
1134 "bionic/recv.cpp",
Josh Gao97271922019-11-06 13:15:00 -08001135 "bionic/recvmsg.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001136 "bionic/rename.cpp",
1137 "bionic/rmdir.cpp",
1138 "bionic/scandir.cpp",
1139 "bionic/sched_getaffinity.cpp",
1140 "bionic/sched_getcpu.cpp",
1141 "bionic/semaphore.cpp",
1142 "bionic/send.cpp",
1143 "bionic/setegid.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001144 "bionic/seteuid.cpp",
1145 "bionic/setpgrp.cpp",
1146 "bionic/sigaction.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001147 "bionic/signal.cpp",
Elliott Hughes7ae39122018-02-26 16:49:43 -08001148 "bionic/sigprocmask.cpp",
Elliott Hughesca3f8e42019-10-28 15:59:38 -07001149 "bionic/sleep.cpp",
Josh Gaob107eab2020-04-29 17:17:56 -07001150 "bionic/socketpair.cpp",
Elliott Hughes14e3ff92017-10-06 16:58:36 -07001151 "bionic/spawn.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001152 "bionic/stat.cpp",
Dan Alberte2fd0102017-07-11 14:27:07 -07001153 "bionic/stdlib_l.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001154 "bionic/strerror.cpp",
Dan Alberte2fd0102017-07-11 14:27:07 -07001155 "bionic/string_l.cpp",
1156 "bionic/strings_l.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001157 "bionic/strsignal.cpp",
Elliott Hughes1921dce2017-12-19 10:27:27 -08001158 "bionic/strtol.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001159 "bionic/strtold.cpp",
Elliott Hughesfa386e02017-10-18 13:34:32 -07001160 "bionic/swab.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001161 "bionic/symlink.cpp",
Colin Crossfc8ed2f2016-04-11 14:51:38 -07001162 "bionic/sync_file_range.cpp",
Elliott Hughes5905d6f2018-01-30 15:09:51 -08001163 "bionic/sys_epoll.cpp",
Elliott Hughes7c59f3f2016-08-16 18:14:26 -07001164 "bionic/sys_msg.cpp",
1165 "bionic/sys_sem.cpp",
1166 "bionic/sys_shm.cpp",
Elliott Hughes6dafb4a2018-01-26 17:47:56 -08001167 "bionic/sys_signalfd.cpp",
Elliott Hughes261bd742019-08-29 20:45:14 -07001168 "bionic/sys_statfs.cpp",
1169 "bionic/sys_statvfs.cpp",
Elliott Hughes449eff02016-06-08 19:51:20 -07001170 "bionic/sys_time.cpp",
Dan Alberte2fd0102017-07-11 14:27:07 -07001171 "bionic/sysinfo.cpp",
1172 "bionic/syslog.cpp",
Elliott Hughes71ba5892018-02-07 12:44:45 -08001173 "bionic/system.cpp",
Tom Cherrye275d6d2017-12-11 23:31:33 -08001174 "bionic/system_property_api.cpp",
1175 "bionic/system_property_set.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001176 "bionic/tdestroy.cpp",
1177 "bionic/termios.cpp",
1178 "bionic/thread_private.cpp",
Elliott Hughes42067112019-04-18 14:27:24 -07001179 "bionic/threads.cpp",
Elliott Hughesf98d87b2018-07-17 13:21:05 -07001180 "bionic/timespec_get.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001181 "bionic/tmpfile.cpp",
1182 "bionic/umount.cpp",
1183 "bionic/unlink.cpp",
Elliott Hughesca3f8e42019-10-28 15:59:38 -07001184 "bionic/usleep.cpp",
Elliott Hughes9a1d3972020-08-07 15:55:02 -07001185 "bionic/utmp.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001186 "bionic/wait.cpp",
1187 "bionic/wchar.cpp",
Dan Alberte2fd0102017-07-11 14:27:07 -07001188 "bionic/wchar_l.cpp",
Elliott Hughes7f0849f2016-08-26 16:17:17 -07001189 "bionic/wcstod.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001190 "bionic/wctype.cpp",
Elliott Hughesc41b5602017-07-27 17:08:08 -07001191 "bionic/wcwidth.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001192 "bionic/wmempcpy.cpp",
Josh Gao0e0e3702017-10-12 13:34:42 -07001193
1194 // This contains a weak stub implementation of __find_icu_symbol for wctype.cpp,
1195 // which will be overridden by the actual one in libc.so.
1196 "bionic/icu_static.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001197 ],
Dan Willemsen268a6732015-10-15 14:49:45 -07001198
Dan Willemsen208ae172015-09-16 16:33:27 -07001199 multilib: {
1200 lib32: {
1201 // LP32 cruft
Colin Cross6ab8f892015-11-23 14:12:15 -08001202 srcs: ["bionic/mmap.cpp"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001203 },
1204 },
Jayant Chowdharyab2f79c2017-09-01 16:29:44 -07001205 product_variables: {
Steven Moreland96bbc5c2017-12-13 14:11:26 -08001206 treble_linker_namespaces: {
1207 cflags: ["-DTREBLE_LINKER_NAMESPACES"],
Jayant Chowdharyab2f79c2017-09-01 16:29:44 -07001208 },
1209 },
Bowgo Tsaia9208f32020-07-24 17:29:52 +08001210 whole_static_libs: [
Bowgo Tsai8f14b652021-07-15 10:13:33 +00001211 "libc_bionic_systrace",
Bowgo Tsaia9208f32020-07-24 17:29:52 +08001212 "libsystemproperties",
1213 ],
Colin Cross50c21ab2015-10-31 23:03:05 -07001214 cppflags: ["-Wold-style-cast"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001215 local_include_dirs: ["stdio"],
1216 include_dirs: ["bionic/libstdc++/include"],
1217 name: "libc_bionic_ndk",
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001218 generated_headers: ["generated_android_ids"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001219}
1220
Dan Willemsen208ae172015-09-16 16:33:27 -07001221// ========================================================
Bowgo Tsaia9208f32020-07-24 17:29:52 +08001222// libc_bionic_systrace.a
1223// ========================================================
1224
1225cc_library_static {
1226 name: "libc_bionic_systrace",
1227 defaults: ["libc_defaults"],
1228 srcs: [
1229 "bionic/bionic_systrace.cpp",
1230 ],
1231 apex_available: [
1232 "com.android.runtime",
1233 ],
1234}
1235
1236// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001237// libc_pthread.a - pthreads parts that previously lived in
1238// libc_bionic.a. Relocated to their own library because
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001239// they can't be included in libc_ndk.a (as the layout of
Dan Willemsen208ae172015-09-16 16:33:27 -07001240// pthread_t has changed over the years and has ABI
1241// compatibility issues).
1242// ========================================================
1243
1244cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001245 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001246 srcs: [
Ryan Prichard45d13492019-01-03 02:51:30 -08001247 "bionic/bionic_elf_tls.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001248 "bionic/pthread_atfork.cpp",
1249 "bionic/pthread_attr.cpp",
Colin Crossa35d23d2015-11-19 13:32:49 -08001250 "bionic/pthread_barrier.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001251 "bionic/pthread_cond.cpp",
1252 "bionic/pthread_create.cpp",
1253 "bionic/pthread_detach.cpp",
1254 "bionic/pthread_equal.cpp",
1255 "bionic/pthread_exit.cpp",
1256 "bionic/pthread_getcpuclockid.cpp",
1257 "bionic/pthread_getschedparam.cpp",
1258 "bionic/pthread_gettid_np.cpp",
Elliott Hughes7484c212017-02-02 02:41:38 +00001259 "bionic/pthread_internal.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001260 "bionic/pthread_join.cpp",
1261 "bionic/pthread_key.cpp",
1262 "bionic/pthread_kill.cpp",
1263 "bionic/pthread_mutex.cpp",
1264 "bionic/pthread_once.cpp",
1265 "bionic/pthread_rwlock.cpp",
Josh Gao726b63f2018-08-27 16:00:58 -07001266 "bionic/pthread_sigqueue.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001267 "bionic/pthread_self.cpp",
1268 "bionic/pthread_setname_np.cpp",
1269 "bionic/pthread_setschedparam.cpp",
Colin Crossa35d23d2015-11-19 13:32:49 -08001270 "bionic/pthread_spinlock.cpp",
Vy Nguyend5007512020-07-14 17:37:04 -04001271 "bionic/sys_thread_properties.cpp",
Josh Gao0e0e3702017-10-12 13:34:42 -07001272
1273 // The following implementations depend on pthread data or implementation,
1274 // so we can't include them in libc_ndk.a.
1275 "bionic/__cxa_thread_atexit_impl.cpp",
Peter Collingbourne5f45c182020-01-14 17:59:41 -08001276 "bionic/android_unsafe_frame_pointer_chase.cpp",
Ryan Prichardafa983c2020-02-04 15:46:15 -08001277 "bionic/atexit.cpp",
Josh Gao0e0e3702017-10-12 13:34:42 -07001278 "bionic/fork.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001279 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001280
Colin Cross50c21ab2015-10-31 23:03:05 -07001281 cppflags: ["-Wold-style-cast"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001282 include_dirs: ["bionic/libstdc++/include"],
Peter Collingbourne5f45c182020-01-14 17:59:41 -08001283 header_libs: ["bionic_libc_platform_headers"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001284 name: "libc_pthread",
Dan Willemsen208ae172015-09-16 16:33:27 -07001285}
1286
1287// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001288// libc_syscalls.a
1289// ========================================================
1290
Elliott Hughes782c4852019-04-16 12:31:00 -07001291genrule {
1292 name: "syscalls-arm.S",
1293 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)",
Chris Parsons98b92e02021-02-23 15:27:58 -05001297 bazel_module: {
1298 bp2build_available: true,
Chris Parsons98b92e02021-02-23 15:27:58 -05001299 }
Elliott Hughes782c4852019-04-16 12:31:00 -07001300}
1301
1302genrule {
1303 name: "syscalls-arm64.S",
1304 out: ["syscalls-arm64.S"],
1305 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001306 tools: ["gensyscalls"],
1307 cmd: "$(location gensyscalls) arm64 $(in) > $(out)",
Chris Parsons98b92e02021-02-23 15:27:58 -05001308 bazel_module: {
1309 bp2build_available: true,
Chris Parsons98b92e02021-02-23 15:27:58 -05001310 },
Elliott Hughes782c4852019-04-16 12:31:00 -07001311}
1312
1313genrule {
1314 name: "syscalls-x86.S",
1315 out: ["syscalls-x86.S"],
1316 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001317 tools: ["gensyscalls"],
1318 cmd: "$(location gensyscalls) x86 $(in) > $(out)",
Chris Parsons98b92e02021-02-23 15:27:58 -05001319 bazel_module: {
1320 bp2build_available: true,
Chris Parsons98b92e02021-02-23 15:27:58 -05001321 },
Elliott Hughes782c4852019-04-16 12:31:00 -07001322}
1323
1324genrule {
1325 name: "syscalls-x86_64.S",
1326 out: ["syscalls-x86_64.S"],
1327 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001328 tools: ["gensyscalls"],
1329 cmd: "$(location gensyscalls) x86_64 $(in) > $(out)",
Chris Parsons98b92e02021-02-23 15:27:58 -05001330 bazel_module: {
1331 bp2build_available: true,
Chris Parsons98b92e02021-02-23 15:27:58 -05001332 },
Elliott Hughes782c4852019-04-16 12:31:00 -07001333}
1334
Dan Willemsen208ae172015-09-16 16:33:27 -07001335cc_library_static {
Colin Cross27c43c52016-04-07 13:27:24 -07001336 defaults: ["libc_defaults"],
Josh Gao0e0e3702017-10-12 13:34:42 -07001337 srcs: ["bionic/__set_errno.cpp"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001338 arch: {
1339 arm: {
Elliott Hughes782c4852019-04-16 12:31:00 -07001340 srcs: [":syscalls-arm.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001341 },
1342 arm64: {
Elliott Hughes782c4852019-04-16 12:31:00 -07001343 srcs: [":syscalls-arm64.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001344 },
1345 x86: {
Elliott Hughes782c4852019-04-16 12:31:00 -07001346 srcs: [":syscalls-x86.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001347 },
1348 x86_64: {
Elliott Hughes782c4852019-04-16 12:31:00 -07001349 srcs: [":syscalls-x86_64.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001350 },
1351 },
1352 name: "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001353}
1354
1355// ========================================================
1356// libc_aeabi.a
1357// This is an LP32 ARM-only library that needs to be built with -fno-builtin
1358// to avoid infinite recursion. For the other architectures we just build an
1359// empty library to keep this makefile simple.
1360// ========================================================
1361
1362cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001363 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001364 arch: {
1365 arm: {
1366 srcs: ["arch-arm/bionic/__aeabi.c"],
1367 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001368 },
1369 name: "libc_aeabi",
Colin Cross50c21ab2015-10-31 23:03:05 -07001370 cflags: ["-fno-builtin"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001371}
1372
1373// ========================================================
1374// libc_ndk.a
1375// Compatibility library for the NDK. This library contains
1376// all the parts of libc that are safe to statically link.
1377// We can't safely statically link things that can only run
1378// on a certain version of the OS. Examples include
1379// anything that talks to netd (a large portion of the DNS
1380// code) and anything that is dependent on the layout of a
1381// data structure that has changed across releases (such as
1382// pthread_t).
1383// ========================================================
1384
1385cc_library_static {
1386 name: "libc_ndk",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001387 defaults: [
1388 "libc_defaults",
1389 "libc_native_allocator_defaults",
1390 ],
Yifan Hong5a39cee2020-01-21 16:43:56 -08001391 ramdisk_available: false,
Yifan Hongb04490d2020-10-21 18:36:36 -07001392 vendor_ramdisk_available: false,
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001393 srcs: libc_common_src_files + [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001394 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001395 "bionic/heap_tagging.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001396 "bionic/malloc_common.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001397 "bionic/malloc_limit.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001398 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001399 multilib: {
1400 lib32: {
1401 srcs: libc_common_src_files_32,
1402 },
1403 },
1404 arch: {
1405 arm: {
1406 srcs: [
1407 "arch-arm/bionic/exidx_dynamic.c",
1408 "arch-common/bionic/crtbegin_so.c",
1409 "arch-arm/bionic/atexit_legacy.c",
1410 "arch-common/bionic/crtend_so.S",
1411 ],
1412 whole_static_libs: ["libc_aeabi"],
1413 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001414 },
1415
Colin Cross50c21ab2015-10-31 23:03:05 -07001416 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -07001417 "-fvisibility=hidden",
1418 "-DLIBC_STATIC",
1419 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001420
1421 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001422 "gwp_asan",
Peter Collingbourne337a5b32020-02-21 12:11:02 -08001423 "libarm-optimized-routines-string",
Rupert Shuttleworth78f48a52021-03-16 06:39:19 +00001424 "libasync_safe",
Dan Willemsen208ae172015-09-16 16:33:27 -07001425 "libc_bionic_ndk",
Ryan Prichard249757b2019-11-01 17:18:28 -07001426 "libc_bootstrap",
George Burgess IV6cb06872017-07-21 13:28:42 -07001427 "libc_fortify",
Dan Willemsen208ae172015-09-16 16:33:27 -07001428 "libc_freebsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001429 "libc_freebsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001430 "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -07001431 "libc_netbsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001432 "libc_openbsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001433 "libc_openbsd_ndk",
Dan Willemsen208ae172015-09-16 16:33:27 -07001434 "libc_syscalls",
1435 "libc_tzcode",
1436 "libm",
Elliott Hughes816fab92016-05-27 17:57:46 -07001437 "libstdc++",
Dan Willemsen208ae172015-09-16 16:33:27 -07001438 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001439}
1440
1441// ========================================================
Josh Gao0e0e3702017-10-12 13:34:42 -07001442// libc_nopthread.a
Dan Willemsen208ae172015-09-16 16:33:27 -07001443// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001444cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001445 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001446 srcs: libc_common_src_files,
1447 multilib: {
1448 lib32: {
1449 srcs: libc_common_src_files_32,
1450 },
1451 },
Josh Gao0e0e3702017-10-12 13:34:42 -07001452 name: "libc_nopthread",
Dan Willemsen208ae172015-09-16 16:33:27 -07001453
1454 whole_static_libs: [
Peter Collingbourne337a5b32020-02-21 12:11:02 -08001455 "libarm-optimized-routines-string",
Rupert Shuttleworth78f48a52021-03-16 06:39:19 +00001456 "libasync_safe",
Dan Willemsen208ae172015-09-16 16:33:27 -07001457 "libc_bionic",
1458 "libc_bionic_ndk",
Ryan Prichard249757b2019-11-01 17:18:28 -07001459 "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -07001460 "libc_dns",
George Burgess IV6cb06872017-07-21 13:28:42 -07001461 "libc_fortify",
Dan Willemsen208ae172015-09-16 16:33:27 -07001462 "libc_freebsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001463 "libc_freebsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001464 "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -07001465 "libc_netbsd",
1466 "libc_openbsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001467 "libc_openbsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001468 "libc_openbsd_ndk",
Dan Willemsen208ae172015-09-16 16:33:27 -07001469 "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001470 "libc_tzcode",
Elliott Hughes816fab92016-05-27 17:57:46 -07001471 "libstdc++",
Dan Willemsen208ae172015-09-16 16:33:27 -07001472 ],
1473
1474 arch: {
1475 arm: {
1476 whole_static_libs: ["libc_aeabi"],
1477 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001478 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001479}
1480
1481// ========================================================
Josh Gao0e0e3702017-10-12 13:34:42 -07001482// libc_common.a
1483// ========================================================
1484
1485cc_library_static {
1486 defaults: ["libc_defaults"],
1487 name: "libc_common",
1488
1489 whole_static_libs: [
1490 "libc_nopthread",
1491 "libc_pthread",
1492 ],
1493}
1494
1495// ========================================================
Ryan Prichard249757b2019-11-01 17:18:28 -07001496// libc_static_dispatch.a
Haibo Huangf71edfa2018-11-12 10:06:56 -08001497// ========================================================
1498cc_library_static {
1499 defaults: ["libc_defaults"],
Ryan Prichard249757b2019-11-01 17:18:28 -07001500 name: "libc_static_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001501
Haibo Huangb9244ff2018-08-11 10:12:13 -07001502 arch: {
ahs919fb7f2022-06-10 07:11:14 +05301503 x86_64: {
1504 srcs: ["arch-x86_64/static_function_dispatch.S"],
1505 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001506 x86: {
1507 srcs: ["arch-x86/static_function_dispatch.S"],
1508 },
Haibo Huangea9957a2018-11-19 11:00:32 -08001509 arm: {
1510 srcs: ["arch-arm/static_function_dispatch.S"],
1511 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001512 arm64: {
1513 srcs: ["arch-arm64/static_function_dispatch.S"],
1514 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001515 },
Haibo Huangf71edfa2018-11-12 10:06:56 -08001516}
1517
1518// ========================================================
Ryan Prichard249757b2019-11-01 17:18:28 -07001519// libc_dynamic_dispatch.a
Haibo Huangf71edfa2018-11-12 10:06:56 -08001520// ========================================================
1521cc_library_static {
1522 defaults: ["libc_defaults"],
Ryan Prichard249757b2019-11-01 17:18:28 -07001523 name: "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001524
Haibo Huangb9244ff2018-08-11 10:12:13 -07001525 cflags: [
Peter Collingbourne36a56442019-10-31 17:11:54 -07001526 "-ffreestanding",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001527 "-fno-stack-protector",
1528 "-fno-jump-tables",
1529 ],
1530 arch: {
ahs919fb7f2022-06-10 07:11:14 +05301531 x86_64: {
1532 srcs: ["arch-x86_64/dynamic_function_dispatch.cpp"],
1533 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001534 x86: {
1535 srcs: ["arch-x86/dynamic_function_dispatch.cpp"],
1536 },
Haibo Huangea9957a2018-11-19 11:00:32 -08001537 arm: {
Elliott Hughes927fe992019-01-31 22:29:22 +00001538 srcs: ["arch-arm/dynamic_function_dispatch.cpp"],
Haibo Huangea9957a2018-11-19 11:00:32 -08001539 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001540 arm64: {
1541 srcs: ["arch-arm64/dynamic_function_dispatch.cpp"],
1542 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001543 },
Ryan Prichard249757b2019-11-01 17:18:28 -07001544}
1545
1546// ========================================================
1547// libc_common_static.a For static binaries.
1548// ========================================================
1549cc_library_static {
1550 defaults: ["libc_defaults"],
1551 name: "libc_common_static",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001552
Haibo Huangf71edfa2018-11-12 10:06:56 -08001553 whole_static_libs: [
1554 "libc_common",
Ryan Prichard249757b2019-11-01 17:18:28 -07001555 "libc_static_dispatch",
1556 ],
1557}
1558
1559// ========================================================
1560// libc_common_shared.a For shared libraries.
1561// ========================================================
1562cc_library_static {
1563 defaults: ["libc_defaults"],
1564 name: "libc_common_shared",
1565
1566 whole_static_libs: [
1567 "libc_common",
1568 "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001569 ],
1570}
1571
Ryan Prichard22a6a052019-10-10 23:59:30 -07001572// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static
1573// executable.
1574cc_library_static {
1575 name: "libc_unwind_static",
1576 defaults: ["libc_defaults"],
1577 cflags: ["-DLIBC_STATIC"],
1578
1579 srcs: ["bionic/dl_iterate_phdr_static.cpp"],
1580 arch: {
1581 // arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs
1582 arm: {
1583 srcs: ["arch-arm/bionic/exidx_static.c"],
1584 },
1585 },
1586}
1587
Haibo Huangf71edfa2018-11-12 10:06:56 -08001588// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001589// libc_nomalloc.a
1590// ========================================================
1591//
Ryan Prichard249757b2019-11-01 17:18:28 -07001592// This is a version of the static C library used by the dynamic linker that exclude malloc. It also
1593// excludes functions selected using ifunc's (e.g. for string.h). Link in either
1594// libc_static_dispatch or libc_dynamic_dispatch to provide those functions.
Dan Willemsen208ae172015-09-16 16:33:27 -07001595
1596cc_library_static {
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -08001597 name: "libc_nomalloc",
Colin Cross50c21ab2015-10-31 23:03:05 -07001598 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001599
Colin Crossa3f9fca2016-01-11 13:20:55 -08001600 whole_static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -07001601 "libc_common",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001602 "libc_init_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001603 "libc_unwind_static",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001604 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001605}
1606
dimitryc0c0ef62018-12-05 16:33:52 +01001607filegroup {
1608 name: "libc_sources_shared",
1609 srcs: [
1610 "arch-common/bionic/crtbegin_so.c",
1611 "arch-common/bionic/crtbrand.S",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001612 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001613 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001614 "bionic/icu.cpp",
1615 "bionic/malloc_common.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001616 "bionic/malloc_common_dynamic.cpp",
Ryan Savitski175c8862020-01-02 19:54:57 +00001617 "bionic/android_profiling_dynamic.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001618 "bionic/malloc_heapprofd.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001619 "bionic/malloc_limit.cpp",
Peter Collingbourne570de332019-12-11 10:00:58 -08001620 "bionic/ndk_cruft.cpp",
1621 "bionic/ndk_cruft_data.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001622 "bionic/NetdClient.cpp",
1623 "arch-common/bionic/crtend_so.S",
1624 ],
Jingwen Chend6a3b782021-02-05 10:05:29 -05001625 bazel_module: { bp2build_available: true },
dimitryc0c0ef62018-12-05 16:33:52 +01001626}
1627
1628filegroup {
1629 name: "libc_sources_static",
1630 srcs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001631 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001632 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001633 "bionic/malloc_common.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001634 "bionic/malloc_limit.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001635 ],
Jingwen Chend6a3b782021-02-05 10:05:29 -05001636 bazel_module: { bp2build_available: true },
dimitryc0c0ef62018-12-05 16:33:52 +01001637}
1638
1639filegroup {
1640 name: "libc_sources_shared_arm",
1641 srcs: [
1642 "arch-arm/bionic/exidx_dynamic.c",
1643 "arch-arm/bionic/atexit_legacy.c",
1644 ],
Jingwen Chend6a3b782021-02-05 10:05:29 -05001645 bazel_module: { bp2build_available: true },
dimitryc0c0ef62018-12-05 16:33:52 +01001646}
1647
Dan Willemsen208ae172015-09-16 16:33:27 -07001648// ========================================================
1649// libc.a + libc.so
1650// ========================================================
1651cc_library {
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001652 defaults: [
1653 "libc_defaults",
1654 "libc_native_allocator_defaults",
1655 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001656 name: "libc",
Dan Albert40f15ec2017-10-27 11:21:20 -07001657 static_ndk_lib: true,
Colin Cross50c21ab2015-10-31 23:03:05 -07001658 product_variables: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001659 platform_sdk_version: {
1660 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1661 },
1662 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001663 static: {
dimitryc0c0ef62018-12-05 16:33:52 +01001664 srcs: [ ":libc_sources_static" ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001665 cflags: ["-DLIBC_STATIC"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001666 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001667 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001668 "libc_init_static",
1669 "libc_common_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001670 "libc_unwind_static",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001671 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001672 },
1673 shared: {
dimitryc0c0ef62018-12-05 16:33:52 +01001674 srcs: [ ":libc_sources_shared" ],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001675 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001676 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001677 "libc_init_dynamic",
1678 "libc_common_shared",
Ryan Prichardcdf71752020-12-16 03:37:22 -08001679 "libunwind-exported",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001680 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001681 },
1682
Neil Fullera7db90f2019-04-25 09:28:27 +01001683 required: [
MarkDacekd88d7ea2022-06-28 20:14:58 +00001684 "tzdata_prebuilt",
1685 "tz_version_prebuilt", // Version metadata for tzdata to help debugging.
Neil Fullera7db90f2019-04-25 09:28:27 +01001686 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001687
Colin Cross4ce94d22016-11-15 13:15:43 -08001688 // Do not pack libc.so relocations; see http://b/20645321 for details.
1689 pack_relocations: false,
1690
dimitry06016f22018-01-05 11:39:28 +01001691 // WARNING: The only libraries libc.so should depend on are libdl.so and ld-android.so!
1692 // If you add other libraries, make sure to add -Wl,--exclude-libs=libgcc.a to the
1693 // LOCAL_LDFLAGS for those libraries. This ensures that symbols that are pulled into
1694 // those new libraries from libgcc.a are not declared external; if that were the case,
1695 // then libc would not pull those symbols from libgcc.a as it should, instead relying
1696 // on the external symbols from the dependent libraries. That would create a "cloaked"
1697 // dependency on libgcc.a in libc though the libraries, which is not what you wanted!
Dan Willemsen208ae172015-09-16 16:33:27 -07001698
dimitry06016f22018-01-05 11:39:28 +01001699 shared_libs: [
1700 "ld-android",
1701 "libdl",
1702 ],
Jiyong Park3ff116a2019-04-02 23:04:52 +09001703 static_libs: [
1704 "libdl_android",
1705 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001706
1707 nocrt: true,
1708
Dan Willemsen208ae172015-09-16 16:33:27 -07001709 arch: {
1710 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001711 // TODO: This is to work around b/24465209. Remove after root cause is fixed.
Chih-Hung Hsiehecbff832018-05-23 18:45:53 -07001712 pack_relocations: false,
Ian Pedowitzb6310c22018-01-18 16:26:19 -08001713 ldflags: ["-Wl,--hash-style=both"],
1714
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001715 version_script: ":libc.arm.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001716 no_libcrt: true,
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001717
Dan Willemsen208ae172015-09-16 16:33:27 -07001718 shared: {
dimitryc0c0ef62018-12-05 16:33:52 +01001719 srcs: [":libc_sources_shared_arm"],
Dan Willemsen0c657082016-05-12 01:43:07 -07001720 // special for arm
1721 cflags: ["-DCRT_LEGACY_WORKAROUND"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001722 // For backwards-compatibility, some arm32 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001723 static_libs: ["libclang_rt.builtins-exported"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001724 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001725
1726 // Arm 32 bit does not produce complete exidx unwind information
1727 // so keep the .debug_frame which is relatively small and does
1728 // include needed unwind information.
1729 // See b/132992102 for details.
1730 strip: {
1731 keep_symbols_and_debug_frame: true,
1732 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001733 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001734 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001735 version_script: ":libc.arm64.map",
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001736
1737 // Leave the symbols in the shared library so that stack unwinders can produce
1738 // meaningful name resolution.
1739 strip: {
1740 keep_symbols: true,
1741 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001742 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001743 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001744 // TODO: This is to work around b/24465209. Remove after root cause is fixed.
Chih-Hung Hsiehecbff832018-05-23 18:45:53 -07001745 pack_relocations: false,
Ian Pedowitzb6310c22018-01-18 16:26:19 -08001746 ldflags: ["-Wl,--hash-style=both"],
1747
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001748 version_script: ":libc.x86.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001749 no_libcrt: true,
1750
1751 shared: {
1752 // For backwards-compatibility, some x86 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001753 static_libs: ["libclang_rt.builtins-exported"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001754 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001755
1756 // Leave the symbols in the shared library so that stack unwinders can produce
1757 // meaningful name resolution.
1758 strip: {
1759 keep_symbols: true,
1760 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001761 },
1762 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001763 version_script: ":libc.x86_64.map",
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001764
1765 // Leave the symbols in the shared library so that stack unwinders can produce
1766 // meaningful name resolution.
1767 strip: {
1768 keep_symbols: true,
1769 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001770 },
1771 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +09001772
1773 stubs: {
1774 symbol_file: "libc.map.txt",
Jooyung Han26ddc4d2020-02-27 18:33:25 +09001775 versions: [
1776 "29",
Jooyung Handbfa0742020-03-30 13:18:44 +09001777 "R",
Dan Albert48943b22020-07-27 13:28:56 -07001778 "current",
Jooyung Han26ddc4d2020-02-27 18:33:25 +09001779 ],
Jiyong Parkc45fe9f2018-12-13 18:26:48 +09001780 },
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001781 llndk: {
1782 symbol_file: "libc.map.txt",
1783 export_headers_as_system: true,
1784 export_preprocessed_headers: ["include"],
1785 export_llndk_headers: ["libc_llndk_headers"],
1786 },
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001787 apex_available: [
1788 "//apex_available:platform",
1789 "com.android.runtime",
1790 ],
1791
Colin Cross7edd0082021-10-28 13:20:35 -07001792 target: {
1793 native_bridge: {
1794 shared: {
1795 installable: false,
1796 },
1797 },
1798 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001799}
1800
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001801genrule {
1802 name: "libc.arm.map",
1803 out: ["libc.arm.map"],
1804 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001805 tools: ["generate-version-script"],
1806 cmd: "$(location generate-version-script) arm $(in) $(out)",
Jingwen Chend6a3b782021-02-05 10:05:29 -05001807 bazel_module: { bp2build_available: true },
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001808}
1809
1810genrule {
1811 name: "libc.arm64.map",
1812 out: ["libc.arm64.map"],
1813 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001814 tools: ["generate-version-script"],
1815 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Jingwen Chend6a3b782021-02-05 10:05:29 -05001816 bazel_module: { bp2build_available: true },
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001817}
1818
1819genrule {
1820 name: "libc.x86.map",
1821 out: ["libc.x86.map"],
1822 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001823 tools: ["generate-version-script"],
1824 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Jingwen Chend6a3b782021-02-05 10:05:29 -05001825 bazel_module: { bp2build_available: true },
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001826}
1827
1828genrule {
1829 name: "libc.x86_64.map",
1830 out: ["libc.x86_64.map"],
1831 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001832 tools: ["generate-version-script"],
1833 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Jingwen Chend6a3b782021-02-05 10:05:29 -05001834 bazel_module: { bp2build_available: true },
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001835}
1836
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001837// Headers that only other parts of the platform can include.
1838cc_library_headers {
1839 name: "bionic_libc_platform_headers",
Martin Stjernholma2763432020-04-23 16:47:19 +01001840 defaults: ["linux_bionic_supported"],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001841 visibility: [
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001842 "//art:__subpackages__",
Josh Gao97271922019-11-06 13:15:00 -08001843 "//bionic:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001844 "//frameworks:__subpackages__",
Roman Kiryanov067f5182020-05-07 14:58:30 -07001845 "//device/generic/goldfish-opengl:__subpackages__",
Mitch Phillips3309b3d2020-03-25 15:05:48 -07001846 "//external/gwp_asan:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001847 "//external/perfetto:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001848 "//external/scudo:__subpackages__",
Josh Gao5074e7d2019-12-13 13:55:53 -08001849 "//system/core/debuggerd:__subpackages__",
Florian Mayerf5d70ce2022-09-13 13:58:30 -07001850 "//system/core/init:__subpackages__",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001851 "//system/core/libcutils:__subpackages__",
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001852 "//system/memory/libmemunreachable:__subpackages__",
Baligh Uddindb0c6de2020-10-15 04:49:00 +00001853 "//system/unwinding/libunwindstack:__subpackages__",
Peter Collingbourne15418002020-05-12 16:02:50 -07001854 "//tools/security/sanitizer-status:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001855 ],
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001856 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001857 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001858 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001859 vendor_ramdisk_available: true,
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001860 recovery_available: true,
1861 native_bridge_supported: true,
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001862 export_include_dirs: [
1863 "platform",
1864 ],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001865 system_shared_libs: [],
1866 stl: "none",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001867 sdk_version: "current",
Jiyong Park4ede1602020-04-28 18:21:08 +09001868
Steven Moreland0cdf1322020-10-05 21:55:26 +00001869 min_sdk_version: "29",
Jiyong Park4ede1602020-04-28 18:21:08 +09001870 apex_available: [
1871 "//apex_available:platform",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001872 "//apex_available:anyapex",
Jiyong Park4ede1602020-04-28 18:21:08 +09001873 ],
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001874 bazel_module: { bp2build_available: true },
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001875}
1876
Logan Chien17af91b2019-01-15 21:19:56 +08001877cc_library_headers {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001878 name: "libc_llndk_headers",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001879 visibility: [
1880 "//external/musl",
1881 ],
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001882 llndk: {
1883 llndk_headers: true,
1884 },
Logan Chien17af91b2019-01-15 21:19:56 +08001885 host_supported: true,
1886 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001887 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001888 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001889 vendor_ramdisk_available: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001890 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001891 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001892 apex_available: [
1893 "//apex_available:platform",
Jiyong Parkad9946c2020-03-30 18:36:07 +09001894 "//apex_available:anyapex",
1895 ],
Jooyung Han15c32a82020-04-16 18:26:45 +09001896 // used by most APEXes indirectly via libunwind_llvm
1897 min_sdk_version: "apex_inherit",
Logan Chien17af91b2019-01-15 21:19:56 +08001898
1899 no_libcrt: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001900 stl: "none",
1901 system_shared_libs: [],
1902
Peter Collingbournef2b1e032019-12-10 17:41:16 -08001903 // The build system generally requires that any dependencies of a target
1904 // with an sdk_version must have a lower sdk_version. By setting sdk_version
1905 // to 1 we let targets with an sdk_version that need to depend on the libc
1906 // headers but cannot depend on libc itself due to circular dependencies
1907 // (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
1908 // is correct because the headers can support any sdk_version.
1909 sdk_version: "1",
1910
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001911 export_system_include_dirs: [
Logan Chien17af91b2019-01-15 21:19:56 +08001912 "kernel/uapi",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001913 "kernel/android/scsi",
Logan Chien17af91b2019-01-15 21:19:56 +08001914 "kernel/android/uapi",
1915 ],
1916
1917 arch: {
1918 arm: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001919 export_system_include_dirs: ["kernel/uapi/asm-arm"],
Logan Chien17af91b2019-01-15 21:19:56 +08001920 },
1921 arm64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001922 export_system_include_dirs: ["kernel/uapi/asm-arm64"],
Logan Chien17af91b2019-01-15 21:19:56 +08001923 },
Elliott Hughes48e53332022-10-07 20:39:25 +00001924 riscv64: {
1925 export_system_include_dirs: ["kernel/uapi/asm-riscv"],
1926 },
Logan Chien17af91b2019-01-15 21:19:56 +08001927 x86: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001928 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001929 },
1930 x86_64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001931 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001932 },
1933 },
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001934 bazel_module: { bp2build_available: true },
Logan Chien17af91b2019-01-15 21:19:56 +08001935}
1936
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001937cc_library_headers {
1938 name: "libc_headers",
1939 host_supported: true,
1940 native_bridge_supported: true,
1941 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001942 product_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001943 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001944 vendor_ramdisk_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001945 recovery_available: true,
1946 sdk_version: "1",
1947
1948 apex_available: [
1949 "//apex_available:platform",
1950 "//apex_available:anyapex",
1951 ],
1952 // used by most APEXes indirectly via libunwind_llvm
1953 min_sdk_version: "apex_inherit",
1954 visibility: [
1955 "//bionic:__subpackages__", // visible to bionic
1956 // ... and only to these places (b/152668052)
1957 "//external/arm-optimized-routines",
1958 "//external/gwp_asan",
1959 "//external/jemalloc_new",
1960 "//external/libunwind_llvm",
1961 "//external/scudo",
1962 "//system/core/property_service/libpropertyinfoparser",
1963 "//system/extras/toolchain-extras",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001964 ],
1965
1966 stl: "none",
1967 no_libcrt: true,
1968 system_shared_libs: [],
1969
1970 target: {
1971 android: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001972 export_system_include_dirs: ["include"],
1973 header_libs: ["libc_llndk_headers"],
1974 export_header_lib_headers: ["libc_llndk_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001975 },
1976 linux_bionic: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001977 export_system_include_dirs: ["include"],
1978 header_libs: ["libc_llndk_headers"],
1979 export_header_lib_headers: ["libc_llndk_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001980 },
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001981 },
1982 bazel_module: { bp2build_available: true },
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001983}
1984
Dan Willemsen208ae172015-09-16 16:33:27 -07001985// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001986// libstdc++.so and libstdc++.a.
Dan Willemsen208ae172015-09-16 16:33:27 -07001987// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001988
Dan Willemsen208ae172015-09-16 16:33:27 -07001989cc_library {
Colin Cross50c21ab2015-10-31 23:03:05 -07001990 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001991 include_dirs: ["bionic/libstdc++/include"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001992 srcs: [
1993 "bionic/__cxa_guard.cpp",
1994 "bionic/__cxa_pure_virtual.cpp",
1995 "bionic/new.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001996 ],
1997 name: "libstdc++",
Dan Albert40f15ec2017-10-27 11:21:20 -07001998 static_ndk_lib: true,
Isaac Chen5e7c90b2017-09-20 14:44:42 +08001999 static_libs: ["libasync_safe"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002000
Dan Willemsen6b3be172018-12-03 13:57:20 -08002001 static: {
2002 system_shared_libs: [],
2003 },
Colin Crossb5bfe0b2021-07-13 16:26:28 -07002004 target: {
2005 bionic: {
2006 shared: {
2007 system_shared_libs: ["libc"],
2008 },
2009 },
Dan Willemsen6b3be172018-12-03 13:57:20 -08002010 },
2011
Ian Pedowitzb6310c22018-01-18 16:26:19 -08002012 //TODO (dimitry): This is to work around b/24465209. Remove after root cause is fixed
Dan Willemsen208ae172015-09-16 16:33:27 -07002013 arch: {
2014 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002015 // TODO: This is to work around b/24465209. Remove after root cause is fixed.
Chih-Hung Hsiehecbff832018-05-23 18:45:53 -07002016 pack_relocations: false,
Ian Pedowitzb6310c22018-01-18 16:26:19 -08002017 ldflags: ["-Wl,--hash-style=both"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002018 version_script: ":libstdc++.arm.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07002019 },
2020 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002021 version_script: ":libstdc++.arm64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07002022 },
2023 x86: {
Chih-Hung Hsiehecbff832018-05-23 18:45:53 -07002024 pack_relocations: false,
Ian Pedowitzb6310c22018-01-18 16:26:19 -08002025 ldflags: ["-Wl,--hash-style=both"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002026 version_script: ":libstdc++.x86.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07002027 },
2028 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002029 version_script: ":libstdc++.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07002030 },
2031 },
2032}
2033
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002034genrule {
2035 name: "libstdc++.arm.map",
2036 out: ["libstdc++.arm.map"],
2037 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00002038 tools: ["generate-version-script"],
2039 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002040}
2041
2042genrule {
2043 name: "libstdc++.arm64.map",
2044 out: ["libstdc++.arm64.map"],
2045 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00002046 tools: ["generate-version-script"],
2047 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002048}
2049
2050genrule {
2051 name: "libstdc++.x86.map",
2052 out: ["libstdc++.x86.map"],
2053 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00002054 tools: ["generate-version-script"],
2055 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002056}
2057
2058genrule {
2059 name: "libstdc++.x86_64.map",
2060 out: ["libstdc++.x86_64.map"],
2061 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00002062 tools: ["generate-version-script"],
2063 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002064}
2065
2066// ========================================================
2067// crt object files.
2068// ========================================================
2069
Colin Cross50c21ab2015-10-31 23:03:05 -07002070cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07002071 name: "crt_and_memtag_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -08002072 defaults: ["linux_bionic_supported"],
Dan Willemsen230a7a42017-04-07 14:09:05 -07002073 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09002074 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08002075 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07002076 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +09002077 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02002078 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09002079 apex_available: [
2080 "//apex_available:platform",
2081 "//apex_available:anyapex",
2082 ],
Dan Albertdc503f62020-07-15 17:22:18 -07002083 // Generate NDK variants of the CRT objects for every supported API level.
2084 min_sdk_version: "16",
2085 stl: "none",
2086 crt: true,
Elliott Hughesd50a1de2018-02-05 17:30:57 -08002087 cflags: [
2088 "-Wno-gcc-compat",
2089 "-Wall",
2090 "-Werror",
2091 ],
Peter Collingbourne7eb851c2019-09-26 12:16:06 -07002092 sanitize: {
2093 never: true,
2094 },
Dan Willemsen208ae172015-09-16 16:33:27 -07002095}
2096
Colin Cross50c21ab2015-10-31 23:03:05 -07002097cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07002098 name: "crt_defaults",
2099 defaults: ["crt_and_memtag_defaults"],
Colin Cross02f81372021-07-22 12:02:10 -07002100 system_shared_libs: [],
Colin Cross10d92682021-06-22 13:25:46 -07002101}
2102
2103cc_defaults {
Colin Cross50c21ab2015-10-31 23:03:05 -07002104 name: "crt_so_defaults",
Colin Cross7d7b3682017-11-03 13:38:40 -07002105 defaults: ["crt_defaults"],
Colin Cross50c21ab2015-10-31 23:03:05 -07002106
2107 arch: {
Colin Cross50c21ab2015-10-31 23:03:05 -07002108 x86: {
2109 cflags: ["-fPIC"],
2110 },
2111 x86_64: {
2112 cflags: ["-fPIC"],
2113 },
Dan Willemsen208ae172015-09-16 16:33:27 -07002114 },
Colin Crossab179442018-09-27 11:03:22 -07002115 stl: "none",
Dan Willemsen208ae172015-09-16 16:33:27 -07002116}
2117
Dan Willemsen208ae172015-09-16 16:33:27 -07002118cc_object {
2119 name: "crtbrand",
Dan Willemsena3ed9012017-04-04 15:51:26 -07002120 // crtbrand.c needs <stdint.h> and a #define for the platform SDK version.
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002121 local_include_dirs: [
2122 "include",
2123 "private", // crtbrand.S depends on private/bionic_asm_note.h
2124 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002125 product_variables: {
2126 platform_sdk_version: {
2127 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
2128 },
2129 },
2130 srcs: ["arch-common/bionic/crtbrand.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002131
Colin Cross7d7b3682017-11-03 13:38:40 -07002132 defaults: ["crt_so_defaults"],
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002133
2134 bazel_module: { bp2build_available: true },
Dan Willemsen208ae172015-09-16 16:33:27 -07002135}
2136
Dan Willemsen208ae172015-09-16 16:33:27 -07002137cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002138 name: "crtbegin_so",
Dan Willemsen208ae172015-09-16 16:33:27 -07002139 local_include_dirs: ["include"],
2140 srcs: ["arch-common/bionic/crtbegin_so.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002141
Colin Cross7d7b3682017-11-03 13:38:40 -07002142 defaults: ["crt_so_defaults"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002143 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002144 "crtbrand",
2145 ],
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002146
2147 bazel_module: { bp2build_available: true },
Dan Willemsen208ae172015-09-16 16:33:27 -07002148}
2149
Dan Willemsen208ae172015-09-16 16:33:27 -07002150cc_object {
2151 name: "crtend_so",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002152 local_include_dirs: [
2153 "include",
2154 "private", // crtend_so.S depends on private/bionic_asm_arm64.h
2155 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002156 srcs: ["arch-common/bionic/crtend_so.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002157
Colin Cross7d7b3682017-11-03 13:38:40 -07002158 defaults: ["crt_so_defaults"],
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002159
2160 bazel_module: { bp2build_available: true },
Dan Willemsen208ae172015-09-16 16:33:27 -07002161}
2162
Dan Willemsen208ae172015-09-16 16:33:27 -07002163cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002164 name: "crtbegin_static",
2165
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002166 local_include_dirs: [
2167 "include",
2168 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2169 ],
Liz Kammere718dd72021-03-09 15:00:06 -05002170
Dan Willemsen208ae172015-09-16 16:33:27 -07002171 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002172 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002173 "crtbrand",
2174 ],
Colin Cross50c21ab2015-10-31 23:03:05 -07002175 defaults: ["crt_defaults"],
Jiyong Park268a6002021-01-12 23:14:37 +09002176 // When using libc.a, we're using the latest library regardless of target API level.
2177 min_sdk_version: "current",
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002178
2179 bazel_module: { bp2build_available: true },
Dan Willemsen208ae172015-09-16 16:33:27 -07002180}
2181
Dan Willemsen208ae172015-09-16 16:33:27 -07002182cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002183 name: "crtbegin_dynamic",
2184
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002185 local_include_dirs: [
2186 "include",
2187 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2188 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002189 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002190 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002191 "crtbrand",
2192 ],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -07002193 target: {
2194 linux_bionic: {
2195 generated_sources: ["host_bionic_linker_asm"],
2196 objs: [
2197 "linker_wrapper",
2198 ],
2199 },
2200 },
Colin Cross50c21ab2015-10-31 23:03:05 -07002201 defaults: ["crt_defaults"],
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002202
2203 bazel_module: { bp2build_available: true },
Dan Willemsen208ae172015-09-16 16:33:27 -07002204}
2205
Dan Willemsen208ae172015-09-16 16:33:27 -07002206cc_object {
2207 // We rename crtend.o to crtend_android.o to avoid a
2208 // name clash between gcc and bionic.
2209 name: "crtend_android",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002210 local_include_dirs: [
2211 "include",
2212 "private", // crtend.S depends on private/bionic_asm_arm64.h
2213 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002214 srcs: ["arch-common/bionic/crtend.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002215
Colin Cross50c21ab2015-10-31 23:03:05 -07002216 defaults: ["crt_defaults"],
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002217
2218 bazel_module: { bp2build_available: true },
Dan Willemsen208ae172015-09-16 16:33:27 -07002219}
Colin Crossbaa48992016-07-13 11:15:21 -07002220
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002221cc_library_static {
2222 name: "note_memtag_heap_async",
2223 arch: {
2224 arm64: {
2225 srcs: ["arch-arm64/bionic/note_memtag_heap_async.S"],
2226 }
2227 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002228 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002229
Colin Cross10d92682021-06-22 13:25:46 -07002230 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002231}
2232
2233cc_library_static {
2234 name: "note_memtag_heap_sync",
2235 arch: {
2236 arm64: {
2237 srcs: ["arch-arm64/bionic/note_memtag_heap_sync.S"],
2238 }
2239 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002240 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002241
Colin Cross10d92682021-06-22 13:25:46 -07002242 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002243}
2244
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002245// ========================================================
2246// NDK headers.
2247// ========================================================
2248
Dan Albert26e1c412018-05-24 14:56:46 -07002249versioned_ndk_headers {
Dan Albert22805ea2017-03-22 15:28:05 -07002250 name: "common_libc",
2251 from: "include",
2252 to: "",
2253 license: "NOTICE",
2254}
Dan Albert4238a352016-06-28 11:18:05 -07002255
2256ndk_headers {
Dan Albert063e86a2016-11-29 11:09:12 -08002257 name: "libc_uapi",
2258 from: "kernel/uapi",
2259 to: "",
2260 srcs: [
2261 "kernel/uapi/asm-generic/**/*.h",
2262 "kernel/uapi/drm/**/*.h",
2263 "kernel/uapi/linux/**/*.h",
2264 "kernel/uapi/misc/**/*.h",
2265 "kernel/uapi/mtd/**/*.h",
2266 "kernel/uapi/rdma/**/*.h",
2267 "kernel/uapi/scsi/**/*.h",
2268 "kernel/uapi/sound/**/*.h",
2269 "kernel/uapi/video/**/*.h",
2270 "kernel/uapi/xen/**/*.h",
2271 ],
Dan Albert92592652016-10-20 01:42:54 -07002272 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002273}
2274
2275ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002276 name: "libc_kernel_android_uapi_linux",
Dan Albertbae16ef2016-09-14 17:15:48 -07002277 from: "kernel/android/uapi/linux",
2278 to: "linux",
2279 srcs: ["kernel/android/uapi/linux/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002280 license: "NOTICE",
Dan Albertbae16ef2016-09-14 17:15:48 -07002281}
2282
2283ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002284 name: "libc_kernel_android_scsi",
Elliott Hughes50599392017-05-25 17:13:32 -07002285 from: "kernel/android/scsi/scsi",
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002286 to: "scsi",
2287 srcs: ["kernel/android/scsi/**/*.h"],
2288 license: "NOTICE",
2289}
2290
2291ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002292 name: "libc_asm_arm",
2293 from: "kernel/uapi/asm-arm",
2294 to: "arm-linux-androideabi",
2295 srcs: ["kernel/uapi/asm-arm/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002296 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002297}
2298
2299ndk_headers {
2300 name: "libc_asm_arm64",
2301 from: "kernel/uapi/asm-arm64",
2302 to: "aarch64-linux-android",
2303 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002304 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002305}
2306
Lazar Trsic790d2f72017-11-27 11:54:11 +01002307ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002308 name: "libc_asm_x86",
2309 from: "kernel/uapi/asm-x86",
2310 to: "i686-linux-android",
2311 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002312 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002313}
2314
2315ndk_headers {
2316 name: "libc_asm_x86_64",
2317 from: "kernel/uapi/asm-x86",
2318 to: "x86_64-linux-android",
2319 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002320 license: "NOTICE",
Dan Albert4238a352016-06-28 11:18:05 -07002321}
2322
Dan Albert4238a352016-06-28 11:18:05 -07002323ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002324 name: "libc",
Dan Albert4238a352016-06-28 11:18:05 -07002325 symbol_file: "libc.map.txt",
2326 first_version: "9",
Dan Albert2d8d2a02021-10-20 13:11:46 -07002327 // APIs implemented in asm don't have debug info: http://b/190554910.
2328 allow_untyped_symbols: true,
Spandan Das6feb2cc2022-09-08 23:41:42 +00002329 export_header_libs: [
2330 "common_libc",
2331 "libc_uapi",
2332 "libc_kernel_android_uapi_linux",
2333 "libc_kernel_android_scsi",
2334 "libc_asm_arm",
2335 "libc_asm_arm64",
2336 "libc_asm_x86",
2337 "libc_asm_x86_64",
2338 ],
Dan Albert4238a352016-06-28 11:18:05 -07002339}
2340
Dan Albertdf31aff2016-10-06 15:50:41 -07002341ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002342 name: "libstdc++",
Dan Albertdf31aff2016-10-06 15:50:41 -07002343 symbol_file: "libstdc++.map.txt",
2344 first_version: "9",
2345}
2346
Dan Willemsenca056d72018-01-08 14:00:24 -08002347// Export these headers for toolbox to process
2348filegroup {
2349 name: "kernel_input_headers",
2350 srcs: [
2351 "kernel/uapi/linux/input.h",
2352 "kernel/uapi/linux/input-event-codes.h",
2353 ],
Jingwen Chen19787b92021-02-22 03:06:20 -05002354 bazel_module: { bp2build_available: true },
Dan Willemsenca056d72018-01-08 14:00:24 -08002355}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002356
2357// Generate a syscall name / number mapping. These objects are text files
2358// (thanks to the -dD -E flags) and not binary files. They will then be
2359// consumed by the genseccomp.py script and converted into C++ code.
2360cc_defaults {
2361 name: "libseccomp_gen_syscall_nrs_defaults",
2362 recovery_available: true,
2363 srcs: ["seccomp/gen_syscall_nrs.cpp"],
2364 cflags: [
2365 "-dD",
2366 "-E",
2367 "-Wall",
2368 "-Werror",
2369 "-nostdinc",
2370 ],
2371}
2372
2373cc_object {
2374 name: "libseccomp_gen_syscall_nrs_arm",
2375 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2376 local_include_dirs: [
2377 "kernel/uapi/asm-arm",
2378 "kernel/uapi",
2379 ],
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002380
2381 bazel_module: { bp2build_available: true },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002382}
2383
2384cc_object {
2385 name: "libseccomp_gen_syscall_nrs_arm64",
2386 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2387 local_include_dirs: [
2388 "kernel/uapi/asm-arm64",
2389 "kernel/uapi",
2390 ],
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002391
2392 bazel_module: { bp2build_available: true },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002393}
2394
2395cc_object {
2396 name: "libseccomp_gen_syscall_nrs_x86",
2397 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2398 srcs: ["seccomp/gen_syscall_nrs_x86.cpp"],
2399 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2400 local_include_dirs: [
2401 "kernel/uapi/asm-x86",
2402 "kernel/uapi",
2403 ],
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002404
2405 bazel_module: { bp2build_available: true },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002406}
2407
2408cc_object {
2409 name: "libseccomp_gen_syscall_nrs_x86_64",
2410 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2411 srcs: ["seccomp/gen_syscall_nrs_x86_64.cpp"],
2412 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2413 local_include_dirs: [
2414 "kernel/uapi/asm-x86",
2415 "kernel/uapi",
2416 ],
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002417
2418 bazel_module: { bp2build_available: true },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002419}
2420
Jingwen Chenca366332021-01-29 05:16:32 -05002421filegroup {
2422 name: "all_kernel_uapi_headers",
2423 srcs: ["kernel/uapi/**/*.h"],
Jingwen Chen19787b92021-02-22 03:06:20 -05002424 bazel_module: { bp2build_available: true },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002425}
2426
Martijn Coenen0c6de752019-01-02 12:52:51 +01002427
2428cc_genrule {
2429 name: "func_to_syscall_nrs",
2430 recovery_available: true,
2431 cmd: "$(location genfunctosyscallnrs) --out-dir=$(genDir) $(in)",
2432
2433 tools: [ "genfunctosyscallnrs" ],
2434
2435 srcs: [
2436 "SYSCALLS.TXT",
2437 ":libseccomp_gen_syscall_nrs_arm",
2438 ":libseccomp_gen_syscall_nrs_arm64",
Martijn Coenen0c6de752019-01-02 12:52:51 +01002439 ":libseccomp_gen_syscall_nrs_x86",
2440 ":libseccomp_gen_syscall_nrs_x86_64",
2441 ],
2442
2443 out: [
2444 "func_to_syscall_nrs.h",
2445 ],
2446}
2447
Victor Hsiehdbb86702020-06-15 09:29:07 -07002448// SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT = SECCOMP_BLOCKLIST_APP.txt - setresgid*
Martijn Coenenc3752be2019-01-09 16:19:57 +01002449genrule {
Victor Hsiehdbb86702020-06-15 09:29:07 -07002450 name: "generate_app_zygote_blocklist",
2451 out: ["SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT"],
2452 srcs: ["SECCOMP_BLOCKLIST_APP.TXT"],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002453 cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)",
2454}
2455
2456cc_genrule {
2457 name: "libseccomp_policy_app_zygote_sources",
2458 recovery_available: true,
2459 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
2460
2461 tools: [ "genseccomp" ],
2462
2463 srcs: [
2464 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002465 "SECCOMP_ALLOWLIST_COMMON.TXT",
2466 "SECCOMP_ALLOWLIST_APP.TXT",
2467 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002468 "SECCOMP_PRIORITY.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002469 ":generate_app_zygote_blocklist",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002470 ":libseccomp_gen_syscall_nrs_arm",
2471 ":libseccomp_gen_syscall_nrs_arm64",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002472 ":libseccomp_gen_syscall_nrs_x86",
2473 ":libseccomp_gen_syscall_nrs_x86_64",
2474 ],
2475
2476 out: [
2477 "arm64_app_zygote_policy.cpp",
2478 "arm_app_zygote_policy.cpp",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002479 "x86_64_app_zygote_policy.cpp",
2480 "x86_app_zygote_policy.cpp",
2481 ],
2482}
2483
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002484cc_genrule {
2485 name: "libseccomp_policy_app_sources",
2486 recovery_available: true,
2487 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
2488
2489 tools: [ "genseccomp" ],
2490
2491 srcs: [
2492 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002493 "SECCOMP_ALLOWLIST_COMMON.TXT",
2494 "SECCOMP_ALLOWLIST_APP.TXT",
2495 "SECCOMP_BLOCKLIST_COMMON.TXT",
2496 "SECCOMP_BLOCKLIST_APP.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002497 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002498 ":libseccomp_gen_syscall_nrs_arm",
2499 ":libseccomp_gen_syscall_nrs_arm64",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002500 ":libseccomp_gen_syscall_nrs_x86",
2501 ":libseccomp_gen_syscall_nrs_x86_64",
2502 ],
2503
2504 out: [
2505 "arm64_app_policy.cpp",
2506 "arm_app_policy.cpp",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002507 "x86_64_app_policy.cpp",
2508 "x86_app_policy.cpp",
2509 ],
2510}
2511
2512cc_genrule {
2513 name: "libseccomp_policy_system_sources",
2514 recovery_available: true,
2515 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
2516
2517 tools: [ "genseccomp" ],
2518
2519 srcs: [
2520 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002521 "SECCOMP_ALLOWLIST_COMMON.TXT",
2522 "SECCOMP_ALLOWLIST_SYSTEM.TXT",
2523 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002524 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002525 ":libseccomp_gen_syscall_nrs_arm",
2526 ":libseccomp_gen_syscall_nrs_arm64",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002527 ":libseccomp_gen_syscall_nrs_x86",
2528 ":libseccomp_gen_syscall_nrs_x86_64",
2529 ],
2530
2531 out: [
2532 "arm64_system_policy.cpp",
2533 "arm_system_policy.cpp",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002534 "x86_64_system_policy.cpp",
2535 "x86_system_policy.cpp",
2536 ],
2537}
2538
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002539cc_library {
2540 name: "libseccomp_policy",
2541 recovery_available: true,
Martijn Coenend269d9b2018-11-08 16:41:42 +01002542 generated_headers: ["func_to_syscall_nrs"],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002543 generated_sources: [
2544 "libseccomp_policy_app_sources",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002545 "libseccomp_policy_app_zygote_sources",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002546 "libseccomp_policy_system_sources",
2547 ],
2548
2549 srcs: [
2550 "seccomp/seccomp_policy.cpp",
2551 ],
2552
2553 export_include_dirs: ["seccomp/include"],
2554 cflags: [
2555 "-Wall",
2556 "-Werror",
2557 ],
2558 shared: {
2559 shared_libs: ["libbase"],
2560 },
2561 static: {
2562 static_libs: ["libbase"],
2563 },
2564}
Christopher Ferrisfc26d712019-02-27 18:07:55 -08002565
Colin Cross048f24e2021-09-01 17:26:00 -07002566cc_library_host_static {
2567 name: "libfts",
2568 srcs: [
2569 "bionic/fts.c",
2570 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
2571 ],
2572 export_include_dirs: ["fts/include"],
2573 local_include_dirs: [
2574 "private",
2575 "upstream-openbsd/android/include",
2576 ],
2577 cflags: [
2578 "-include openbsd-compat.h",
2579 "-Wno-unused-parameter",
2580 ],
2581 enabled: false,
2582 target: {
2583 musl: {
2584 enabled: true,
2585 },
2586 },
Colin Cross2a9843f2022-01-13 12:26:30 -08002587 stl: "none",
2588}
2589
2590cc_library_host_static {
2591 name: "libexecinfo",
2592 visibility: ["//external/musl"],
2593 srcs: ["bionic/execinfo.cpp"],
2594 export_include_dirs: ["execinfo/include"],
2595 local_include_dirs: ["private"],
2596 enabled: false,
2597 target: {
2598 musl: {
2599 enabled: true,
2600 system_shared_libs: [],
2601 header_libs: ["libc_musl_headers"],
2602 },
2603 },
2604 stl: "none",
Colin Cross048f24e2021-09-01 17:26:00 -07002605}
2606
Colin Cross9da85fa2022-01-24 18:20:05 -08002607cc_library_host_static {
2608 name: "libb64",
2609 visibility: ["//external/musl"],
2610 srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
2611 export_include_dirs: ["b64/include"],
2612 local_include_dirs: [
2613 "private",
2614 "upstream-openbsd/android/include",
2615 ],
2616 cflags: [
2617 "-include openbsd-compat.h",
2618 ],
2619 enabled: false,
2620 target: {
2621 musl: {
2622 enabled: true,
2623 system_shared_libs: [],
2624 header_libs: ["libc_musl_headers"],
2625 },
2626 },
2627 stl: "none",
2628}
2629
Colin Cross9d4a56e2022-02-03 10:20:32 -08002630// Export kernel uapi headers to be used in the musl sysroot.
2631// Also include the execinfo headers for the libexecinfo and the
2632// b64 headers for libb64 embedded in musl libc.
2633cc_genrule {
2634 name: "libc_musl_sysroot_bionic_headers",
2635 visibility: ["//external/musl"],
2636 host_supported: true,
2637 device_supported: false,
2638 enabled: false,
2639 target: {
2640 musl: {
2641 enabled: true,
2642 },
2643 },
2644 srcs: [
2645 "kernel/uapi/**/*.h",
2646 "kernel/android/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002647 "execinfo/include/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002648 "b64/include/**/*.h",
Colin Crossaeef9f02022-02-07 21:01:26 -08002649
Colin Crossaeef9f02022-02-07 21:01:26 -08002650 "NOTICE",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002651
2652 ":libc_musl_sysroot_bionic_arch_headers",
2653 ],
2654 out: ["libc_musl_sysroot_bionic_headers.zip"],
2655 tools: [
2656 "soong_zip",
2657 "merge_zips",
2658 "zip2zip",
2659 ],
Colin Crossaeef9f02022-02-07 21:01:26 -08002660 cmd: "BIONIC_LIBC_DIR=$$(dirname $(location NOTICE)) && " +
2661 "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
Colin Crossad33d022022-02-25 18:27:04 -08002662 // NOTICE
2663 " -j -f $(location NOTICE) " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002664 // headers
2665 " -P include " +
Colin Crossaeef9f02022-02-07 21:01:26 -08002666 " -C $${BIONIC_LIBC_DIR}/kernel/uapi " +
2667 " -D $${BIONIC_LIBC_DIR}/kernel/uapi " +
2668 " -C $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2669 " -D $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2670 " -C $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2671 " -D $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2672 " -C $${BIONIC_LIBC_DIR}/execinfo/include " +
2673 " -D $${BIONIC_LIBC_DIR}/execinfo/include " +
2674 " -C $${BIONIC_LIBC_DIR}/b64/include " +
2675 " -D $${BIONIC_LIBC_DIR}/b64/include " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002676 " && " +
Colin Crossad33d022022-02-25 18:27:04 -08002677 "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(genDir)/sysroot-renamed.zip " +
Colin Cross1c0a7a02022-08-11 12:22:26 -07002678 " -x **/BUILD " +
Colin Crossad33d022022-02-25 18:27:04 -08002679 " include/**/*:include/ " +
2680 " NOTICE:NOTICE.bionic " +
2681 " && " +
2682 "$(location merge_zips) $(out) $(location :libc_musl_sysroot_bionic_arch_headers) $(genDir)/sysroot-renamed.zip",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002683}
2684
2685// The architecture-specific bits have to be handled separately because the label varies based
2686// on architecture, which prevents using $(locations) to find them and requires using $(in)
2687// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
2688// genrule.
2689cc_genrule {
2690 name: "libc_musl_sysroot_bionic_arch_headers",
2691 visibility: ["//visibility:private"],
2692 host_supported: true,
2693 device_supported: false,
2694 enabled: false,
2695 target: {
2696 musl: {
2697 enabled: true,
2698 },
2699 },
2700 arch: {
2701 arm: {
2702 srcs: ["kernel/uapi/asm-arm/**/*.h"],
2703 },
2704 arm64: {
2705 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
2706 },
2707 x86: {
2708 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2709 },
2710 x86_64: {
2711 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2712 },
2713 },
2714 out: ["libc_musl_sysroot_bionic_arch_headers.zip"],
2715 tools: ["soong_zip"],
2716 cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/asm -j -D $$(dirname $${includes[0]})",
2717}