blob: 76f0dfb785c13d0954b23d77d4489db8d30c861a [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"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700107}
108
Elliott Hughes788075a2024-06-18 12:25:37 +0000109// Workaround for b/24465209.
110// We're unlikely to be able to remove this before we just
111// remove ILP32 support completely.
112// Note that we also still have `pack_relocations: false`
113// for both libc and libm, even on LP64.
114// ========================================================
115cc_defaults {
116 name: "bug_24465209_workaround",
Elliott Hughesfeb94732024-06-18 19:44:18 +0000117 target: {
118 android_arm: {
Elliott Hughes788075a2024-06-18 12:25:37 +0000119 pack_relocations: false,
120 ldflags: ["-Wl,--hash-style=both"],
121 },
Elliott Hughesfeb94732024-06-18 19:44:18 +0000122 android_x86: {
Elliott Hughes788075a2024-06-18 12:25:37 +0000123 pack_relocations: false,
124 ldflags: ["-Wl,--hash-style=both"],
Elliott Hughesb4e02782024-06-21 11:35:18 +0000125 },
Elliott Hughes788075a2024-06-18 12:25:37 +0000126 },
127}
128
Elliott Hughes89aada12024-07-01 21:59:04 +0000129// Leave the symbols in the shared library so that stack unwinders can produce
130// meaningful name resolution. This is a bit more ugly than it sounds because
131// arm32 is a bit broken.
132// ========================================================
133cc_defaults {
134 name: "keep_symbols",
135 arch: {
136 arm: {
137 // arm32 does not produce complete exidx unwind information,
138 // so keep the .debug_frame which is relatively small and does
139 // include needed unwind information.
140 // See b/132992102 for details.
141 strip: {
142 keep_symbols_and_debug_frame: true,
143 },
144 },
145 arm64: {
146 strip: {
147 keep_symbols: true,
148 },
149 },
150 riscv64: {
151 strip: {
152 keep_symbols: true,
153 },
154 },
155 x86: {
156 strip: {
157 keep_symbols: true,
158 },
159 },
160 x86_64: {
161 strip: {
162 keep_symbols: true,
163 },
164 },
165 },
166}
167
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700168// Defaults for native allocator libs/includes to make it
169// easier to change.
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700170// ========================================================
171cc_defaults {
172 name: "libc_native_allocator_defaults",
173
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700174 whole_static_libs: [
Christopher Ferrisb5425052024-04-23 17:15:39 -0700175 "libscudo",
176 ],
177 cflags: [
178 "-DUSE_SCUDO",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700179 ],
Mitch Phillipsf3968e82020-01-31 19:57:04 -0800180 header_libs: ["gwp_asan_headers"],
Christopher Ferrisb5425052024-04-23 17:15:39 -0700181 product_variables: {
182 malloc_low_memory: {
183 cflags: ["-UUSE_SCUDO"],
184 whole_static_libs: [
185 "libjemalloc5",
186 "libc_jemalloc_wrapper",
187 ],
188 exclude_static_libs: [
189 "libscudo",
190 ],
191 },
192 },
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700193}
194
195// Functions not implemented by jemalloc directly, or that need to
196// be modified for Android.
197cc_library_static {
198 name: "libc_jemalloc_wrapper",
199 defaults: ["libc_defaults"],
200 srcs: ["bionic/jemalloc_wrapper.cpp"],
201 cflags: ["-fvisibility=hidden"],
202
Christopher Ferris4df29ed2020-01-24 18:06:42 -0800203 // Used to pull in the jemalloc include directory so that if the
204 // library is removed, the include directory is also removed.
205 static_libs: ["libjemalloc5"],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700206}
207
Dan Willemsen208ae172015-09-16 16:33:27 -0700208// ========================================================
Ryan Prichard249757b2019-11-01 17:18:28 -0700209// libc_bootstrap.a - -fno-stack-protector and -ffreestanding
Dan Willemsen208ae172015-09-16 16:33:27 -0700210// ========================================================
211//
Ryan Prichard249757b2019-11-01 17:18:28 -0700212// Code that implements the stack protector (or that runs before TLS has been set up) needs to be
213// compiled with -fno-stack-protector, since it accesses the stack canary TLS slot. In the linker,
214// some of this code runs before ifunc resolvers have made string.h functions work, so compile with
215// -ffreestanding.
Dan Willemsen208ae172015-09-16 16:33:27 -0700216
217cc_library_static {
218
Colin Crossa3f9fca2016-01-11 13:20:55 -0800219 srcs: [
220 "bionic/__libc_init_main_thread.cpp",
221 "bionic/__stack_chk_fail.cpp",
Ryan Prichard249757b2019-11-01 17:18:28 -0700222 "bionic/bionic_call_ifunc_resolver.cpp",
223 "bionic/getauxval.cpp",
Colin Crossa3f9fca2016-01-11 13:20:55 -0800224 ],
225 arch: {
226 arm64: {
227 srcs: ["arch-arm64/bionic/__set_tls.c"],
228 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000229 riscv64: {
230 srcs: ["arch-riscv64/bionic/__set_tls.c"],
231 },
Colin Crossa3f9fca2016-01-11 13:20:55 -0800232 x86: {
Ryan Prichard27475b52018-05-17 17:14:18 -0700233 srcs: [
234 "arch-x86/bionic/__libc_init_sysinfo.cpp",
Pirama Arumuga Nainar7b89be72021-02-12 15:09:49 -0800235 "arch-x86/bionic/__libc_int0x80.S",
Ryan Prichard27475b52018-05-17 17:14:18 -0700236 "arch-x86/bionic/__set_tls.cpp",
237 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800238 },
239 x86_64: {
240 srcs: ["arch-x86_64/bionic/__set_tls.c"],
241 },
242 },
243
Colin Cross50c21ab2015-10-31 23:03:05 -0700244 defaults: ["libc_defaults"],
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000245 cflags: [
246 "-fno-stack-protector",
247 "-ffreestanding",
248 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700249 name: "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -0700250}
251
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800252filegroup {
253 name: "elf_note_sources",
254 srcs: ["bionic/elf_note.cpp"],
255}
256
Ryan Prichard249757b2019-11-01 17:18:28 -0700257// libc_init_static.cpp and libc_init_dynamic.cpp need to be built without stack protector.
258// libc_init_static.cpp sets up TLS for static executables, and libc_init_dynamic.cpp initializes
259// the stack protector global variable.
Colin Crossa3f9fca2016-01-11 13:20:55 -0800260
261cc_library_static {
262 name: "libc_init_static",
263 defaults: ["libc_defaults"],
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800264 srcs: [
Florian Mayera6e9dcf2024-11-06 12:41:22 -0800265 "bionic/libc_init_mte.cpp",
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800266 "bionic/libc_init_static.cpp",
267 ":elf_note_sources",
268 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700269 cflags: [
270 "-fno-stack-protector",
271
272 // Compile libc_init_static.cpp with -ffreestanding, because some of its code is called
273 // from the linker before ifunc resolvers have made string.h functions available.
274 "-ffreestanding",
275 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800276}
277
Stephen Cranef4b1cbd2017-05-09 14:27:43 -0700278cc_library_static {
279 name: "libc_init_dynamic",
280 defaults: ["libc_defaults"],
281 srcs: ["bionic/libc_init_dynamic.cpp"],
282 cflags: ["-fno-stack-protector"],
283}
Colin Crossa3f9fca2016-01-11 13:20:55 -0800284
Dan Willemsen208ae172015-09-16 16:33:27 -0700285// ========================================================
286// libc_tzcode.a - upstream 'tzcode' code
287// ========================================================
288
289cc_library_static {
290
Colin Cross50c21ab2015-10-31 23:03:05 -0700291 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700292 srcs: [
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800293 "tzcode/**/*.c",
Elliott Hughes0e8616a2017-04-11 14:44:51 -0700294 "tzcode/bionic.cpp",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700295 // tzcode doesn't include strptime, so we use a fork of the
296 // OpenBSD code which needs this global data.
Elliott Hughesd3627a42022-12-06 22:24:27 +0000297 "upstream-openbsd/lib/libc/locale/_def_time.c",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700298 // tzcode doesn't include wcsftime, so we use the FreeBSD code.
299 "upstream-freebsd/lib/libc/locale/wcsftime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700300 ],
301
Colin Cross50c21ab2015-10-31 23:03:05 -0700302 cflags: [
Dan Willemsen268a6732015-10-15 14:49:45 -0700303 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700304 // Don't use ridiculous amounts of stack.
305 "-DALL_STATE",
306 // Include tzsetwall, timelocal, timegm, time2posix, and posix2time.
307 "-DSTD_INSPIRED",
Colin Crossa35d23d2015-11-19 13:32:49 -0800308 // Obviously, we want to be thread-safe.
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000309 "-DTHREAD_SAFE=1",
Dan Willemsen208ae172015-09-16 16:33:27 -0700310 // The name of the tm_gmtoff field in our struct tm.
311 "-DTM_GMTOFF=tm_gmtoff",
Elliott Hughes31fc69f2023-06-20 15:36:11 -0700312 // Android uses a system property instead of /etc/localtime, so make callers crash.
Almaz Mingaleeva52a0da2022-02-28 16:55:50 +0000313 "-DTZDEFAULT=NULL",
Dan Willemsen208ae172015-09-16 16:33:27 -0700314 // Where we store our tzdata.
Colin Cross7b294952016-09-29 14:08:13 -0700315 "-DTZDIR=\"/system/usr/share/zoneinfo\"",
Elliott Hughes0a610d02016-07-29 14:04:17 -0700316 // Include `tzname`, `timezone`, and `daylight` globals.
317 "-DHAVE_POSIX_DECLS=0",
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000318 "-DUSG_COMPAT=2",
319 "-DHAVE_TZNAME=2",
320 // stdbool.h is available
321 "-DHAVE_STDBOOL_H",
Colin Crossa35d23d2015-11-19 13:32:49 -0800322 // Use the empty string (instead of " ") as the timezone abbreviation
323 // fallback.
Colin Cross7b294952016-09-29 14:08:13 -0700324 "-DWILDABBR=\"\"",
Dan Willemsen208ae172015-09-16 16:33:27 -0700325 "-Dlint",
326 ],
327
Elliott Hughes2bd43162023-06-15 13:17:08 -0700328 local_include_dirs: [
329 "tzcode/",
330 "upstream-freebsd/android/include",
331 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700332 name: "libc_tzcode",
Dan Willemsen208ae172015-09-16 16:33:27 -0700333}
334
335// ========================================================
336// libc_dns.a - modified NetBSD DNS code
337// ========================================================
338
339cc_library_static {
340
Colin Cross50c21ab2015-10-31 23:03:05 -0700341 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700342 srcs: [
Elliott Hughesd0bbfa82021-04-08 11:58:51 -0700343 "dns/**/*.c*",
Dan Willemsen208ae172015-09-16 16:33:27 -0700344
345 "upstream-netbsd/lib/libc/isc/ev_streams.c",
346 "upstream-netbsd/lib/libc/isc/ev_timers.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700347 ],
348
Colin Cross50c21ab2015-10-31 23:03:05 -0700349 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700350 "-DANDROID_CHANGES",
351 "-DINET6",
Dan Willemsen208ae172015-09-16 16:33:27 -0700352 "-Wno-unused-parameter",
353 "-include netbsd-compat.h",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700354 "-Wframe-larger-than=66000",
Dan Willemsen208ae172015-09-16 16:33:27 -0700355 ],
356
Dan Willemsen208ae172015-09-16 16:33:27 -0700357 local_include_dirs: [
358 "dns/include",
359 "private",
360 "upstream-netbsd/lib/libc/include",
361 "upstream-netbsd/android/include",
362 ],
363
364 name: "libc_dns",
Dan Willemsen208ae172015-09-16 16:33:27 -0700365}
366
367// ========================================================
368// libc_freebsd.a - upstream FreeBSD C library code
369// ========================================================
370//
371// These files are built with the freebsd-compat.h header file
372// automatically included.
373
374cc_library_static {
Elliott Hughesc2043342023-07-20 20:24:09 +0000375 name: "libc_freebsd_ldexp",
376 defaults: ["libc_defaults"],
377 cflags: ["-Dscalbn=ldexp"],
378 srcs: [":libc_ldexp_srcs"],
379}
380
381cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700382 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700383 srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700384 "upstream-freebsd/lib/libc/stdlib/getopt_long.c",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700385 "upstream-freebsd/lib/libc/stdlib/hcreate.c",
386 "upstream-freebsd/lib/libc/stdlib/hcreate_r.c",
387 "upstream-freebsd/lib/libc/stdlib/hdestroy_r.c",
388 "upstream-freebsd/lib/libc/stdlib/hsearch_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700389 "upstream-freebsd/lib/libc/stdlib/qsort.c",
Elliott Hughes5bae5722024-07-30 12:47:33 -0400390 "upstream-freebsd/lib/libc/stdlib/qsort_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700391 "upstream-freebsd/lib/libc/stdlib/quick_exit.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700392 "upstream-freebsd/lib/libc/string/wcpcpy.c",
393 "upstream-freebsd/lib/libc/string/wcpncpy.c",
394 "upstream-freebsd/lib/libc/string/wcscasecmp.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700395 "upstream-freebsd/lib/libc/string/wcscat.c",
396 "upstream-freebsd/lib/libc/string/wcschr.c",
397 "upstream-freebsd/lib/libc/string/wcscmp.c",
398 "upstream-freebsd/lib/libc/string/wcscpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700399 "upstream-freebsd/lib/libc/string/wcscspn.c",
400 "upstream-freebsd/lib/libc/string/wcsdup.c",
401 "upstream-freebsd/lib/libc/string/wcslcat.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700402 "upstream-freebsd/lib/libc/string/wcslen.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700403 "upstream-freebsd/lib/libc/string/wcsncasecmp.c",
404 "upstream-freebsd/lib/libc/string/wcsncat.c",
405 "upstream-freebsd/lib/libc/string/wcsncmp.c",
406 "upstream-freebsd/lib/libc/string/wcsncpy.c",
407 "upstream-freebsd/lib/libc/string/wcsnlen.c",
408 "upstream-freebsd/lib/libc/string/wcspbrk.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700409 "upstream-freebsd/lib/libc/string/wcsrchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700410 "upstream-freebsd/lib/libc/string/wcsspn.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700411 "upstream-freebsd/lib/libc/string/wcsstr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700412 "upstream-freebsd/lib/libc/string/wcstok.c",
413 "upstream-freebsd/lib/libc/string/wmemchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700414 "upstream-freebsd/lib/libc/string/wmemcmp.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700415 "upstream-freebsd/lib/libc/string/wmemcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700416 "upstream-freebsd/lib/libc/string/wmemmove.c",
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800417 "upstream-freebsd/lib/libc/string/wmemset.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700418 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700419
Colin Cross50c21ab2015-10-31 23:03:05 -0700420 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700421 "-Wno-sign-compare",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700422 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700423 "-include freebsd-compat.h",
424 ],
425
Dan Willemsen208ae172015-09-16 16:33:27 -0700426 local_include_dirs: [
427 "upstream-freebsd/android/include",
428 ],
429
430 name: "libc_freebsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700431}
432
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700433cc_library_static {
434 defaults: ["libc_defaults"],
435 srcs: [
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700436 "upstream-freebsd/lib/libc/gen/glob.c",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700437 ],
438
439 cflags: [
440 "-Wno-sign-compare",
441 "-include freebsd-compat.h",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700442 "-Wframe-larger-than=66000",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700443 ],
444
445 local_include_dirs: [
446 "upstream-freebsd/android/include",
447 ],
448
449 name: "libc_freebsd_large_stack",
450}
451
Dan Willemsen208ae172015-09-16 16:33:27 -0700452// ========================================================
453// libc_netbsd.a - upstream NetBSD C library code
454// ========================================================
455//
456// These files are built with the netbsd-compat.h header file
457// automatically included.
458
459cc_library_static {
460
Colin Cross50c21ab2015-10-31 23:03:05 -0700461 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700462 srcs: [
463 "upstream-netbsd/common/lib/libc/stdlib/random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700464 "upstream-netbsd/lib/libc/gen/nice.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700465 "upstream-netbsd/lib/libc/gen/psignal.c",
466 "upstream-netbsd/lib/libc/gen/utime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700467 "upstream-netbsd/lib/libc/inet/nsap_addr.c",
468 "upstream-netbsd/lib/libc/regex/regcomp.c",
469 "upstream-netbsd/lib/libc/regex/regerror.c",
470 "upstream-netbsd/lib/libc/regex/regexec.c",
471 "upstream-netbsd/lib/libc/regex/regfree.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700472 "upstream-netbsd/lib/libc/stdlib/drand48.c",
473 "upstream-netbsd/lib/libc/stdlib/erand48.c",
474 "upstream-netbsd/lib/libc/stdlib/jrand48.c",
475 "upstream-netbsd/lib/libc/stdlib/lcong48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700476 "upstream-netbsd/lib/libc/stdlib/lrand48.c",
477 "upstream-netbsd/lib/libc/stdlib/mrand48.c",
478 "upstream-netbsd/lib/libc/stdlib/nrand48.c",
479 "upstream-netbsd/lib/libc/stdlib/_rand48.c",
480 "upstream-netbsd/lib/libc/stdlib/rand_r.c",
481 "upstream-netbsd/lib/libc/stdlib/reallocarr.c",
482 "upstream-netbsd/lib/libc/stdlib/seed48.c",
483 "upstream-netbsd/lib/libc/stdlib/srand48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700484 ],
485 multilib: {
486 lib32: {
487 // LP32 cruft
488 srcs: ["upstream-netbsd/common/lib/libc/hash/sha1/sha1.c"],
489 },
490 },
Colin Cross50c21ab2015-10-31 23:03:05 -0700491 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700492 "-Wno-sign-compare",
Dan Willemsen879cec22016-02-29 10:37:56 -0800493 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700494 "-DPOSIX_MISTAKE",
495 "-include netbsd-compat.h",
496 ],
497
Dan Willemsen208ae172015-09-16 16:33:27 -0700498 local_include_dirs: [
499 "upstream-netbsd/android/include",
500 "upstream-netbsd/lib/libc/include",
501 ],
502
503 name: "libc_netbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700504}
505
506// ========================================================
Elliott Hughes968adf92024-02-08 13:15:53 -0800507// libc_openbsd.a - upstream OpenBSD C library code
Dan Willemsen208ae172015-09-16 16:33:27 -0700508// ========================================================
509//
510// These files are built with the openbsd-compat.h header file
511// automatically included.
Dan Willemsen208ae172015-09-16 16:33:27 -0700512cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700513 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700514 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800515 "upstream-openbsd/lib/libc/crypt/arc4random.c",
516 "upstream-openbsd/lib/libc/crypt/arc4random_uniform.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700517 "upstream-openbsd/lib/libc/gen/alarm.c",
518 "upstream-openbsd/lib/libc/gen/ctype_.c",
519 "upstream-openbsd/lib/libc/gen/daemon.c",
520 "upstream-openbsd/lib/libc/gen/err.c",
521 "upstream-openbsd/lib/libc/gen/errx.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700522 "upstream-openbsd/lib/libc/gen/fnmatch.c",
523 "upstream-openbsd/lib/libc/gen/ftok.c",
524 "upstream-openbsd/lib/libc/gen/getprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700525 "upstream-openbsd/lib/libc/gen/setprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700526 "upstream-openbsd/lib/libc/gen/verr.c",
527 "upstream-openbsd/lib/libc/gen/verrx.c",
528 "upstream-openbsd/lib/libc/gen/vwarn.c",
529 "upstream-openbsd/lib/libc/gen/vwarnx.c",
530 "upstream-openbsd/lib/libc/gen/warn.c",
531 "upstream-openbsd/lib/libc/gen/warnx.c",
532 "upstream-openbsd/lib/libc/locale/btowc.c",
533 "upstream-openbsd/lib/libc/locale/mbrlen.c",
534 "upstream-openbsd/lib/libc/locale/mbstowcs.c",
535 "upstream-openbsd/lib/libc/locale/mbtowc.c",
536 "upstream-openbsd/lib/libc/locale/wcscoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700537 "upstream-openbsd/lib/libc/locale/wcstombs.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700538 "upstream-openbsd/lib/libc/locale/wcsxfrm.c",
539 "upstream-openbsd/lib/libc/locale/wctob.c",
540 "upstream-openbsd/lib/libc/locale/wctomb.c",
Elliott Hughes26fda772016-04-06 11:56:41 -0700541 "upstream-openbsd/lib/libc/net/base64.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700542 "upstream-openbsd/lib/libc/net/htonl.c",
543 "upstream-openbsd/lib/libc/net/htons.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700544 "upstream-openbsd/lib/libc/net/inet_lnaof.c",
545 "upstream-openbsd/lib/libc/net/inet_makeaddr.c",
546 "upstream-openbsd/lib/libc/net/inet_netof.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700547 "upstream-openbsd/lib/libc/net/inet_ntoa.c",
548 "upstream-openbsd/lib/libc/net/inet_ntop.c",
549 "upstream-openbsd/lib/libc/net/inet_pton.c",
550 "upstream-openbsd/lib/libc/net/ntohl.c",
551 "upstream-openbsd/lib/libc/net/ntohs.c",
Colin Cross8ce38af2016-01-19 12:50:20 -0800552 "upstream-openbsd/lib/libc/net/res_random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700553 "upstream-openbsd/lib/libc/stdio/fgetln.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700554 "upstream-openbsd/lib/libc/stdio/fgetwc.c",
555 "upstream-openbsd/lib/libc/stdio/fgetws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700556 "upstream-openbsd/lib/libc/stdio/flags.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700557 "upstream-openbsd/lib/libc/stdio/fputwc.c",
558 "upstream-openbsd/lib/libc/stdio/fputws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700559 "upstream-openbsd/lib/libc/stdio/fvwrite.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700560 "upstream-openbsd/lib/libc/stdio/fwide.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700561 "upstream-openbsd/lib/libc/stdio/getdelim.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700562 "upstream-openbsd/lib/libc/stdio/gets.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700563 "upstream-openbsd/lib/libc/stdio/makebuf.c",
564 "upstream-openbsd/lib/libc/stdio/mktemp.c",
565 "upstream-openbsd/lib/libc/stdio/open_memstream.c",
566 "upstream-openbsd/lib/libc/stdio/open_wmemstream.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700567 "upstream-openbsd/lib/libc/stdio/rget.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700568 "upstream-openbsd/lib/libc/stdio/setvbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700569 "upstream-openbsd/lib/libc/stdio/ungetc.c",
570 "upstream-openbsd/lib/libc/stdio/ungetwc.c",
571 "upstream-openbsd/lib/libc/stdio/vasprintf.c",
572 "upstream-openbsd/lib/libc/stdio/vdprintf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700573 "upstream-openbsd/lib/libc/stdio/vsscanf.c",
574 "upstream-openbsd/lib/libc/stdio/vswprintf.c",
575 "upstream-openbsd/lib/libc/stdio/vswscanf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700576 "upstream-openbsd/lib/libc/stdio/wbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700577 "upstream-openbsd/lib/libc/stdio/wsetup.c",
578 "upstream-openbsd/lib/libc/stdlib/abs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800579 "upstream-openbsd/lib/libc/stdlib/div.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700580 "upstream-openbsd/lib/libc/stdlib/getenv.c",
Colin Crossb8396102016-04-07 13:24:50 -0700581 "upstream-openbsd/lib/libc/stdlib/getsubopt.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700582 "upstream-openbsd/lib/libc/stdlib/insque.c",
583 "upstream-openbsd/lib/libc/stdlib/imaxabs.c",
584 "upstream-openbsd/lib/libc/stdlib/imaxdiv.c",
585 "upstream-openbsd/lib/libc/stdlib/labs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800586 "upstream-openbsd/lib/libc/stdlib/ldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700587 "upstream-openbsd/lib/libc/stdlib/llabs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800588 "upstream-openbsd/lib/libc/stdlib/lldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700589 "upstream-openbsd/lib/libc/stdlib/lsearch.c",
Elliott Hughes26b06072020-07-31 11:00:10 -0700590 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700591 "upstream-openbsd/lib/libc/stdlib/remque.c",
592 "upstream-openbsd/lib/libc/stdlib/setenv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700593 "upstream-openbsd/lib/libc/stdlib/tfind.c",
594 "upstream-openbsd/lib/libc/stdlib/tsearch.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800595 "upstream-openbsd/lib/libc/string/memccpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700596 "upstream-openbsd/lib/libc/string/strcasecmp.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800597 "upstream-openbsd/lib/libc/string/strcasestr.c",
598 "upstream-openbsd/lib/libc/string/strcoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700599 "upstream-openbsd/lib/libc/string/strcspn.c",
600 "upstream-openbsd/lib/libc/string/strdup.c",
601 "upstream-openbsd/lib/libc/string/strndup.c",
602 "upstream-openbsd/lib/libc/string/strpbrk.c",
603 "upstream-openbsd/lib/libc/string/strsep.c",
604 "upstream-openbsd/lib/libc/string/strspn.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700605 "upstream-openbsd/lib/libc/string/strtok.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800606 "upstream-openbsd/lib/libc/string/strxfrm.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700607 "upstream-openbsd/lib/libc/string/wcslcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700608 "upstream-openbsd/lib/libc/string/wcswidth.c",
Colin Cross69bcb8b2021-09-08 13:24:16 -0700609
Elliott Hughesd4c61182024-08-16 17:31:24 -0400610 // These files are originally from OpenBSD,
611 // and benefit from being compiled with openbsd-compat.h.
612 // TODO: clean them up instead.
Colin Cross69bcb8b2021-09-08 13:24:16 -0700613 "bionic/fts.c",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400614 "stdio/vfprintf.cpp",
615 "stdio/vfwprintf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700616 ],
617
Elliott Hughes7d136662023-10-27 15:40:32 -0700618 // Each architecture has optimized versions of some routines,
619 // and only includes the portable C versions of ones it's missing.
Dan Willemsen208ae172015-09-16 16:33:27 -0700620 arch: {
621 arm: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700622 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700623 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700624 "upstream-openbsd/lib/libc/string/strncat.c",
625 "upstream-openbsd/lib/libc/string/strncmp.c",
626 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700627 ],
628 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700629 arm64: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700630 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700631 "upstream-openbsd/lib/libc/string/strcat.c",
Elliott Hughesaefe9992023-11-08 12:04:41 -0800632 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700633 "upstream-openbsd/lib/libc/string/strncat.c",
634 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700635 ],
636 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000637 riscv64: {
638 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700639 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughesebc19a92022-10-14 23:25:36 +0000640 ],
641 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700642 x86: {
Elliott Hughesaefe9992023-11-08 12:04:41 -0800643 srcs: [
644 // x86 has custom implementations of all of these.
645 ],
Elliott Hughes7d136662023-10-27 15:40:32 -0700646 },
647 x86_64: {
648 srcs: [
George Burgess IV414bfb32024-11-19 09:00:39 -0700649 // x86_64 has custom/llvm-libc implementations of all of these.
Colin Cross6ab8f892015-11-23 14:12:15 -0800650 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700651 },
652 },
653
Colin Cross50c21ab2015-10-31 23:03:05 -0700654 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700655 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700656 "-Wno-unused-parameter",
657 "-include openbsd-compat.h",
658 ],
659
Dan Willemsen208ae172015-09-16 16:33:27 -0700660 local_include_dirs: [
661 "private",
Elliott Hughes968adf92024-02-08 13:15:53 -0800662 "stdio",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400663 "upstream-openbsd/android/include/",
664 "upstream-openbsd/lib/libc/gdtoa/",
665 "upstream-openbsd/lib/libc/include/",
666 "upstream-openbsd/lib/libc/stdio/",
Dan Willemsen208ae172015-09-16 16:33:27 -0700667 ],
668
669 name: "libc_openbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700670}
671
Elliott Hughes968adf92024-02-08 13:15:53 -0800672cc_library_static {
673 name: "libc_openbsd_large_stack",
674 defaults: ["libc_defaults"],
675 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800676 "upstream-openbsd/lib/libc/string/memmem.c",
677 "upstream-openbsd/lib/libc/string/strstr.c",
678 ],
679 cflags: [
680 "-include openbsd-compat.h",
681 "-Wno-sign-compare",
682 "-Wframe-larger-than=5000",
683 ],
684
685 local_include_dirs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800686 "upstream-openbsd/android/include/",
Elliott Hughes968adf92024-02-08 13:15:53 -0800687 ],
688}
689
Dan Willemsen208ae172015-09-16 16:33:27 -0700690// ========================================================
691// libc_gdtoa.a - upstream OpenBSD C library gdtoa code
692// ========================================================
693//
694// These files are built with the openbsd-compat.h header file
695// automatically included.
696
697cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700698 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700699 srcs: [
700 "upstream-openbsd/android/gdtoa_support.cpp",
701 "upstream-openbsd/lib/libc/gdtoa/dmisc.c",
702 "upstream-openbsd/lib/libc/gdtoa/dtoa.c",
703 "upstream-openbsd/lib/libc/gdtoa/gdtoa.c",
704 "upstream-openbsd/lib/libc/gdtoa/gethex.c",
705 "upstream-openbsd/lib/libc/gdtoa/gmisc.c",
706 "upstream-openbsd/lib/libc/gdtoa/hd_init.c",
707 "upstream-openbsd/lib/libc/gdtoa/hdtoa.c",
708 "upstream-openbsd/lib/libc/gdtoa/hexnan.c",
709 "upstream-openbsd/lib/libc/gdtoa/ldtoa.c",
710 "upstream-openbsd/lib/libc/gdtoa/misc.c",
711 "upstream-openbsd/lib/libc/gdtoa/smisc.c",
712 "upstream-openbsd/lib/libc/gdtoa/strtod.c",
713 "upstream-openbsd/lib/libc/gdtoa/strtodg.c",
714 "upstream-openbsd/lib/libc/gdtoa/strtof.c",
715 "upstream-openbsd/lib/libc/gdtoa/strtord.c",
716 "upstream-openbsd/lib/libc/gdtoa/sum.c",
717 "upstream-openbsd/lib/libc/gdtoa/ulp.c",
718 ],
719 multilib: {
720 lib64: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800721 srcs: ["upstream-openbsd/lib/libc/gdtoa/strtorQ.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700722 },
723 },
724
Colin Cross50c21ab2015-10-31 23:03:05 -0700725 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700726 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700727 "-include openbsd-compat.h",
728 ],
729
Dan Willemsen208ae172015-09-16 16:33:27 -0700730 local_include_dirs: [
731 "private",
732 "upstream-openbsd/android/include",
733 "upstream-openbsd/lib/libc/include",
734 ],
735
736 name: "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -0700737}
738
739// ========================================================
Pierre-Clément Tosi467e58e2023-02-01 13:44:43 +0000740// libc_fortify.a - container for our FORTIFY
George Burgess IV6cb06872017-07-21 13:28:42 -0700741// implementation details
742// ========================================================
743cc_library_static {
744 defaults: ["libc_defaults"],
George Burgess IVd34b0a92017-07-25 11:43:39 -0700745 srcs: ["bionic/fortify.cpp"],
George Burgess IV6cb06872017-07-21 13:28:42 -0700746
747 name: "libc_fortify",
748
749 // Disable FORTIFY for the compilation of these, so we don't end up having
750 // FORTIFY silently call itself.
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800751 cflags: [
752 "-U_FORTIFY_SOURCE",
753 "-D__BIONIC_DECLARE_FORTIFY_HELPERS",
754 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700755
756 arch: {
757 arm: {
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800758 cflags: [
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800759 "-DRENAME___STRCAT_CHK",
760 "-DRENAME___STRCPY_CHK",
761 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700762 srcs: [
763 "arch-arm/generic/bionic/__memcpy_chk.S",
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800764
765 "arch-arm/cortex-a15/bionic/__strcat_chk.S",
766 "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
767
768 "arch-arm/cortex-a7/bionic/__strcat_chk.S",
769 "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
770
771 "arch-arm/cortex-a9/bionic/__strcat_chk.S",
772 "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
773
774 "arch-arm/krait/bionic/__strcat_chk.S",
775 "arch-arm/krait/bionic/__strcpy_chk.S",
776
777 "arch-arm/cortex-a53/bionic/__strcat_chk.S",
778 "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
779
Haibo Huang01bfd892018-12-03 15:05:16 -0800780 "arch-arm/cortex-a55/bionic/__strcat_chk.S",
781 "arch-arm/cortex-a55/bionic/__strcpy_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700782 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700783 },
784 arm64: {
785 srcs: [
Elliott Hughes023e4e72022-11-17 19:27:02 +0000786 "arch-arm64/string/__memcpy_chk.S",
787 "arch-arm64/string/__memset_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700788 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700789 },
790 },
791}
792
793// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -0700794// libc_bionic.a - home-grown C library code
795// ========================================================
796
797cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700798 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700799 srcs: [
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800800 "bionic/NetdClientDispatch.cpp",
801 "bionic/__bionic_get_shell_path.cpp",
802 "bionic/__cmsg_nxthdr.cpp",
803 "bionic/__cxa_thread_atexit_impl.cpp",
804 "bionic/__errno.cpp",
805 "bionic/__gnu_basename.cpp",
806 "bionic/__libc_current_sigrtmax.cpp",
807 "bionic/__libc_current_sigrtmin.cpp",
808 "bionic/abort.cpp",
809 "bionic/accept.cpp",
810 "bionic/access.cpp",
Florian Mayerca4749a2024-02-14 12:55:46 -0800811 "bionic/android_crash_detail.cpp",
Josh Gao10ec9282017-04-03 15:13:29 -0700812 "bionic/android_set_abort_message.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000813 "bionic/android_unsafe_frame_pointer_chase.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800814 "bionic/arpa_inet.cpp",
815 "bionic/assert.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000816 "bionic/atexit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800817 "bionic/atof.cpp",
818 "bionic/bionic_allocator.cpp",
819 "bionic/bionic_arc4random.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000820 "bionic/bionic_elf_tls.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800821 "bionic/bionic_futex.cpp",
822 "bionic/bionic_netlink.cpp",
823 "bionic/bionic_systrace.cpp",
824 "bionic/bionic_time_conversions.cpp",
825 "bionic/brk.cpp",
826 "bionic/c16rtomb.cpp",
827 "bionic/c32rtomb.cpp",
828 "bionic/chmod.cpp",
829 "bionic/chown.cpp",
830 "bionic/clearenv.cpp",
831 "bionic/clock.cpp",
832 "bionic/clock_getcpuclockid.cpp",
833 "bionic/clock_nanosleep.cpp",
834 "bionic/clone.cpp",
835 "bionic/ctype.cpp",
836 "bionic/dirent.cpp",
837 "bionic/dup.cpp",
838 "bionic/environ.cpp",
839 "bionic/error.cpp",
840 "bionic/eventfd.cpp",
841 "bionic/exec.cpp",
842 "bionic/execinfo.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800843 "bionic/exit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800844 "bionic/faccessat.cpp",
845 "bionic/fchmod.cpp",
846 "bionic/fchmodat.cpp",
847 "bionic/fcntl.cpp",
848 "bionic/fdsan.cpp",
849 "bionic/fdtrack.cpp",
850 "bionic/ffs.cpp",
851 "bionic/fgetxattr.cpp",
852 "bionic/flistxattr.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000853 "bionic/fork.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800854 "bionic/fpclassify.cpp",
855 "bionic/fsetxattr.cpp",
856 "bionic/ftruncate.cpp",
857 "bionic/ftw.cpp",
858 "bionic/futimens.cpp",
859 "bionic/getcwd.cpp",
860 "bionic/getdomainname.cpp",
861 "bionic/getentropy.cpp",
862 "bionic/gethostname.cpp",
863 "bionic/getloadavg.cpp",
864 "bionic/getpagesize.cpp",
865 "bionic/getpgrp.cpp",
866 "bionic/getpid.cpp",
867 "bionic/getpriority.cpp",
868 "bionic/gettid.cpp",
869 "bionic/get_device_api_level.cpp",
870 "bionic/grp_pwd.cpp",
871 "bionic/grp_pwd_file.cpp",
872 "bionic/heap_zero_init.cpp",
873 "bionic/iconv.cpp",
874 "bionic/icu_wrappers.cpp",
875 "bionic/ifaddrs.cpp",
876 "bionic/inotify_init.cpp",
877 "bionic/ioctl.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800878 "bionic/isatty.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800879 "bionic/killpg.cpp",
880 "bionic/langinfo.cpp",
Elliott Hughes219e6022024-08-27 19:12:08 +0000881 "bionic/lchmod.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800882 "bionic/lchown.cpp",
883 "bionic/lfs64_support.cpp",
884 "bionic/libc_init_common.cpp",
885 "bionic/libgen.cpp",
886 "bionic/link.cpp",
887 "bionic/locale.cpp",
888 "bionic/lockf.cpp",
889 "bionic/lstat.cpp",
890 "bionic/mblen.cpp",
891 "bionic/mbrtoc16.cpp",
892 "bionic/mbrtoc32.cpp",
893 "bionic/mempcpy.cpp",
894 "bionic/memset_explicit.cpp",
895 "bionic/mkdir.cpp",
896 "bionic/mkfifo.cpp",
897 "bionic/mknod.cpp",
898 "bionic/mntent.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800899 "bionic/netdb.cpp",
Elliott Hughes3ed6e722024-02-16 01:18:01 +0000900 "bionic/net_if.cpp",
901 "bionic/netinet_ether.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800902 "bionic/netinet_in.cpp",
903 "bionic/nl_types.cpp",
904 "bionic/open.cpp",
905 "bionic/pathconf.cpp",
906 "bionic/pause.cpp",
907 "bionic/pidfd.cpp",
908 "bionic/pipe.cpp",
909 "bionic/poll.cpp",
910 "bionic/posix_fadvise.cpp",
911 "bionic/posix_fallocate.cpp",
912 "bionic/posix_madvise.cpp",
913 "bionic/posix_timers.cpp",
914 "bionic/preadv_pwritev.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000915 "bionic/pthread_atfork.cpp",
916 "bionic/pthread_attr.cpp",
917 "bionic/pthread_barrier.cpp",
918 "bionic/pthread_cond.cpp",
919 "bionic/pthread_create.cpp",
920 "bionic/pthread_detach.cpp",
921 "bionic/pthread_equal.cpp",
922 "bionic/pthread_exit.cpp",
Elliott Hughese117d6e2024-11-14 17:31:13 +0000923 "bionic/pthread_getaffinity.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000924 "bionic/pthread_getcpuclockid.cpp",
925 "bionic/pthread_getschedparam.cpp",
926 "bionic/pthread_gettid_np.cpp",
927 "bionic/pthread_internal.cpp",
928 "bionic/pthread_join.cpp",
929 "bionic/pthread_key.cpp",
930 "bionic/pthread_kill.cpp",
931 "bionic/pthread_mutex.cpp",
932 "bionic/pthread_once.cpp",
933 "bionic/pthread_rwlock.cpp",
934 "bionic/pthread_sigqueue.cpp",
935 "bionic/pthread_self.cpp",
936 "bionic/pthread_setname_np.cpp",
Elliott Hughese117d6e2024-11-14 17:31:13 +0000937 "bionic/pthread_setaffinity.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000938 "bionic/pthread_setschedparam.cpp",
939 "bionic/pthread_spinlock.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800940 "bionic/ptrace.cpp",
941 "bionic/pty.cpp",
942 "bionic/raise.cpp",
943 "bionic/rand.cpp",
944 "bionic/readlink.cpp",
945 "bionic/realpath.cpp",
946 "bionic/reboot.cpp",
947 "bionic/recv.cpp",
948 "bionic/recvmsg.cpp",
949 "bionic/rename.cpp",
950 "bionic/rmdir.cpp",
951 "bionic/scandir.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800952 "bionic/sched_cpualloc.cpp",
953 "bionic/sched_cpucount.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800954 "bionic/sched_getaffinity.cpp",
955 "bionic/sched_getcpu.cpp",
956 "bionic/semaphore.cpp",
957 "bionic/send.cpp",
958 "bionic/setegid.cpp",
959 "bionic/seteuid.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000960 "bionic/setjmp_cookie.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800961 "bionic/setpgrp.cpp",
962 "bionic/sigaction.cpp",
963 "bionic/signal.cpp",
964 "bionic/sigprocmask.cpp",
965 "bionic/sleep.cpp",
966 "bionic/socketpair.cpp",
967 "bionic/spawn.cpp",
968 "bionic/stat.cpp",
969 "bionic/stdlib_l.cpp",
970 "bionic/strerror.cpp",
971 "bionic/string_l.cpp",
972 "bionic/strings_l.cpp",
973 "bionic/strsignal.cpp",
974 "bionic/strtol.cpp",
975 "bionic/strtold.cpp",
976 "bionic/swab.cpp",
977 "bionic/symlink.cpp",
978 "bionic/sync_file_range.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000979 "bionic/sysconf.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800980 "bionic/sys_epoll.cpp",
981 "bionic/sys_msg.cpp",
982 "bionic/sys_sem.cpp",
983 "bionic/sys_shm.cpp",
984 "bionic/sys_signalfd.cpp",
985 "bionic/sys_statfs.cpp",
986 "bionic/sys_statvfs.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000987 "bionic/sys_thread_properties.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800988 "bionic/sys_time.cpp",
989 "bionic/sysinfo.cpp",
990 "bionic/syslog.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800991 "bionic/sysprop_helpers.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800992 "bionic/system.cpp",
993 "bionic/system_property_api.cpp",
994 "bionic/system_property_set.cpp",
995 "bionic/tdestroy.cpp",
996 "bionic/termios.cpp",
997 "bionic/thread_private.cpp",
998 "bionic/threads.cpp",
999 "bionic/time.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001000 "bionic/tmpfile.cpp",
1001 "bionic/umount.cpp",
1002 "bionic/unlink.cpp",
1003 "bionic/usleep.cpp",
1004 "bionic/utmp.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001005 "bionic/vdso.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001006 "bionic/wait.cpp",
1007 "bionic/wchar.cpp",
1008 "bionic/wchar_l.cpp",
1009 "bionic/wcstod.cpp",
1010 "bionic/wctype.cpp",
1011 "bionic/wcwidth.cpp",
1012 "bionic/wmempcpy.cpp",
1013
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001014 // Forked but not yet cleaned up/rewritten stdio code.
1015 // TODO: finish cleanup.
1016 "stdio/fmemopen.cpp",
1017 "stdio/parsefloat.c",
1018 "stdio/refill.c",
1019 "stdio/stdio.cpp",
1020 "stdio/stdio_ext.cpp",
1021 "stdio/vfscanf.cpp",
1022 "stdio/vfwscanf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001023 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001024
1025 arch: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001026 arm: {
Elliott Hughes1b61d782019-06-04 10:38:34 -07001027 asflags: libc_common_flags + ["-mno-restrict-it"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001028 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -08001029 "arch-arm/bionic/__aeabi_read_tp.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001030 "arch-arm/bionic/__bionic_clone.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001031 "arch-arm/bionic/__restore.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001032 "arch-arm/bionic/_exit_with_stack_teardown.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001033 "arch-arm/bionic/atomics_arm.c",
1034 "arch-arm/bionic/bpabi.c",
Yi Kong165b1cf2019-02-13 14:10:10 -08001035 "arch-arm/bionic/libcrt_compat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001036 "arch-arm/bionic/popcount_tab.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001037 "arch-arm/bionic/setjmp.S",
1038 "arch-arm/bionic/syscall.S",
1039 "arch-arm/bionic/vfork.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001040
Haibo Huangea9957a2018-11-19 11:00:32 -08001041 "arch-arm/cortex-a7/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001042 "arch-arm/cortex-a7/bionic/memset.S",
1043
1044 "arch-arm/cortex-a9/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001045 "arch-arm/cortex-a9/bionic/memset.S",
1046 "arch-arm/cortex-a9/bionic/stpcpy.S",
1047 "arch-arm/cortex-a9/bionic/strcat.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001048 "arch-arm/cortex-a9/bionic/strcpy.S",
1049 "arch-arm/cortex-a9/bionic/strlen.S",
1050
Elliott Hughesaefe9992023-11-08 12:04:41 -08001051 "arch-arm/cortex-a15/bionic/memcpy.S",
1052 "arch-arm/cortex-a15/bionic/memmove.S",
1053 "arch-arm/cortex-a15/bionic/memset.S",
1054 "arch-arm/cortex-a15/bionic/stpcpy.S",
1055 "arch-arm/cortex-a15/bionic/strcat.S",
1056 "arch-arm/cortex-a15/bionic/strcmp.S",
1057 "arch-arm/cortex-a15/bionic/strcpy.S",
1058 "arch-arm/cortex-a15/bionic/strlen.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001059
1060 "arch-arm/cortex-a53/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001061
Haibo Huang01bfd892018-12-03 15:05:16 -08001062 "arch-arm/cortex-a55/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001063
Elliott Hughesaefe9992023-11-08 12:04:41 -08001064 "arch-arm/generic/bionic/memcmp.S",
1065 "arch-arm/generic/bionic/memmove.S",
1066 "arch-arm/generic/bionic/memset.S",
1067 "arch-arm/generic/bionic/stpcpy.c",
1068 "arch-arm/generic/bionic/strcat.c",
1069 "arch-arm/generic/bionic/strcmp.S",
1070 "arch-arm/generic/bionic/strcpy.S",
1071 "arch-arm/generic/bionic/strlen.c",
1072
1073 "arch-arm/krait/bionic/memcpy.S",
1074 "arch-arm/krait/bionic/memset.S",
1075
Haibo Huangea9957a2018-11-19 11:00:32 -08001076 "arch-arm/kryo/bionic/memcpy.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001077 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001078 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001079 arm64: {
1080 srcs: [
Dan Willemsen3e621712016-02-03 21:48:08 -08001081 "arch-arm64/bionic/__bionic_clone.S",
1082 "arch-arm64/bionic/_exit_with_stack_teardown.S",
1083 "arch-arm64/bionic/setjmp.S",
1084 "arch-arm64/bionic/syscall.S",
1085 "arch-arm64/bionic/vfork.S",
Vaisakh K V83e55842024-03-29 12:47:39 +05301086 "arch-arm64/oryon/memcpy-nt.S",
Vaisakh K V54a61212024-03-29 13:32:45 +05301087 "arch-arm64/oryon/memset-nt.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001088 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001089 },
1090
Elliott Hughesebc19a92022-10-14 23:25:36 +00001091 riscv64: {
1092 srcs: [
1093 "arch-riscv64/bionic/__bionic_clone.S",
1094 "arch-riscv64/bionic/_exit_with_stack_teardown.S",
Elliott Hughese1905ed2022-10-17 23:23:36 +00001095 "arch-riscv64/bionic/setjmp.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001096 "arch-riscv64/bionic/syscall.S",
1097 "arch-riscv64/bionic/vfork.S",
Yun Hsiang40a82d02023-05-26 10:10:40 +08001098
Elliott Hughesff7bb092025-02-03 06:06:55 -08001099 "arch-riscv64/string/memchr.S",
1100 "arch-riscv64/string/memcmp.S",
1101 "arch-riscv64/string/memcpy.S",
1102 "arch-riscv64/string/memmove.S",
1103 "arch-riscv64/string/memset.S",
1104 "arch-riscv64/string/stpcpy.S",
1105 "arch-riscv64/string/strcat.S",
1106 "arch-riscv64/string/strchr.S",
1107 "arch-riscv64/string/strcmp.S",
1108 "arch-riscv64/string/strcpy.S",
1109 "arch-riscv64/string/strlen.S",
1110 "arch-riscv64/string/strncat.S",
1111 "arch-riscv64/string/strncmp.S",
1112 "arch-riscv64/string/strncpy.S",
1113 "arch-riscv64/string/strnlen.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001114 ],
1115 },
1116
Dan Willemsen208ae172015-09-16 16:33:27 -07001117 x86: {
1118 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001119 "arch-x86/bionic/__bionic_clone.S",
1120 "arch-x86/bionic/_exit_with_stack_teardown.S",
1121 "arch-x86/bionic/libcrt_compat.c",
Elliott Hughes7d136662023-10-27 15:40:32 -07001122 "arch-x86/bionic/setjmp.S",
1123 "arch-x86/bionic/syscall.S",
1124 "arch-x86/bionic/vfork.S",
1125 "arch-x86/bionic/__x86.get_pc_thunk.S",
1126
Elliott Hughesed777142022-07-25 16:25:11 +00001127 "arch-x86/string/sse2-memmove-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001128 "arch-x86/string/sse2-memset-slm.S",
1129 "arch-x86/string/sse2-stpcpy-slm.S",
1130 "arch-x86/string/sse2-stpncpy-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001131 "arch-x86/string/sse2-strcpy-slm.S",
1132 "arch-x86/string/sse2-strlen-slm.S",
1133 "arch-x86/string/sse2-strncpy-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001134
1135 "arch-x86/string/ssse3-memcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001136 "arch-x86/string/ssse3-strcat-atom.S",
1137 "arch-x86/string/ssse3-strcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001138 "arch-x86/string/ssse3-strncat-atom.S",
1139 "arch-x86/string/ssse3-strncmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001140
1141 "arch-x86/string/sse4-memcmp-slm.S",
Dan Willemsen268a6732015-10-15 14:49:45 -07001142 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001143 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001144 x86_64: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001145 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001146 "arch-x86_64/bionic/__bionic_clone.S",
1147 "arch-x86_64/bionic/_exit_with_stack_teardown.S",
1148 "arch-x86_64/bionic/__restore_rt.S",
1149 "arch-x86_64/bionic/setjmp.S",
1150 "arch-x86_64/bionic/syscall.S",
1151 "arch-x86_64/bionic/vfork.S",
1152
ahs919fb7f2022-06-10 07:11:14 +05301153 "arch-x86_64/string/avx2-memset-kbl.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001154 "arch-x86_64/string/sse2-memmove-slm.S",
1155 "arch-x86_64/string/sse2-memset-slm.S",
1156 "arch-x86_64/string/sse2-stpcpy-slm.S",
1157 "arch-x86_64/string/sse2-stpncpy-slm.S",
1158 "arch-x86_64/string/sse2-strcat-slm.S",
1159 "arch-x86_64/string/sse2-strcpy-slm.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001160 "arch-x86_64/string/sse2-strlen-slm.S",
1161 "arch-x86_64/string/sse2-strncat-slm.S",
1162 "arch-x86_64/string/sse2-strncpy-slm.S",
1163 "arch-x86_64/string/sse4-memcmp-slm.S",
1164 "arch-x86_64/string/ssse3-strcmp-slm.S",
1165 "arch-x86_64/string/ssse3-strncmp-slm.S",
1166 ],
1167 },
Dan Willemsen268a6732015-10-15 14:49:45 -07001168 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001169
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001170 multilib: {
1171 lib32: {
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001172 srcs: [
1173 // off64_t/time64_t support on LP32.
1174 "bionic/legacy_32_bit_support.cpp",
1175 "bionic/time64.c",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001176 ],
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001177 },
1178 },
1179
1180 local_include_dirs: ["stdio"],
1181 generated_headers: ["generated_android_ids"],
1182
1183 whole_static_libs: [
George Burgess IVc5a98e62024-11-18 14:50:32 -07001184 "//external/llvm-libc:llvmlibc",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001185 "libsystemproperties",
1186 ],
1187
Colin Cross50c21ab2015-10-31 23:03:05 -07001188 cppflags: ["-Wold-style-cast"],
Dan Willemsen268a6732015-10-15 14:49:45 -07001189 include_dirs: ["bionic/libstdc++/include"],
1190 name: "libc_bionic",
Dan Willemsen268a6732015-10-15 14:49:45 -07001191}
1192
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001193genrule {
1194 name: "generated_android_ids",
Colin Cross35bbed82017-01-17 18:16:07 -08001195 out: ["generated_android_ids.h"],
1196 srcs: [":android_filesystem_config_header"],
Cole Faustb1a0a9d2023-11-28 17:51:16 -08001197 tools: ["fs_config_generator"],
1198 cmd: "$(location fs_config_generator) aidarray $(in) > $(out)",
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001199}
1200
Dan Willemsen268a6732015-10-15 14:49:45 -07001201// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001202// libc_syscalls.a
1203// ========================================================
1204
Elliott Hughes782c4852019-04-16 12:31:00 -07001205genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001206 name: "syscalls-arm",
Elliott Hughes782c4852019-04-16 12:31:00 -07001207 out: ["syscalls-arm.S"],
1208 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001209 tools: ["gensyscalls"],
1210 cmd: "$(location gensyscalls) arm $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001211}
1212
1213genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001214 name: "syscalls-arm64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001215 out: ["syscalls-arm64.S"],
1216 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001217 tools: ["gensyscalls"],
1218 cmd: "$(location gensyscalls) arm64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001219}
1220
1221genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001222 name: "syscalls-riscv64",
Elliott Hughes704772b2022-10-10 17:06:43 +00001223 out: ["syscalls-riscv64.S"],
1224 srcs: ["SYSCALLS.TXT"],
1225 tools: ["gensyscalls"],
1226 cmd: "$(location gensyscalls) riscv64 $(in) > $(out)",
1227}
1228
1229genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001230 name: "syscalls-x86",
Elliott Hughes782c4852019-04-16 12:31:00 -07001231 out: ["syscalls-x86.S"],
1232 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001233 tools: ["gensyscalls"],
1234 cmd: "$(location gensyscalls) x86 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001235}
1236
1237genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001238 name: "syscalls-x86_64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001239 out: ["syscalls-x86_64.S"],
1240 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001241 tools: ["gensyscalls"],
1242 cmd: "$(location gensyscalls) x86_64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001243}
1244
Dan Willemsen208ae172015-09-16 16:33:27 -07001245cc_library_static {
Colin Cross27c43c52016-04-07 13:27:24 -07001246 defaults: ["libc_defaults"],
Josh Gao0e0e3702017-10-12 13:34:42 -07001247 srcs: ["bionic/__set_errno.cpp"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001248 arch: {
1249 arm: {
Cole Faustf5968d82023-04-11 15:20:19 -07001250 srcs: [":syscalls-arm"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001251 },
1252 arm64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001253 srcs: [":syscalls-arm64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001254 },
Elliott Hughes704772b2022-10-10 17:06:43 +00001255 riscv64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001256 srcs: [":syscalls-riscv64"],
Elliott Hughes704772b2022-10-10 17:06:43 +00001257 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001258 x86: {
Cole Faustf5968d82023-04-11 15:20:19 -07001259 srcs: [":syscalls-x86"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001260 },
1261 x86_64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001262 srcs: [":syscalls-x86_64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001263 },
1264 },
1265 name: "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001266}
1267
1268// ========================================================
1269// libc_aeabi.a
1270// This is an LP32 ARM-only library that needs to be built with -fno-builtin
1271// to avoid infinite recursion. For the other architectures we just build an
1272// empty library to keep this makefile simple.
1273// ========================================================
1274
1275cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001276 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001277 arch: {
1278 arm: {
1279 srcs: ["arch-arm/bionic/__aeabi.c"],
1280 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001281 },
1282 name: "libc_aeabi",
Colin Cross50c21ab2015-10-31 23:03:05 -07001283 cflags: ["-fno-builtin"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001284}
1285
1286// ========================================================
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001287// libc_common.a --- everything shared by libc.a and libc.so
Dan Willemsen208ae172015-09-16 16:33:27 -07001288// ========================================================
Elliott Hughesb0948922024-01-26 00:28:12 +00001289
Dan Willemsen208ae172015-09-16 16:33:27 -07001290cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001291 defaults: ["libc_defaults"],
Elliott Hughesb0948922024-01-26 00:28:12 +00001292 name: "libc_common",
1293
Dan Willemsen208ae172015-09-16 16:33:27 -07001294 whole_static_libs: [
Peter Collingbourne337a5b32020-02-21 12:11:02 -08001295 "libarm-optimized-routines-string",
Rupert Shuttleworth78f48a52021-03-16 06:39:19 +00001296 "libasync_safe",
Dan Willemsen208ae172015-09-16 16:33:27 -07001297 "libc_bionic",
Ryan Prichard249757b2019-11-01 17:18:28 -07001298 "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -07001299 "libc_dns",
George Burgess IV6cb06872017-07-21 13:28:42 -07001300 "libc_fortify",
Dan Willemsen208ae172015-09-16 16:33:27 -07001301 "libc_freebsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001302 "libc_freebsd_large_stack",
Elliott Hughesc2043342023-07-20 20:24:09 +00001303 "libc_freebsd_ldexp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001304 "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -07001305 "libc_netbsd",
1306 "libc_openbsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001307 "libc_openbsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001308 "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001309 "libc_tzcode",
Elliott Hughes816fab92016-05-27 17:57:46 -07001310 "libstdc++",
Dan Willemsen208ae172015-09-16 16:33:27 -07001311 ],
1312
1313 arch: {
1314 arm: {
1315 whole_static_libs: ["libc_aeabi"],
1316 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001317 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001318}
1319
1320// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001321// libc_static_dispatch.a/libc_dynamic_dispatch.a --- string/memory "ifuncs"
1322// (Actually ifuncs for libc.so, but a home-grown alternative for libc.a.)
Haibo Huangf71edfa2018-11-12 10:06:56 -08001323// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001324
1325cc_defaults {
1326 name: "libc_dispatch_defaults",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001327 defaults: ["libc_defaults"],
Haibo Huangb9244ff2018-08-11 10:12:13 -07001328 arch: {
ahs919fb7f2022-06-10 07:11:14 +05301329 x86_64: {
1330 srcs: ["arch-x86_64/dynamic_function_dispatch.cpp"],
1331 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001332 x86: {
1333 srcs: ["arch-x86/dynamic_function_dispatch.cpp"],
1334 },
Haibo Huangea9957a2018-11-19 11:00:32 -08001335 arm: {
Elliott Hughes927fe992019-01-31 22:29:22 +00001336 srcs: ["arch-arm/dynamic_function_dispatch.cpp"],
Haibo Huangea9957a2018-11-19 11:00:32 -08001337 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001338 arm64: {
1339 srcs: ["arch-arm64/dynamic_function_dispatch.cpp"],
1340 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001341 },
Elliott Hughesadc41712024-08-16 13:08:11 +00001342 // Prevent the compiler from inserting calls to libc/taking the address of
1343 // a jump table from within an ifunc (or, in the static case, code that
1344 // can be executed arbitrarily early).
1345 cflags: [
1346 "-ffreestanding",
1347 "-fno-stack-protector",
1348 "-fno-jump-tables",
1349 ],
1350}
1351
1352cc_library_static {
1353 name: "libc_static_dispatch",
1354 defaults: ["libc_dispatch_defaults"],
1355 cflags: [
1356 "-DBIONIC_STATIC_DISPATCH",
1357 ],
1358}
1359
1360cc_library_static {
1361 name: "libc_dynamic_dispatch",
1362 defaults: ["libc_dispatch_defaults"],
1363 cflags: [
1364 "-DBIONIC_DYNAMIC_DISPATCH",
1365 ],
Ryan Prichard249757b2019-11-01 17:18:28 -07001366}
1367
1368// ========================================================
1369// libc_common_static.a For static binaries.
1370// ========================================================
1371cc_library_static {
1372 defaults: ["libc_defaults"],
1373 name: "libc_common_static",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001374
Haibo Huangf71edfa2018-11-12 10:06:56 -08001375 whole_static_libs: [
1376 "libc_common",
Ryan Prichard249757b2019-11-01 17:18:28 -07001377 "libc_static_dispatch",
1378 ],
1379}
1380
1381// ========================================================
1382// libc_common_shared.a For shared libraries.
1383// ========================================================
1384cc_library_static {
1385 defaults: ["libc_defaults"],
1386 name: "libc_common_shared",
1387
1388 whole_static_libs: [
1389 "libc_common",
1390 "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001391 ],
1392}
1393
Ryan Prichard22a6a052019-10-10 23:59:30 -07001394// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static
1395// executable.
1396cc_library_static {
1397 name: "libc_unwind_static",
1398 defaults: ["libc_defaults"],
1399 cflags: ["-DLIBC_STATIC"],
1400
1401 srcs: ["bionic/dl_iterate_phdr_static.cpp"],
1402 arch: {
1403 // arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs
1404 arm: {
1405 srcs: ["arch-arm/bionic/exidx_static.c"],
1406 },
1407 },
1408}
1409
Haibo Huangf71edfa2018-11-12 10:06:56 -08001410// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001411// libc_nomalloc.a
1412// ========================================================
1413//
Ryan Prichard249757b2019-11-01 17:18:28 -07001414// This is a version of the static C library used by the dynamic linker that exclude malloc. It also
1415// excludes functions selected using ifunc's (e.g. for string.h). Link in either
1416// libc_static_dispatch or libc_dynamic_dispatch to provide those functions.
Dan Willemsen208ae172015-09-16 16:33:27 -07001417
1418cc_library_static {
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -08001419 name: "libc_nomalloc",
Colin Cross50c21ab2015-10-31 23:03:05 -07001420 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001421
Colin Crossa3f9fca2016-01-11 13:20:55 -08001422 whole_static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -07001423 "libc_common",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001424 "libc_init_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001425 "libc_unwind_static",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001426 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001427}
1428
dimitryc0c0ef62018-12-05 16:33:52 +01001429filegroup {
1430 name: "libc_sources_shared",
1431 srcs: [
1432 "arch-common/bionic/crtbegin_so.c",
1433 "arch-common/bionic/crtbrand.S",
Christopher Ferris0ac5da02024-11-07 06:59:33 +00001434 "bionic/android_mallopt.cpp",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001435 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001436 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001437 "bionic/icu.cpp",
1438 "bionic/malloc_common.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001439 "bionic/malloc_common_dynamic.cpp",
Ryan Savitski175c8862020-01-02 19:54:57 +00001440 "bionic/android_profiling_dynamic.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001441 "bionic/malloc_heapprofd.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001442 "bionic/malloc_limit.cpp",
Peter Collingbourne570de332019-12-11 10:00:58 -08001443 "bionic/ndk_cruft.cpp",
1444 "bionic/ndk_cruft_data.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001445 "bionic/NetdClient.cpp",
1446 "arch-common/bionic/crtend_so.S",
1447 ],
1448}
1449
1450filegroup {
1451 name: "libc_sources_static",
1452 srcs: [
Christopher Ferris0ac5da02024-11-07 06:59:33 +00001453 "bionic/android_mallopt.cpp",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001454 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001455 "bionic/heap_tagging.cpp",
Elliott Hughes72b0f3b2024-07-02 20:22:35 +00001456 "bionic/icu_static.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001457 "bionic/malloc_common.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001458 "bionic/malloc_limit.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001459 ],
1460}
1461
1462filegroup {
1463 name: "libc_sources_shared_arm",
1464 srcs: [
1465 "arch-arm/bionic/exidx_dynamic.c",
1466 "arch-arm/bionic/atexit_legacy.c",
1467 ],
1468}
1469
Dan Willemsen208ae172015-09-16 16:33:27 -07001470// ========================================================
1471// libc.a + libc.so
1472// ========================================================
Florian Mayerc10d0642023-03-22 16:12:49 -07001473cc_defaults {
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001474 defaults: [
1475 "libc_defaults",
1476 "libc_native_allocator_defaults",
Elliott Hughes788075a2024-06-18 12:25:37 +00001477 "bug_24465209_workaround",
Elliott Hughes89aada12024-07-01 21:59:04 +00001478 "keep_symbols",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001479 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001480 name: "libc_library_defaults",
Colin Cross50c21ab2015-10-31 23:03:05 -07001481 product_variables: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001482 platform_sdk_version: {
1483 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1484 },
1485 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001486 static: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001487 srcs: [":libc_sources_static"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001488 cflags: ["-DLIBC_STATIC"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001489 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001490 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001491 "libc_init_static",
1492 "libc_common_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001493 "libc_unwind_static",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001494 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001495 },
1496 shared: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001497 srcs: [":libc_sources_shared"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001498 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001499 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001500 "libc_init_dynamic",
1501 "libc_common_shared",
Ryan Prichardcdf71752020-12-16 03:37:22 -08001502 "libunwind-exported",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001503 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001504 },
1505
Neil Fullera7db90f2019-04-25 09:28:27 +01001506 required: [
MarkDacekd88d7ea2022-06-28 20:14:58 +00001507 "tzdata_prebuilt",
1508 "tz_version_prebuilt", // Version metadata for tzdata to help debugging.
Neil Fullera7db90f2019-04-25 09:28:27 +01001509 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001510
Colin Cross4ce94d22016-11-15 13:15:43 -08001511 // Do not pack libc.so relocations; see http://b/20645321 for details.
1512 pack_relocations: false,
1513
dimitry06016f22018-01-05 11:39:28 +01001514 shared_libs: [
1515 "ld-android",
1516 "libdl",
1517 ],
Jiyong Park3ff116a2019-04-02 23:04:52 +09001518 static_libs: [
1519 "libdl_android",
1520 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001521
1522 nocrt: true,
1523
Dan Willemsen208ae172015-09-16 16:33:27 -07001524 arch: {
1525 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001526 version_script: ":libc.arm.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001527 no_libcrt: true,
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001528
Dan Willemsen208ae172015-09-16 16:33:27 -07001529 shared: {
dimitryc0c0ef62018-12-05 16:33:52 +01001530 srcs: [":libc_sources_shared_arm"],
Dan Willemsen0c657082016-05-12 01:43:07 -07001531 // special for arm
1532 cflags: ["-DCRT_LEGACY_WORKAROUND"],
Elliott Hughes89aada12024-07-01 21:59:04 +00001533 // For backwards compatibility, some arm32 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001534 static_libs: ["libclang_rt.builtins-exported"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001535 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001536
Elliott Hughes89aada12024-07-01 21:59:04 +00001537 ldflags: [
1538 // Since we preserve the debug_frame for libc, do not compress
1539 // in this case to make unwinds as fast as possible.
1540 "-Wl,--compress-debug-sections=none",
1541 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001542 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001543 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001544 version_script: ":libc.arm64.map",
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001545 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001546 riscv64: {
1547 version_script: ":libc.riscv64.map",
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001548 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001549 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001550 version_script: ":libc.x86.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001551 no_libcrt: true,
1552
1553 shared: {
Elliott Hughes89aada12024-07-01 21:59:04 +00001554 // For backwards compatibility, some x86 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001555 static_libs: ["libclang_rt.builtins-exported"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001556 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001557 },
1558 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001559 version_script: ":libc.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001560 },
1561 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +09001562
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001563 apex_available: [
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001564 "com.android.runtime",
1565 ],
1566
Colin Cross7edd0082021-10-28 13:20:35 -07001567 target: {
1568 native_bridge: {
1569 shared: {
1570 installable: false,
1571 },
1572 },
1573 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001574}
1575
Florian Mayerc10d0642023-03-22 16:12:49 -07001576cc_library {
1577 name: "libc",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001578 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001579 "libc_library_defaults",
1580 ],
1581 stubs: {
1582 symbol_file: "libc.map.txt",
1583 versions: [
1584 "29",
1585 "R",
1586 "current",
1587 ],
1588 },
1589 static_ndk_lib: true,
1590 llndk: {
1591 symbol_file: "libc.map.txt",
1592 export_headers_as_system: true,
Dan Alberte9f02e02024-08-28 23:20:20 +00001593 export_llndk_headers: ["libc_headers"],
Florian Mayerc10d0642023-03-22 16:12:49 -07001594 },
1595}
1596
1597cc_library {
1598 name: "libc_hwasan",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001599 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001600 "libc_library_defaults",
1601 ],
1602 sanitize: {
1603 hwaddress: true,
1604 },
1605 enabled: false,
Florian Mayerff116ed2023-04-14 17:38:53 -07001606 target: {
1607 android_arm64: {
Florian Mayerc10d0642023-03-22 16:12:49 -07001608 enabled: true,
1609 },
1610 },
1611 stem: "libc",
1612 relative_install_path: "hwasan",
1613 // We don't really need the stubs, but this needs to stay to trigger the
1614 // symlink logic in soong.
1615 stubs: {
1616 symbol_file: "libc.map.txt",
1617 },
1618 native_bridge_supported: false,
1619 // It is never correct to depend on this directly. This is only
Kiyoung Kim06a86dc2024-12-02 11:18:51 +09001620 // needed for the runtime apex, and in base_system.mk, and system_image_defaults
1621 // which is default module for soong-defined system image.
1622 visibility: [
1623 "//bionic/apex",
Kiyoung Kim4028fec2025-01-08 14:30:55 +09001624 "//visibility:any_system_partition",
Kiyoung Kim06a86dc2024-12-02 11:18:51 +09001625 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001626}
1627
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001628genrule {
1629 name: "libc.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001630 out: ["libc.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001631 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001632 tools: ["generate-version-script"],
1633 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001634}
1635
1636genrule {
1637 name: "libc.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001638 out: ["libc.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001639 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001640 tools: ["generate-version-script"],
1641 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001642}
1643
1644genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001645 name: "libc.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001646 out: ["libc.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001647 srcs: ["libc.map.txt"],
1648 tools: ["generate-version-script"],
1649 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1650}
1651
1652genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001653 name: "libc.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001654 out: ["libc.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001655 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001656 tools: ["generate-version-script"],
1657 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001658}
1659
1660genrule {
1661 name: "libc.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001662 out: ["libc.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001663 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001664 tools: ["generate-version-script"],
1665 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001666}
1667
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001668// Headers that only other parts of the platform can include.
1669cc_library_headers {
1670 name: "bionic_libc_platform_headers",
Martin Stjernholma2763432020-04-23 16:47:19 +01001671 defaults: ["linux_bionic_supported"],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001672 visibility: [
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001673 "//art:__subpackages__",
Josh Gao97271922019-11-06 13:15:00 -08001674 "//bionic:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001675 "//frameworks:__subpackages__",
Roman Kiryanov067f5182020-05-07 14:58:30 -07001676 "//device/generic/goldfish-opengl:__subpackages__",
Mitch Phillips3309b3d2020-03-25 15:05:48 -07001677 "//external/gwp_asan:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001678 "//external/perfetto:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001679 "//external/scudo:__subpackages__",
Josh Gao5074e7d2019-12-13 13:55:53 -08001680 "//system/core/debuggerd:__subpackages__",
Florian Mayerf5d70ce2022-09-13 13:58:30 -07001681 "//system/core/init:__subpackages__",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001682 "//system/core/libcutils:__subpackages__",
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001683 "//system/memory/libmemunreachable:__subpackages__",
Baligh Uddindb0c6de2020-10-15 04:49:00 +00001684 "//system/unwinding/libunwindstack:__subpackages__",
Peter Collingbourne15418002020-05-12 16:02:50 -07001685 "//tools/security/sanitizer-status:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001686 ],
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001687 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001688 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001689 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001690 vendor_ramdisk_available: true,
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001691 recovery_available: true,
1692 native_bridge_supported: true,
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001693 export_include_dirs: [
1694 "platform",
1695 ],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001696 system_shared_libs: [],
1697 stl: "none",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001698 sdk_version: "current",
Jiyong Park4ede1602020-04-28 18:21:08 +09001699
Steven Moreland0cdf1322020-10-05 21:55:26 +00001700 min_sdk_version: "29",
Jiyong Park4ede1602020-04-28 18:21:08 +09001701 apex_available: [
1702 "//apex_available:platform",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001703 "//apex_available:anyapex",
Jiyong Park4ede1602020-04-28 18:21:08 +09001704 ],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001705}
1706
Logan Chien17af91b2019-01-15 21:19:56 +08001707cc_library_headers {
Dan Albert64a6efc2024-08-29 19:04:59 +00001708 name: "libc_uapi_headers",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001709 visibility: [
1710 "//external/musl",
Alistair Delvabad22722024-10-07 12:52:40 -07001711 "//external/rust/crates/v4l2r/android",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001712 ],
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001713 llndk: {
1714 llndk_headers: true,
1715 },
Logan Chien17af91b2019-01-15 21:19:56 +08001716 host_supported: true,
1717 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001718 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001719 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001720 vendor_ramdisk_available: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001721 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001722 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001723 apex_available: [
1724 "//apex_available:platform",
Jiyong Parkad9946c2020-03-30 18:36:07 +09001725 "//apex_available:anyapex",
1726 ],
Jooyung Han15c32a82020-04-16 18:26:45 +09001727 // used by most APEXes indirectly via libunwind_llvm
1728 min_sdk_version: "apex_inherit",
Logan Chien17af91b2019-01-15 21:19:56 +08001729
1730 no_libcrt: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001731 stl: "none",
1732 system_shared_libs: [],
1733
Peter Collingbournef2b1e032019-12-10 17:41:16 -08001734 // The build system generally requires that any dependencies of a target
1735 // with an sdk_version must have a lower sdk_version. By setting sdk_version
1736 // to 1 we let targets with an sdk_version that need to depend on the libc
1737 // headers but cannot depend on libc itself due to circular dependencies
1738 // (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
1739 // is correct because the headers can support any sdk_version.
1740 sdk_version: "1",
1741
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001742 export_system_include_dirs: [
Logan Chien17af91b2019-01-15 21:19:56 +08001743 "kernel/uapi",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001744 "kernel/android/scsi",
Logan Chien17af91b2019-01-15 21:19:56 +08001745 "kernel/android/uapi",
1746 ],
1747
1748 arch: {
1749 arm: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001750 export_system_include_dirs: ["kernel/uapi/asm-arm"],
Logan Chien17af91b2019-01-15 21:19:56 +08001751 },
1752 arm64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001753 export_system_include_dirs: ["kernel/uapi/asm-arm64"],
Logan Chien17af91b2019-01-15 21:19:56 +08001754 },
Elliott Hughes48e53332022-10-07 20:39:25 +00001755 riscv64: {
1756 export_system_include_dirs: ["kernel/uapi/asm-riscv"],
1757 },
Logan Chien17af91b2019-01-15 21:19:56 +08001758 x86: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001759 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001760 },
1761 x86_64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001762 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001763 },
1764 },
1765}
1766
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001767cc_library_headers {
1768 name: "libc_headers",
1769 host_supported: true,
1770 native_bridge_supported: true,
1771 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001772 product_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001773 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001774 vendor_ramdisk_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001775 recovery_available: true,
1776 sdk_version: "1",
1777
1778 apex_available: [
1779 "//apex_available:platform",
1780 "//apex_available:anyapex",
1781 ],
1782 // used by most APEXes indirectly via libunwind_llvm
1783 min_sdk_version: "apex_inherit",
1784 visibility: [
1785 "//bionic:__subpackages__", // visible to bionic
1786 // ... and only to these places (b/152668052)
1787 "//external/arm-optimized-routines",
1788 "//external/gwp_asan",
1789 "//external/jemalloc_new",
1790 "//external/libunwind_llvm",
Nick Desaulniers942ae552024-02-12 10:26:19 -08001791 "//external/llvm-libc",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001792 "//external/scudo",
1793 "//system/core/property_service/libpropertyinfoparser",
1794 "//system/extras/toolchain-extras",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001795 ],
1796
1797 stl: "none",
1798 no_libcrt: true,
1799 system_shared_libs: [],
1800
1801 target: {
1802 android: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001803 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001804 header_libs: ["libc_uapi_headers"],
1805 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001806 },
1807 linux_bionic: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001808 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001809 header_libs: ["libc_uapi_headers"],
1810 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001811 },
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001812 },
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001813}
1814
Dan Willemsen208ae172015-09-16 16:33:27 -07001815// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001816// libstdc++.so and libstdc++.a.
Dan Willemsen208ae172015-09-16 16:33:27 -07001817// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001818
Dan Willemsen208ae172015-09-16 16:33:27 -07001819cc_library {
Elliott Hughes788075a2024-06-18 12:25:37 +00001820 defaults: [
1821 "libc_defaults",
1822 "bug_24465209_workaround",
1823 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001824 include_dirs: ["bionic/libstdc++/include"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001825 srcs: [
1826 "bionic/__cxa_guard.cpp",
1827 "bionic/__cxa_pure_virtual.cpp",
1828 "bionic/new.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001829 ],
1830 name: "libstdc++",
Dan Albert40f15ec2017-10-27 11:21:20 -07001831 static_ndk_lib: true,
Isaac Chen5e7c90b2017-09-20 14:44:42 +08001832 static_libs: ["libasync_safe"],
Elliott Hughesc2043342023-07-20 20:24:09 +00001833 apex_available: [
1834 "//apex_available:platform",
1835 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001836
Dan Willemsen6b3be172018-12-03 13:57:20 -08001837 static: {
1838 system_shared_libs: [],
1839 },
Colin Crossb5bfe0b2021-07-13 16:26:28 -07001840 target: {
1841 bionic: {
1842 shared: {
1843 system_shared_libs: ["libc"],
1844 },
1845 },
Dan Willemsen6b3be172018-12-03 13:57:20 -08001846 },
1847
Dan Willemsen208ae172015-09-16 16:33:27 -07001848 arch: {
1849 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001850 version_script: ":libstdc++.arm.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001851 },
1852 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001853 version_script: ":libstdc++.arm64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001854 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001855 riscv64: {
1856 version_script: ":libstdc++.riscv64.map",
1857 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001858 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001859 version_script: ":libstdc++.x86.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001860 },
1861 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001862 version_script: ":libstdc++.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001863 },
1864 },
1865}
1866
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001867genrule {
1868 name: "libstdc++.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001869 out: ["libstdc++.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001870 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001871 tools: ["generate-version-script"],
1872 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001873}
1874
1875genrule {
1876 name: "libstdc++.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001877 out: ["libstdc++.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001878 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001879 tools: ["generate-version-script"],
1880 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001881}
1882
1883genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001884 name: "libstdc++.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001885 out: ["libstdc++.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001886 srcs: ["libstdc++.map.txt"],
1887 tools: ["generate-version-script"],
1888 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1889}
1890
1891genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001892 name: "libstdc++.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001893 out: ["libstdc++.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001894 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001895 tools: ["generate-version-script"],
1896 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001897}
1898
1899genrule {
1900 name: "libstdc++.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001901 out: ["libstdc++.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001902 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001903 tools: ["generate-version-script"],
1904 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001905}
1906
1907// ========================================================
1908// crt object files.
1909// ========================================================
1910
Colin Cross50c21ab2015-10-31 23:03:05 -07001911cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001912 name: "crt_and_memtag_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -08001913 defaults: ["linux_bionic_supported"],
Dan Willemsen230a7a42017-04-07 14:09:05 -07001914 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001915 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001916 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001917 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +09001918 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001919 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001920 apex_available: [
1921 "//apex_available:platform",
1922 "//apex_available:anyapex",
1923 ],
Dan Albertdc503f62020-07-15 17:22:18 -07001924 // Generate NDK variants of the CRT objects for every supported API level.
1925 min_sdk_version: "16",
1926 stl: "none",
1927 crt: true,
Elliott Hughesd50a1de2018-02-05 17:30:57 -08001928 cflags: [
1929 "-Wno-gcc-compat",
1930 "-Wall",
1931 "-Werror",
1932 ],
Peter Collingbourne7eb851c2019-09-26 12:16:06 -07001933 sanitize: {
1934 never: true,
1935 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001936}
1937
Colin Cross50c21ab2015-10-31 23:03:05 -07001938cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001939 name: "crt_defaults",
1940 defaults: ["crt_and_memtag_defaults"],
Colin Cross02f81372021-07-22 12:02:10 -07001941 system_shared_libs: [],
Colin Cross10d92682021-06-22 13:25:46 -07001942}
1943
1944cc_defaults {
Colin Cross50c21ab2015-10-31 23:03:05 -07001945 name: "crt_so_defaults",
Colin Cross7d7b3682017-11-03 13:38:40 -07001946 defaults: ["crt_defaults"],
Colin Crossab179442018-09-27 11:03:22 -07001947 stl: "none",
Dan Willemsen208ae172015-09-16 16:33:27 -07001948}
1949
Dan Willemsen208ae172015-09-16 16:33:27 -07001950cc_object {
1951 name: "crtbrand",
Jingwen Chen7e13cf22021-02-23 00:43:01 -05001952 local_include_dirs: [
Jingwen Chen7e13cf22021-02-23 00:43:01 -05001953 "private", // crtbrand.S depends on private/bionic_asm_note.h
1954 ],
Elliott Hughes6a30b712024-03-13 23:41:32 +00001955 // crtbrand.S needs to know the platform SDK version.
Dan Willemsen208ae172015-09-16 16:33:27 -07001956 product_variables: {
1957 platform_sdk_version: {
1958 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1959 },
1960 },
1961 srcs: ["arch-common/bionic/crtbrand.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001962
Colin Cross7d7b3682017-11-03 13:38:40 -07001963 defaults: ["crt_so_defaults"],
Dan Alberteee46dc2023-04-04 23:27:52 +00001964 // crtbrand is an intermediate artifact, not a final CRT object.
1965 exclude_from_ndk_sysroot: true,
Dan Willemsen208ae172015-09-16 16:33:27 -07001966}
1967
Dan Willemsen208ae172015-09-16 16:33:27 -07001968cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05001969 name: "crtbegin_so",
Dan Willemsen208ae172015-09-16 16:33:27 -07001970 local_include_dirs: ["include"],
1971 srcs: ["arch-common/bionic/crtbegin_so.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001972
Colin Cross7d7b3682017-11-03 13:38:40 -07001973 defaults: ["crt_so_defaults"],
Colin Cross77d57bf2016-04-11 14:34:18 -07001974 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07001975 "crtbrand",
1976 ],
1977}
1978
Dan Willemsen208ae172015-09-16 16:33:27 -07001979cc_object {
1980 name: "crtend_so",
Liz Kammeraab2ad72021-03-15 18:03:24 -04001981 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001982 "private", // crtend_so.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04001983 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001984 srcs: ["arch-common/bionic/crtend_so.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001985
Colin Cross7d7b3682017-11-03 13:38:40 -07001986 defaults: ["crt_so_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001987}
1988
Dan Willemsen208ae172015-09-16 16:33:27 -07001989cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05001990 name: "crtbegin_static",
1991
Jingwen Chen0b1611e2021-02-18 23:22:03 -05001992 local_include_dirs: [
1993 "include",
1994 "bionic", // crtbegin.c includes bionic/libc_init_common.h
1995 ],
Liz Kammere718dd72021-03-09 15:00:06 -05001996
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001997 cflags: ["-DCRTBEGIN_STATIC"],
Yabin Cui744cfd32023-08-24 13:20:23 -07001998
Dan Willemsen208ae172015-09-16 16:33:27 -07001999 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002000 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002001 "crtbrand",
2002 ],
Colin Cross50c21ab2015-10-31 23:03:05 -07002003 defaults: ["crt_defaults"],
Jiyong Park268a6002021-01-12 23:14:37 +09002004 // When using libc.a, we're using the latest library regardless of target API level.
2005 min_sdk_version: "current",
Dan Willemsen208ae172015-09-16 16:33:27 -07002006}
2007
Dan Willemsen208ae172015-09-16 16:33:27 -07002008cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002009 name: "crtbegin_dynamic",
2010
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002011 local_include_dirs: [
2012 "include",
2013 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2014 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002015 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002016 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002017 "crtbrand",
2018 ],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -07002019 target: {
2020 linux_bionic: {
2021 generated_sources: ["host_bionic_linker_asm"],
2022 objs: [
2023 "linker_wrapper",
2024 ],
2025 },
2026 },
Colin Cross50c21ab2015-10-31 23:03:05 -07002027 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002028}
2029
Dan Willemsen208ae172015-09-16 16:33:27 -07002030cc_object {
2031 // We rename crtend.o to crtend_android.o to avoid a
2032 // name clash between gcc and bionic.
2033 name: "crtend_android",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002034 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002035 "private", // crtend.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002036 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002037 srcs: ["arch-common/bionic/crtend.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002038
Colin Cross50c21ab2015-10-31 23:03:05 -07002039 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002040}
Colin Crossbaa48992016-07-13 11:15:21 -07002041
Kalesh Singh862a23d2024-01-09 13:13:50 -08002042cc_object {
2043 name: "crt_pad_segment",
2044 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002045 "private", // crt_pad_segment.S depends on private/bionic_asm_note.h
Kalesh Singh862a23d2024-01-09 13:13:50 -08002046 ],
2047 srcs: ["arch-common/bionic/crt_pad_segment.S"],
2048
2049 defaults: ["crt_defaults"],
2050}
2051
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002052cc_library_static {
2053 name: "note_memtag_heap_async",
2054 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002055 arm64: {
2056 srcs: ["arch-arm64/bionic/note_memtag_heap_async.S"],
2057 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002058 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002059 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002060
Colin Cross10d92682021-06-22 13:25:46 -07002061 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002062}
2063
2064cc_library_static {
2065 name: "note_memtag_heap_sync",
2066 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002067 arm64: {
2068 srcs: ["arch-arm64/bionic/note_memtag_heap_sync.S"],
2069 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002070 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002071 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002072
Colin Cross10d92682021-06-22 13:25:46 -07002073 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002074}
2075
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002076// ========================================================
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002077// libc dependencies for baremetal Rust projects.
2078// ========================================================
2079
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002080// This library contains the following unresolved symbols:
2081// __errno
Daniel Verkamp1c040692025-01-31 11:52:14 -08002082// __x86_shared_cache_size_half (x86_64 only)
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002083// abort
2084// async_safe_fatal_va_list
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002085cc_library_static {
2086 name: "librust_baremetal",
Pierre-Clément Tosi9018e5f2024-10-02 15:57:00 +01002087 defaults: ["cc_baremetal_defaults"],
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002088 header_libs: ["libc_headers"],
2089 include_dirs: [
2090 "bionic/libc/async_safe/include",
2091 "bionic/libc/platform",
2092 ],
2093 cflags: [
2094 "-Wall",
2095 "-Werror",
2096 ],
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002097 srcs: [
2098 "bionic/fortify.cpp",
Pierre-Clément Tosi816176c2022-11-30 14:33:41 +00002099 "bionic/strtol.cpp",
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002100 ],
2101 arch: {
Daniel Verkamp1c040692025-01-31 11:52:14 -08002102 arm: {
2103 enabled: false,
2104 },
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002105 arm64: {
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002106 srcs: [
2107 "arch-arm64/string/__memcpy_chk.S",
2108 ],
2109 },
Daniel Verkamp1c040692025-01-31 11:52:14 -08002110 x86: {
2111 enabled: false,
2112 },
2113 x86_64: {
2114 srcs: [
2115 "arch-x86_64/string/sse2-memmove-slm.S",
2116 "arch-x86_64/string/sse2-memset-slm.S",
2117 "arch-x86_64/string/sse2-stpcpy-slm.S",
2118 "arch-x86_64/string/sse2-stpncpy-slm.S",
2119 "arch-x86_64/string/sse2-strcat-slm.S",
2120 "arch-x86_64/string/sse2-strcpy-slm.S",
2121 "arch-x86_64/string/sse2-strlen-slm.S",
2122 "arch-x86_64/string/sse2-strncat-slm.S",
2123 "arch-x86_64/string/sse2-strncpy-slm.S",
2124 "arch-x86_64/string/sse4-memcmp-slm.S",
2125 "arch-x86_64/string/ssse3-strcmp-slm.S",
2126 "arch-x86_64/string/ssse3-strncmp-slm.S",
2127 ],
2128 },
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002129 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002130 whole_static_libs: [
George Burgess IVc5a98e62024-11-18 14:50:32 -07002131 "//external/llvm-libc:llvmlibc",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002132 "libarm-optimized-routines-mem",
Pierre-Clément Tosieb46ac92023-02-01 13:44:57 +00002133 "libc_netbsd",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002134 ],
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002135 system_shared_libs: [],
2136 nocrt: true,
2137 stl: "none",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002138 visibility: [
Jiyong Park072ce532024-07-22 11:20:47 +09002139 "//packages/modules/Virtualization/libs/libvmbase",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002140 ],
Zijun427504a2024-08-15 23:16:27 +00002141
2142 // b/358211032: This library gets linked into a rust rlib. Disable LTO
2143 // until cross-language lto is supported.
2144 lto: {
2145 never: true,
2146 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002147}
2148
2149// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002150// NDK headers.
2151// ========================================================
2152
Dan Albertcce54372024-08-22 18:24:30 +00002153ndk_headers {
Dan Albert22805ea2017-03-22 15:28:05 -07002154 name: "common_libc",
2155 from: "include",
2156 to: "",
Dan Albertcce54372024-08-22 18:24:30 +00002157 srcs: ["include/**/*.h"],
Dan Albert22805ea2017-03-22 15:28:05 -07002158 license: "NOTICE",
Dan Albertcce54372024-08-22 18:24:30 +00002159 // These don't pass the bad verification we do because many of them are
2160 // arch-specific, and they aren't necessarily independently includable.
2161 // That's not much of a problem though, since C-incompaitibilities in the
2162 // UAPI headers should run into problems long before they reach us.
2163 skip_verification: true,
Dan Albert22805ea2017-03-22 15:28:05 -07002164}
Dan Albert4238a352016-06-28 11:18:05 -07002165
2166ndk_headers {
Dan Albert063e86a2016-11-29 11:09:12 -08002167 name: "libc_uapi",
2168 from: "kernel/uapi",
2169 to: "",
2170 srcs: [
2171 "kernel/uapi/asm-generic/**/*.h",
2172 "kernel/uapi/drm/**/*.h",
2173 "kernel/uapi/linux/**/*.h",
2174 "kernel/uapi/misc/**/*.h",
2175 "kernel/uapi/mtd/**/*.h",
2176 "kernel/uapi/rdma/**/*.h",
2177 "kernel/uapi/scsi/**/*.h",
2178 "kernel/uapi/sound/**/*.h",
2179 "kernel/uapi/video/**/*.h",
2180 "kernel/uapi/xen/**/*.h",
2181 ],
Dan Albert92592652016-10-20 01:42:54 -07002182 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002183 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002184}
2185
2186ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002187 name: "libc_kernel_android_uapi_linux",
Dan Albertbae16ef2016-09-14 17:15:48 -07002188 from: "kernel/android/uapi/linux",
2189 to: "linux",
2190 srcs: ["kernel/android/uapi/linux/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002191 license: "NOTICE",
Dan Albertbae16ef2016-09-14 17:15:48 -07002192}
2193
2194ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002195 name: "libc_kernel_android_scsi",
Elliott Hughes50599392017-05-25 17:13:32 -07002196 from: "kernel/android/scsi/scsi",
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002197 to: "scsi",
2198 srcs: ["kernel/android/scsi/**/*.h"],
2199 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002200 skip_verification: true,
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002201}
2202
2203ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002204 name: "libc_asm_arm",
2205 from: "kernel/uapi/asm-arm",
2206 to: "arm-linux-androideabi",
2207 srcs: ["kernel/uapi/asm-arm/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002208 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002209 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002210}
2211
2212ndk_headers {
2213 name: "libc_asm_arm64",
2214 from: "kernel/uapi/asm-arm64",
2215 to: "aarch64-linux-android",
2216 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002217 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002218 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002219}
2220
Lazar Trsic790d2f72017-11-27 11:54:11 +01002221ndk_headers {
Colin Crossbd26e0f2022-10-19 15:03:14 -07002222 name: "libc_asm_riscv64",
2223 from: "kernel/uapi/asm-riscv",
2224 to: "riscv64-linux-android",
2225 srcs: ["kernel/uapi/asm-riscv/**/*.h"],
2226 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002227 skip_verification: true,
Colin Crossbd26e0f2022-10-19 15:03:14 -07002228}
2229
2230ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002231 name: "libc_asm_x86",
2232 from: "kernel/uapi/asm-x86",
2233 to: "i686-linux-android",
2234 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002235 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002236 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002237}
2238
2239ndk_headers {
2240 name: "libc_asm_x86_64",
2241 from: "kernel/uapi/asm-x86",
2242 to: "x86_64-linux-android",
2243 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002244 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002245 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002246}
2247
Dan Albert4238a352016-06-28 11:18:05 -07002248ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002249 name: "libc",
Dan Albert4238a352016-06-28 11:18:05 -07002250 symbol_file: "libc.map.txt",
2251 first_version: "9",
2252}
2253
Dan Albertdf31aff2016-10-06 15:50:41 -07002254ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002255 name: "libstdc++",
Dan Albertdf31aff2016-10-06 15:50:41 -07002256 symbol_file: "libstdc++.map.txt",
2257 first_version: "9",
2258}
2259
Dan Willemsenca056d72018-01-08 14:00:24 -08002260// Export these headers for toolbox to process
2261filegroup {
2262 name: "kernel_input_headers",
2263 srcs: [
2264 "kernel/uapi/linux/input.h",
2265 "kernel/uapi/linux/input-event-codes.h",
2266 ],
2267}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002268
2269// Generate a syscall name / number mapping. These objects are text files
2270// (thanks to the -dD -E flags) and not binary files. They will then be
2271// consumed by the genseccomp.py script and converted into C++ code.
2272cc_defaults {
2273 name: "libseccomp_gen_syscall_nrs_defaults",
2274 recovery_available: true,
2275 srcs: ["seccomp/gen_syscall_nrs.cpp"],
2276 cflags: [
2277 "-dD",
2278 "-E",
2279 "-Wall",
2280 "-Werror",
Ryan Prichardeffe86f2024-12-18 17:07:37 -08002281 // Soong implicitly adds a -c argument that we override with -E.
2282 // Suppress Clang's error about the unused -c argument.
2283 "-Wno-unused-command-line-argument",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002284 "-nostdinc",
2285 ],
2286}
2287
2288cc_object {
2289 name: "libseccomp_gen_syscall_nrs_arm",
2290 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2291 local_include_dirs: [
2292 "kernel/uapi/asm-arm",
2293 "kernel/uapi",
2294 ],
2295}
2296
2297cc_object {
2298 name: "libseccomp_gen_syscall_nrs_arm64",
2299 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2300 local_include_dirs: [
2301 "kernel/uapi/asm-arm64",
2302 "kernel/uapi",
2303 ],
2304}
2305
2306cc_object {
Elliott Hughes704772b2022-10-10 17:06:43 +00002307 name: "libseccomp_gen_syscall_nrs_riscv64",
2308 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2309 local_include_dirs: [
2310 "kernel/uapi/asm-riscv",
2311 "kernel/uapi",
2312 ],
2313}
2314
2315cc_object {
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002316 name: "libseccomp_gen_syscall_nrs_x86",
2317 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2318 srcs: ["seccomp/gen_syscall_nrs_x86.cpp"],
2319 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2320 local_include_dirs: [
2321 "kernel/uapi/asm-x86",
2322 "kernel/uapi",
2323 ],
2324}
2325
2326cc_object {
2327 name: "libseccomp_gen_syscall_nrs_x86_64",
2328 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2329 srcs: ["seccomp/gen_syscall_nrs_x86_64.cpp"],
2330 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2331 local_include_dirs: [
2332 "kernel/uapi/asm-x86",
2333 "kernel/uapi",
2334 ],
2335}
2336
Jingwen Chenca366332021-01-29 05:16:32 -05002337filegroup {
2338 name: "all_kernel_uapi_headers",
2339 srcs: ["kernel/uapi/**/*.h"],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002340}
2341
Martijn Coenen0c6de752019-01-02 12:52:51 +01002342cc_genrule {
2343 name: "func_to_syscall_nrs",
2344 recovery_available: true,
2345 cmd: "$(location genfunctosyscallnrs) --out-dir=$(genDir) $(in)",
2346
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002347 tools: ["genfunctosyscallnrs"],
Martijn Coenen0c6de752019-01-02 12:52:51 +01002348
2349 srcs: [
2350 "SYSCALLS.TXT",
Martijn Coenen0c6de752019-01-02 12:52:51 +01002351 ],
2352
Elliott Hughes704772b2022-10-10 17:06:43 +00002353 arch: {
2354 arm: {
2355 srcs: [
2356 ":libseccomp_gen_syscall_nrs_arm",
2357 ":libseccomp_gen_syscall_nrs_arm64",
2358 ],
2359 },
2360 arm64: {
2361 srcs: [
2362 ":libseccomp_gen_syscall_nrs_arm",
2363 ":libseccomp_gen_syscall_nrs_arm64",
2364 ],
2365 },
2366 riscv64: {
2367 srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
2368 },
2369 x86: {
2370 srcs: [
2371 ":libseccomp_gen_syscall_nrs_x86",
2372 ":libseccomp_gen_syscall_nrs_x86_64",
2373 ],
2374 },
2375 x86_64: {
2376 srcs: [
2377 ":libseccomp_gen_syscall_nrs_x86",
2378 ":libseccomp_gen_syscall_nrs_x86_64",
2379 ],
2380 },
2381 },
2382
Martijn Coenen0c6de752019-01-02 12:52:51 +01002383 out: [
2384 "func_to_syscall_nrs.h",
2385 ],
2386}
2387
Victor Hsiehdbb86702020-06-15 09:29:07 -07002388// SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT = SECCOMP_BLOCKLIST_APP.txt - setresgid*
Martijn Coenenc3752be2019-01-09 16:19:57 +01002389genrule {
Victor Hsiehdbb86702020-06-15 09:29:07 -07002390 name: "generate_app_zygote_blocklist",
2391 out: ["SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT"],
2392 srcs: ["SECCOMP_BLOCKLIST_APP.TXT"],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002393 cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)",
2394}
2395
Yu Liu938ec9b2022-10-17 16:36:30 -07002396filegroup {
2397 name: "seccomp_syscalls_sources_zygote",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002398 srcs: [
2399 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002400 "SECCOMP_ALLOWLIST_COMMON.TXT",
2401 "SECCOMP_ALLOWLIST_APP.TXT",
2402 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002403 "SECCOMP_PRIORITY.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002404 ":generate_app_zygote_blocklist",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002405 ],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002406}
2407
Yu Liu938ec9b2022-10-17 16:36:30 -07002408filegroup {
2409 name: "seccomp_syscalls_sources_app",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002410 srcs: [
2411 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002412 "SECCOMP_ALLOWLIST_COMMON.TXT",
2413 "SECCOMP_ALLOWLIST_APP.TXT",
2414 "SECCOMP_BLOCKLIST_COMMON.TXT",
2415 "SECCOMP_BLOCKLIST_APP.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002416 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002417 ],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002418}
2419
Yu Liu938ec9b2022-10-17 16:36:30 -07002420filegroup {
2421 name: "seccomp_syscalls_sources_system",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002422 srcs: [
2423 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002424 "SECCOMP_ALLOWLIST_COMMON.TXT",
2425 "SECCOMP_ALLOWLIST_SYSTEM.TXT",
2426 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002427 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002428 ],
Yu Liu938ec9b2022-10-17 16:36:30 -07002429}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002430
Yu Liu938ec9b2022-10-17 16:36:30 -07002431cc_genrule {
2432 name: "libseccomp_policy_app_zygote_sources_x86",
2433 recovery_available: true,
2434 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002435 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002436 srcs: [
2437 ":seccomp_syscalls_sources_zygote",
2438 ":libseccomp_gen_syscall_nrs_x86",
2439 ":libseccomp_gen_syscall_nrs_x86_64",
2440 ],
2441 out: [
2442 "x86_app_zygote_policy.cpp",
2443 "x86_64_app_zygote_policy.cpp",
2444 ],
2445 enabled: false,
Yu Liu3a579692022-10-18 03:02:32 +00002446 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002447 x86: {
2448 enabled: true,
2449 },
2450 x86_64: {
2451 enabled: true,
2452 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002453 },
2454}
2455
2456cc_genrule {
2457 name: "libseccomp_policy_app_zygote_sources_arm",
2458 recovery_available: true,
2459 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002460 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002461 srcs: [
2462 ":seccomp_syscalls_sources_zygote",
2463 ":libseccomp_gen_syscall_nrs_arm",
2464 ":libseccomp_gen_syscall_nrs_arm64",
2465 ],
2466 out: [
2467 "arm_app_zygote_policy.cpp",
2468 "arm64_app_zygote_policy.cpp",
2469 ],
2470 enabled: false,
2471 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002472 arm: {
2473 enabled: true,
2474 },
2475 arm64: {
2476 enabled: true,
2477 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002478 },
2479}
2480
2481cc_genrule {
2482 name: "libseccomp_policy_app_zygote_sources_riscv64",
2483 recovery_available: true,
2484 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002485 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002486 srcs: [
2487 ":seccomp_syscalls_sources_zygote",
2488 ":libseccomp_gen_syscall_nrs_riscv64",
2489 ],
2490 out: [
2491 "riscv64_app_zygote_policy.cpp",
2492 ],
2493 enabled: false,
2494 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002495 riscv64: {
2496 enabled: true,
2497 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002498 },
2499}
2500
2501cc_genrule {
2502 name: "libseccomp_policy_app_sources_x86",
2503 recovery_available: true,
2504 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002505 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002506 srcs: [
2507 ":seccomp_syscalls_sources_app",
2508 ":libseccomp_gen_syscall_nrs_x86",
2509 ":libseccomp_gen_syscall_nrs_x86_64",
2510 ],
2511 out: [
2512 "x86_app_policy.cpp",
2513 "x86_64_app_policy.cpp",
2514 ],
2515 enabled: false,
2516 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002517 x86: {
2518 enabled: true,
2519 },
2520 x86_64: {
2521 enabled: true,
2522 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002523 },
2524}
2525
2526cc_genrule {
2527 name: "libseccomp_policy_app_sources_arm",
2528 recovery_available: true,
2529 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002530 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002531 srcs: [
2532 ":seccomp_syscalls_sources_app",
2533 ":libseccomp_gen_syscall_nrs_arm",
2534 ":libseccomp_gen_syscall_nrs_arm64",
2535 ],
2536 out: [
2537 "arm_app_policy.cpp",
2538 "arm64_app_policy.cpp",
2539 ],
2540 enabled: false,
2541 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002542 arm: {
2543 enabled: true,
2544 },
2545 arm64: {
2546 enabled: true,
2547 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002548 },
2549}
2550
2551cc_genrule {
2552 name: "libseccomp_policy_app_sources_riscv64",
2553 recovery_available: true,
2554 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002555 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002556 srcs: [
2557 ":seccomp_syscalls_sources_app",
2558 ":libseccomp_gen_syscall_nrs_riscv64",
2559 ],
2560 out: [
2561 "riscv64_app_policy.cpp",
2562 ],
2563 enabled: false,
2564 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002565 riscv64: {
2566 enabled: true,
2567 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002568 },
2569}
2570
2571cc_genrule {
2572 name: "libseccomp_policy_system_sources_x86",
2573 recovery_available: true,
2574 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002575 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002576 srcs: [
2577 ":seccomp_syscalls_sources_system",
2578 ":libseccomp_gen_syscall_nrs_x86",
2579 ":libseccomp_gen_syscall_nrs_x86_64",
2580 ],
2581 out: [
2582 "x86_system_policy.cpp",
2583 "x86_64_system_policy.cpp",
2584 ],
2585 enabled: false,
2586 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002587 x86: {
2588 enabled: true,
2589 },
2590 x86_64: {
2591 enabled: true,
2592 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002593 },
2594}
2595
2596cc_genrule {
2597 name: "libseccomp_policy_system_sources_arm",
2598 recovery_available: true,
2599 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002600 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002601 srcs: [
2602 ":seccomp_syscalls_sources_system",
2603 ":libseccomp_gen_syscall_nrs_arm",
2604 ":libseccomp_gen_syscall_nrs_arm64",
2605 ],
2606 out: [
2607 "arm_system_policy.cpp",
2608 "arm64_system_policy.cpp",
2609 ],
2610 enabled: false,
2611 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002612 arm: {
2613 enabled: true,
2614 },
2615 arm64: {
2616 enabled: true,
2617 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002618 },
2619}
2620
2621cc_genrule {
2622 name: "libseccomp_policy_system_sources_riscv64",
2623 recovery_available: true,
2624 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002625 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002626 srcs: [
2627 ":seccomp_syscalls_sources_system",
2628 ":libseccomp_gen_syscall_nrs_riscv64",
2629 ],
2630 out: [
2631 "riscv64_system_policy.cpp",
2632 ],
2633 enabled: false,
2634 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002635 riscv64: {
2636 enabled: true,
2637 },
Yu Liu3a579692022-10-18 03:02:32 +00002638 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002639}
2640
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002641cc_library {
2642 name: "libseccomp_policy",
2643 recovery_available: true,
Martijn Coenend269d9b2018-11-08 16:41:42 +01002644 generated_headers: ["func_to_syscall_nrs"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002645
2646 arch: {
2647 arm: {
2648 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002649 "libseccomp_policy_app_sources_arm",
2650 "libseccomp_policy_app_zygote_sources_arm",
2651 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002652 ],
2653 },
2654 arm64: {
2655 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002656 "libseccomp_policy_app_sources_arm",
2657 "libseccomp_policy_app_zygote_sources_arm",
2658 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002659 ],
2660 },
2661 riscv64: {
2662 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002663 "libseccomp_policy_app_sources_riscv64",
2664 "libseccomp_policy_app_zygote_sources_riscv64",
2665 "libseccomp_policy_system_sources_riscv64",
Yu Liu938ec9b2022-10-17 16:36:30 -07002666 ],
2667 },
2668 x86: {
2669 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002670 "libseccomp_policy_app_sources_x86",
2671 "libseccomp_policy_app_zygote_sources_x86",
2672 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002673 ],
2674 },
2675 x86_64: {
2676 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002677 "libseccomp_policy_app_sources_x86",
2678 "libseccomp_policy_app_zygote_sources_x86",
2679 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002680 ],
2681 },
2682 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002683
2684 srcs: [
2685 "seccomp/seccomp_policy.cpp",
2686 ],
2687
2688 export_include_dirs: ["seccomp/include"],
2689 cflags: [
2690 "-Wall",
2691 "-Werror",
2692 ],
2693 shared: {
2694 shared_libs: ["libbase"],
2695 },
2696 static: {
2697 static_libs: ["libbase"],
2698 },
2699}
Christopher Ferrisfc26d712019-02-27 18:07:55 -08002700
Colin Cross048f24e2021-09-01 17:26:00 -07002701cc_library_host_static {
2702 name: "libfts",
2703 srcs: [
2704 "bionic/fts.c",
2705 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
2706 ],
2707 export_include_dirs: ["fts/include"],
2708 local_include_dirs: [
2709 "private",
2710 "upstream-openbsd/android/include",
2711 ],
2712 cflags: [
2713 "-include openbsd-compat.h",
2714 "-Wno-unused-parameter",
2715 ],
2716 enabled: false,
2717 target: {
2718 musl: {
2719 enabled: true,
2720 },
2721 },
Colin Cross2a9843f2022-01-13 12:26:30 -08002722 stl: "none",
2723}
2724
2725cc_library_host_static {
2726 name: "libexecinfo",
2727 visibility: ["//external/musl"],
2728 srcs: ["bionic/execinfo.cpp"],
2729 export_include_dirs: ["execinfo/include"],
2730 local_include_dirs: ["private"],
2731 enabled: false,
2732 target: {
2733 musl: {
2734 enabled: true,
2735 system_shared_libs: [],
2736 header_libs: ["libc_musl_headers"],
2737 },
2738 },
2739 stl: "none",
Colin Cross048f24e2021-09-01 17:26:00 -07002740}
2741
Colin Cross9da85fa2022-01-24 18:20:05 -08002742cc_library_host_static {
2743 name: "libb64",
2744 visibility: ["//external/musl"],
2745 srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
2746 export_include_dirs: ["b64/include"],
2747 local_include_dirs: [
2748 "private",
2749 "upstream-openbsd/android/include",
2750 ],
2751 cflags: [
2752 "-include openbsd-compat.h",
2753 ],
2754 enabled: false,
2755 target: {
2756 musl: {
2757 enabled: true,
2758 system_shared_libs: [],
2759 header_libs: ["libc_musl_headers"],
2760 },
2761 },
2762 stl: "none",
2763}
2764
Colin Cross9d4a56e2022-02-03 10:20:32 -08002765// Export kernel uapi headers to be used in the musl sysroot.
2766// Also include the execinfo headers for the libexecinfo and the
2767// b64 headers for libb64 embedded in musl libc.
2768cc_genrule {
2769 name: "libc_musl_sysroot_bionic_headers",
2770 visibility: ["//external/musl"],
2771 host_supported: true,
2772 device_supported: false,
2773 enabled: false,
2774 target: {
2775 musl: {
2776 enabled: true,
2777 },
2778 },
2779 srcs: [
2780 "kernel/uapi/**/*.h",
2781 "kernel/android/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002782 "execinfo/include/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002783 "b64/include/**/*.h",
Colin Crossaeef9f02022-02-07 21:01:26 -08002784
Colin Crossaeef9f02022-02-07 21:01:26 -08002785 "NOTICE",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002786
2787 ":libc_musl_sysroot_bionic_arch_headers",
2788 ],
2789 out: ["libc_musl_sysroot_bionic_headers.zip"],
2790 tools: [
2791 "soong_zip",
2792 "merge_zips",
2793 "zip2zip",
2794 ],
Colin Crossaeef9f02022-02-07 21:01:26 -08002795 cmd: "BIONIC_LIBC_DIR=$$(dirname $(location NOTICE)) && " +
2796 "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
Colin Crossad33d022022-02-25 18:27:04 -08002797 // NOTICE
2798 " -j -f $(location NOTICE) " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002799 // headers
2800 " -P include " +
Colin Crossaeef9f02022-02-07 21:01:26 -08002801 " -C $${BIONIC_LIBC_DIR}/kernel/uapi " +
2802 " -D $${BIONIC_LIBC_DIR}/kernel/uapi " +
2803 " -C $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2804 " -D $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2805 " -C $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2806 " -D $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2807 " -C $${BIONIC_LIBC_DIR}/execinfo/include " +
2808 " -D $${BIONIC_LIBC_DIR}/execinfo/include " +
2809 " -C $${BIONIC_LIBC_DIR}/b64/include " +
2810 " -D $${BIONIC_LIBC_DIR}/b64/include " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002811 " && " +
Colin Crossad33d022022-02-25 18:27:04 -08002812 "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(genDir)/sysroot-renamed.zip " +
Colin Cross1c0a7a02022-08-11 12:22:26 -07002813 " -x **/BUILD " +
Colin Crossad33d022022-02-25 18:27:04 -08002814 " include/**/*:include/ " +
2815 " NOTICE:NOTICE.bionic " +
2816 " && " +
2817 "$(location merge_zips) $(out) $(location :libc_musl_sysroot_bionic_arch_headers) $(genDir)/sysroot-renamed.zip",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002818}
2819
2820// The architecture-specific bits have to be handled separately because the label varies based
2821// on architecture, which prevents using $(locations) to find them and requires using $(in)
2822// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
2823// genrule.
2824cc_genrule {
2825 name: "libc_musl_sysroot_bionic_arch_headers",
2826 visibility: ["//visibility:private"],
2827 host_supported: true,
2828 device_supported: false,
2829 enabled: false,
2830 target: {
2831 musl: {
2832 enabled: true,
2833 },
2834 },
2835 arch: {
2836 arm: {
2837 srcs: ["kernel/uapi/asm-arm/**/*.h"],
2838 },
2839 arm64: {
2840 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
2841 },
2842 x86: {
2843 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2844 },
2845 x86_64: {
2846 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2847 },
2848 },
2849 out: ["libc_musl_sysroot_bionic_arch_headers.zip"],
2850 tools: ["soong_zip"],
2851 cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/asm -j -D $$(dirname $${includes[0]})",
2852}
Colin Cross290c4952022-10-13 12:51:13 -07002853
2854cc_genrule {
2855 name: "bionic_sysroot_crt_objects",
2856 visibility: ["//visibility:private"],
2857 out: ["bionic_sysroot_crt_objects.zip"],
2858 tools: ["soong_zip"],
2859 srcs: [
2860 ":crtbegin_dynamic",
2861 ":crtbegin_so",
2862 ":crtbegin_static",
2863 ":crtend_android",
2864 ":crtend_so",
2865 ],
2866 cmd: "$(location soong_zip) -o $(out) -j " +
2867 "-f $(location :crtbegin_dynamic) " +
2868 "-f $(location :crtbegin_so) " +
2869 "-f $(location :crtbegin_static) " +
2870 "-f $(location :crtend_android) " +
2871 "-f $(location :crtend_so)",
2872 dist: {
2873 targets: ["bionic_sysroot_crt_objects"],
2874 },
2875 arch: {
2876 arm: {
2877 dist: {
2878 suffix: "_arm",
2879 },
2880 },
2881 arm64: {
2882 dist: {
2883 suffix: "_arm64",
2884 },
2885 },
2886 riscv64: {
2887 dist: {
2888 suffix: "_riscv64",
2889 },
2890 },
2891 x86: {
2892 dist: {
2893 suffix: "_x86",
2894 },
2895 },
2896 x86_64: {
2897 dist: {
2898 suffix: "_x86_64",
2899 },
2900 },
2901 },
2902}
Spandan Das8fce52a2023-09-28 18:00:12 +00002903
Jiyong Park35a280d2024-05-03 16:53:39 +09002904filegroup {
2905 name: "linux_capability_header",
2906 srcs: ["kernel/uapi/linux/capability.h"],
2907}