blob: d9b3658d6c9f41c4e53edbf140662a95751a741c [file] [log] [blame]
Bob Badouraa7d8352021-02-19 13:06:22 -08001package {
2 default_applicable_licenses: ["bionic_libc_license"],
3}
4
5license {
6 name: "bionic_libc_license",
7 visibility: [":__subpackages__"],
8 license_kinds: [
9 "SPDX-license-identifier-Apache-2.0",
10 "SPDX-license-identifier-BSD",
11 "SPDX-license-identifier-ISC",
12 "SPDX-license-identifier-MIT",
13 "legacy_notice",
14 "legacy_unencumbered",
15 ],
16 license_text: [
17 "NOTICE",
18 ],
19}
20
Elliott Hughes53cf3482016-08-09 13:06:41 -070021libc_common_flags = [
22 "-D_LIBC=1",
Elliott Hughes25f17e42018-02-12 15:48:01 -080023 "-D__BIONIC_LP32_USE_STAT64",
Elliott Hughes53cf3482016-08-09 13:06:41 -070024 "-Wall",
25 "-Wextra",
26 "-Wunused",
Elliott Hughes3048a362018-01-19 17:58:07 -080027 "-Wno-char-subscripts",
Elliott Hughes53cf3482016-08-09 13:06:41 -070028 "-Wno-deprecated-declarations",
Elliott Hughesb348d5c2017-07-24 16:53:11 -070029 "-Wno-gcc-compat",
Elliott Hughes8e547bd2016-08-16 15:57:47 -070030 "-Wframe-larger-than=2048",
Christopher Ferris1de7a482023-09-12 11:06:29 -070031 "-Wno-reorder-init-list",
Elliott Hughes53cf3482016-08-09 13:06:41 -070032
33 // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
34 "-Werror=pointer-to-int-cast",
35 "-Werror=int-to-pointer-cast",
36 "-Werror=type-limits",
37 "-Werror",
Ryan Prichard8f419572018-02-20 17:09:05 -080038
39 // Clang's exit-time destructor registration hides __dso_handle, but
40 // __dso_handle needs to have default visibility on ARM32. See b/73485611.
41 "-Wexit-time-destructors",
Mitch Phillipsf3968e82020-01-31 19:57:04 -080042
Elliott Hughesa13d0662021-12-02 14:42:16 -080043 // We know clang does a lot of harm by rewriting what we've said, and sadly
44 // never see any good it does, so let's just ask it to do what we say...
45 // (The specific motivating example was clang turning a loop that would only
46 // ever touch 0, 1, or 2 bytes into a call to memset, which was never going
47 // to amortize.)
48 "-fno-builtin",
Elliott Hughes53cf3482016-08-09 13:06:41 -070049]
50
Dan Willemsen208ae172015-09-16 16:33:27 -070051// Define some common cflags
52// ========================================================
Colin Cross50c21ab2015-10-31 23:03:05 -070053cc_defaults {
54 name: "libc_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -080055 defaults: ["linux_bionic_supported"],
Christopher Ferrisb5425052024-04-23 17:15:39 -070056 cflags: libc_common_flags + [
57 "-DUSE_SCUDO",
58 ],
Elliott Hughes53cf3482016-08-09 13:06:41 -070059 asflags: libc_common_flags,
Colin Cross50c21ab2015-10-31 23:03:05 -070060 conlyflags: ["-std=gnu99"],
61 cppflags: [],
Christopher Ferris7a3681e2017-04-24 17:48:32 -070062 include_dirs: [
63 "bionic/libc/async_safe/include",
Peter Collingbourne5d3aa862020-09-11 15:05:17 -070064 "bionic/libc/platform",
Tom Cherry379ed1e2020-09-17 09:36:25 -070065 // For android_filesystem_config.h.
66 "system/core/libcutils/include",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070067 ],
Colin Cross50c21ab2015-10-31 23:03:05 -070068
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010069 header_libs: [
70 "libc_headers",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +000071 "liblog_headers", // needed by bionic/libc/async_safe/include
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010072 ],
73 export_header_lib_headers: [
74 "libc_headers",
75 ],
Mitch Phillipsf3968e82020-01-31 19:57:04 -080076
Colin Cross50c21ab2015-10-31 23:03:05 -070077 stl: "none",
78 system_shared_libs: [],
Colin Cross27c43c52016-04-07 13:27:24 -070079 sanitize: {
Evgenii Stepanovbe551f52018-08-13 16:46:15 -070080 address: false,
81 integer_overflow: false,
Mitch Phillipsdfde0ee2019-05-01 14:26:13 -070082 // TODO(b/132640749): Fix broken fuzzer support.
83 fuzzer: false,
Colin Cross27c43c52016-04-07 13:27:24 -070084 },
Yifan Hong5a39cee2020-01-21 16:43:56 -080085 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -070086 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +090087 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +020088 native_bridge_supported: true,
Ivan Lozanof17fd1d2018-11-27 07:56:17 -080089
Peter Collingbournee99912f2019-11-01 15:37:00 -070090 product_variables: {
Evgenii Stepanov5a73e032020-04-29 14:59:44 -070091 malloc_zero_contents: {
92 cflags: ["-DSCUDO_ZERO_CONTENTS"],
93 },
94 malloc_pattern_fill_contents: {
95 cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
96 },
Christopher Ferrisb5425052024-04-23 17:15:39 -070097 malloc_low_memory: {
98 cflags: ["-UUSE_SCUDO"],
Steven Morelandfb65ee42020-07-31 00:18:38 +000099 },
Peter Collingbournee99912f2019-11-01 15:37:00 -0700100 },
Yi Kong9e33b762021-10-29 02:43:22 +0800101
102 lto: {
103 never: true,
104 },
Elliott Hughesc2043342023-07-20 20:24:09 +0000105
106 apex_available: ["com.android.runtime"],
Elliott Hughes7d136662023-10-27 15:40:32 -0700107
108 tidy_disabled_srcs: ["upstream-*/**/*.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700109}
110
Elliott Hughes788075a2024-06-18 12:25:37 +0000111// Workaround for b/24465209.
112// We're unlikely to be able to remove this before we just
113// remove ILP32 support completely.
114// Note that we also still have `pack_relocations: false`
115// for both libc and libm, even on LP64.
116// ========================================================
117cc_defaults {
118 name: "bug_24465209_workaround",
Elliott Hughesfeb94732024-06-18 19:44:18 +0000119 target: {
120 android_arm: {
Elliott Hughes788075a2024-06-18 12:25:37 +0000121 pack_relocations: false,
122 ldflags: ["-Wl,--hash-style=both"],
123 },
Elliott Hughesfeb94732024-06-18 19:44:18 +0000124 android_x86: {
Elliott Hughes788075a2024-06-18 12:25:37 +0000125 pack_relocations: false,
126 ldflags: ["-Wl,--hash-style=both"],
Elliott Hughesb4e02782024-06-21 11:35:18 +0000127 },
Elliott Hughes788075a2024-06-18 12:25:37 +0000128 },
129}
130
Elliott Hughes89aada12024-07-01 21:59:04 +0000131// Leave the symbols in the shared library so that stack unwinders can produce
132// meaningful name resolution. This is a bit more ugly than it sounds because
133// arm32 is a bit broken.
134// ========================================================
135cc_defaults {
136 name: "keep_symbols",
137 arch: {
138 arm: {
139 // arm32 does not produce complete exidx unwind information,
140 // so keep the .debug_frame which is relatively small and does
141 // include needed unwind information.
142 // See b/132992102 for details.
143 strip: {
144 keep_symbols_and_debug_frame: true,
145 },
146 },
147 arm64: {
148 strip: {
149 keep_symbols: true,
150 },
151 },
152 riscv64: {
153 strip: {
154 keep_symbols: true,
155 },
156 },
157 x86: {
158 strip: {
159 keep_symbols: true,
160 },
161 },
162 x86_64: {
163 strip: {
164 keep_symbols: true,
165 },
166 },
167 },
168}
169
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700170// Defaults for native allocator libs/includes to make it
171// easier to change.
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700172// ========================================================
173cc_defaults {
174 name: "libc_native_allocator_defaults",
175
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700176 whole_static_libs: [
Christopher Ferrisb5425052024-04-23 17:15:39 -0700177 "libscudo",
178 ],
179 cflags: [
180 "-DUSE_SCUDO",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700181 ],
Mitch Phillipsf3968e82020-01-31 19:57:04 -0800182 header_libs: ["gwp_asan_headers"],
Christopher Ferrisb5425052024-04-23 17:15:39 -0700183 product_variables: {
184 malloc_low_memory: {
185 cflags: ["-UUSE_SCUDO"],
186 whole_static_libs: [
187 "libjemalloc5",
188 "libc_jemalloc_wrapper",
189 ],
190 exclude_static_libs: [
191 "libscudo",
192 ],
193 },
194 },
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700195}
196
197// Functions not implemented by jemalloc directly, or that need to
198// be modified for Android.
199cc_library_static {
200 name: "libc_jemalloc_wrapper",
201 defaults: ["libc_defaults"],
202 srcs: ["bionic/jemalloc_wrapper.cpp"],
203 cflags: ["-fvisibility=hidden"],
204
Christopher Ferris4df29ed2020-01-24 18:06:42 -0800205 // Used to pull in the jemalloc include directory so that if the
206 // library is removed, the include directory is also removed.
207 static_libs: ["libjemalloc5"],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700208}
209
Dan Willemsen208ae172015-09-16 16:33:27 -0700210// ========================================================
Ryan Prichard249757b2019-11-01 17:18:28 -0700211// libc_bootstrap.a - -fno-stack-protector and -ffreestanding
Dan Willemsen208ae172015-09-16 16:33:27 -0700212// ========================================================
213//
Ryan Prichard249757b2019-11-01 17:18:28 -0700214// Code that implements the stack protector (or that runs before TLS has been set up) needs to be
215// compiled with -fno-stack-protector, since it accesses the stack canary TLS slot. In the linker,
216// some of this code runs before ifunc resolvers have made string.h functions work, so compile with
217// -ffreestanding.
Dan Willemsen208ae172015-09-16 16:33:27 -0700218
219cc_library_static {
220
Colin Crossa3f9fca2016-01-11 13:20:55 -0800221 srcs: [
222 "bionic/__libc_init_main_thread.cpp",
223 "bionic/__stack_chk_fail.cpp",
Ryan Prichard249757b2019-11-01 17:18:28 -0700224 "bionic/bionic_call_ifunc_resolver.cpp",
225 "bionic/getauxval.cpp",
Colin Crossa3f9fca2016-01-11 13:20:55 -0800226 ],
227 arch: {
228 arm64: {
229 srcs: ["arch-arm64/bionic/__set_tls.c"],
230 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000231 riscv64: {
232 srcs: ["arch-riscv64/bionic/__set_tls.c"],
233 },
Colin Crossa3f9fca2016-01-11 13:20:55 -0800234 x86: {
Ryan Prichard27475b52018-05-17 17:14:18 -0700235 srcs: [
236 "arch-x86/bionic/__libc_init_sysinfo.cpp",
Pirama Arumuga Nainar7b89be72021-02-12 15:09:49 -0800237 "arch-x86/bionic/__libc_int0x80.S",
Ryan Prichard27475b52018-05-17 17:14:18 -0700238 "arch-x86/bionic/__set_tls.cpp",
239 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800240 },
241 x86_64: {
242 srcs: ["arch-x86_64/bionic/__set_tls.c"],
243 },
244 },
245
Colin Cross50c21ab2015-10-31 23:03:05 -0700246 defaults: ["libc_defaults"],
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000247 cflags: [
248 "-fno-stack-protector",
249 "-ffreestanding",
250 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700251 name: "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -0700252}
253
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800254filegroup {
255 name: "elf_note_sources",
256 srcs: ["bionic/elf_note.cpp"],
257}
258
Ryan Prichard249757b2019-11-01 17:18:28 -0700259// libc_init_static.cpp and libc_init_dynamic.cpp need to be built without stack protector.
260// libc_init_static.cpp sets up TLS for static executables, and libc_init_dynamic.cpp initializes
261// the stack protector global variable.
Colin Crossa3f9fca2016-01-11 13:20:55 -0800262
263cc_library_static {
264 name: "libc_init_static",
265 defaults: ["libc_defaults"],
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800266 srcs: [
267 "bionic/libc_init_static.cpp",
268 ":elf_note_sources",
269 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700270 cflags: [
271 "-fno-stack-protector",
272
273 // Compile libc_init_static.cpp with -ffreestanding, because some of its code is called
274 // from the linker before ifunc resolvers have made string.h functions available.
275 "-ffreestanding",
276 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800277}
278
Stephen Cranef4b1cbd2017-05-09 14:27:43 -0700279cc_library_static {
280 name: "libc_init_dynamic",
281 defaults: ["libc_defaults"],
282 srcs: ["bionic/libc_init_dynamic.cpp"],
283 cflags: ["-fno-stack-protector"],
284}
Colin Crossa3f9fca2016-01-11 13:20:55 -0800285
Dan Willemsen208ae172015-09-16 16:33:27 -0700286// ========================================================
287// libc_tzcode.a - upstream 'tzcode' code
288// ========================================================
289
290cc_library_static {
291
Colin Cross50c21ab2015-10-31 23:03:05 -0700292 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700293 srcs: [
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800294 "tzcode/**/*.c",
Elliott Hughes0e8616a2017-04-11 14:44:51 -0700295 "tzcode/bionic.cpp",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700296 // tzcode doesn't include strptime, so we use a fork of the
297 // OpenBSD code which needs this global data.
Elliott Hughesd3627a42022-12-06 22:24:27 +0000298 "upstream-openbsd/lib/libc/locale/_def_time.c",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700299 // tzcode doesn't include wcsftime, so we use the FreeBSD code.
300 "upstream-freebsd/lib/libc/locale/wcsftime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700301 ],
302
Colin Cross50c21ab2015-10-31 23:03:05 -0700303 cflags: [
Dan Willemsen268a6732015-10-15 14:49:45 -0700304 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700305 // Don't use ridiculous amounts of stack.
306 "-DALL_STATE",
307 // Include tzsetwall, timelocal, timegm, time2posix, and posix2time.
308 "-DSTD_INSPIRED",
Colin Crossa35d23d2015-11-19 13:32:49 -0800309 // Obviously, we want to be thread-safe.
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000310 "-DTHREAD_SAFE=1",
Dan Willemsen208ae172015-09-16 16:33:27 -0700311 // The name of the tm_gmtoff field in our struct tm.
312 "-DTM_GMTOFF=tm_gmtoff",
Elliott Hughes31fc69f2023-06-20 15:36:11 -0700313 // Android uses a system property instead of /etc/localtime, so make callers crash.
Almaz Mingaleeva52a0da2022-02-28 16:55:50 +0000314 "-DTZDEFAULT=NULL",
Dan Willemsen208ae172015-09-16 16:33:27 -0700315 // Where we store our tzdata.
Colin Cross7b294952016-09-29 14:08:13 -0700316 "-DTZDIR=\"/system/usr/share/zoneinfo\"",
Elliott Hughes0a610d02016-07-29 14:04:17 -0700317 // Include `tzname`, `timezone`, and `daylight` globals.
318 "-DHAVE_POSIX_DECLS=0",
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000319 "-DUSG_COMPAT=2",
320 "-DHAVE_TZNAME=2",
321 // stdbool.h is available
322 "-DHAVE_STDBOOL_H",
Colin Crossa35d23d2015-11-19 13:32:49 -0800323 // Use the empty string (instead of " ") as the timezone abbreviation
324 // fallback.
Colin Cross7b294952016-09-29 14:08:13 -0700325 "-DWILDABBR=\"\"",
Dan Willemsen208ae172015-09-16 16:33:27 -0700326 "-Dlint",
327 ],
328
Elliott Hughes2bd43162023-06-15 13:17:08 -0700329 local_include_dirs: [
330 "tzcode/",
331 "upstream-freebsd/android/include",
332 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700333 name: "libc_tzcode",
Dan Willemsen208ae172015-09-16 16:33:27 -0700334}
335
336// ========================================================
337// libc_dns.a - modified NetBSD DNS code
338// ========================================================
339
340cc_library_static {
341
Colin Cross50c21ab2015-10-31 23:03:05 -0700342 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700343 srcs: [
Elliott Hughesd0bbfa82021-04-08 11:58:51 -0700344 "dns/**/*.c*",
Dan Willemsen208ae172015-09-16 16:33:27 -0700345
346 "upstream-netbsd/lib/libc/isc/ev_streams.c",
347 "upstream-netbsd/lib/libc/isc/ev_timers.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700348 ],
349
Colin Cross50c21ab2015-10-31 23:03:05 -0700350 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700351 "-DANDROID_CHANGES",
352 "-DINET6",
Dan Willemsen208ae172015-09-16 16:33:27 -0700353 "-Wno-unused-parameter",
354 "-include netbsd-compat.h",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700355 "-Wframe-larger-than=66000",
Dan Willemsen208ae172015-09-16 16:33:27 -0700356 ],
357
Dan Willemsen208ae172015-09-16 16:33:27 -0700358 local_include_dirs: [
359 "dns/include",
360 "private",
361 "upstream-netbsd/lib/libc/include",
362 "upstream-netbsd/android/include",
363 ],
364
365 name: "libc_dns",
Dan Willemsen208ae172015-09-16 16:33:27 -0700366}
367
368// ========================================================
369// libc_freebsd.a - upstream FreeBSD C library code
370// ========================================================
371//
372// These files are built with the freebsd-compat.h header file
373// automatically included.
374
375cc_library_static {
Elliott Hughesc2043342023-07-20 20:24:09 +0000376 name: "libc_freebsd_ldexp",
377 defaults: ["libc_defaults"],
378 cflags: ["-Dscalbn=ldexp"],
379 srcs: [":libc_ldexp_srcs"],
380}
381
382cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700383 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700384 srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700385 "upstream-freebsd/lib/libc/stdlib/getopt_long.c",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700386 "upstream-freebsd/lib/libc/stdlib/hcreate.c",
387 "upstream-freebsd/lib/libc/stdlib/hcreate_r.c",
388 "upstream-freebsd/lib/libc/stdlib/hdestroy_r.c",
389 "upstream-freebsd/lib/libc/stdlib/hsearch_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700390 "upstream-freebsd/lib/libc/stdlib/qsort.c",
Elliott Hughes5bae5722024-07-30 12:47:33 -0400391 "upstream-freebsd/lib/libc/stdlib/qsort_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700392 "upstream-freebsd/lib/libc/stdlib/quick_exit.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700393 "upstream-freebsd/lib/libc/string/wcpcpy.c",
394 "upstream-freebsd/lib/libc/string/wcpncpy.c",
395 "upstream-freebsd/lib/libc/string/wcscasecmp.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700396 "upstream-freebsd/lib/libc/string/wcscat.c",
397 "upstream-freebsd/lib/libc/string/wcschr.c",
398 "upstream-freebsd/lib/libc/string/wcscmp.c",
399 "upstream-freebsd/lib/libc/string/wcscpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700400 "upstream-freebsd/lib/libc/string/wcscspn.c",
401 "upstream-freebsd/lib/libc/string/wcsdup.c",
402 "upstream-freebsd/lib/libc/string/wcslcat.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700403 "upstream-freebsd/lib/libc/string/wcslen.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700404 "upstream-freebsd/lib/libc/string/wcsncasecmp.c",
405 "upstream-freebsd/lib/libc/string/wcsncat.c",
406 "upstream-freebsd/lib/libc/string/wcsncmp.c",
407 "upstream-freebsd/lib/libc/string/wcsncpy.c",
408 "upstream-freebsd/lib/libc/string/wcsnlen.c",
409 "upstream-freebsd/lib/libc/string/wcspbrk.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700410 "upstream-freebsd/lib/libc/string/wcsrchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700411 "upstream-freebsd/lib/libc/string/wcsspn.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700412 "upstream-freebsd/lib/libc/string/wcsstr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700413 "upstream-freebsd/lib/libc/string/wcstok.c",
414 "upstream-freebsd/lib/libc/string/wmemchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700415 "upstream-freebsd/lib/libc/string/wmemcmp.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700416 "upstream-freebsd/lib/libc/string/wmemcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700417 "upstream-freebsd/lib/libc/string/wmemmove.c",
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800418 "upstream-freebsd/lib/libc/string/wmemset.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700419 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700420
Colin Cross50c21ab2015-10-31 23:03:05 -0700421 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700422 "-Wno-sign-compare",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700423 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700424 "-include freebsd-compat.h",
425 ],
426
Dan Willemsen208ae172015-09-16 16:33:27 -0700427 local_include_dirs: [
428 "upstream-freebsd/android/include",
429 ],
430
431 name: "libc_freebsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700432}
433
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700434cc_library_static {
435 defaults: ["libc_defaults"],
436 srcs: [
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700437 "upstream-freebsd/lib/libc/gen/glob.c",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700438 ],
439
440 cflags: [
441 "-Wno-sign-compare",
442 "-include freebsd-compat.h",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700443 "-Wframe-larger-than=66000",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700444 ],
445
446 local_include_dirs: [
447 "upstream-freebsd/android/include",
448 ],
449
450 name: "libc_freebsd_large_stack",
451}
452
Dan Willemsen208ae172015-09-16 16:33:27 -0700453// ========================================================
454// libc_netbsd.a - upstream NetBSD C library code
455// ========================================================
456//
457// These files are built with the netbsd-compat.h header file
458// automatically included.
459
460cc_library_static {
461
Colin Cross50c21ab2015-10-31 23:03:05 -0700462 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700463 srcs: [
464 "upstream-netbsd/common/lib/libc/stdlib/random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700465 "upstream-netbsd/lib/libc/gen/nice.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700466 "upstream-netbsd/lib/libc/gen/psignal.c",
467 "upstream-netbsd/lib/libc/gen/utime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700468 "upstream-netbsd/lib/libc/inet/nsap_addr.c",
469 "upstream-netbsd/lib/libc/regex/regcomp.c",
470 "upstream-netbsd/lib/libc/regex/regerror.c",
471 "upstream-netbsd/lib/libc/regex/regexec.c",
472 "upstream-netbsd/lib/libc/regex/regfree.c",
473 "upstream-netbsd/lib/libc/stdlib/bsearch.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700474 "upstream-netbsd/lib/libc/stdlib/drand48.c",
475 "upstream-netbsd/lib/libc/stdlib/erand48.c",
476 "upstream-netbsd/lib/libc/stdlib/jrand48.c",
477 "upstream-netbsd/lib/libc/stdlib/lcong48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700478 "upstream-netbsd/lib/libc/stdlib/lrand48.c",
479 "upstream-netbsd/lib/libc/stdlib/mrand48.c",
480 "upstream-netbsd/lib/libc/stdlib/nrand48.c",
481 "upstream-netbsd/lib/libc/stdlib/_rand48.c",
482 "upstream-netbsd/lib/libc/stdlib/rand_r.c",
483 "upstream-netbsd/lib/libc/stdlib/reallocarr.c",
484 "upstream-netbsd/lib/libc/stdlib/seed48.c",
485 "upstream-netbsd/lib/libc/stdlib/srand48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700486 ],
487 multilib: {
488 lib32: {
489 // LP32 cruft
490 srcs: ["upstream-netbsd/common/lib/libc/hash/sha1/sha1.c"],
491 },
492 },
Colin Cross50c21ab2015-10-31 23:03:05 -0700493 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700494 "-Wno-sign-compare",
Dan Willemsen879cec22016-02-29 10:37:56 -0800495 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700496 "-DPOSIX_MISTAKE",
497 "-include netbsd-compat.h",
498 ],
499
Dan Willemsen208ae172015-09-16 16:33:27 -0700500 local_include_dirs: [
501 "upstream-netbsd/android/include",
502 "upstream-netbsd/lib/libc/include",
503 ],
504
505 name: "libc_netbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700506}
507
508// ========================================================
Elliott Hughes968adf92024-02-08 13:15:53 -0800509// libc_openbsd.a - upstream OpenBSD C library code
Dan Willemsen208ae172015-09-16 16:33:27 -0700510// ========================================================
511//
512// These files are built with the openbsd-compat.h header file
513// automatically included.
Dan Willemsen208ae172015-09-16 16:33:27 -0700514cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700515 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700516 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800517 "upstream-openbsd/lib/libc/crypt/arc4random.c",
518 "upstream-openbsd/lib/libc/crypt/arc4random_uniform.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700519 "upstream-openbsd/lib/libc/gen/alarm.c",
520 "upstream-openbsd/lib/libc/gen/ctype_.c",
521 "upstream-openbsd/lib/libc/gen/daemon.c",
522 "upstream-openbsd/lib/libc/gen/err.c",
523 "upstream-openbsd/lib/libc/gen/errx.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700524 "upstream-openbsd/lib/libc/gen/fnmatch.c",
525 "upstream-openbsd/lib/libc/gen/ftok.c",
526 "upstream-openbsd/lib/libc/gen/getprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700527 "upstream-openbsd/lib/libc/gen/setprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700528 "upstream-openbsd/lib/libc/gen/verr.c",
529 "upstream-openbsd/lib/libc/gen/verrx.c",
530 "upstream-openbsd/lib/libc/gen/vwarn.c",
531 "upstream-openbsd/lib/libc/gen/vwarnx.c",
532 "upstream-openbsd/lib/libc/gen/warn.c",
533 "upstream-openbsd/lib/libc/gen/warnx.c",
534 "upstream-openbsd/lib/libc/locale/btowc.c",
535 "upstream-openbsd/lib/libc/locale/mbrlen.c",
536 "upstream-openbsd/lib/libc/locale/mbstowcs.c",
537 "upstream-openbsd/lib/libc/locale/mbtowc.c",
538 "upstream-openbsd/lib/libc/locale/wcscoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700539 "upstream-openbsd/lib/libc/locale/wcstombs.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700540 "upstream-openbsd/lib/libc/locale/wcsxfrm.c",
541 "upstream-openbsd/lib/libc/locale/wctob.c",
542 "upstream-openbsd/lib/libc/locale/wctomb.c",
Elliott Hughes26fda772016-04-06 11:56:41 -0700543 "upstream-openbsd/lib/libc/net/base64.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700544 "upstream-openbsd/lib/libc/net/htonl.c",
545 "upstream-openbsd/lib/libc/net/htons.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700546 "upstream-openbsd/lib/libc/net/inet_lnaof.c",
547 "upstream-openbsd/lib/libc/net/inet_makeaddr.c",
548 "upstream-openbsd/lib/libc/net/inet_netof.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700549 "upstream-openbsd/lib/libc/net/inet_ntoa.c",
550 "upstream-openbsd/lib/libc/net/inet_ntop.c",
551 "upstream-openbsd/lib/libc/net/inet_pton.c",
552 "upstream-openbsd/lib/libc/net/ntohl.c",
553 "upstream-openbsd/lib/libc/net/ntohs.c",
Colin Cross8ce38af2016-01-19 12:50:20 -0800554 "upstream-openbsd/lib/libc/net/res_random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700555 "upstream-openbsd/lib/libc/stdio/fgetln.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700556 "upstream-openbsd/lib/libc/stdio/fgetwc.c",
557 "upstream-openbsd/lib/libc/stdio/fgetws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700558 "upstream-openbsd/lib/libc/stdio/flags.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700559 "upstream-openbsd/lib/libc/stdio/fputwc.c",
560 "upstream-openbsd/lib/libc/stdio/fputws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700561 "upstream-openbsd/lib/libc/stdio/fvwrite.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700562 "upstream-openbsd/lib/libc/stdio/fwide.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700563 "upstream-openbsd/lib/libc/stdio/getdelim.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700564 "upstream-openbsd/lib/libc/stdio/gets.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700565 "upstream-openbsd/lib/libc/stdio/makebuf.c",
566 "upstream-openbsd/lib/libc/stdio/mktemp.c",
567 "upstream-openbsd/lib/libc/stdio/open_memstream.c",
568 "upstream-openbsd/lib/libc/stdio/open_wmemstream.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700569 "upstream-openbsd/lib/libc/stdio/rget.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700570 "upstream-openbsd/lib/libc/stdio/setvbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700571 "upstream-openbsd/lib/libc/stdio/ungetc.c",
572 "upstream-openbsd/lib/libc/stdio/ungetwc.c",
573 "upstream-openbsd/lib/libc/stdio/vasprintf.c",
574 "upstream-openbsd/lib/libc/stdio/vdprintf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700575 "upstream-openbsd/lib/libc/stdio/vsscanf.c",
576 "upstream-openbsd/lib/libc/stdio/vswprintf.c",
577 "upstream-openbsd/lib/libc/stdio/vswscanf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700578 "upstream-openbsd/lib/libc/stdio/wbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700579 "upstream-openbsd/lib/libc/stdio/wsetup.c",
580 "upstream-openbsd/lib/libc/stdlib/abs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800581 "upstream-openbsd/lib/libc/stdlib/div.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700582 "upstream-openbsd/lib/libc/stdlib/getenv.c",
Colin Crossb8396102016-04-07 13:24:50 -0700583 "upstream-openbsd/lib/libc/stdlib/getsubopt.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700584 "upstream-openbsd/lib/libc/stdlib/insque.c",
585 "upstream-openbsd/lib/libc/stdlib/imaxabs.c",
586 "upstream-openbsd/lib/libc/stdlib/imaxdiv.c",
587 "upstream-openbsd/lib/libc/stdlib/labs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800588 "upstream-openbsd/lib/libc/stdlib/ldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700589 "upstream-openbsd/lib/libc/stdlib/llabs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800590 "upstream-openbsd/lib/libc/stdlib/lldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700591 "upstream-openbsd/lib/libc/stdlib/lsearch.c",
Elliott Hughes26b06072020-07-31 11:00:10 -0700592 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700593 "upstream-openbsd/lib/libc/stdlib/remque.c",
594 "upstream-openbsd/lib/libc/stdlib/setenv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700595 "upstream-openbsd/lib/libc/stdlib/tfind.c",
596 "upstream-openbsd/lib/libc/stdlib/tsearch.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800597 "upstream-openbsd/lib/libc/string/memccpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700598 "upstream-openbsd/lib/libc/string/strcasecmp.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800599 "upstream-openbsd/lib/libc/string/strcasestr.c",
600 "upstream-openbsd/lib/libc/string/strcoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700601 "upstream-openbsd/lib/libc/string/strcspn.c",
602 "upstream-openbsd/lib/libc/string/strdup.c",
603 "upstream-openbsd/lib/libc/string/strndup.c",
604 "upstream-openbsd/lib/libc/string/strpbrk.c",
605 "upstream-openbsd/lib/libc/string/strsep.c",
606 "upstream-openbsd/lib/libc/string/strspn.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700607 "upstream-openbsd/lib/libc/string/strtok.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800608 "upstream-openbsd/lib/libc/string/strxfrm.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700609 "upstream-openbsd/lib/libc/string/wcslcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700610 "upstream-openbsd/lib/libc/string/wcswidth.c",
Colin Cross69bcb8b2021-09-08 13:24:16 -0700611
Elliott Hughesd4c61182024-08-16 17:31:24 -0400612 // These files are originally from OpenBSD,
613 // and benefit from being compiled with openbsd-compat.h.
614 // TODO: clean them up instead.
Colin Cross69bcb8b2021-09-08 13:24:16 -0700615 "bionic/fts.c",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400616 "stdio/vfprintf.cpp",
617 "stdio/vfwprintf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700618 ],
619
Elliott Hughes7d136662023-10-27 15:40:32 -0700620 // Each architecture has optimized versions of some routines,
621 // and only includes the portable C versions of ones it's missing.
Dan Willemsen208ae172015-09-16 16:33:27 -0700622 arch: {
623 arm: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700624 srcs: [
625 "upstream-openbsd/lib/libc/string/memchr.c",
626 "upstream-openbsd/lib/libc/string/memrchr.c",
627 "upstream-openbsd/lib/libc/string/stpncpy.c",
628 "upstream-openbsd/lib/libc/string/strlcat.c",
629 "upstream-openbsd/lib/libc/string/strlcpy.c",
630 "upstream-openbsd/lib/libc/string/strncat.c",
631 "upstream-openbsd/lib/libc/string/strncmp.c",
632 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700633 ],
634 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700635 arm64: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700636 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700637 "upstream-openbsd/lib/libc/string/strcat.c",
Elliott Hughesaefe9992023-11-08 12:04:41 -0800638 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700639 "upstream-openbsd/lib/libc/string/strlcat.c",
640 "upstream-openbsd/lib/libc/string/strlcpy.c",
641 "upstream-openbsd/lib/libc/string/strncat.c",
642 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700643 ],
644 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000645 riscv64: {
646 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700647 "upstream-openbsd/lib/libc/string/memrchr.c",
648 "upstream-openbsd/lib/libc/string/stpncpy.c",
649 "upstream-openbsd/lib/libc/string/strlcat.c",
650 "upstream-openbsd/lib/libc/string/strlcpy.c",
Elliott Hughesebc19a92022-10-14 23:25:36 +0000651 ],
652 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700653 x86: {
Elliott Hughesaefe9992023-11-08 12:04:41 -0800654 srcs: [
655 // x86 has custom implementations of all of these.
656 ],
Elliott Hughes7d136662023-10-27 15:40:32 -0700657 },
658 x86_64: {
659 srcs: [
Colin Cross6ab8f892015-11-23 14:12:15 -0800660 "upstream-openbsd/lib/libc/string/memchr.c",
Colin Cross6ab8f892015-11-23 14:12:15 -0800661 "upstream-openbsd/lib/libc/string/memrchr.c",
Haibo Huangb9244ff2018-08-11 10:12:13 -0700662 "upstream-openbsd/lib/libc/string/strlcat.c",
663 "upstream-openbsd/lib/libc/string/strlcpy.c",
Colin Cross6ab8f892015-11-23 14:12:15 -0800664 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700665 },
666 },
667
Colin Cross50c21ab2015-10-31 23:03:05 -0700668 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700669 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700670 "-Wno-unused-parameter",
671 "-include openbsd-compat.h",
672 ],
673
Dan Willemsen208ae172015-09-16 16:33:27 -0700674 local_include_dirs: [
675 "private",
Elliott Hughes968adf92024-02-08 13:15:53 -0800676 "stdio",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400677 "upstream-openbsd/android/include/",
678 "upstream-openbsd/lib/libc/gdtoa/",
679 "upstream-openbsd/lib/libc/include/",
680 "upstream-openbsd/lib/libc/stdio/",
Dan Willemsen208ae172015-09-16 16:33:27 -0700681 ],
682
683 name: "libc_openbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700684}
685
Elliott Hughes968adf92024-02-08 13:15:53 -0800686cc_library_static {
687 name: "libc_openbsd_large_stack",
688 defaults: ["libc_defaults"],
689 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800690 "upstream-openbsd/lib/libc/string/memmem.c",
691 "upstream-openbsd/lib/libc/string/strstr.c",
692 ],
693 cflags: [
694 "-include openbsd-compat.h",
695 "-Wno-sign-compare",
696 "-Wframe-larger-than=5000",
697 ],
698
699 local_include_dirs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800700 "upstream-openbsd/android/include/",
Elliott Hughes968adf92024-02-08 13:15:53 -0800701 ],
702}
703
Dan Willemsen208ae172015-09-16 16:33:27 -0700704// ========================================================
705// libc_gdtoa.a - upstream OpenBSD C library gdtoa code
706// ========================================================
707//
708// These files are built with the openbsd-compat.h header file
709// automatically included.
710
711cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700712 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700713 srcs: [
714 "upstream-openbsd/android/gdtoa_support.cpp",
715 "upstream-openbsd/lib/libc/gdtoa/dmisc.c",
716 "upstream-openbsd/lib/libc/gdtoa/dtoa.c",
717 "upstream-openbsd/lib/libc/gdtoa/gdtoa.c",
718 "upstream-openbsd/lib/libc/gdtoa/gethex.c",
719 "upstream-openbsd/lib/libc/gdtoa/gmisc.c",
720 "upstream-openbsd/lib/libc/gdtoa/hd_init.c",
721 "upstream-openbsd/lib/libc/gdtoa/hdtoa.c",
722 "upstream-openbsd/lib/libc/gdtoa/hexnan.c",
723 "upstream-openbsd/lib/libc/gdtoa/ldtoa.c",
724 "upstream-openbsd/lib/libc/gdtoa/misc.c",
725 "upstream-openbsd/lib/libc/gdtoa/smisc.c",
726 "upstream-openbsd/lib/libc/gdtoa/strtod.c",
727 "upstream-openbsd/lib/libc/gdtoa/strtodg.c",
728 "upstream-openbsd/lib/libc/gdtoa/strtof.c",
729 "upstream-openbsd/lib/libc/gdtoa/strtord.c",
730 "upstream-openbsd/lib/libc/gdtoa/sum.c",
731 "upstream-openbsd/lib/libc/gdtoa/ulp.c",
732 ],
733 multilib: {
734 lib64: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800735 srcs: ["upstream-openbsd/lib/libc/gdtoa/strtorQ.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700736 },
737 },
738
Colin Cross50c21ab2015-10-31 23:03:05 -0700739 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700740 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700741 "-include openbsd-compat.h",
742 ],
743
Dan Willemsen208ae172015-09-16 16:33:27 -0700744 local_include_dirs: [
745 "private",
746 "upstream-openbsd/android/include",
747 "upstream-openbsd/lib/libc/include",
748 ],
749
750 name: "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -0700751}
752
753// ========================================================
Pierre-Clément Tosi467e58e2023-02-01 13:44:43 +0000754// libc_fortify.a - container for our FORTIFY
George Burgess IV6cb06872017-07-21 13:28:42 -0700755// implementation details
756// ========================================================
757cc_library_static {
758 defaults: ["libc_defaults"],
George Burgess IVd34b0a92017-07-25 11:43:39 -0700759 srcs: ["bionic/fortify.cpp"],
George Burgess IV6cb06872017-07-21 13:28:42 -0700760
761 name: "libc_fortify",
762
763 // Disable FORTIFY for the compilation of these, so we don't end up having
764 // FORTIFY silently call itself.
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800765 cflags: [
766 "-U_FORTIFY_SOURCE",
767 "-D__BIONIC_DECLARE_FORTIFY_HELPERS",
768 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700769
770 arch: {
771 arm: {
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800772 cflags: [
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800773 "-DRENAME___STRCAT_CHK",
774 "-DRENAME___STRCPY_CHK",
775 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700776 srcs: [
777 "arch-arm/generic/bionic/__memcpy_chk.S",
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800778
779 "arch-arm/cortex-a15/bionic/__strcat_chk.S",
780 "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
781
782 "arch-arm/cortex-a7/bionic/__strcat_chk.S",
783 "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
784
785 "arch-arm/cortex-a9/bionic/__strcat_chk.S",
786 "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
787
788 "arch-arm/krait/bionic/__strcat_chk.S",
789 "arch-arm/krait/bionic/__strcpy_chk.S",
790
791 "arch-arm/cortex-a53/bionic/__strcat_chk.S",
792 "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
793
Haibo Huang01bfd892018-12-03 15:05:16 -0800794 "arch-arm/cortex-a55/bionic/__strcat_chk.S",
795 "arch-arm/cortex-a55/bionic/__strcpy_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700796 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700797 },
798 arm64: {
799 srcs: [
Elliott Hughes023e4e72022-11-17 19:27:02 +0000800 "arch-arm64/string/__memcpy_chk.S",
801 "arch-arm64/string/__memset_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700802 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700803 },
caowenchengab457f92023-03-06 14:57:55 +0800804 riscv64: {
805 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000806 "arch-riscv64/string/__memset_chk.S",
807 "arch-riscv64/string/__memcpy_chk.S",
caowenchengab457f92023-03-06 14:57:55 +0800808 ],
809 },
George Burgess IV6cb06872017-07-21 13:28:42 -0700810 },
811}
812
813// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -0700814// libc_bionic.a - home-grown C library code
815// ========================================================
816
817cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700818 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700819 srcs: [
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800820 "bionic/NetdClientDispatch.cpp",
821 "bionic/__bionic_get_shell_path.cpp",
822 "bionic/__cmsg_nxthdr.cpp",
823 "bionic/__cxa_thread_atexit_impl.cpp",
824 "bionic/__errno.cpp",
825 "bionic/__gnu_basename.cpp",
826 "bionic/__libc_current_sigrtmax.cpp",
827 "bionic/__libc_current_sigrtmin.cpp",
828 "bionic/abort.cpp",
829 "bionic/accept.cpp",
830 "bionic/access.cpp",
Florian Mayerca4749a2024-02-14 12:55:46 -0800831 "bionic/android_crash_detail.cpp",
Josh Gao10ec9282017-04-03 15:13:29 -0700832 "bionic/android_set_abort_message.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000833 "bionic/android_unsafe_frame_pointer_chase.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800834 "bionic/arpa_inet.cpp",
835 "bionic/assert.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000836 "bionic/atexit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800837 "bionic/atof.cpp",
838 "bionic/bionic_allocator.cpp",
839 "bionic/bionic_arc4random.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000840 "bionic/bionic_elf_tls.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800841 "bionic/bionic_futex.cpp",
842 "bionic/bionic_netlink.cpp",
843 "bionic/bionic_systrace.cpp",
844 "bionic/bionic_time_conversions.cpp",
845 "bionic/brk.cpp",
846 "bionic/c16rtomb.cpp",
847 "bionic/c32rtomb.cpp",
848 "bionic/chmod.cpp",
849 "bionic/chown.cpp",
850 "bionic/clearenv.cpp",
851 "bionic/clock.cpp",
852 "bionic/clock_getcpuclockid.cpp",
853 "bionic/clock_nanosleep.cpp",
854 "bionic/clone.cpp",
855 "bionic/ctype.cpp",
856 "bionic/dirent.cpp",
857 "bionic/dup.cpp",
858 "bionic/environ.cpp",
859 "bionic/error.cpp",
860 "bionic/eventfd.cpp",
861 "bionic/exec.cpp",
862 "bionic/execinfo.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800863 "bionic/exit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800864 "bionic/faccessat.cpp",
865 "bionic/fchmod.cpp",
866 "bionic/fchmodat.cpp",
867 "bionic/fcntl.cpp",
868 "bionic/fdsan.cpp",
869 "bionic/fdtrack.cpp",
870 "bionic/ffs.cpp",
871 "bionic/fgetxattr.cpp",
872 "bionic/flistxattr.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000873 "bionic/fork.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800874 "bionic/fpclassify.cpp",
875 "bionic/fsetxattr.cpp",
876 "bionic/ftruncate.cpp",
877 "bionic/ftw.cpp",
878 "bionic/futimens.cpp",
879 "bionic/getcwd.cpp",
880 "bionic/getdomainname.cpp",
881 "bionic/getentropy.cpp",
882 "bionic/gethostname.cpp",
883 "bionic/getloadavg.cpp",
884 "bionic/getpagesize.cpp",
885 "bionic/getpgrp.cpp",
886 "bionic/getpid.cpp",
887 "bionic/getpriority.cpp",
888 "bionic/gettid.cpp",
889 "bionic/get_device_api_level.cpp",
890 "bionic/grp_pwd.cpp",
891 "bionic/grp_pwd_file.cpp",
892 "bionic/heap_zero_init.cpp",
893 "bionic/iconv.cpp",
894 "bionic/icu_wrappers.cpp",
895 "bionic/ifaddrs.cpp",
896 "bionic/inotify_init.cpp",
897 "bionic/ioctl.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800898 "bionic/isatty.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800899 "bionic/killpg.cpp",
900 "bionic/langinfo.cpp",
Elliott Hughes219e6022024-08-27 19:12:08 +0000901 "bionic/lchmod.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800902 "bionic/lchown.cpp",
903 "bionic/lfs64_support.cpp",
904 "bionic/libc_init_common.cpp",
905 "bionic/libgen.cpp",
906 "bionic/link.cpp",
907 "bionic/locale.cpp",
908 "bionic/lockf.cpp",
909 "bionic/lstat.cpp",
910 "bionic/mblen.cpp",
911 "bionic/mbrtoc16.cpp",
912 "bionic/mbrtoc32.cpp",
913 "bionic/mempcpy.cpp",
914 "bionic/memset_explicit.cpp",
915 "bionic/mkdir.cpp",
916 "bionic/mkfifo.cpp",
917 "bionic/mknod.cpp",
918 "bionic/mntent.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800919 "bionic/netdb.cpp",
Elliott Hughes3ed6e722024-02-16 01:18:01 +0000920 "bionic/net_if.cpp",
921 "bionic/netinet_ether.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800922 "bionic/netinet_in.cpp",
923 "bionic/nl_types.cpp",
924 "bionic/open.cpp",
925 "bionic/pathconf.cpp",
926 "bionic/pause.cpp",
927 "bionic/pidfd.cpp",
928 "bionic/pipe.cpp",
929 "bionic/poll.cpp",
930 "bionic/posix_fadvise.cpp",
931 "bionic/posix_fallocate.cpp",
932 "bionic/posix_madvise.cpp",
933 "bionic/posix_timers.cpp",
934 "bionic/preadv_pwritev.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000935 "bionic/pthread_atfork.cpp",
936 "bionic/pthread_attr.cpp",
937 "bionic/pthread_barrier.cpp",
938 "bionic/pthread_cond.cpp",
939 "bionic/pthread_create.cpp",
940 "bionic/pthread_detach.cpp",
941 "bionic/pthread_equal.cpp",
942 "bionic/pthread_exit.cpp",
943 "bionic/pthread_getcpuclockid.cpp",
944 "bionic/pthread_getschedparam.cpp",
945 "bionic/pthread_gettid_np.cpp",
946 "bionic/pthread_internal.cpp",
947 "bionic/pthread_join.cpp",
948 "bionic/pthread_key.cpp",
949 "bionic/pthread_kill.cpp",
950 "bionic/pthread_mutex.cpp",
951 "bionic/pthread_once.cpp",
952 "bionic/pthread_rwlock.cpp",
953 "bionic/pthread_sigqueue.cpp",
954 "bionic/pthread_self.cpp",
955 "bionic/pthread_setname_np.cpp",
956 "bionic/pthread_setschedparam.cpp",
957 "bionic/pthread_spinlock.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800958 "bionic/ptrace.cpp",
959 "bionic/pty.cpp",
960 "bionic/raise.cpp",
961 "bionic/rand.cpp",
962 "bionic/readlink.cpp",
963 "bionic/realpath.cpp",
964 "bionic/reboot.cpp",
965 "bionic/recv.cpp",
966 "bionic/recvmsg.cpp",
967 "bionic/rename.cpp",
968 "bionic/rmdir.cpp",
969 "bionic/scandir.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800970 "bionic/sched_cpualloc.cpp",
971 "bionic/sched_cpucount.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800972 "bionic/sched_getaffinity.cpp",
973 "bionic/sched_getcpu.cpp",
974 "bionic/semaphore.cpp",
975 "bionic/send.cpp",
976 "bionic/setegid.cpp",
977 "bionic/seteuid.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000978 "bionic/setjmp_cookie.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800979 "bionic/setpgrp.cpp",
980 "bionic/sigaction.cpp",
981 "bionic/signal.cpp",
982 "bionic/sigprocmask.cpp",
983 "bionic/sleep.cpp",
984 "bionic/socketpair.cpp",
985 "bionic/spawn.cpp",
986 "bionic/stat.cpp",
987 "bionic/stdlib_l.cpp",
988 "bionic/strerror.cpp",
989 "bionic/string_l.cpp",
990 "bionic/strings_l.cpp",
991 "bionic/strsignal.cpp",
992 "bionic/strtol.cpp",
993 "bionic/strtold.cpp",
994 "bionic/swab.cpp",
995 "bionic/symlink.cpp",
996 "bionic/sync_file_range.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000997 "bionic/sysconf.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800998 "bionic/sys_epoll.cpp",
999 "bionic/sys_msg.cpp",
1000 "bionic/sys_sem.cpp",
1001 "bionic/sys_shm.cpp",
1002 "bionic/sys_signalfd.cpp",
1003 "bionic/sys_statfs.cpp",
1004 "bionic/sys_statvfs.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001005 "bionic/sys_thread_properties.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001006 "bionic/sys_time.cpp",
1007 "bionic/sysinfo.cpp",
1008 "bionic/syslog.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001009 "bionic/sysprop_helpers.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001010 "bionic/system.cpp",
1011 "bionic/system_property_api.cpp",
1012 "bionic/system_property_set.cpp",
1013 "bionic/tdestroy.cpp",
1014 "bionic/termios.cpp",
1015 "bionic/thread_private.cpp",
1016 "bionic/threads.cpp",
1017 "bionic/time.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001018 "bionic/tmpfile.cpp",
1019 "bionic/umount.cpp",
1020 "bionic/unlink.cpp",
1021 "bionic/usleep.cpp",
1022 "bionic/utmp.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001023 "bionic/vdso.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001024 "bionic/wait.cpp",
1025 "bionic/wchar.cpp",
1026 "bionic/wchar_l.cpp",
1027 "bionic/wcstod.cpp",
1028 "bionic/wctype.cpp",
1029 "bionic/wcwidth.cpp",
1030 "bionic/wmempcpy.cpp",
1031
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001032 // Forked but not yet cleaned up/rewritten stdio code.
1033 // TODO: finish cleanup.
1034 "stdio/fmemopen.cpp",
1035 "stdio/parsefloat.c",
1036 "stdio/refill.c",
1037 "stdio/stdio.cpp",
1038 "stdio/stdio_ext.cpp",
1039 "stdio/vfscanf.cpp",
1040 "stdio/vfwscanf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001041 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001042
1043 arch: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001044 arm: {
Elliott Hughes1b61d782019-06-04 10:38:34 -07001045 asflags: libc_common_flags + ["-mno-restrict-it"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001046 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -08001047 "arch-arm/bionic/__aeabi_read_tp.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001048 "arch-arm/bionic/__bionic_clone.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001049 "arch-arm/bionic/__restore.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001050 "arch-arm/bionic/_exit_with_stack_teardown.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001051 "arch-arm/bionic/atomics_arm.c",
1052 "arch-arm/bionic/bpabi.c",
Yi Kong165b1cf2019-02-13 14:10:10 -08001053 "arch-arm/bionic/libcrt_compat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001054 "arch-arm/bionic/popcount_tab.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001055 "arch-arm/bionic/setjmp.S",
1056 "arch-arm/bionic/syscall.S",
1057 "arch-arm/bionic/vfork.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001058
Haibo Huangea9957a2018-11-19 11:00:32 -08001059 "arch-arm/cortex-a7/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001060 "arch-arm/cortex-a7/bionic/memset.S",
1061
1062 "arch-arm/cortex-a9/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001063 "arch-arm/cortex-a9/bionic/memset.S",
1064 "arch-arm/cortex-a9/bionic/stpcpy.S",
1065 "arch-arm/cortex-a9/bionic/strcat.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001066 "arch-arm/cortex-a9/bionic/strcpy.S",
1067 "arch-arm/cortex-a9/bionic/strlen.S",
1068
Elliott Hughesaefe9992023-11-08 12:04:41 -08001069 "arch-arm/cortex-a15/bionic/memcpy.S",
1070 "arch-arm/cortex-a15/bionic/memmove.S",
1071 "arch-arm/cortex-a15/bionic/memset.S",
1072 "arch-arm/cortex-a15/bionic/stpcpy.S",
1073 "arch-arm/cortex-a15/bionic/strcat.S",
1074 "arch-arm/cortex-a15/bionic/strcmp.S",
1075 "arch-arm/cortex-a15/bionic/strcpy.S",
1076 "arch-arm/cortex-a15/bionic/strlen.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001077
1078 "arch-arm/cortex-a53/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001079
Haibo Huang01bfd892018-12-03 15:05:16 -08001080 "arch-arm/cortex-a55/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001081
Elliott Hughesaefe9992023-11-08 12:04:41 -08001082 "arch-arm/generic/bionic/memcmp.S",
1083 "arch-arm/generic/bionic/memmove.S",
1084 "arch-arm/generic/bionic/memset.S",
1085 "arch-arm/generic/bionic/stpcpy.c",
1086 "arch-arm/generic/bionic/strcat.c",
1087 "arch-arm/generic/bionic/strcmp.S",
1088 "arch-arm/generic/bionic/strcpy.S",
1089 "arch-arm/generic/bionic/strlen.c",
1090
1091 "arch-arm/krait/bionic/memcpy.S",
1092 "arch-arm/krait/bionic/memset.S",
1093
Haibo Huangea9957a2018-11-19 11:00:32 -08001094 "arch-arm/kryo/bionic/memcpy.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001095
1096 "bionic/strchr.cpp",
1097 "bionic/strchrnul.cpp",
1098 "bionic/strnlen.cpp",
1099 "bionic/strrchr.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001100 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001101 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001102 arm64: {
1103 srcs: [
Dan Willemsen3e621712016-02-03 21:48:08 -08001104 "arch-arm64/bionic/__bionic_clone.S",
1105 "arch-arm64/bionic/_exit_with_stack_teardown.S",
1106 "arch-arm64/bionic/setjmp.S",
1107 "arch-arm64/bionic/syscall.S",
1108 "arch-arm64/bionic/vfork.S",
Vaisakh K V83e55842024-03-29 12:47:39 +05301109 "arch-arm64/oryon/memcpy-nt.S",
Vaisakh K V54a61212024-03-29 13:32:45 +05301110 "arch-arm64/oryon/memset-nt.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001111 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001112 },
1113
Elliott Hughesebc19a92022-10-14 23:25:36 +00001114 riscv64: {
1115 srcs: [
1116 "arch-riscv64/bionic/__bionic_clone.S",
1117 "arch-riscv64/bionic/_exit_with_stack_teardown.S",
Elliott Hughese1905ed2022-10-17 23:23:36 +00001118 "arch-riscv64/bionic/setjmp.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001119 "arch-riscv64/bionic/syscall.S",
1120 "arch-riscv64/bionic/vfork.S",
Yun Hsiang40a82d02023-05-26 10:10:40 +08001121
Elliott Hughesaefe9992023-11-08 12:04:41 -08001122 "arch-riscv64/string/memchr_v.S",
1123 "arch-riscv64/string/memcmp_v.S",
1124 "arch-riscv64/string/memcpy_v.S",
1125 "arch-riscv64/string/memmove_v.S",
1126 "arch-riscv64/string/memset_v.S",
1127 "arch-riscv64/string/stpcpy_v.S",
1128 "arch-riscv64/string/strcat_v.S",
1129 "arch-riscv64/string/strchr_v.S",
1130 "arch-riscv64/string/strcmp_v.S",
1131 "arch-riscv64/string/strcpy_v.S",
1132 "arch-riscv64/string/strlen_v.S",
1133 "arch-riscv64/string/strncat_v.S",
1134 "arch-riscv64/string/strncmp_v.S",
1135 "arch-riscv64/string/strncpy_v.S",
1136 "arch-riscv64/string/strnlen_v.S",
1137
1138 "arch-riscv64/string/memchr.c",
1139 "arch-riscv64/string/memcmp.c",
1140 "arch-riscv64/string/memcpy.c",
1141 "arch-riscv64/string/memmove.c",
1142 "arch-riscv64/string/memset.c",
1143 "arch-riscv64/string/stpcpy.c",
1144 "arch-riscv64/string/strcat.c",
1145 "arch-riscv64/string/strchr.c",
1146 "arch-riscv64/string/strcmp.c",
1147 "arch-riscv64/string/strcpy.c",
1148 "arch-riscv64/string/strlen.c",
1149 "arch-riscv64/string/strncat.c",
1150 "arch-riscv64/string/strncmp.c",
1151 "arch-riscv64/string/strncpy.c",
1152 "arch-riscv64/string/strnlen.c",
Prashanth Swaminathana4d71022023-10-30 17:35:19 -07001153
Elliott Hughes7d136662023-10-27 15:40:32 -07001154 "bionic/strchrnul.cpp",
1155 "bionic/strrchr.cpp",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001156 ],
1157 },
1158
Dan Willemsen208ae172015-09-16 16:33:27 -07001159 x86: {
1160 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001161 "arch-x86/bionic/__bionic_clone.S",
1162 "arch-x86/bionic/_exit_with_stack_teardown.S",
1163 "arch-x86/bionic/libcrt_compat.c",
Elliott Hughes7d136662023-10-27 15:40:32 -07001164 "arch-x86/bionic/setjmp.S",
1165 "arch-x86/bionic/syscall.S",
1166 "arch-x86/bionic/vfork.S",
1167 "arch-x86/bionic/__x86.get_pc_thunk.S",
1168
Elliott Hughesed777142022-07-25 16:25:11 +00001169 "arch-x86/string/sse2-memchr-atom.S",
1170 "arch-x86/string/sse2-memmove-slm.S",
1171 "arch-x86/string/sse2-memrchr-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001172 "arch-x86/string/sse2-memset-slm.S",
1173 "arch-x86/string/sse2-stpcpy-slm.S",
1174 "arch-x86/string/sse2-stpncpy-slm.S",
1175 "arch-x86/string/sse2-strchr-atom.S",
1176 "arch-x86/string/sse2-strcpy-slm.S",
1177 "arch-x86/string/sse2-strlen-slm.S",
1178 "arch-x86/string/sse2-strncpy-slm.S",
1179 "arch-x86/string/sse2-strnlen-atom.S",
1180 "arch-x86/string/sse2-strrchr-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001181
1182 "arch-x86/string/ssse3-memcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001183 "arch-x86/string/ssse3-strcat-atom.S",
1184 "arch-x86/string/ssse3-strcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001185 "arch-x86/string/ssse3-strlcat-atom.S",
1186 "arch-x86/string/ssse3-strlcpy-atom.S",
1187 "arch-x86/string/ssse3-strncat-atom.S",
1188 "arch-x86/string/ssse3-strncmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001189
1190 "arch-x86/string/sse4-memcmp-slm.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001191
1192 "bionic/strchrnul.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001193 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001194 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001195 x86_64: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001196 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001197 "arch-x86_64/bionic/__bionic_clone.S",
1198 "arch-x86_64/bionic/_exit_with_stack_teardown.S",
1199 "arch-x86_64/bionic/__restore_rt.S",
1200 "arch-x86_64/bionic/setjmp.S",
1201 "arch-x86_64/bionic/syscall.S",
1202 "arch-x86_64/bionic/vfork.S",
1203
ahs919fb7f2022-06-10 07:11:14 +05301204 "arch-x86_64/string/avx2-memset-kbl.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001205 "arch-x86_64/string/sse2-memmove-slm.S",
1206 "arch-x86_64/string/sse2-memset-slm.S",
1207 "arch-x86_64/string/sse2-stpcpy-slm.S",
1208 "arch-x86_64/string/sse2-stpncpy-slm.S",
1209 "arch-x86_64/string/sse2-strcat-slm.S",
1210 "arch-x86_64/string/sse2-strcpy-slm.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001211 "arch-x86_64/string/sse2-strlen-slm.S",
1212 "arch-x86_64/string/sse2-strncat-slm.S",
1213 "arch-x86_64/string/sse2-strncpy-slm.S",
1214 "arch-x86_64/string/sse4-memcmp-slm.S",
1215 "arch-x86_64/string/ssse3-strcmp-slm.S",
1216 "arch-x86_64/string/ssse3-strncmp-slm.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001217
1218 "bionic/strchr.cpp",
1219 "bionic/strchrnul.cpp",
1220 "bionic/strnlen.cpp",
1221 "bionic/strrchr.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001222 ],
1223 },
Dan Willemsen268a6732015-10-15 14:49:45 -07001224 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001225
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001226 multilib: {
1227 lib32: {
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001228 srcs: [
1229 // off64_t/time64_t support on LP32.
1230 "bionic/legacy_32_bit_support.cpp",
1231 "bionic/time64.c",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001232 ],
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001233 },
1234 },
1235
1236 local_include_dirs: ["stdio"],
1237 generated_headers: ["generated_android_ids"],
1238
1239 whole_static_libs: [
1240 "libsystemproperties",
1241 ],
1242
Colin Cross50c21ab2015-10-31 23:03:05 -07001243 cppflags: ["-Wold-style-cast"],
Dan Willemsen268a6732015-10-15 14:49:45 -07001244 include_dirs: ["bionic/libstdc++/include"],
1245 name: "libc_bionic",
Dan Willemsen268a6732015-10-15 14:49:45 -07001246}
1247
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001248genrule {
1249 name: "generated_android_ids",
Colin Cross35bbed82017-01-17 18:16:07 -08001250 out: ["generated_android_ids.h"],
1251 srcs: [":android_filesystem_config_header"],
Cole Faustb1a0a9d2023-11-28 17:51:16 -08001252 tools: ["fs_config_generator"],
1253 cmd: "$(location fs_config_generator) aidarray $(in) > $(out)",
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001254}
1255
Dan Willemsen268a6732015-10-15 14:49:45 -07001256// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001257// libc_syscalls.a
1258// ========================================================
1259
Elliott Hughes782c4852019-04-16 12:31:00 -07001260genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001261 name: "syscalls-arm",
Elliott Hughes782c4852019-04-16 12:31:00 -07001262 out: ["syscalls-arm.S"],
1263 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001264 tools: ["gensyscalls"],
1265 cmd: "$(location gensyscalls) arm $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001266}
1267
1268genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001269 name: "syscalls-arm64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001270 out: ["syscalls-arm64.S"],
1271 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001272 tools: ["gensyscalls"],
1273 cmd: "$(location gensyscalls) arm64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001274}
1275
1276genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001277 name: "syscalls-riscv64",
Elliott Hughes704772b2022-10-10 17:06:43 +00001278 out: ["syscalls-riscv64.S"],
1279 srcs: ["SYSCALLS.TXT"],
1280 tools: ["gensyscalls"],
1281 cmd: "$(location gensyscalls) riscv64 $(in) > $(out)",
1282}
1283
1284genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001285 name: "syscalls-x86",
Elliott Hughes782c4852019-04-16 12:31:00 -07001286 out: ["syscalls-x86.S"],
1287 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001288 tools: ["gensyscalls"],
1289 cmd: "$(location gensyscalls) x86 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001290}
1291
1292genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001293 name: "syscalls-x86_64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001294 out: ["syscalls-x86_64.S"],
1295 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001296 tools: ["gensyscalls"],
1297 cmd: "$(location gensyscalls) x86_64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001298}
1299
Dan Willemsen208ae172015-09-16 16:33:27 -07001300cc_library_static {
Colin Cross27c43c52016-04-07 13:27:24 -07001301 defaults: ["libc_defaults"],
Josh Gao0e0e3702017-10-12 13:34:42 -07001302 srcs: ["bionic/__set_errno.cpp"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001303 arch: {
1304 arm: {
Cole Faustf5968d82023-04-11 15:20:19 -07001305 srcs: [":syscalls-arm"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001306 },
1307 arm64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001308 srcs: [":syscalls-arm64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001309 },
Elliott Hughes704772b2022-10-10 17:06:43 +00001310 riscv64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001311 srcs: [":syscalls-riscv64"],
Elliott Hughes704772b2022-10-10 17:06:43 +00001312 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001313 x86: {
Cole Faustf5968d82023-04-11 15:20:19 -07001314 srcs: [":syscalls-x86"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001315 },
1316 x86_64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001317 srcs: [":syscalls-x86_64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001318 },
1319 },
1320 name: "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001321}
1322
1323// ========================================================
1324// libc_aeabi.a
1325// This is an LP32 ARM-only library that needs to be built with -fno-builtin
1326// to avoid infinite recursion. For the other architectures we just build an
1327// empty library to keep this makefile simple.
1328// ========================================================
1329
1330cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001331 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001332 arch: {
1333 arm: {
1334 srcs: ["arch-arm/bionic/__aeabi.c"],
1335 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001336 },
1337 name: "libc_aeabi",
Colin Cross50c21ab2015-10-31 23:03:05 -07001338 cflags: ["-fno-builtin"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001339}
1340
1341// ========================================================
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001342// libc_common.a --- everything shared by libc.a and libc.so
Dan Willemsen208ae172015-09-16 16:33:27 -07001343// ========================================================
Elliott Hughesb0948922024-01-26 00:28:12 +00001344
Dan Willemsen208ae172015-09-16 16:33:27 -07001345cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001346 defaults: ["libc_defaults"],
Elliott Hughesb0948922024-01-26 00:28:12 +00001347 name: "libc_common",
1348
Dan Willemsen208ae172015-09-16 16:33:27 -07001349 whole_static_libs: [
Peter Collingbourne337a5b32020-02-21 12:11:02 -08001350 "libarm-optimized-routines-string",
Rupert Shuttleworth78f48a52021-03-16 06:39:19 +00001351 "libasync_safe",
Dan Willemsen208ae172015-09-16 16:33:27 -07001352 "libc_bionic",
Ryan Prichard249757b2019-11-01 17:18:28 -07001353 "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -07001354 "libc_dns",
George Burgess IV6cb06872017-07-21 13:28:42 -07001355 "libc_fortify",
Dan Willemsen208ae172015-09-16 16:33:27 -07001356 "libc_freebsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001357 "libc_freebsd_large_stack",
Elliott Hughesc2043342023-07-20 20:24:09 +00001358 "libc_freebsd_ldexp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001359 "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -07001360 "libc_netbsd",
1361 "libc_openbsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001362 "libc_openbsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001363 "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001364 "libc_tzcode",
Elliott Hughes816fab92016-05-27 17:57:46 -07001365 "libstdc++",
Dan Willemsen208ae172015-09-16 16:33:27 -07001366 ],
1367
1368 arch: {
1369 arm: {
1370 whole_static_libs: ["libc_aeabi"],
1371 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001372 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001373}
1374
1375// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001376// libc_static_dispatch.a/libc_dynamic_dispatch.a --- string/memory "ifuncs"
1377// (Actually ifuncs for libc.so, but a home-grown alternative for libc.a.)
Haibo Huangf71edfa2018-11-12 10:06:56 -08001378// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001379
1380cc_defaults {
1381 name: "libc_dispatch_defaults",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001382 defaults: ["libc_defaults"],
Haibo Huangb9244ff2018-08-11 10:12:13 -07001383 arch: {
ahs919fb7f2022-06-10 07:11:14 +05301384 x86_64: {
1385 srcs: ["arch-x86_64/dynamic_function_dispatch.cpp"],
1386 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001387 x86: {
1388 srcs: ["arch-x86/dynamic_function_dispatch.cpp"],
1389 },
Haibo Huangea9957a2018-11-19 11:00:32 -08001390 arm: {
Elliott Hughes927fe992019-01-31 22:29:22 +00001391 srcs: ["arch-arm/dynamic_function_dispatch.cpp"],
Haibo Huangea9957a2018-11-19 11:00:32 -08001392 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001393 arm64: {
1394 srcs: ["arch-arm64/dynamic_function_dispatch.cpp"],
1395 },
Elliott Hughesaefe9992023-11-08 12:04:41 -08001396 riscv64: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001397 srcs: ["arch-riscv64/dynamic_function_dispatch.cpp"],
Elliott Hughesaefe9992023-11-08 12:04:41 -08001398 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001399 },
Elliott Hughesadc41712024-08-16 13:08:11 +00001400 // Prevent the compiler from inserting calls to libc/taking the address of
1401 // a jump table from within an ifunc (or, in the static case, code that
1402 // can be executed arbitrarily early).
1403 cflags: [
1404 "-ffreestanding",
1405 "-fno-stack-protector",
1406 "-fno-jump-tables",
1407 ],
1408}
1409
1410cc_library_static {
1411 name: "libc_static_dispatch",
1412 defaults: ["libc_dispatch_defaults"],
1413 cflags: [
1414 "-DBIONIC_STATIC_DISPATCH",
1415 ],
1416}
1417
1418cc_library_static {
1419 name: "libc_dynamic_dispatch",
1420 defaults: ["libc_dispatch_defaults"],
1421 cflags: [
1422 "-DBIONIC_DYNAMIC_DISPATCH",
1423 ],
Ryan Prichard249757b2019-11-01 17:18:28 -07001424}
1425
1426// ========================================================
1427// libc_common_static.a For static binaries.
1428// ========================================================
1429cc_library_static {
1430 defaults: ["libc_defaults"],
1431 name: "libc_common_static",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001432
Haibo Huangf71edfa2018-11-12 10:06:56 -08001433 whole_static_libs: [
1434 "libc_common",
Ryan Prichard249757b2019-11-01 17:18:28 -07001435 "libc_static_dispatch",
1436 ],
1437}
1438
1439// ========================================================
1440// libc_common_shared.a For shared libraries.
1441// ========================================================
1442cc_library_static {
1443 defaults: ["libc_defaults"],
1444 name: "libc_common_shared",
1445
1446 whole_static_libs: [
1447 "libc_common",
1448 "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001449 ],
1450}
1451
Ryan Prichard22a6a052019-10-10 23:59:30 -07001452// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static
1453// executable.
1454cc_library_static {
1455 name: "libc_unwind_static",
1456 defaults: ["libc_defaults"],
1457 cflags: ["-DLIBC_STATIC"],
1458
1459 srcs: ["bionic/dl_iterate_phdr_static.cpp"],
1460 arch: {
1461 // arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs
1462 arm: {
1463 srcs: ["arch-arm/bionic/exidx_static.c"],
1464 },
1465 },
1466}
1467
Haibo Huangf71edfa2018-11-12 10:06:56 -08001468// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001469// libc_nomalloc.a
1470// ========================================================
1471//
Ryan Prichard249757b2019-11-01 17:18:28 -07001472// This is a version of the static C library used by the dynamic linker that exclude malloc. It also
1473// excludes functions selected using ifunc's (e.g. for string.h). Link in either
1474// libc_static_dispatch or libc_dynamic_dispatch to provide those functions.
Dan Willemsen208ae172015-09-16 16:33:27 -07001475
1476cc_library_static {
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -08001477 name: "libc_nomalloc",
Colin Cross50c21ab2015-10-31 23:03:05 -07001478 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001479
Colin Crossa3f9fca2016-01-11 13:20:55 -08001480 whole_static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -07001481 "libc_common",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001482 "libc_init_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001483 "libc_unwind_static",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001484 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001485}
1486
dimitryc0c0ef62018-12-05 16:33:52 +01001487filegroup {
1488 name: "libc_sources_shared",
1489 srcs: [
1490 "arch-common/bionic/crtbegin_so.c",
1491 "arch-common/bionic/crtbrand.S",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001492 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001493 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001494 "bionic/icu.cpp",
1495 "bionic/malloc_common.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001496 "bionic/malloc_common_dynamic.cpp",
Ryan Savitski175c8862020-01-02 19:54:57 +00001497 "bionic/android_profiling_dynamic.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001498 "bionic/malloc_heapprofd.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001499 "bionic/malloc_limit.cpp",
Peter Collingbourne570de332019-12-11 10:00:58 -08001500 "bionic/ndk_cruft.cpp",
1501 "bionic/ndk_cruft_data.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001502 "bionic/NetdClient.cpp",
1503 "arch-common/bionic/crtend_so.S",
1504 ],
1505}
1506
1507filegroup {
1508 name: "libc_sources_static",
1509 srcs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001510 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001511 "bionic/heap_tagging.cpp",
Elliott Hughes72b0f3b2024-07-02 20:22:35 +00001512 "bionic/icu_static.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001513 "bionic/malloc_common.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001514 "bionic/malloc_limit.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001515 ],
1516}
1517
1518filegroup {
1519 name: "libc_sources_shared_arm",
1520 srcs: [
1521 "arch-arm/bionic/exidx_dynamic.c",
1522 "arch-arm/bionic/atexit_legacy.c",
1523 ],
1524}
1525
Dan Willemsen208ae172015-09-16 16:33:27 -07001526// ========================================================
1527// libc.a + libc.so
1528// ========================================================
Florian Mayerc10d0642023-03-22 16:12:49 -07001529cc_defaults {
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001530 defaults: [
1531 "libc_defaults",
1532 "libc_native_allocator_defaults",
Elliott Hughes788075a2024-06-18 12:25:37 +00001533 "bug_24465209_workaround",
Elliott Hughes89aada12024-07-01 21:59:04 +00001534 "keep_symbols",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001535 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001536 name: "libc_library_defaults",
Colin Cross50c21ab2015-10-31 23:03:05 -07001537 product_variables: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001538 platform_sdk_version: {
1539 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1540 },
1541 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001542 static: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001543 srcs: [":libc_sources_static"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001544 cflags: ["-DLIBC_STATIC"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001545 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001546 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001547 "libc_init_static",
1548 "libc_common_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001549 "libc_unwind_static",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001550 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001551 },
1552 shared: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001553 srcs: [":libc_sources_shared"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001554 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001555 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001556 "libc_init_dynamic",
1557 "libc_common_shared",
Ryan Prichardcdf71752020-12-16 03:37:22 -08001558 "libunwind-exported",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001559 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001560 },
1561
Neil Fullera7db90f2019-04-25 09:28:27 +01001562 required: [
MarkDacekd88d7ea2022-06-28 20:14:58 +00001563 "tzdata_prebuilt",
1564 "tz_version_prebuilt", // Version metadata for tzdata to help debugging.
Neil Fullera7db90f2019-04-25 09:28:27 +01001565 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001566
Colin Cross4ce94d22016-11-15 13:15:43 -08001567 // Do not pack libc.so relocations; see http://b/20645321 for details.
1568 pack_relocations: false,
1569
dimitry06016f22018-01-05 11:39:28 +01001570 shared_libs: [
1571 "ld-android",
1572 "libdl",
1573 ],
Jiyong Park3ff116a2019-04-02 23:04:52 +09001574 static_libs: [
1575 "libdl_android",
1576 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001577
1578 nocrt: true,
1579
Dan Willemsen208ae172015-09-16 16:33:27 -07001580 arch: {
1581 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001582 version_script: ":libc.arm.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001583 no_libcrt: true,
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001584
Dan Willemsen208ae172015-09-16 16:33:27 -07001585 shared: {
dimitryc0c0ef62018-12-05 16:33:52 +01001586 srcs: [":libc_sources_shared_arm"],
Dan Willemsen0c657082016-05-12 01:43:07 -07001587 // special for arm
1588 cflags: ["-DCRT_LEGACY_WORKAROUND"],
Elliott Hughes89aada12024-07-01 21:59:04 +00001589 // For backwards compatibility, some arm32 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001590 static_libs: ["libclang_rt.builtins-exported"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001591 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001592
Elliott Hughes89aada12024-07-01 21:59:04 +00001593 ldflags: [
1594 // Since we preserve the debug_frame for libc, do not compress
1595 // in this case to make unwinds as fast as possible.
1596 "-Wl,--compress-debug-sections=none",
1597 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001598 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001599 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001600 version_script: ":libc.arm64.map",
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001601 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001602 riscv64: {
1603 version_script: ":libc.riscv64.map",
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001604 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001605 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001606 version_script: ":libc.x86.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001607 no_libcrt: true,
1608
1609 shared: {
Elliott Hughes89aada12024-07-01 21:59:04 +00001610 // For backwards compatibility, some x86 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001611 static_libs: ["libclang_rt.builtins-exported"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001612 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001613 },
1614 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001615 version_script: ":libc.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001616 },
1617 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +09001618
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001619 apex_available: [
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001620 "com.android.runtime",
1621 ],
1622
Colin Cross7edd0082021-10-28 13:20:35 -07001623 target: {
1624 native_bridge: {
1625 shared: {
1626 installable: false,
1627 },
1628 },
1629 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001630}
1631
Florian Mayerc10d0642023-03-22 16:12:49 -07001632cc_library {
1633 name: "libc",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001634 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001635 "libc_library_defaults",
1636 ],
1637 stubs: {
1638 symbol_file: "libc.map.txt",
1639 versions: [
1640 "29",
1641 "R",
1642 "current",
1643 ],
1644 },
1645 static_ndk_lib: true,
1646 llndk: {
1647 symbol_file: "libc.map.txt",
1648 export_headers_as_system: true,
Dan Alberte9f02e02024-08-28 23:20:20 +00001649 export_llndk_headers: ["libc_headers"],
Florian Mayerc10d0642023-03-22 16:12:49 -07001650 },
1651}
1652
1653cc_library {
1654 name: "libc_hwasan",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001655 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001656 "libc_library_defaults",
1657 ],
1658 sanitize: {
1659 hwaddress: true,
1660 },
1661 enabled: false,
Florian Mayerff116ed2023-04-14 17:38:53 -07001662 target: {
1663 android_arm64: {
Florian Mayerc10d0642023-03-22 16:12:49 -07001664 enabled: true,
1665 },
1666 },
1667 stem: "libc",
1668 relative_install_path: "hwasan",
1669 // We don't really need the stubs, but this needs to stay to trigger the
1670 // symlink logic in soong.
1671 stubs: {
1672 symbol_file: "libc.map.txt",
1673 },
1674 native_bridge_supported: false,
1675 // It is never correct to depend on this directly. This is only
1676 // needed for the runtime apex, and in base_system.mk.
1677 visibility: ["//bionic/apex"],
1678}
1679
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001680genrule {
1681 name: "libc.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001682 out: ["libc.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001683 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001684 tools: ["generate-version-script"],
1685 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001686}
1687
1688genrule {
1689 name: "libc.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001690 out: ["libc.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001691 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001692 tools: ["generate-version-script"],
1693 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001694}
1695
1696genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001697 name: "libc.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001698 out: ["libc.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001699 srcs: ["libc.map.txt"],
1700 tools: ["generate-version-script"],
1701 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1702}
1703
1704genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001705 name: "libc.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001706 out: ["libc.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001707 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001708 tools: ["generate-version-script"],
1709 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001710}
1711
1712genrule {
1713 name: "libc.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001714 out: ["libc.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001715 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001716 tools: ["generate-version-script"],
1717 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001718}
1719
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001720// Headers that only other parts of the platform can include.
1721cc_library_headers {
1722 name: "bionic_libc_platform_headers",
Martin Stjernholma2763432020-04-23 16:47:19 +01001723 defaults: ["linux_bionic_supported"],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001724 visibility: [
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001725 "//art:__subpackages__",
Josh Gao97271922019-11-06 13:15:00 -08001726 "//bionic:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001727 "//frameworks:__subpackages__",
Roman Kiryanov067f5182020-05-07 14:58:30 -07001728 "//device/generic/goldfish-opengl:__subpackages__",
Mitch Phillips3309b3d2020-03-25 15:05:48 -07001729 "//external/gwp_asan:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001730 "//external/perfetto:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001731 "//external/scudo:__subpackages__",
Josh Gao5074e7d2019-12-13 13:55:53 -08001732 "//system/core/debuggerd:__subpackages__",
Florian Mayerf5d70ce2022-09-13 13:58:30 -07001733 "//system/core/init:__subpackages__",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001734 "//system/core/libcutils:__subpackages__",
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001735 "//system/memory/libmemunreachable:__subpackages__",
Baligh Uddindb0c6de2020-10-15 04:49:00 +00001736 "//system/unwinding/libunwindstack:__subpackages__",
Peter Collingbourne15418002020-05-12 16:02:50 -07001737 "//tools/security/sanitizer-status:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001738 ],
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001739 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001740 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001741 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001742 vendor_ramdisk_available: true,
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001743 recovery_available: true,
1744 native_bridge_supported: true,
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001745 export_include_dirs: [
1746 "platform",
1747 ],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001748 system_shared_libs: [],
1749 stl: "none",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001750 sdk_version: "current",
Jiyong Park4ede1602020-04-28 18:21:08 +09001751
Steven Moreland0cdf1322020-10-05 21:55:26 +00001752 min_sdk_version: "29",
Jiyong Park4ede1602020-04-28 18:21:08 +09001753 apex_available: [
1754 "//apex_available:platform",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001755 "//apex_available:anyapex",
Jiyong Park4ede1602020-04-28 18:21:08 +09001756 ],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001757}
1758
Logan Chien17af91b2019-01-15 21:19:56 +08001759cc_library_headers {
Dan Albert64a6efc2024-08-29 19:04:59 +00001760 name: "libc_uapi_headers",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001761 visibility: [
1762 "//external/musl",
Alistair Delvabad22722024-10-07 12:52:40 -07001763 "//external/rust/crates/v4l2r/android",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001764 ],
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001765 llndk: {
1766 llndk_headers: true,
1767 },
Logan Chien17af91b2019-01-15 21:19:56 +08001768 host_supported: true,
1769 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001770 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001771 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001772 vendor_ramdisk_available: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001773 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001774 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001775 apex_available: [
1776 "//apex_available:platform",
Jiyong Parkad9946c2020-03-30 18:36:07 +09001777 "//apex_available:anyapex",
1778 ],
Jooyung Han15c32a82020-04-16 18:26:45 +09001779 // used by most APEXes indirectly via libunwind_llvm
1780 min_sdk_version: "apex_inherit",
Logan Chien17af91b2019-01-15 21:19:56 +08001781
1782 no_libcrt: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001783 stl: "none",
1784 system_shared_libs: [],
1785
Peter Collingbournef2b1e032019-12-10 17:41:16 -08001786 // The build system generally requires that any dependencies of a target
1787 // with an sdk_version must have a lower sdk_version. By setting sdk_version
1788 // to 1 we let targets with an sdk_version that need to depend on the libc
1789 // headers but cannot depend on libc itself due to circular dependencies
1790 // (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
1791 // is correct because the headers can support any sdk_version.
1792 sdk_version: "1",
1793
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001794 export_system_include_dirs: [
Logan Chien17af91b2019-01-15 21:19:56 +08001795 "kernel/uapi",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001796 "kernel/android/scsi",
Logan Chien17af91b2019-01-15 21:19:56 +08001797 "kernel/android/uapi",
1798 ],
1799
1800 arch: {
1801 arm: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001802 export_system_include_dirs: ["kernel/uapi/asm-arm"],
Logan Chien17af91b2019-01-15 21:19:56 +08001803 },
1804 arm64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001805 export_system_include_dirs: ["kernel/uapi/asm-arm64"],
Logan Chien17af91b2019-01-15 21:19:56 +08001806 },
Elliott Hughes48e53332022-10-07 20:39:25 +00001807 riscv64: {
1808 export_system_include_dirs: ["kernel/uapi/asm-riscv"],
1809 },
Logan Chien17af91b2019-01-15 21:19:56 +08001810 x86: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001811 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001812 },
1813 x86_64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001814 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001815 },
1816 },
1817}
1818
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001819cc_library_headers {
1820 name: "libc_headers",
1821 host_supported: true,
1822 native_bridge_supported: true,
1823 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001824 product_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001825 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001826 vendor_ramdisk_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001827 recovery_available: true,
1828 sdk_version: "1",
1829
1830 apex_available: [
1831 "//apex_available:platform",
1832 "//apex_available:anyapex",
1833 ],
1834 // used by most APEXes indirectly via libunwind_llvm
1835 min_sdk_version: "apex_inherit",
1836 visibility: [
1837 "//bionic:__subpackages__", // visible to bionic
1838 // ... and only to these places (b/152668052)
1839 "//external/arm-optimized-routines",
1840 "//external/gwp_asan",
1841 "//external/jemalloc_new",
1842 "//external/libunwind_llvm",
Nick Desaulniers942ae552024-02-12 10:26:19 -08001843 "//external/llvm-libc",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001844 "//external/scudo",
1845 "//system/core/property_service/libpropertyinfoparser",
1846 "//system/extras/toolchain-extras",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001847 ],
1848
1849 stl: "none",
1850 no_libcrt: true,
1851 system_shared_libs: [],
1852
1853 target: {
1854 android: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001855 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001856 header_libs: ["libc_uapi_headers"],
1857 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001858 },
1859 linux_bionic: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001860 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001861 header_libs: ["libc_uapi_headers"],
1862 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001863 },
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001864 },
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001865}
1866
Dan Willemsen208ae172015-09-16 16:33:27 -07001867// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001868// libstdc++.so and libstdc++.a.
Dan Willemsen208ae172015-09-16 16:33:27 -07001869// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001870
Dan Willemsen208ae172015-09-16 16:33:27 -07001871cc_library {
Elliott Hughes788075a2024-06-18 12:25:37 +00001872 defaults: [
1873 "libc_defaults",
1874 "bug_24465209_workaround",
1875 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001876 include_dirs: ["bionic/libstdc++/include"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001877 srcs: [
1878 "bionic/__cxa_guard.cpp",
1879 "bionic/__cxa_pure_virtual.cpp",
1880 "bionic/new.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001881 ],
1882 name: "libstdc++",
Dan Albert40f15ec2017-10-27 11:21:20 -07001883 static_ndk_lib: true,
Isaac Chen5e7c90b2017-09-20 14:44:42 +08001884 static_libs: ["libasync_safe"],
Elliott Hughesc2043342023-07-20 20:24:09 +00001885 apex_available: [
1886 "//apex_available:platform",
1887 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001888
Dan Willemsen6b3be172018-12-03 13:57:20 -08001889 static: {
1890 system_shared_libs: [],
1891 },
Colin Crossb5bfe0b2021-07-13 16:26:28 -07001892 target: {
1893 bionic: {
1894 shared: {
1895 system_shared_libs: ["libc"],
1896 },
1897 },
Dan Willemsen6b3be172018-12-03 13:57:20 -08001898 },
1899
Dan Willemsen208ae172015-09-16 16:33:27 -07001900 arch: {
1901 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001902 version_script: ":libstdc++.arm.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001903 },
1904 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001905 version_script: ":libstdc++.arm64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001906 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001907 riscv64: {
1908 version_script: ":libstdc++.riscv64.map",
1909 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001910 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001911 version_script: ":libstdc++.x86.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001912 },
1913 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001914 version_script: ":libstdc++.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001915 },
1916 },
1917}
1918
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001919genrule {
1920 name: "libstdc++.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001921 out: ["libstdc++.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001922 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001923 tools: ["generate-version-script"],
1924 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001925}
1926
1927genrule {
1928 name: "libstdc++.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001929 out: ["libstdc++.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001930 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001931 tools: ["generate-version-script"],
1932 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001933}
1934
1935genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001936 name: "libstdc++.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001937 out: ["libstdc++.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001938 srcs: ["libstdc++.map.txt"],
1939 tools: ["generate-version-script"],
1940 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1941}
1942
1943genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001944 name: "libstdc++.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001945 out: ["libstdc++.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001946 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001947 tools: ["generate-version-script"],
1948 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001949}
1950
1951genrule {
1952 name: "libstdc++.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001953 out: ["libstdc++.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001954 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001955 tools: ["generate-version-script"],
1956 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001957}
1958
1959// ========================================================
1960// crt object files.
1961// ========================================================
1962
Colin Cross50c21ab2015-10-31 23:03:05 -07001963cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001964 name: "crt_and_memtag_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -08001965 defaults: ["linux_bionic_supported"],
Dan Willemsen230a7a42017-04-07 14:09:05 -07001966 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001967 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001968 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001969 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +09001970 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001971 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001972 apex_available: [
1973 "//apex_available:platform",
1974 "//apex_available:anyapex",
1975 ],
Dan Albertdc503f62020-07-15 17:22:18 -07001976 // Generate NDK variants of the CRT objects for every supported API level.
1977 min_sdk_version: "16",
1978 stl: "none",
1979 crt: true,
Elliott Hughesd50a1de2018-02-05 17:30:57 -08001980 cflags: [
1981 "-Wno-gcc-compat",
1982 "-Wall",
1983 "-Werror",
1984 ],
Peter Collingbourne7eb851c2019-09-26 12:16:06 -07001985 sanitize: {
1986 never: true,
1987 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001988}
1989
Colin Cross50c21ab2015-10-31 23:03:05 -07001990cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001991 name: "crt_defaults",
1992 defaults: ["crt_and_memtag_defaults"],
Colin Cross02f81372021-07-22 12:02:10 -07001993 system_shared_libs: [],
Colin Cross10d92682021-06-22 13:25:46 -07001994}
1995
1996cc_defaults {
Colin Cross50c21ab2015-10-31 23:03:05 -07001997 name: "crt_so_defaults",
Colin Cross7d7b3682017-11-03 13:38:40 -07001998 defaults: ["crt_defaults"],
Colin Crossab179442018-09-27 11:03:22 -07001999 stl: "none",
Dan Willemsen208ae172015-09-16 16:33:27 -07002000}
2001
Dan Willemsen208ae172015-09-16 16:33:27 -07002002cc_object {
2003 name: "crtbrand",
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002004 local_include_dirs: [
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002005 "private", // crtbrand.S depends on private/bionic_asm_note.h
2006 ],
Elliott Hughes6a30b712024-03-13 23:41:32 +00002007 // crtbrand.S needs to know the platform SDK version.
Dan Willemsen208ae172015-09-16 16:33:27 -07002008 product_variables: {
2009 platform_sdk_version: {
2010 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
2011 },
2012 },
2013 srcs: ["arch-common/bionic/crtbrand.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002014
Colin Cross7d7b3682017-11-03 13:38:40 -07002015 defaults: ["crt_so_defaults"],
Dan Alberteee46dc2023-04-04 23:27:52 +00002016 // crtbrand is an intermediate artifact, not a final CRT object.
2017 exclude_from_ndk_sysroot: true,
Dan Willemsen208ae172015-09-16 16:33:27 -07002018}
2019
Dan Willemsen208ae172015-09-16 16:33:27 -07002020cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002021 name: "crtbegin_so",
Dan Willemsen208ae172015-09-16 16:33:27 -07002022 local_include_dirs: ["include"],
2023 srcs: ["arch-common/bionic/crtbegin_so.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002024
Colin Cross7d7b3682017-11-03 13:38:40 -07002025 defaults: ["crt_so_defaults"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002026 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002027 "crtbrand",
2028 ],
2029}
2030
Dan Willemsen208ae172015-09-16 16:33:27 -07002031cc_object {
2032 name: "crtend_so",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002033 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002034 "private", // crtend_so.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002035 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002036 srcs: ["arch-common/bionic/crtend_so.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002037
Colin Cross7d7b3682017-11-03 13:38:40 -07002038 defaults: ["crt_so_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002039}
2040
Dan Willemsen208ae172015-09-16 16:33:27 -07002041cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002042 name: "crtbegin_static",
2043
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002044 local_include_dirs: [
2045 "include",
2046 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2047 ],
Liz Kammere718dd72021-03-09 15:00:06 -05002048
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002049 cflags: ["-DCRTBEGIN_STATIC"],
Yabin Cui744cfd32023-08-24 13:20:23 -07002050
Dan Willemsen208ae172015-09-16 16:33:27 -07002051 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002052 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002053 "crtbrand",
2054 ],
Colin Cross50c21ab2015-10-31 23:03:05 -07002055 defaults: ["crt_defaults"],
Jiyong Park268a6002021-01-12 23:14:37 +09002056 // When using libc.a, we're using the latest library regardless of target API level.
2057 min_sdk_version: "current",
Dan Willemsen208ae172015-09-16 16:33:27 -07002058}
2059
Dan Willemsen208ae172015-09-16 16:33:27 -07002060cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002061 name: "crtbegin_dynamic",
2062
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002063 local_include_dirs: [
2064 "include",
2065 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2066 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002067 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002068 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002069 "crtbrand",
2070 ],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -07002071 target: {
2072 linux_bionic: {
2073 generated_sources: ["host_bionic_linker_asm"],
2074 objs: [
2075 "linker_wrapper",
2076 ],
2077 },
2078 },
Colin Cross50c21ab2015-10-31 23:03:05 -07002079 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002080}
2081
Dan Willemsen208ae172015-09-16 16:33:27 -07002082cc_object {
2083 // We rename crtend.o to crtend_android.o to avoid a
2084 // name clash between gcc and bionic.
2085 name: "crtend_android",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002086 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002087 "private", // crtend.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002088 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002089 srcs: ["arch-common/bionic/crtend.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002090
Colin Cross50c21ab2015-10-31 23:03:05 -07002091 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002092}
Colin Crossbaa48992016-07-13 11:15:21 -07002093
Kalesh Singh862a23d2024-01-09 13:13:50 -08002094cc_object {
2095 name: "crt_pad_segment",
2096 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002097 "private", // crt_pad_segment.S depends on private/bionic_asm_note.h
Kalesh Singh862a23d2024-01-09 13:13:50 -08002098 ],
2099 srcs: ["arch-common/bionic/crt_pad_segment.S"],
2100
2101 defaults: ["crt_defaults"],
2102}
2103
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002104cc_library_static {
2105 name: "note_memtag_heap_async",
2106 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002107 arm64: {
2108 srcs: ["arch-arm64/bionic/note_memtag_heap_async.S"],
2109 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002110 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002111 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002112
Colin Cross10d92682021-06-22 13:25:46 -07002113 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002114}
2115
2116cc_library_static {
2117 name: "note_memtag_heap_sync",
2118 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002119 arm64: {
2120 srcs: ["arch-arm64/bionic/note_memtag_heap_sync.S"],
2121 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002122 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002123 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002124
Colin Cross10d92682021-06-22 13:25:46 -07002125 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002126}
2127
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002128// ========================================================
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002129// libc dependencies for baremetal Rust projects.
2130// ========================================================
2131
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002132// This library contains the following unresolved symbols:
2133// __errno
2134// abort
2135// async_safe_fatal_va_list
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002136cc_library_static {
2137 name: "librust_baremetal",
Pierre-Clément Tosi9018e5f2024-10-02 15:57:00 +01002138 defaults: ["cc_baremetal_defaults"],
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002139 header_libs: ["libc_headers"],
2140 include_dirs: [
2141 "bionic/libc/async_safe/include",
2142 "bionic/libc/platform",
2143 ],
2144 cflags: [
2145 "-Wall",
2146 "-Werror",
2147 ],
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002148 srcs: [
2149 "bionic/fortify.cpp",
Pierre-Clément Tosi816176c2022-11-30 14:33:41 +00002150 "bionic/strtol.cpp",
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002151 ],
2152 arch: {
2153 arm64: {
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002154 srcs: [
2155 "arch-arm64/string/__memcpy_chk.S",
2156 ],
2157 },
caowencheng9a39eb32023-03-20 16:24:41 +08002158 riscv64: {
2159 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002160 "arch-riscv64/string/__memcpy_chk.S",
caowencheng9a39eb32023-03-20 16:24:41 +08002161 ],
2162 },
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002163 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002164 whole_static_libs: [
2165 "libarm-optimized-routines-mem",
Pierre-Clément Tosieb46ac92023-02-01 13:44:57 +00002166 "libc_netbsd",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002167 ],
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002168 system_shared_libs: [],
2169 nocrt: true,
2170 stl: "none",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002171 visibility: [
Jiyong Park072ce532024-07-22 11:20:47 +09002172 "//packages/modules/Virtualization/libs/libvmbase",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002173 ],
Zijun427504a2024-08-15 23:16:27 +00002174
2175 // b/358211032: This library gets linked into a rust rlib. Disable LTO
2176 // until cross-language lto is supported.
2177 lto: {
2178 never: true,
2179 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002180}
2181
2182// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002183// NDK headers.
2184// ========================================================
2185
Dan Albertcce54372024-08-22 18:24:30 +00002186ndk_headers {
Dan Albert22805ea2017-03-22 15:28:05 -07002187 name: "common_libc",
2188 from: "include",
2189 to: "",
Dan Albertcce54372024-08-22 18:24:30 +00002190 srcs: ["include/**/*.h"],
Dan Albert22805ea2017-03-22 15:28:05 -07002191 license: "NOTICE",
Dan Albertcce54372024-08-22 18:24:30 +00002192 // These don't pass the bad verification we do because many of them are
2193 // arch-specific, and they aren't necessarily independently includable.
2194 // That's not much of a problem though, since C-incompaitibilities in the
2195 // UAPI headers should run into problems long before they reach us.
2196 skip_verification: true,
Dan Albert22805ea2017-03-22 15:28:05 -07002197}
Dan Albert4238a352016-06-28 11:18:05 -07002198
2199ndk_headers {
Dan Albert063e86a2016-11-29 11:09:12 -08002200 name: "libc_uapi",
2201 from: "kernel/uapi",
2202 to: "",
2203 srcs: [
2204 "kernel/uapi/asm-generic/**/*.h",
2205 "kernel/uapi/drm/**/*.h",
2206 "kernel/uapi/linux/**/*.h",
2207 "kernel/uapi/misc/**/*.h",
2208 "kernel/uapi/mtd/**/*.h",
2209 "kernel/uapi/rdma/**/*.h",
2210 "kernel/uapi/scsi/**/*.h",
2211 "kernel/uapi/sound/**/*.h",
2212 "kernel/uapi/video/**/*.h",
2213 "kernel/uapi/xen/**/*.h",
2214 ],
Dan Albert92592652016-10-20 01:42:54 -07002215 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002216 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002217}
2218
2219ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002220 name: "libc_kernel_android_uapi_linux",
Dan Albertbae16ef2016-09-14 17:15:48 -07002221 from: "kernel/android/uapi/linux",
2222 to: "linux",
2223 srcs: ["kernel/android/uapi/linux/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002224 license: "NOTICE",
Dan Albertbae16ef2016-09-14 17:15:48 -07002225}
2226
2227ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002228 name: "libc_kernel_android_scsi",
Elliott Hughes50599392017-05-25 17:13:32 -07002229 from: "kernel/android/scsi/scsi",
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002230 to: "scsi",
2231 srcs: ["kernel/android/scsi/**/*.h"],
2232 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002233 skip_verification: true,
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002234}
2235
2236ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002237 name: "libc_asm_arm",
2238 from: "kernel/uapi/asm-arm",
2239 to: "arm-linux-androideabi",
2240 srcs: ["kernel/uapi/asm-arm/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002241 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002242 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002243}
2244
2245ndk_headers {
2246 name: "libc_asm_arm64",
2247 from: "kernel/uapi/asm-arm64",
2248 to: "aarch64-linux-android",
2249 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002250 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002251 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002252}
2253
Lazar Trsic790d2f72017-11-27 11:54:11 +01002254ndk_headers {
Colin Crossbd26e0f2022-10-19 15:03:14 -07002255 name: "libc_asm_riscv64",
2256 from: "kernel/uapi/asm-riscv",
2257 to: "riscv64-linux-android",
2258 srcs: ["kernel/uapi/asm-riscv/**/*.h"],
2259 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002260 skip_verification: true,
Colin Crossbd26e0f2022-10-19 15:03:14 -07002261}
2262
2263ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002264 name: "libc_asm_x86",
2265 from: "kernel/uapi/asm-x86",
2266 to: "i686-linux-android",
2267 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002268 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002269 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002270}
2271
2272ndk_headers {
2273 name: "libc_asm_x86_64",
2274 from: "kernel/uapi/asm-x86",
2275 to: "x86_64-linux-android",
2276 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002277 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002278 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002279}
2280
Dan Albert4238a352016-06-28 11:18:05 -07002281ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002282 name: "libc",
Dan Albert4238a352016-06-28 11:18:05 -07002283 symbol_file: "libc.map.txt",
2284 first_version: "9",
2285}
2286
Dan Albertdf31aff2016-10-06 15:50:41 -07002287ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002288 name: "libstdc++",
Dan Albertdf31aff2016-10-06 15:50:41 -07002289 symbol_file: "libstdc++.map.txt",
2290 first_version: "9",
2291}
2292
Dan Willemsenca056d72018-01-08 14:00:24 -08002293// Export these headers for toolbox to process
2294filegroup {
2295 name: "kernel_input_headers",
2296 srcs: [
2297 "kernel/uapi/linux/input.h",
2298 "kernel/uapi/linux/input-event-codes.h",
2299 ],
2300}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002301
2302// Generate a syscall name / number mapping. These objects are text files
2303// (thanks to the -dD -E flags) and not binary files. They will then be
2304// consumed by the genseccomp.py script and converted into C++ code.
2305cc_defaults {
2306 name: "libseccomp_gen_syscall_nrs_defaults",
2307 recovery_available: true,
2308 srcs: ["seccomp/gen_syscall_nrs.cpp"],
2309 cflags: [
2310 "-dD",
2311 "-E",
2312 "-Wall",
2313 "-Werror",
2314 "-nostdinc",
2315 ],
2316}
2317
2318cc_object {
2319 name: "libseccomp_gen_syscall_nrs_arm",
2320 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2321 local_include_dirs: [
2322 "kernel/uapi/asm-arm",
2323 "kernel/uapi",
2324 ],
2325}
2326
2327cc_object {
2328 name: "libseccomp_gen_syscall_nrs_arm64",
2329 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2330 local_include_dirs: [
2331 "kernel/uapi/asm-arm64",
2332 "kernel/uapi",
2333 ],
2334}
2335
2336cc_object {
Elliott Hughes704772b2022-10-10 17:06:43 +00002337 name: "libseccomp_gen_syscall_nrs_riscv64",
2338 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2339 local_include_dirs: [
2340 "kernel/uapi/asm-riscv",
2341 "kernel/uapi",
2342 ],
2343}
2344
2345cc_object {
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002346 name: "libseccomp_gen_syscall_nrs_x86",
2347 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2348 srcs: ["seccomp/gen_syscall_nrs_x86.cpp"],
2349 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2350 local_include_dirs: [
2351 "kernel/uapi/asm-x86",
2352 "kernel/uapi",
2353 ],
2354}
2355
2356cc_object {
2357 name: "libseccomp_gen_syscall_nrs_x86_64",
2358 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2359 srcs: ["seccomp/gen_syscall_nrs_x86_64.cpp"],
2360 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2361 local_include_dirs: [
2362 "kernel/uapi/asm-x86",
2363 "kernel/uapi",
2364 ],
2365}
2366
Jingwen Chenca366332021-01-29 05:16:32 -05002367filegroup {
2368 name: "all_kernel_uapi_headers",
2369 srcs: ["kernel/uapi/**/*.h"],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002370}
2371
Martijn Coenen0c6de752019-01-02 12:52:51 +01002372cc_genrule {
2373 name: "func_to_syscall_nrs",
2374 recovery_available: true,
2375 cmd: "$(location genfunctosyscallnrs) --out-dir=$(genDir) $(in)",
2376
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002377 tools: ["genfunctosyscallnrs"],
Martijn Coenen0c6de752019-01-02 12:52:51 +01002378
2379 srcs: [
2380 "SYSCALLS.TXT",
Martijn Coenen0c6de752019-01-02 12:52:51 +01002381 ],
2382
Elliott Hughes704772b2022-10-10 17:06:43 +00002383 arch: {
2384 arm: {
2385 srcs: [
2386 ":libseccomp_gen_syscall_nrs_arm",
2387 ":libseccomp_gen_syscall_nrs_arm64",
2388 ],
2389 },
2390 arm64: {
2391 srcs: [
2392 ":libseccomp_gen_syscall_nrs_arm",
2393 ":libseccomp_gen_syscall_nrs_arm64",
2394 ],
2395 },
2396 riscv64: {
2397 srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
2398 },
2399 x86: {
2400 srcs: [
2401 ":libseccomp_gen_syscall_nrs_x86",
2402 ":libseccomp_gen_syscall_nrs_x86_64",
2403 ],
2404 },
2405 x86_64: {
2406 srcs: [
2407 ":libseccomp_gen_syscall_nrs_x86",
2408 ":libseccomp_gen_syscall_nrs_x86_64",
2409 ],
2410 },
2411 },
2412
Martijn Coenen0c6de752019-01-02 12:52:51 +01002413 out: [
2414 "func_to_syscall_nrs.h",
2415 ],
2416}
2417
Victor Hsiehdbb86702020-06-15 09:29:07 -07002418// SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT = SECCOMP_BLOCKLIST_APP.txt - setresgid*
Martijn Coenenc3752be2019-01-09 16:19:57 +01002419genrule {
Victor Hsiehdbb86702020-06-15 09:29:07 -07002420 name: "generate_app_zygote_blocklist",
2421 out: ["SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT"],
2422 srcs: ["SECCOMP_BLOCKLIST_APP.TXT"],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002423 cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)",
2424}
2425
Yu Liu938ec9b2022-10-17 16:36:30 -07002426filegroup {
2427 name: "seccomp_syscalls_sources_zygote",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002428 srcs: [
2429 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002430 "SECCOMP_ALLOWLIST_COMMON.TXT",
2431 "SECCOMP_ALLOWLIST_APP.TXT",
2432 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002433 "SECCOMP_PRIORITY.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002434 ":generate_app_zygote_blocklist",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002435 ],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002436}
2437
Yu Liu938ec9b2022-10-17 16:36:30 -07002438filegroup {
2439 name: "seccomp_syscalls_sources_app",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002440 srcs: [
2441 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002442 "SECCOMP_ALLOWLIST_COMMON.TXT",
2443 "SECCOMP_ALLOWLIST_APP.TXT",
2444 "SECCOMP_BLOCKLIST_COMMON.TXT",
2445 "SECCOMP_BLOCKLIST_APP.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002446 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002447 ],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002448}
2449
Yu Liu938ec9b2022-10-17 16:36:30 -07002450filegroup {
2451 name: "seccomp_syscalls_sources_system",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002452 srcs: [
2453 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002454 "SECCOMP_ALLOWLIST_COMMON.TXT",
2455 "SECCOMP_ALLOWLIST_SYSTEM.TXT",
2456 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002457 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002458 ],
Yu Liu938ec9b2022-10-17 16:36:30 -07002459}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002460
Yu Liu938ec9b2022-10-17 16:36:30 -07002461cc_genrule {
2462 name: "libseccomp_policy_app_zygote_sources_x86",
2463 recovery_available: true,
2464 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002465 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002466 srcs: [
2467 ":seccomp_syscalls_sources_zygote",
2468 ":libseccomp_gen_syscall_nrs_x86",
2469 ":libseccomp_gen_syscall_nrs_x86_64",
2470 ],
2471 out: [
2472 "x86_app_zygote_policy.cpp",
2473 "x86_64_app_zygote_policy.cpp",
2474 ],
2475 enabled: false,
Yu Liu3a579692022-10-18 03:02:32 +00002476 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002477 x86: {
2478 enabled: true,
2479 },
2480 x86_64: {
2481 enabled: true,
2482 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002483 },
2484}
2485
2486cc_genrule {
2487 name: "libseccomp_policy_app_zygote_sources_arm",
2488 recovery_available: true,
2489 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002490 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002491 srcs: [
2492 ":seccomp_syscalls_sources_zygote",
2493 ":libseccomp_gen_syscall_nrs_arm",
2494 ":libseccomp_gen_syscall_nrs_arm64",
2495 ],
2496 out: [
2497 "arm_app_zygote_policy.cpp",
2498 "arm64_app_zygote_policy.cpp",
2499 ],
2500 enabled: false,
2501 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002502 arm: {
2503 enabled: true,
2504 },
2505 arm64: {
2506 enabled: true,
2507 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002508 },
2509}
2510
2511cc_genrule {
2512 name: "libseccomp_policy_app_zygote_sources_riscv64",
2513 recovery_available: true,
2514 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002515 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002516 srcs: [
2517 ":seccomp_syscalls_sources_zygote",
2518 ":libseccomp_gen_syscall_nrs_riscv64",
2519 ],
2520 out: [
2521 "riscv64_app_zygote_policy.cpp",
2522 ],
2523 enabled: false,
2524 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002525 riscv64: {
2526 enabled: true,
2527 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002528 },
2529}
2530
2531cc_genrule {
2532 name: "libseccomp_policy_app_sources_x86",
2533 recovery_available: true,
2534 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002535 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002536 srcs: [
2537 ":seccomp_syscalls_sources_app",
2538 ":libseccomp_gen_syscall_nrs_x86",
2539 ":libseccomp_gen_syscall_nrs_x86_64",
2540 ],
2541 out: [
2542 "x86_app_policy.cpp",
2543 "x86_64_app_policy.cpp",
2544 ],
2545 enabled: false,
2546 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002547 x86: {
2548 enabled: true,
2549 },
2550 x86_64: {
2551 enabled: true,
2552 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002553 },
2554}
2555
2556cc_genrule {
2557 name: "libseccomp_policy_app_sources_arm",
2558 recovery_available: true,
2559 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002560 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002561 srcs: [
2562 ":seccomp_syscalls_sources_app",
2563 ":libseccomp_gen_syscall_nrs_arm",
2564 ":libseccomp_gen_syscall_nrs_arm64",
2565 ],
2566 out: [
2567 "arm_app_policy.cpp",
2568 "arm64_app_policy.cpp",
2569 ],
2570 enabled: false,
2571 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002572 arm: {
2573 enabled: true,
2574 },
2575 arm64: {
2576 enabled: true,
2577 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002578 },
2579}
2580
2581cc_genrule {
2582 name: "libseccomp_policy_app_sources_riscv64",
2583 recovery_available: true,
2584 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002585 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002586 srcs: [
2587 ":seccomp_syscalls_sources_app",
2588 ":libseccomp_gen_syscall_nrs_riscv64",
2589 ],
2590 out: [
2591 "riscv64_app_policy.cpp",
2592 ],
2593 enabled: false,
2594 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002595 riscv64: {
2596 enabled: true,
2597 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002598 },
2599}
2600
2601cc_genrule {
2602 name: "libseccomp_policy_system_sources_x86",
2603 recovery_available: true,
2604 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002605 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002606 srcs: [
2607 ":seccomp_syscalls_sources_system",
2608 ":libseccomp_gen_syscall_nrs_x86",
2609 ":libseccomp_gen_syscall_nrs_x86_64",
2610 ],
2611 out: [
2612 "x86_system_policy.cpp",
2613 "x86_64_system_policy.cpp",
2614 ],
2615 enabled: false,
2616 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002617 x86: {
2618 enabled: true,
2619 },
2620 x86_64: {
2621 enabled: true,
2622 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002623 },
2624}
2625
2626cc_genrule {
2627 name: "libseccomp_policy_system_sources_arm",
2628 recovery_available: true,
2629 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002630 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002631 srcs: [
2632 ":seccomp_syscalls_sources_system",
2633 ":libseccomp_gen_syscall_nrs_arm",
2634 ":libseccomp_gen_syscall_nrs_arm64",
2635 ],
2636 out: [
2637 "arm_system_policy.cpp",
2638 "arm64_system_policy.cpp",
2639 ],
2640 enabled: false,
2641 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002642 arm: {
2643 enabled: true,
2644 },
2645 arm64: {
2646 enabled: true,
2647 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002648 },
2649}
2650
2651cc_genrule {
2652 name: "libseccomp_policy_system_sources_riscv64",
2653 recovery_available: true,
2654 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002655 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002656 srcs: [
2657 ":seccomp_syscalls_sources_system",
2658 ":libseccomp_gen_syscall_nrs_riscv64",
2659 ],
2660 out: [
2661 "riscv64_system_policy.cpp",
2662 ],
2663 enabled: false,
2664 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002665 riscv64: {
2666 enabled: true,
2667 },
Yu Liu3a579692022-10-18 03:02:32 +00002668 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002669}
2670
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002671cc_library {
2672 name: "libseccomp_policy",
2673 recovery_available: true,
Martijn Coenend269d9b2018-11-08 16:41:42 +01002674 generated_headers: ["func_to_syscall_nrs"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002675
2676 arch: {
2677 arm: {
2678 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002679 "libseccomp_policy_app_sources_arm",
2680 "libseccomp_policy_app_zygote_sources_arm",
2681 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002682 ],
2683 },
2684 arm64: {
2685 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002686 "libseccomp_policy_app_sources_arm",
2687 "libseccomp_policy_app_zygote_sources_arm",
2688 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002689 ],
2690 },
2691 riscv64: {
2692 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002693 "libseccomp_policy_app_sources_riscv64",
2694 "libseccomp_policy_app_zygote_sources_riscv64",
2695 "libseccomp_policy_system_sources_riscv64",
Yu Liu938ec9b2022-10-17 16:36:30 -07002696 ],
2697 },
2698 x86: {
2699 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002700 "libseccomp_policy_app_sources_x86",
2701 "libseccomp_policy_app_zygote_sources_x86",
2702 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002703 ],
2704 },
2705 x86_64: {
2706 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002707 "libseccomp_policy_app_sources_x86",
2708 "libseccomp_policy_app_zygote_sources_x86",
2709 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002710 ],
2711 },
2712 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002713
2714 srcs: [
2715 "seccomp/seccomp_policy.cpp",
2716 ],
2717
2718 export_include_dirs: ["seccomp/include"],
2719 cflags: [
2720 "-Wall",
2721 "-Werror",
2722 ],
2723 shared: {
2724 shared_libs: ["libbase"],
2725 },
2726 static: {
2727 static_libs: ["libbase"],
2728 },
2729}
Christopher Ferrisfc26d712019-02-27 18:07:55 -08002730
Colin Cross048f24e2021-09-01 17:26:00 -07002731cc_library_host_static {
2732 name: "libfts",
2733 srcs: [
2734 "bionic/fts.c",
2735 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
2736 ],
2737 export_include_dirs: ["fts/include"],
2738 local_include_dirs: [
2739 "private",
2740 "upstream-openbsd/android/include",
2741 ],
2742 cflags: [
2743 "-include openbsd-compat.h",
2744 "-Wno-unused-parameter",
2745 ],
2746 enabled: false,
2747 target: {
2748 musl: {
2749 enabled: true,
2750 },
2751 },
Colin Cross2a9843f2022-01-13 12:26:30 -08002752 stl: "none",
2753}
2754
2755cc_library_host_static {
2756 name: "libexecinfo",
2757 visibility: ["//external/musl"],
2758 srcs: ["bionic/execinfo.cpp"],
2759 export_include_dirs: ["execinfo/include"],
2760 local_include_dirs: ["private"],
2761 enabled: false,
2762 target: {
2763 musl: {
2764 enabled: true,
2765 system_shared_libs: [],
2766 header_libs: ["libc_musl_headers"],
2767 },
2768 },
2769 stl: "none",
Colin Cross048f24e2021-09-01 17:26:00 -07002770}
2771
Colin Cross9da85fa2022-01-24 18:20:05 -08002772cc_library_host_static {
2773 name: "libb64",
2774 visibility: ["//external/musl"],
2775 srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
2776 export_include_dirs: ["b64/include"],
2777 local_include_dirs: [
2778 "private",
2779 "upstream-openbsd/android/include",
2780 ],
2781 cflags: [
2782 "-include openbsd-compat.h",
2783 ],
2784 enabled: false,
2785 target: {
2786 musl: {
2787 enabled: true,
2788 system_shared_libs: [],
2789 header_libs: ["libc_musl_headers"],
2790 },
2791 },
2792 stl: "none",
2793}
2794
Colin Cross9d4a56e2022-02-03 10:20:32 -08002795// Export kernel uapi headers to be used in the musl sysroot.
2796// Also include the execinfo headers for the libexecinfo and the
2797// b64 headers for libb64 embedded in musl libc.
2798cc_genrule {
2799 name: "libc_musl_sysroot_bionic_headers",
2800 visibility: ["//external/musl"],
2801 host_supported: true,
2802 device_supported: false,
2803 enabled: false,
2804 target: {
2805 musl: {
2806 enabled: true,
2807 },
2808 },
2809 srcs: [
2810 "kernel/uapi/**/*.h",
2811 "kernel/android/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002812 "execinfo/include/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002813 "b64/include/**/*.h",
Colin Crossaeef9f02022-02-07 21:01:26 -08002814
Colin Crossaeef9f02022-02-07 21:01:26 -08002815 "NOTICE",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002816
2817 ":libc_musl_sysroot_bionic_arch_headers",
2818 ],
2819 out: ["libc_musl_sysroot_bionic_headers.zip"],
2820 tools: [
2821 "soong_zip",
2822 "merge_zips",
2823 "zip2zip",
2824 ],
Colin Crossaeef9f02022-02-07 21:01:26 -08002825 cmd: "BIONIC_LIBC_DIR=$$(dirname $(location NOTICE)) && " +
2826 "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
Colin Crossad33d022022-02-25 18:27:04 -08002827 // NOTICE
2828 " -j -f $(location NOTICE) " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002829 // headers
2830 " -P include " +
Colin Crossaeef9f02022-02-07 21:01:26 -08002831 " -C $${BIONIC_LIBC_DIR}/kernel/uapi " +
2832 " -D $${BIONIC_LIBC_DIR}/kernel/uapi " +
2833 " -C $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2834 " -D $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2835 " -C $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2836 " -D $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2837 " -C $${BIONIC_LIBC_DIR}/execinfo/include " +
2838 " -D $${BIONIC_LIBC_DIR}/execinfo/include " +
2839 " -C $${BIONIC_LIBC_DIR}/b64/include " +
2840 " -D $${BIONIC_LIBC_DIR}/b64/include " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002841 " && " +
Colin Crossad33d022022-02-25 18:27:04 -08002842 "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(genDir)/sysroot-renamed.zip " +
Colin Cross1c0a7a02022-08-11 12:22:26 -07002843 " -x **/BUILD " +
Colin Crossad33d022022-02-25 18:27:04 -08002844 " include/**/*:include/ " +
2845 " NOTICE:NOTICE.bionic " +
2846 " && " +
2847 "$(location merge_zips) $(out) $(location :libc_musl_sysroot_bionic_arch_headers) $(genDir)/sysroot-renamed.zip",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002848}
2849
2850// The architecture-specific bits have to be handled separately because the label varies based
2851// on architecture, which prevents using $(locations) to find them and requires using $(in)
2852// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
2853// genrule.
2854cc_genrule {
2855 name: "libc_musl_sysroot_bionic_arch_headers",
2856 visibility: ["//visibility:private"],
2857 host_supported: true,
2858 device_supported: false,
2859 enabled: false,
2860 target: {
2861 musl: {
2862 enabled: true,
2863 },
2864 },
2865 arch: {
2866 arm: {
2867 srcs: ["kernel/uapi/asm-arm/**/*.h"],
2868 },
2869 arm64: {
2870 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
2871 },
2872 x86: {
2873 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2874 },
2875 x86_64: {
2876 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2877 },
2878 },
2879 out: ["libc_musl_sysroot_bionic_arch_headers.zip"],
2880 tools: ["soong_zip"],
2881 cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/asm -j -D $$(dirname $${includes[0]})",
2882}
Colin Cross290c4952022-10-13 12:51:13 -07002883
2884cc_genrule {
2885 name: "bionic_sysroot_crt_objects",
2886 visibility: ["//visibility:private"],
2887 out: ["bionic_sysroot_crt_objects.zip"],
2888 tools: ["soong_zip"],
2889 srcs: [
2890 ":crtbegin_dynamic",
2891 ":crtbegin_so",
2892 ":crtbegin_static",
2893 ":crtend_android",
2894 ":crtend_so",
2895 ],
2896 cmd: "$(location soong_zip) -o $(out) -j " +
2897 "-f $(location :crtbegin_dynamic) " +
2898 "-f $(location :crtbegin_so) " +
2899 "-f $(location :crtbegin_static) " +
2900 "-f $(location :crtend_android) " +
2901 "-f $(location :crtend_so)",
2902 dist: {
2903 targets: ["bionic_sysroot_crt_objects"],
2904 },
2905 arch: {
2906 arm: {
2907 dist: {
2908 suffix: "_arm",
2909 },
2910 },
2911 arm64: {
2912 dist: {
2913 suffix: "_arm64",
2914 },
2915 },
2916 riscv64: {
2917 dist: {
2918 suffix: "_riscv64",
2919 },
2920 },
2921 x86: {
2922 dist: {
2923 suffix: "_x86",
2924 },
2925 },
2926 x86_64: {
2927 dist: {
2928 suffix: "_x86_64",
2929 },
2930 },
2931 },
2932}
Spandan Das8fce52a2023-09-28 18:00:12 +00002933
Jiyong Park35a280d2024-05-03 16:53:39 +09002934filegroup {
2935 name: "linux_capability_header",
2936 srcs: ["kernel/uapi/linux/capability.h"],
2937}