blob: c5bf010ea4d6620065c783071c506519c93c763b [file] [log] [blame]
Bob Badouraa7d8352021-02-19 13:06:22 -08001package {
2 default_applicable_licenses: ["bionic_libc_license"],
Sophie Zhengd62e1312025-05-15 10:58:39 -07003 default_team: "trendy_team_native_tools_libraries",
Bob Badouraa7d8352021-02-19 13:06:22 -08004}
5
6license {
7 name: "bionic_libc_license",
8 visibility: [":__subpackages__"],
9 license_kinds: [
10 "SPDX-license-identifier-Apache-2.0",
11 "SPDX-license-identifier-BSD",
12 "SPDX-license-identifier-ISC",
13 "SPDX-license-identifier-MIT",
14 "legacy_notice",
15 "legacy_unencumbered",
16 ],
17 license_text: [
18 "NOTICE",
19 ],
20}
21
Elliott Hughes53cf3482016-08-09 13:06:41 -070022libc_common_flags = [
23 "-D_LIBC=1",
24 "-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,
Elliott Hughes827b61a2025-03-28 05:56:43 -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: {
Colin Crossa3f9fca2016-01-11 13:20:55 -0800226 x86: {
Ryan Prichard27475b52018-05-17 17:14:18 -0700227 srcs: [
228 "arch-x86/bionic/__libc_init_sysinfo.cpp",
Pirama Arumuga Nainar7b89be72021-02-12 15:09:49 -0800229 "arch-x86/bionic/__libc_int0x80.S",
Ryan Prichard27475b52018-05-17 17:14:18 -0700230 "arch-x86/bionic/__set_tls.cpp",
231 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800232 },
Colin Crossa3f9fca2016-01-11 13:20:55 -0800233 },
234
Colin Cross50c21ab2015-10-31 23:03:05 -0700235 defaults: ["libc_defaults"],
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000236 cflags: [
237 "-fno-stack-protector",
238 "-ffreestanding",
239 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700240 name: "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -0700241}
242
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800243filegroup {
244 name: "elf_note_sources",
245 srcs: ["bionic/elf_note.cpp"],
246}
247
Ryan Prichard249757b2019-11-01 17:18:28 -0700248// libc_init_static.cpp and libc_init_dynamic.cpp need to be built without stack protector.
249// libc_init_static.cpp sets up TLS for static executables, and libc_init_dynamic.cpp initializes
250// the stack protector global variable.
Colin Crossa3f9fca2016-01-11 13:20:55 -0800251
252cc_library_static {
253 name: "libc_init_static",
254 defaults: ["libc_defaults"],
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800255 srcs: [
Florian Mayera6e9dcf2024-11-06 12:41:22 -0800256 "bionic/libc_init_mte.cpp",
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800257 "bionic/libc_init_static.cpp",
258 ":elf_note_sources",
259 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700260 cflags: [
261 "-fno-stack-protector",
262
263 // Compile libc_init_static.cpp with -ffreestanding, because some of its code is called
264 // from the linker before ifunc resolvers have made string.h functions available.
265 "-ffreestanding",
266 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800267}
268
Stephen Cranef4b1cbd2017-05-09 14:27:43 -0700269cc_library_static {
270 name: "libc_init_dynamic",
271 defaults: ["libc_defaults"],
272 srcs: ["bionic/libc_init_dynamic.cpp"],
273 cflags: ["-fno-stack-protector"],
274}
Colin Crossa3f9fca2016-01-11 13:20:55 -0800275
Dan Willemsen208ae172015-09-16 16:33:27 -0700276// ========================================================
277// libc_tzcode.a - upstream 'tzcode' code
278// ========================================================
279
280cc_library_static {
281
Colin Cross50c21ab2015-10-31 23:03:05 -0700282 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700283 srcs: [
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800284 "tzcode/**/*.c",
Elliott Hughes0e8616a2017-04-11 14:44:51 -0700285 "tzcode/bionic.cpp",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700286 // tzcode doesn't include strptime, so we use a fork of the
287 // OpenBSD code which needs this global data.
Elliott Hughesd3627a42022-12-06 22:24:27 +0000288 "upstream-openbsd/lib/libc/locale/_def_time.c",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700289 // tzcode doesn't include wcsftime, so we use the FreeBSD code.
290 "upstream-freebsd/lib/libc/locale/wcsftime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700291 ],
292
Colin Cross50c21ab2015-10-31 23:03:05 -0700293 cflags: [
Dan Willemsen268a6732015-10-15 14:49:45 -0700294 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700295 // Don't use ridiculous amounts of stack.
296 "-DALL_STATE",
297 // Include tzsetwall, timelocal, timegm, time2posix, and posix2time.
298 "-DSTD_INSPIRED",
Colin Crossa35d23d2015-11-19 13:32:49 -0800299 // Obviously, we want to be thread-safe.
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000300 "-DTHREAD_SAFE=1",
Dan Willemsen208ae172015-09-16 16:33:27 -0700301 // The name of the tm_gmtoff field in our struct tm.
302 "-DTM_GMTOFF=tm_gmtoff",
Elliott Hughes31fc69f2023-06-20 15:36:11 -0700303 // Android uses a system property instead of /etc/localtime, so make callers crash.
Almaz Mingaleeva52a0da2022-02-28 16:55:50 +0000304 "-DTZDEFAULT=NULL",
Dan Willemsen208ae172015-09-16 16:33:27 -0700305 // Where we store our tzdata.
Colin Cross7b294952016-09-29 14:08:13 -0700306 "-DTZDIR=\"/system/usr/share/zoneinfo\"",
Elliott Hughes0a610d02016-07-29 14:04:17 -0700307 // Include `tzname`, `timezone`, and `daylight` globals.
308 "-DHAVE_POSIX_DECLS=0",
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000309 "-DUSG_COMPAT=2",
310 "-DHAVE_TZNAME=2",
311 // stdbool.h is available
312 "-DHAVE_STDBOOL_H",
Colin Crossa35d23d2015-11-19 13:32:49 -0800313 // Use the empty string (instead of " ") as the timezone abbreviation
314 // fallback.
Colin Cross7b294952016-09-29 14:08:13 -0700315 "-DWILDABBR=\"\"",
Dan Willemsen208ae172015-09-16 16:33:27 -0700316 "-Dlint",
317 ],
318
Elliott Hughes2bd43162023-06-15 13:17:08 -0700319 local_include_dirs: [
320 "tzcode/",
321 "upstream-freebsd/android/include",
322 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700323 name: "libc_tzcode",
Dan Willemsen208ae172015-09-16 16:33:27 -0700324}
325
326// ========================================================
327// libc_dns.a - modified NetBSD DNS code
328// ========================================================
329
330cc_library_static {
331
Colin Cross50c21ab2015-10-31 23:03:05 -0700332 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700333 srcs: [
Elliott Hughesd0bbfa82021-04-08 11:58:51 -0700334 "dns/**/*.c*",
Dan Willemsen208ae172015-09-16 16:33:27 -0700335
336 "upstream-netbsd/lib/libc/isc/ev_streams.c",
337 "upstream-netbsd/lib/libc/isc/ev_timers.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700338 ],
339
Colin Cross50c21ab2015-10-31 23:03:05 -0700340 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700341 "-DANDROID_CHANGES",
342 "-DINET6",
Dan Willemsen208ae172015-09-16 16:33:27 -0700343 "-Wno-unused-parameter",
344 "-include netbsd-compat.h",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700345 "-Wframe-larger-than=66000",
Dan Willemsen208ae172015-09-16 16:33:27 -0700346 ],
347
Dan Willemsen208ae172015-09-16 16:33:27 -0700348 local_include_dirs: [
349 "dns/include",
350 "private",
351 "upstream-netbsd/lib/libc/include",
352 "upstream-netbsd/android/include",
353 ],
354
355 name: "libc_dns",
Dan Willemsen208ae172015-09-16 16:33:27 -0700356}
357
358// ========================================================
359// libc_freebsd.a - upstream FreeBSD C library code
360// ========================================================
361//
362// These files are built with the freebsd-compat.h header file
363// automatically included.
364
365cc_library_static {
Elliott Hughesc2043342023-07-20 20:24:09 +0000366 name: "libc_freebsd_ldexp",
367 defaults: ["libc_defaults"],
368 cflags: ["-Dscalbn=ldexp"],
369 srcs: [":libc_ldexp_srcs"],
370}
371
372cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700373 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700374 srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700375 "upstream-freebsd/lib/libc/stdlib/getopt_long.c",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700376 "upstream-freebsd/lib/libc/stdlib/hcreate.c",
377 "upstream-freebsd/lib/libc/stdlib/hcreate_r.c",
378 "upstream-freebsd/lib/libc/stdlib/hdestroy_r.c",
379 "upstream-freebsd/lib/libc/stdlib/hsearch_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700380 "upstream-freebsd/lib/libc/stdlib/quick_exit.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700381 "upstream-freebsd/lib/libc/string/wcpcpy.c",
382 "upstream-freebsd/lib/libc/string/wcpncpy.c",
383 "upstream-freebsd/lib/libc/string/wcscasecmp.c",
384 "upstream-freebsd/lib/libc/string/wcscspn.c",
385 "upstream-freebsd/lib/libc/string/wcsdup.c",
386 "upstream-freebsd/lib/libc/string/wcslcat.c",
387 "upstream-freebsd/lib/libc/string/wcsncasecmp.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700388 "upstream-freebsd/lib/libc/string/wcsnlen.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700389 "upstream-freebsd/lib/libc/string/wcstok.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700390 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700391
Colin Cross50c21ab2015-10-31 23:03:05 -0700392 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700393 "-Wno-sign-compare",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700394 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700395 "-include freebsd-compat.h",
396 ],
397
Dan Willemsen208ae172015-09-16 16:33:27 -0700398 local_include_dirs: [
399 "upstream-freebsd/android/include",
400 ],
401
402 name: "libc_freebsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700403}
404
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700405cc_library_static {
406 defaults: ["libc_defaults"],
407 srcs: [
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700408 "upstream-freebsd/lib/libc/gen/glob.c",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700409 ],
410
411 cflags: [
412 "-Wno-sign-compare",
413 "-include freebsd-compat.h",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700414 "-Wframe-larger-than=66000",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700415 ],
416
417 local_include_dirs: [
418 "upstream-freebsd/android/include",
419 ],
420
421 name: "libc_freebsd_large_stack",
422}
423
Dan Willemsen208ae172015-09-16 16:33:27 -0700424// ========================================================
425// libc_netbsd.a - upstream NetBSD C library code
426// ========================================================
427//
428// These files are built with the netbsd-compat.h header file
429// automatically included.
430
431cc_library_static {
432
Colin Cross50c21ab2015-10-31 23:03:05 -0700433 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700434 srcs: [
435 "upstream-netbsd/common/lib/libc/stdlib/random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700436 "upstream-netbsd/lib/libc/gen/nice.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700437 "upstream-netbsd/lib/libc/inet/nsap_addr.c",
438 "upstream-netbsd/lib/libc/regex/regcomp.c",
439 "upstream-netbsd/lib/libc/regex/regerror.c",
440 "upstream-netbsd/lib/libc/regex/regexec.c",
441 "upstream-netbsd/lib/libc/regex/regfree.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700442 "upstream-netbsd/lib/libc/stdlib/drand48.c",
443 "upstream-netbsd/lib/libc/stdlib/erand48.c",
444 "upstream-netbsd/lib/libc/stdlib/jrand48.c",
445 "upstream-netbsd/lib/libc/stdlib/lcong48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700446 "upstream-netbsd/lib/libc/stdlib/lrand48.c",
447 "upstream-netbsd/lib/libc/stdlib/mrand48.c",
448 "upstream-netbsd/lib/libc/stdlib/nrand48.c",
449 "upstream-netbsd/lib/libc/stdlib/_rand48.c",
450 "upstream-netbsd/lib/libc/stdlib/rand_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700451 "upstream-netbsd/lib/libc/stdlib/seed48.c",
452 "upstream-netbsd/lib/libc/stdlib/srand48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700453 ],
454 multilib: {
455 lib32: {
456 // LP32 cruft
457 srcs: ["upstream-netbsd/common/lib/libc/hash/sha1/sha1.c"],
458 },
459 },
Colin Cross50c21ab2015-10-31 23:03:05 -0700460 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700461 "-Wno-sign-compare",
Dan Willemsen879cec22016-02-29 10:37:56 -0800462 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700463 "-DPOSIX_MISTAKE",
464 "-include netbsd-compat.h",
465 ],
466
Dan Willemsen208ae172015-09-16 16:33:27 -0700467 local_include_dirs: [
468 "upstream-netbsd/android/include",
469 "upstream-netbsd/lib/libc/include",
470 ],
471
472 name: "libc_netbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700473}
474
475// ========================================================
Elliott Hughes968adf92024-02-08 13:15:53 -0800476// libc_openbsd.a - upstream OpenBSD C library code
Dan Willemsen208ae172015-09-16 16:33:27 -0700477// ========================================================
478//
479// These files are built with the openbsd-compat.h header file
480// automatically included.
Dan Willemsen208ae172015-09-16 16:33:27 -0700481cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700482 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700483 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800484 "upstream-openbsd/lib/libc/crypt/arc4random.c",
485 "upstream-openbsd/lib/libc/crypt/arc4random_uniform.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700486 "upstream-openbsd/lib/libc/gen/alarm.c",
487 "upstream-openbsd/lib/libc/gen/ctype_.c",
488 "upstream-openbsd/lib/libc/gen/daemon.c",
489 "upstream-openbsd/lib/libc/gen/err.c",
490 "upstream-openbsd/lib/libc/gen/errx.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700491 "upstream-openbsd/lib/libc/gen/fnmatch.c",
492 "upstream-openbsd/lib/libc/gen/ftok.c",
493 "upstream-openbsd/lib/libc/gen/getprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700494 "upstream-openbsd/lib/libc/gen/setprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700495 "upstream-openbsd/lib/libc/gen/verr.c",
496 "upstream-openbsd/lib/libc/gen/verrx.c",
497 "upstream-openbsd/lib/libc/gen/vwarn.c",
498 "upstream-openbsd/lib/libc/gen/vwarnx.c",
499 "upstream-openbsd/lib/libc/gen/warn.c",
500 "upstream-openbsd/lib/libc/gen/warnx.c",
501 "upstream-openbsd/lib/libc/locale/btowc.c",
502 "upstream-openbsd/lib/libc/locale/mbrlen.c",
503 "upstream-openbsd/lib/libc/locale/mbstowcs.c",
504 "upstream-openbsd/lib/libc/locale/mbtowc.c",
505 "upstream-openbsd/lib/libc/locale/wcscoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700506 "upstream-openbsd/lib/libc/locale/wcstombs.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700507 "upstream-openbsd/lib/libc/locale/wcsxfrm.c",
508 "upstream-openbsd/lib/libc/locale/wctob.c",
509 "upstream-openbsd/lib/libc/locale/wctomb.c",
Elliott Hughes26fda772016-04-06 11:56:41 -0700510 "upstream-openbsd/lib/libc/net/base64.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700511 "upstream-openbsd/lib/libc/net/htonl.c",
512 "upstream-openbsd/lib/libc/net/htons.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700513 "upstream-openbsd/lib/libc/net/inet_lnaof.c",
514 "upstream-openbsd/lib/libc/net/inet_makeaddr.c",
515 "upstream-openbsd/lib/libc/net/inet_netof.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700516 "upstream-openbsd/lib/libc/net/inet_ntoa.c",
517 "upstream-openbsd/lib/libc/net/inet_ntop.c",
518 "upstream-openbsd/lib/libc/net/inet_pton.c",
519 "upstream-openbsd/lib/libc/net/ntohl.c",
520 "upstream-openbsd/lib/libc/net/ntohs.c",
Colin Cross8ce38af2016-01-19 12:50:20 -0800521 "upstream-openbsd/lib/libc/net/res_random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700522 "upstream-openbsd/lib/libc/stdio/fgetln.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700523 "upstream-openbsd/lib/libc/stdio/fgetwc.c",
524 "upstream-openbsd/lib/libc/stdio/fgetws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700525 "upstream-openbsd/lib/libc/stdio/flags.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700526 "upstream-openbsd/lib/libc/stdio/fputwc.c",
527 "upstream-openbsd/lib/libc/stdio/fputws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700528 "upstream-openbsd/lib/libc/stdio/fvwrite.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700529 "upstream-openbsd/lib/libc/stdio/fwide.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700530 "upstream-openbsd/lib/libc/stdio/getdelim.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700531 "upstream-openbsd/lib/libc/stdio/gets.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700532 "upstream-openbsd/lib/libc/stdio/makebuf.c",
533 "upstream-openbsd/lib/libc/stdio/mktemp.c",
534 "upstream-openbsd/lib/libc/stdio/open_memstream.c",
535 "upstream-openbsd/lib/libc/stdio/open_wmemstream.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700536 "upstream-openbsd/lib/libc/stdio/rget.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700537 "upstream-openbsd/lib/libc/stdio/setvbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700538 "upstream-openbsd/lib/libc/stdio/ungetc.c",
539 "upstream-openbsd/lib/libc/stdio/ungetwc.c",
540 "upstream-openbsd/lib/libc/stdio/vasprintf.c",
541 "upstream-openbsd/lib/libc/stdio/vdprintf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700542 "upstream-openbsd/lib/libc/stdio/vsscanf.c",
543 "upstream-openbsd/lib/libc/stdio/vswprintf.c",
544 "upstream-openbsd/lib/libc/stdio/vswscanf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700545 "upstream-openbsd/lib/libc/stdio/wbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700546 "upstream-openbsd/lib/libc/stdio/wsetup.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700547 "upstream-openbsd/lib/libc/stdlib/getenv.c",
Colin Crossb8396102016-04-07 13:24:50 -0700548 "upstream-openbsd/lib/libc/stdlib/getsubopt.c",
Elliott Hughes26b06072020-07-31 11:00:10 -0700549 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700550 "upstream-openbsd/lib/libc/stdlib/setenv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700551 "upstream-openbsd/lib/libc/stdlib/tfind.c",
552 "upstream-openbsd/lib/libc/stdlib/tsearch.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800553 "upstream-openbsd/lib/libc/string/memccpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700554 "upstream-openbsd/lib/libc/string/strcasecmp.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800555 "upstream-openbsd/lib/libc/string/strcasestr.c",
556 "upstream-openbsd/lib/libc/string/strcoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700557 "upstream-openbsd/lib/libc/string/strcspn.c",
558 "upstream-openbsd/lib/libc/string/strdup.c",
559 "upstream-openbsd/lib/libc/string/strndup.c",
560 "upstream-openbsd/lib/libc/string/strpbrk.c",
561 "upstream-openbsd/lib/libc/string/strsep.c",
562 "upstream-openbsd/lib/libc/string/strspn.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700563 "upstream-openbsd/lib/libc/string/strtok.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800564 "upstream-openbsd/lib/libc/string/strxfrm.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700565 "upstream-openbsd/lib/libc/string/wcslcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700566 "upstream-openbsd/lib/libc/string/wcswidth.c",
Colin Cross69bcb8b2021-09-08 13:24:16 -0700567
Elliott Hughesd4c61182024-08-16 17:31:24 -0400568 // These files are originally from OpenBSD,
569 // and benefit from being compiled with openbsd-compat.h.
570 // TODO: clean them up instead.
Colin Cross69bcb8b2021-09-08 13:24:16 -0700571 "bionic/fts.c",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400572 "stdio/vfprintf.cpp",
573 "stdio/vfwprintf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700574 ],
575
Elliott Hughes7d136662023-10-27 15:40:32 -0700576 // Each architecture has optimized versions of some routines,
577 // and only includes the portable C versions of ones it's missing.
Dan Willemsen208ae172015-09-16 16:33:27 -0700578 arch: {
579 arm: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700580 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700581 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700582 "upstream-openbsd/lib/libc/string/strncat.c",
583 "upstream-openbsd/lib/libc/string/strncmp.c",
584 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700585 ],
586 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700587 arm64: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700588 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700589 "upstream-openbsd/lib/libc/string/strcat.c",
Elliott Hughesaefe9992023-11-08 12:04:41 -0800590 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700591 "upstream-openbsd/lib/libc/string/strncat.c",
592 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700593 ],
594 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000595 riscv64: {
596 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700597 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughesebc19a92022-10-14 23:25:36 +0000598 ],
599 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700600 x86: {
Elliott Hughesaefe9992023-11-08 12:04:41 -0800601 srcs: [
602 // x86 has custom implementations of all of these.
603 ],
Elliott Hughes7d136662023-10-27 15:40:32 -0700604 },
605 x86_64: {
606 srcs: [
George Burgess IV414bfb32024-11-19 09:00:39 -0700607 // x86_64 has custom/llvm-libc implementations of all of these.
Colin Cross6ab8f892015-11-23 14:12:15 -0800608 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700609 },
610 },
611
Colin Cross50c21ab2015-10-31 23:03:05 -0700612 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700613 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700614 "-Wno-unused-parameter",
615 "-include openbsd-compat.h",
616 ],
617
Dan Willemsen208ae172015-09-16 16:33:27 -0700618 local_include_dirs: [
619 "private",
Elliott Hughes968adf92024-02-08 13:15:53 -0800620 "stdio",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400621 "upstream-openbsd/android/include/",
622 "upstream-openbsd/lib/libc/gdtoa/",
623 "upstream-openbsd/lib/libc/include/",
624 "upstream-openbsd/lib/libc/stdio/",
Dan Willemsen208ae172015-09-16 16:33:27 -0700625 ],
626
627 name: "libc_openbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700628}
629
Elliott Hughes968adf92024-02-08 13:15:53 -0800630cc_library_static {
631 name: "libc_openbsd_large_stack",
632 defaults: ["libc_defaults"],
633 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800634 "upstream-openbsd/lib/libc/string/memmem.c",
635 "upstream-openbsd/lib/libc/string/strstr.c",
636 ],
637 cflags: [
638 "-include openbsd-compat.h",
639 "-Wno-sign-compare",
640 "-Wframe-larger-than=5000",
641 ],
642
643 local_include_dirs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800644 "upstream-openbsd/android/include/",
Elliott Hughes968adf92024-02-08 13:15:53 -0800645 ],
646}
647
Dan Willemsen208ae172015-09-16 16:33:27 -0700648// ========================================================
649// libc_gdtoa.a - upstream OpenBSD C library gdtoa code
650// ========================================================
651//
652// These files are built with the openbsd-compat.h header file
653// automatically included.
654
655cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700656 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700657 srcs: [
658 "upstream-openbsd/android/gdtoa_support.cpp",
659 "upstream-openbsd/lib/libc/gdtoa/dmisc.c",
660 "upstream-openbsd/lib/libc/gdtoa/dtoa.c",
661 "upstream-openbsd/lib/libc/gdtoa/gdtoa.c",
662 "upstream-openbsd/lib/libc/gdtoa/gethex.c",
663 "upstream-openbsd/lib/libc/gdtoa/gmisc.c",
664 "upstream-openbsd/lib/libc/gdtoa/hd_init.c",
665 "upstream-openbsd/lib/libc/gdtoa/hdtoa.c",
666 "upstream-openbsd/lib/libc/gdtoa/hexnan.c",
667 "upstream-openbsd/lib/libc/gdtoa/ldtoa.c",
668 "upstream-openbsd/lib/libc/gdtoa/misc.c",
669 "upstream-openbsd/lib/libc/gdtoa/smisc.c",
670 "upstream-openbsd/lib/libc/gdtoa/strtod.c",
671 "upstream-openbsd/lib/libc/gdtoa/strtodg.c",
672 "upstream-openbsd/lib/libc/gdtoa/strtof.c",
673 "upstream-openbsd/lib/libc/gdtoa/strtord.c",
674 "upstream-openbsd/lib/libc/gdtoa/sum.c",
675 "upstream-openbsd/lib/libc/gdtoa/ulp.c",
676 ],
677 multilib: {
678 lib64: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800679 srcs: ["upstream-openbsd/lib/libc/gdtoa/strtorQ.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700680 },
681 },
682
Colin Cross50c21ab2015-10-31 23:03:05 -0700683 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700684 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700685 "-include openbsd-compat.h",
686 ],
687
Dan Willemsen208ae172015-09-16 16:33:27 -0700688 local_include_dirs: [
689 "private",
690 "upstream-openbsd/android/include",
691 "upstream-openbsd/lib/libc/include",
692 ],
693
694 name: "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -0700695}
696
697// ========================================================
Pierre-Clément Tosi467e58e2023-02-01 13:44:43 +0000698// libc_fortify.a - container for our FORTIFY
George Burgess IV6cb06872017-07-21 13:28:42 -0700699// implementation details
700// ========================================================
701cc_library_static {
702 defaults: ["libc_defaults"],
George Burgess IVd34b0a92017-07-25 11:43:39 -0700703 srcs: ["bionic/fortify.cpp"],
George Burgess IV6cb06872017-07-21 13:28:42 -0700704
705 name: "libc_fortify",
706
707 // Disable FORTIFY for the compilation of these, so we don't end up having
708 // FORTIFY silently call itself.
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800709 cflags: [
710 "-U_FORTIFY_SOURCE",
711 "-D__BIONIC_DECLARE_FORTIFY_HELPERS",
712 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700713
714 arch: {
715 arm: {
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800716 cflags: [
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800717 "-DRENAME___STRCAT_CHK",
718 "-DRENAME___STRCPY_CHK",
719 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700720 srcs: [
721 "arch-arm/generic/bionic/__memcpy_chk.S",
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800722
723 "arch-arm/cortex-a15/bionic/__strcat_chk.S",
724 "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
725
726 "arch-arm/cortex-a7/bionic/__strcat_chk.S",
727 "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
728
729 "arch-arm/cortex-a9/bionic/__strcat_chk.S",
730 "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
731
732 "arch-arm/krait/bionic/__strcat_chk.S",
733 "arch-arm/krait/bionic/__strcpy_chk.S",
734
735 "arch-arm/cortex-a53/bionic/__strcat_chk.S",
736 "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
737
Haibo Huang01bfd892018-12-03 15:05:16 -0800738 "arch-arm/cortex-a55/bionic/__strcat_chk.S",
739 "arch-arm/cortex-a55/bionic/__strcpy_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700740 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700741 },
742 arm64: {
743 srcs: [
Elliott Hughes023e4e72022-11-17 19:27:02 +0000744 "arch-arm64/string/__memcpy_chk.S",
745 "arch-arm64/string/__memset_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700746 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700747 },
748 },
749}
750
751// ========================================================
Manish Goregaokar361854c2025-03-05 15:02:28 -0800752// icu4x_bionic.a - Thin Rust wrapper around ICU4X
753// ========================================================
754
755rust_ffi_static {
756 name: "libicu4x_bionic",
757 crate_name: "icu4x_bionic",
758 crate_root: "bionic/icu4x.rs",
759 edition: "2021",
760 features: [],
761 rustlibs: [
762 "//external/rust/android-crates-io/crates/icu_casemap:libicu_casemap",
763 "//external/rust/android-crates-io/crates/icu_collections:libicu_collections",
764 "//external/rust/android-crates-io/crates/icu_properties:libicu_properties",
765 ],
766 apex_available: [
767 "//apex_available:platform",
768 "//apex_available:anyapex",
769 ],
770 vendor_available: true,
771 product_available: true,
772 ramdisk_available: true,
773 vendor_ramdisk_available: true,
774 recovery_available: true,
775 native_bridge_supported: true,
776 sdk_version: "minimum",
777 defaults: ["linux_bionic_supported"],
778}
779
780// current rust implementation detail; will be removed as part of a larger cleanup later
781// go/android-mto-staticlibs-in-make
782cc_rustlibs_for_make {
783 name: "libstatic_rustlibs_for_make",
784 whole_static_libs: ["libicu4x_bionic"],
785 apex_available: [
786 "//apex_available:platform",
787 "//apex_available:anyapex",
788 ],
789 vendor_available: true,
790 product_available: true,
791 ramdisk_available: true,
792 vendor_ramdisk_available: true,
793 recovery_available: true,
794 native_bridge_supported: true,
795 defaults: ["linux_bionic_supported"],
796}
797
798// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -0700799// libc_bionic.a - home-grown C library code
800// ========================================================
801
802cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700803 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700804 srcs: [
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800805 "bionic/NetdClientDispatch.cpp",
806 "bionic/__bionic_get_shell_path.cpp",
807 "bionic/__cmsg_nxthdr.cpp",
808 "bionic/__cxa_thread_atexit_impl.cpp",
809 "bionic/__errno.cpp",
810 "bionic/__gnu_basename.cpp",
811 "bionic/__libc_current_sigrtmax.cpp",
812 "bionic/__libc_current_sigrtmin.cpp",
813 "bionic/abort.cpp",
814 "bionic/accept.cpp",
815 "bionic/access.cpp",
Florian Mayerca4749a2024-02-14 12:55:46 -0800816 "bionic/android_crash_detail.cpp",
Josh Gao10ec9282017-04-03 15:13:29 -0700817 "bionic/android_set_abort_message.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000818 "bionic/android_unsafe_frame_pointer_chase.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800819 "bionic/arpa_inet.cpp",
820 "bionic/assert.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000821 "bionic/atexit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800822 "bionic/atof.cpp",
823 "bionic/bionic_allocator.cpp",
824 "bionic/bionic_arc4random.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000825 "bionic/bionic_elf_tls.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800826 "bionic/bionic_futex.cpp",
827 "bionic/bionic_netlink.cpp",
828 "bionic/bionic_systrace.cpp",
829 "bionic/bionic_time_conversions.cpp",
830 "bionic/brk.cpp",
831 "bionic/c16rtomb.cpp",
832 "bionic/c32rtomb.cpp",
833 "bionic/chmod.cpp",
834 "bionic/chown.cpp",
835 "bionic/clearenv.cpp",
836 "bionic/clock.cpp",
837 "bionic/clock_getcpuclockid.cpp",
838 "bionic/clock_nanosleep.cpp",
839 "bionic/clone.cpp",
840 "bionic/ctype.cpp",
841 "bionic/dirent.cpp",
842 "bionic/dup.cpp",
843 "bionic/environ.cpp",
844 "bionic/error.cpp",
845 "bionic/eventfd.cpp",
846 "bionic/exec.cpp",
847 "bionic/execinfo.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800848 "bionic/exit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800849 "bionic/faccessat.cpp",
850 "bionic/fchmod.cpp",
851 "bionic/fchmodat.cpp",
852 "bionic/fcntl.cpp",
853 "bionic/fdsan.cpp",
854 "bionic/fdtrack.cpp",
855 "bionic/ffs.cpp",
856 "bionic/fgetxattr.cpp",
857 "bionic/flistxattr.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000858 "bionic/fork.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800859 "bionic/fpclassify.cpp",
860 "bionic/fsetxattr.cpp",
861 "bionic/ftruncate.cpp",
862 "bionic/ftw.cpp",
863 "bionic/futimens.cpp",
864 "bionic/getcwd.cpp",
865 "bionic/getdomainname.cpp",
866 "bionic/getentropy.cpp",
867 "bionic/gethostname.cpp",
868 "bionic/getloadavg.cpp",
869 "bionic/getpagesize.cpp",
870 "bionic/getpgrp.cpp",
871 "bionic/getpid.cpp",
872 "bionic/getpriority.cpp",
873 "bionic/gettid.cpp",
874 "bionic/get_device_api_level.cpp",
875 "bionic/grp_pwd.cpp",
876 "bionic/grp_pwd_file.cpp",
877 "bionic/heap_zero_init.cpp",
878 "bionic/iconv.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800879 "bionic/ifaddrs.cpp",
880 "bionic/inotify_init.cpp",
881 "bionic/ioctl.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800882 "bionic/isatty.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800883 "bionic/killpg.cpp",
884 "bionic/langinfo.cpp",
Elliott Hughes219e6022024-08-27 19:12:08 +0000885 "bionic/lchmod.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800886 "bionic/lchown.cpp",
887 "bionic/lfs64_support.cpp",
888 "bionic/libc_init_common.cpp",
889 "bionic/libgen.cpp",
890 "bionic/link.cpp",
891 "bionic/locale.cpp",
892 "bionic/lockf.cpp",
893 "bionic/lstat.cpp",
894 "bionic/mblen.cpp",
895 "bionic/mbrtoc16.cpp",
896 "bionic/mbrtoc32.cpp",
897 "bionic/mempcpy.cpp",
898 "bionic/memset_explicit.cpp",
899 "bionic/mkdir.cpp",
900 "bionic/mkfifo.cpp",
901 "bionic/mknod.cpp",
902 "bionic/mntent.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800903 "bionic/netdb.cpp",
Elliott Hughes3ed6e722024-02-16 01:18:01 +0000904 "bionic/net_if.cpp",
905 "bionic/netinet_ether.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800906 "bionic/netinet_in.cpp",
907 "bionic/nl_types.cpp",
908 "bionic/open.cpp",
909 "bionic/pathconf.cpp",
910 "bionic/pause.cpp",
911 "bionic/pidfd.cpp",
912 "bionic/pipe.cpp",
913 "bionic/poll.cpp",
914 "bionic/posix_fadvise.cpp",
915 "bionic/posix_fallocate.cpp",
916 "bionic/posix_madvise.cpp",
917 "bionic/posix_timers.cpp",
918 "bionic/preadv_pwritev.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000919 "bionic/pthread_atfork.cpp",
920 "bionic/pthread_attr.cpp",
921 "bionic/pthread_barrier.cpp",
922 "bionic/pthread_cond.cpp",
923 "bionic/pthread_create.cpp",
924 "bionic/pthread_detach.cpp",
925 "bionic/pthread_equal.cpp",
926 "bionic/pthread_exit.cpp",
Elliott Hughese117d6e2024-11-14 17:31:13 +0000927 "bionic/pthread_getaffinity.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000928 "bionic/pthread_getcpuclockid.cpp",
929 "bionic/pthread_getschedparam.cpp",
930 "bionic/pthread_gettid_np.cpp",
931 "bionic/pthread_internal.cpp",
932 "bionic/pthread_join.cpp",
933 "bionic/pthread_key.cpp",
934 "bionic/pthread_kill.cpp",
935 "bionic/pthread_mutex.cpp",
936 "bionic/pthread_once.cpp",
937 "bionic/pthread_rwlock.cpp",
938 "bionic/pthread_sigqueue.cpp",
939 "bionic/pthread_self.cpp",
940 "bionic/pthread_setname_np.cpp",
Elliott Hughese117d6e2024-11-14 17:31:13 +0000941 "bionic/pthread_setaffinity.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000942 "bionic/pthread_setschedparam.cpp",
943 "bionic/pthread_spinlock.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800944 "bionic/ptrace.cpp",
945 "bionic/pty.cpp",
946 "bionic/raise.cpp",
947 "bionic/rand.cpp",
948 "bionic/readlink.cpp",
949 "bionic/realpath.cpp",
950 "bionic/reboot.cpp",
951 "bionic/recv.cpp",
952 "bionic/recvmsg.cpp",
953 "bionic/rename.cpp",
954 "bionic/rmdir.cpp",
955 "bionic/scandir.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800956 "bionic/sched_cpualloc.cpp",
957 "bionic/sched_cpucount.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800958 "bionic/sched_getaffinity.cpp",
959 "bionic/sched_getcpu.cpp",
960 "bionic/semaphore.cpp",
961 "bionic/send.cpp",
962 "bionic/setegid.cpp",
963 "bionic/seteuid.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000964 "bionic/setjmp_cookie.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800965 "bionic/setpgrp.cpp",
966 "bionic/sigaction.cpp",
967 "bionic/signal.cpp",
968 "bionic/sigprocmask.cpp",
969 "bionic/sleep.cpp",
970 "bionic/socketpair.cpp",
971 "bionic/spawn.cpp",
972 "bionic/stat.cpp",
973 "bionic/stdlib_l.cpp",
974 "bionic/strerror.cpp",
975 "bionic/string_l.cpp",
976 "bionic/strings_l.cpp",
977 "bionic/strsignal.cpp",
978 "bionic/strtol.cpp",
979 "bionic/strtold.cpp",
980 "bionic/swab.cpp",
981 "bionic/symlink.cpp",
982 "bionic/sync_file_range.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000983 "bionic/sysconf.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800984 "bionic/sys_epoll.cpp",
985 "bionic/sys_msg.cpp",
986 "bionic/sys_sem.cpp",
987 "bionic/sys_shm.cpp",
988 "bionic/sys_signalfd.cpp",
989 "bionic/sys_statfs.cpp",
990 "bionic/sys_statvfs.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000991 "bionic/sys_thread_properties.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800992 "bionic/sys_time.cpp",
993 "bionic/sysinfo.cpp",
994 "bionic/syslog.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800995 "bionic/sysprop_helpers.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800996 "bionic/system.cpp",
997 "bionic/system_property_api.cpp",
998 "bionic/system_property_set.cpp",
999 "bionic/tdestroy.cpp",
1000 "bionic/termios.cpp",
1001 "bionic/thread_private.cpp",
1002 "bionic/threads.cpp",
1003 "bionic/time.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001004 "bionic/tmpfile.cpp",
1005 "bionic/umount.cpp",
1006 "bionic/unlink.cpp",
1007 "bionic/usleep.cpp",
Elliott Hughes4d5ea532025-05-09 11:16:42 -07001008 "bionic/utime.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001009 "bionic/utmp.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001010 "bionic/vdso.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001011 "bionic/wait.cpp",
1012 "bionic/wchar.cpp",
1013 "bionic/wchar_l.cpp",
1014 "bionic/wcstod.cpp",
1015 "bionic/wctype.cpp",
1016 "bionic/wcwidth.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001017
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001018 // Forked but not yet cleaned up/rewritten stdio code.
1019 // TODO: finish cleanup.
1020 "stdio/fmemopen.cpp",
1021 "stdio/parsefloat.c",
1022 "stdio/refill.c",
1023 "stdio/stdio.cpp",
1024 "stdio/stdio_ext.cpp",
1025 "stdio/vfscanf.cpp",
1026 "stdio/vfwscanf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001027 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001028
1029 arch: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001030 arm: {
Elliott Hughes1b61d782019-06-04 10:38:34 -07001031 asflags: libc_common_flags + ["-mno-restrict-it"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001032 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -08001033 "arch-arm/bionic/__aeabi_read_tp.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001034 "arch-arm/bionic/__bionic_clone.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001035 "arch-arm/bionic/__restore.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001036 "arch-arm/bionic/_exit_with_stack_teardown.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001037 "arch-arm/bionic/atomics_arm.c",
1038 "arch-arm/bionic/bpabi.c",
Yi Kong165b1cf2019-02-13 14:10:10 -08001039 "arch-arm/bionic/libcrt_compat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001040 "arch-arm/bionic/popcount_tab.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001041 "arch-arm/bionic/setjmp.S",
1042 "arch-arm/bionic/syscall.S",
1043 "arch-arm/bionic/vfork.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001044
Haibo Huangea9957a2018-11-19 11:00:32 -08001045 "arch-arm/cortex-a7/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001046 "arch-arm/cortex-a7/bionic/memset.S",
1047
1048 "arch-arm/cortex-a9/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001049 "arch-arm/cortex-a9/bionic/memset.S",
1050 "arch-arm/cortex-a9/bionic/stpcpy.S",
1051 "arch-arm/cortex-a9/bionic/strcat.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001052 "arch-arm/cortex-a9/bionic/strcpy.S",
1053 "arch-arm/cortex-a9/bionic/strlen.S",
1054
Elliott Hughesaefe9992023-11-08 12:04:41 -08001055 "arch-arm/cortex-a15/bionic/memcpy.S",
1056 "arch-arm/cortex-a15/bionic/memmove.S",
1057 "arch-arm/cortex-a15/bionic/memset.S",
1058 "arch-arm/cortex-a15/bionic/stpcpy.S",
1059 "arch-arm/cortex-a15/bionic/strcat.S",
1060 "arch-arm/cortex-a15/bionic/strcmp.S",
1061 "arch-arm/cortex-a15/bionic/strcpy.S",
1062 "arch-arm/cortex-a15/bionic/strlen.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001063
1064 "arch-arm/cortex-a53/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001065
Haibo Huang01bfd892018-12-03 15:05:16 -08001066 "arch-arm/cortex-a55/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001067
Elliott Hughesaefe9992023-11-08 12:04:41 -08001068 "arch-arm/generic/bionic/memcmp.S",
1069 "arch-arm/generic/bionic/memmove.S",
1070 "arch-arm/generic/bionic/memset.S",
1071 "arch-arm/generic/bionic/stpcpy.c",
1072 "arch-arm/generic/bionic/strcat.c",
1073 "arch-arm/generic/bionic/strcmp.S",
1074 "arch-arm/generic/bionic/strcpy.S",
1075 "arch-arm/generic/bionic/strlen.c",
1076
1077 "arch-arm/krait/bionic/memcpy.S",
1078 "arch-arm/krait/bionic/memset.S",
1079
Haibo Huangea9957a2018-11-19 11:00:32 -08001080 "arch-arm/kryo/bionic/memcpy.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001081 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001082 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001083 arm64: {
1084 srcs: [
Dan Willemsen3e621712016-02-03 21:48:08 -08001085 "arch-arm64/bionic/__bionic_clone.S",
1086 "arch-arm64/bionic/_exit_with_stack_teardown.S",
1087 "arch-arm64/bionic/setjmp.S",
1088 "arch-arm64/bionic/syscall.S",
1089 "arch-arm64/bionic/vfork.S",
Vaisakh K V83e55842024-03-29 12:47:39 +05301090 "arch-arm64/oryon/memcpy-nt.S",
Vaisakh K V54a61212024-03-29 13:32:45 +05301091 "arch-arm64/oryon/memset-nt.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001092 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001093 },
1094
Elliott Hughesebc19a92022-10-14 23:25:36 +00001095 riscv64: {
1096 srcs: [
1097 "arch-riscv64/bionic/__bionic_clone.S",
1098 "arch-riscv64/bionic/_exit_with_stack_teardown.S",
Elliott Hughese1905ed2022-10-17 23:23:36 +00001099 "arch-riscv64/bionic/setjmp.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001100 "arch-riscv64/bionic/syscall.S",
1101 "arch-riscv64/bionic/vfork.S",
Yun Hsiang40a82d02023-05-26 10:10:40 +08001102
Elliott Hughesff7bb092025-02-03 06:06:55 -08001103 "arch-riscv64/string/memchr.S",
1104 "arch-riscv64/string/memcmp.S",
1105 "arch-riscv64/string/memcpy.S",
1106 "arch-riscv64/string/memmove.S",
1107 "arch-riscv64/string/memset.S",
1108 "arch-riscv64/string/stpcpy.S",
1109 "arch-riscv64/string/strcat.S",
1110 "arch-riscv64/string/strchr.S",
1111 "arch-riscv64/string/strcmp.S",
1112 "arch-riscv64/string/strcpy.S",
1113 "arch-riscv64/string/strlen.S",
1114 "arch-riscv64/string/strncat.S",
1115 "arch-riscv64/string/strncmp.S",
1116 "arch-riscv64/string/strncpy.S",
1117 "arch-riscv64/string/strnlen.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001118 ],
1119 },
1120
Dan Willemsen208ae172015-09-16 16:33:27 -07001121 x86: {
1122 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001123 "arch-x86/bionic/__bionic_clone.S",
1124 "arch-x86/bionic/_exit_with_stack_teardown.S",
1125 "arch-x86/bionic/libcrt_compat.c",
Elliott Hughes7d136662023-10-27 15:40:32 -07001126 "arch-x86/bionic/setjmp.S",
1127 "arch-x86/bionic/syscall.S",
1128 "arch-x86/bionic/vfork.S",
1129 "arch-x86/bionic/__x86.get_pc_thunk.S",
1130
Elliott Hughesed777142022-07-25 16:25:11 +00001131 "arch-x86/string/sse2-memmove-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001132 "arch-x86/string/sse2-memset-slm.S",
1133 "arch-x86/string/sse2-stpcpy-slm.S",
1134 "arch-x86/string/sse2-stpncpy-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001135 "arch-x86/string/sse2-strcpy-slm.S",
1136 "arch-x86/string/sse2-strlen-slm.S",
1137 "arch-x86/string/sse2-strncpy-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001138
1139 "arch-x86/string/ssse3-memcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001140 "arch-x86/string/ssse3-strcat-atom.S",
1141 "arch-x86/string/ssse3-strcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001142 "arch-x86/string/ssse3-strncat-atom.S",
1143 "arch-x86/string/ssse3-strncmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001144
1145 "arch-x86/string/sse4-memcmp-slm.S",
Dan Willemsen268a6732015-10-15 14:49:45 -07001146 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001147 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001148 x86_64: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001149 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001150 "arch-x86_64/bionic/__bionic_clone.S",
1151 "arch-x86_64/bionic/_exit_with_stack_teardown.S",
1152 "arch-x86_64/bionic/__restore_rt.S",
1153 "arch-x86_64/bionic/setjmp.S",
1154 "arch-x86_64/bionic/syscall.S",
1155 "arch-x86_64/bionic/vfork.S",
1156
Ravi Kumar Soni406c98d2024-10-15 20:43:55 +05301157 "arch-x86_64/string/avx2-memmove-kbl.S",
ahs919fb7f2022-06-10 07:11:14 +05301158 "arch-x86_64/string/avx2-memset-kbl.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001159 "arch-x86_64/string/sse2-memmove-slm.S",
1160 "arch-x86_64/string/sse2-memset-slm.S",
1161 "arch-x86_64/string/sse2-stpcpy-slm.S",
1162 "arch-x86_64/string/sse2-stpncpy-slm.S",
1163 "arch-x86_64/string/sse2-strcat-slm.S",
1164 "arch-x86_64/string/sse2-strcpy-slm.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001165 "arch-x86_64/string/sse2-strlen-slm.S",
1166 "arch-x86_64/string/sse2-strncat-slm.S",
1167 "arch-x86_64/string/sse2-strncpy-slm.S",
1168 "arch-x86_64/string/sse4-memcmp-slm.S",
1169 "arch-x86_64/string/ssse3-strcmp-slm.S",
1170 "arch-x86_64/string/ssse3-strncmp-slm.S",
1171 ],
1172 },
Dan Willemsen268a6732015-10-15 14:49:45 -07001173 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001174
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001175 multilib: {
1176 lib32: {
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001177 srcs: [
1178 // off64_t/time64_t support on LP32.
1179 "bionic/legacy_32_bit_support.cpp",
1180 "bionic/time64.c",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001181 ],
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001182 },
1183 },
1184
1185 local_include_dirs: ["stdio"],
1186 generated_headers: ["generated_android_ids"],
1187
1188 whole_static_libs: [
George Burgess IVc5a98e62024-11-18 14:50:32 -07001189 "//external/llvm-libc:llvmlibc",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001190 "libsystemproperties",
Manish Goregaokar361854c2025-03-05 15:02:28 -08001191 "libicu4x_bionic",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001192 ],
1193
Colin Cross50c21ab2015-10-31 23:03:05 -07001194 cppflags: ["-Wold-style-cast"],
Dan Willemsen268a6732015-10-15 14:49:45 -07001195 include_dirs: ["bionic/libstdc++/include"],
1196 name: "libc_bionic",
Dan Willemsen268a6732015-10-15 14:49:45 -07001197}
1198
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001199genrule {
1200 name: "generated_android_ids",
Colin Cross35bbed82017-01-17 18:16:07 -08001201 out: ["generated_android_ids.h"],
1202 srcs: [":android_filesystem_config_header"],
Cole Faustb1a0a9d2023-11-28 17:51:16 -08001203 tools: ["fs_config_generator"],
1204 cmd: "$(location fs_config_generator) aidarray $(in) > $(out)",
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001205}
1206
Dan Willemsen268a6732015-10-15 14:49:45 -07001207// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001208// libc_syscalls.a
1209// ========================================================
1210
Elliott Hughes782c4852019-04-16 12:31:00 -07001211genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001212 name: "syscalls-arm",
Elliott Hughes782c4852019-04-16 12:31:00 -07001213 out: ["syscalls-arm.S"],
1214 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001215 tools: ["gensyscalls"],
1216 cmd: "$(location gensyscalls) arm $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001217}
1218
1219genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001220 name: "syscalls-arm64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001221 out: ["syscalls-arm64.S"],
1222 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001223 tools: ["gensyscalls"],
1224 cmd: "$(location gensyscalls) arm64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001225}
1226
1227genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001228 name: "syscalls-riscv64",
Elliott Hughes704772b2022-10-10 17:06:43 +00001229 out: ["syscalls-riscv64.S"],
1230 srcs: ["SYSCALLS.TXT"],
1231 tools: ["gensyscalls"],
1232 cmd: "$(location gensyscalls) riscv64 $(in) > $(out)",
1233}
1234
1235genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001236 name: "syscalls-x86",
Elliott Hughes782c4852019-04-16 12:31:00 -07001237 out: ["syscalls-x86.S"],
1238 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001239 tools: ["gensyscalls"],
1240 cmd: "$(location gensyscalls) x86 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001241}
1242
1243genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001244 name: "syscalls-x86_64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001245 out: ["syscalls-x86_64.S"],
1246 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001247 tools: ["gensyscalls"],
1248 cmd: "$(location gensyscalls) x86_64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001249}
1250
Dan Willemsen208ae172015-09-16 16:33:27 -07001251cc_library_static {
Colin Cross27c43c52016-04-07 13:27:24 -07001252 defaults: ["libc_defaults"],
Josh Gao0e0e3702017-10-12 13:34:42 -07001253 srcs: ["bionic/__set_errno.cpp"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001254 arch: {
1255 arm: {
Cole Faustf5968d82023-04-11 15:20:19 -07001256 srcs: [":syscalls-arm"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001257 },
1258 arm64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001259 srcs: [":syscalls-arm64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001260 },
Elliott Hughes704772b2022-10-10 17:06:43 +00001261 riscv64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001262 srcs: [":syscalls-riscv64"],
Elliott Hughes704772b2022-10-10 17:06:43 +00001263 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001264 x86: {
Cole Faustf5968d82023-04-11 15:20:19 -07001265 srcs: [":syscalls-x86"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001266 },
1267 x86_64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001268 srcs: [":syscalls-x86_64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001269 },
1270 },
1271 name: "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001272}
1273
1274// ========================================================
1275// libc_aeabi.a
1276// This is an LP32 ARM-only library that needs to be built with -fno-builtin
1277// to avoid infinite recursion. For the other architectures we just build an
1278// empty library to keep this makefile simple.
1279// ========================================================
1280
1281cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001282 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001283 arch: {
1284 arm: {
1285 srcs: ["arch-arm/bionic/__aeabi.c"],
1286 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001287 },
1288 name: "libc_aeabi",
Colin Cross50c21ab2015-10-31 23:03:05 -07001289 cflags: ["-fno-builtin"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001290}
1291
1292// ========================================================
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001293// libc_common.a --- everything shared by libc.a and libc.so
Dan Willemsen208ae172015-09-16 16:33:27 -07001294// ========================================================
Elliott Hughesb0948922024-01-26 00:28:12 +00001295
Dan Willemsen208ae172015-09-16 16:33:27 -07001296cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001297 defaults: ["libc_defaults"],
Elliott Hughesb0948922024-01-26 00:28:12 +00001298 name: "libc_common",
1299
Dan Willemsen208ae172015-09-16 16:33:27 -07001300 whole_static_libs: [
Peter Collingbourne337a5b32020-02-21 12:11:02 -08001301 "libarm-optimized-routines-string",
Rupert Shuttleworth78f48a52021-03-16 06:39:19 +00001302 "libasync_safe",
Dan Willemsen208ae172015-09-16 16:33:27 -07001303 "libc_bionic",
Ryan Prichard249757b2019-11-01 17:18:28 -07001304 "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -07001305 "libc_dns",
George Burgess IV6cb06872017-07-21 13:28:42 -07001306 "libc_fortify",
Dan Willemsen208ae172015-09-16 16:33:27 -07001307 "libc_freebsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001308 "libc_freebsd_large_stack",
Elliott Hughesc2043342023-07-20 20:24:09 +00001309 "libc_freebsd_ldexp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001310 "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -07001311 "libc_netbsd",
1312 "libc_openbsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001313 "libc_openbsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001314 "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001315 "libc_tzcode",
Elliott Hughes816fab92016-05-27 17:57:46 -07001316 "libstdc++",
Dan Willemsen208ae172015-09-16 16:33:27 -07001317 ],
1318
1319 arch: {
1320 arm: {
1321 whole_static_libs: ["libc_aeabi"],
1322 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001323 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001324}
1325
1326// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001327// libc_static_dispatch.a/libc_dynamic_dispatch.a --- string/memory "ifuncs"
Haibo Huangf71edfa2018-11-12 10:06:56 -08001328// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001329
1330cc_defaults {
Elliott Hughes0f08d1a2025-04-24 08:26:14 -07001331 name: "libc_ifunc_defaults",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001332 defaults: ["libc_defaults"],
Haibo Huangb9244ff2018-08-11 10:12:13 -07001333 arch: {
Haibo Huangea9957a2018-11-19 11:00:32 -08001334 arm: {
Elliott Hughes0f08d1a2025-04-24 08:26:14 -07001335 srcs: ["arch-arm/ifuncs.cpp"],
Haibo Huangea9957a2018-11-19 11:00:32 -08001336 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001337 arm64: {
Elliott Hughes0f08d1a2025-04-24 08:26:14 -07001338 srcs: ["arch-arm64/ifuncs.cpp"],
1339 },
1340 x86: {
1341 srcs: ["arch-x86/ifuncs.cpp"],
1342 },
1343 x86_64: {
1344 srcs: ["arch-x86_64/ifuncs.cpp"],
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001345 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001346 },
Elliott Hughesadc41712024-08-16 13:08:11 +00001347 // Prevent the compiler from inserting calls to libc/taking the address of
1348 // a jump table from within an ifunc (or, in the static case, code that
1349 // can be executed arbitrarily early).
1350 cflags: [
1351 "-ffreestanding",
1352 "-fno-stack-protector",
1353 "-fno-jump-tables",
1354 ],
1355}
1356
1357cc_library_static {
1358 name: "libc_static_dispatch",
Elliott Hughes0f08d1a2025-04-24 08:26:14 -07001359 defaults: ["libc_ifunc_defaults"],
Elliott Hughesadc41712024-08-16 13:08:11 +00001360 cflags: [
1361 "-DBIONIC_STATIC_DISPATCH",
1362 ],
1363}
1364
1365cc_library_static {
1366 name: "libc_dynamic_dispatch",
Elliott Hughes0f08d1a2025-04-24 08:26:14 -07001367 defaults: ["libc_ifunc_defaults"],
Elliott Hughesadc41712024-08-16 13:08:11 +00001368 cflags: [
1369 "-DBIONIC_DYNAMIC_DISPATCH",
1370 ],
Ryan Prichard249757b2019-11-01 17:18:28 -07001371}
1372
1373// ========================================================
1374// libc_common_static.a For static binaries.
1375// ========================================================
1376cc_library_static {
1377 defaults: ["libc_defaults"],
1378 name: "libc_common_static",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001379
Haibo Huangf71edfa2018-11-12 10:06:56 -08001380 whole_static_libs: [
1381 "libc_common",
Ryan Prichard249757b2019-11-01 17:18:28 -07001382 "libc_static_dispatch",
1383 ],
1384}
1385
1386// ========================================================
1387// libc_common_shared.a For shared libraries.
1388// ========================================================
1389cc_library_static {
1390 defaults: ["libc_defaults"],
1391 name: "libc_common_shared",
1392
1393 whole_static_libs: [
1394 "libc_common",
1395 "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001396 ],
1397}
1398
Ryan Prichard22a6a052019-10-10 23:59:30 -07001399// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static
1400// executable.
1401cc_library_static {
1402 name: "libc_unwind_static",
1403 defaults: ["libc_defaults"],
1404 cflags: ["-DLIBC_STATIC"],
1405
1406 srcs: ["bionic/dl_iterate_phdr_static.cpp"],
1407 arch: {
1408 // arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs
1409 arm: {
1410 srcs: ["arch-arm/bionic/exidx_static.c"],
1411 },
1412 },
1413}
1414
Haibo Huangf71edfa2018-11-12 10:06:56 -08001415// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001416// libc_nomalloc.a
1417// ========================================================
1418//
Ryan Prichard249757b2019-11-01 17:18:28 -07001419// This is a version of the static C library used by the dynamic linker that exclude malloc. It also
1420// excludes functions selected using ifunc's (e.g. for string.h). Link in either
1421// libc_static_dispatch or libc_dynamic_dispatch to provide those functions.
Dan Willemsen208ae172015-09-16 16:33:27 -07001422
1423cc_library_static {
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -08001424 name: "libc_nomalloc",
Colin Cross50c21ab2015-10-31 23:03:05 -07001425 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001426
Colin Crossa3f9fca2016-01-11 13:20:55 -08001427 whole_static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -07001428 "libc_common",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001429 "libc_init_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001430 "libc_unwind_static",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001431 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001432}
1433
dimitryc0c0ef62018-12-05 16:33:52 +01001434filegroup {
1435 name: "libc_sources_shared",
1436 srcs: [
1437 "arch-common/bionic/crtbegin_so.c",
1438 "arch-common/bionic/crtbrand.S",
Christopher Ferris0ac5da02024-11-07 06:59:33 +00001439 "bionic/android_mallopt.cpp",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001440 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001441 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001442 "bionic/malloc_common.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001443 "bionic/malloc_common_dynamic.cpp",
Ryan Savitski175c8862020-01-02 19:54:57 +00001444 "bionic/android_profiling_dynamic.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001445 "bionic/malloc_heapprofd.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001446 "bionic/malloc_limit.cpp",
Peter Collingbourne570de332019-12-11 10:00:58 -08001447 "bionic/ndk_cruft.cpp",
1448 "bionic/ndk_cruft_data.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001449 "bionic/NetdClient.cpp",
1450 "arch-common/bionic/crtend_so.S",
1451 ],
1452}
1453
1454filegroup {
1455 name: "libc_sources_static",
1456 srcs: [
Christopher Ferris0ac5da02024-11-07 06:59:33 +00001457 "bionic/android_mallopt.cpp",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001458 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001459 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001460 "bionic/malloc_common.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001461 "bionic/malloc_limit.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001462 ],
1463}
1464
1465filegroup {
1466 name: "libc_sources_shared_arm",
1467 srcs: [
1468 "arch-arm/bionic/exidx_dynamic.c",
1469 "arch-arm/bionic/atexit_legacy.c",
1470 ],
1471}
1472
Dan Willemsen208ae172015-09-16 16:33:27 -07001473// ========================================================
1474// libc.a + libc.so
1475// ========================================================
Florian Mayerc10d0642023-03-22 16:12:49 -07001476cc_defaults {
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001477 defaults: [
1478 "libc_defaults",
1479 "libc_native_allocator_defaults",
Elliott Hughes788075a2024-06-18 12:25:37 +00001480 "bug_24465209_workaround",
Elliott Hughes89aada12024-07-01 21:59:04 +00001481 "keep_symbols",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001482 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001483 name: "libc_library_defaults",
Colin Cross50c21ab2015-10-31 23:03:05 -07001484 product_variables: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001485 platform_sdk_version: {
1486 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1487 },
1488 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001489 static: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001490 srcs: [":libc_sources_static"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001491 cflags: ["-DLIBC_STATIC"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001492 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001493 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001494 "libc_init_static",
1495 "libc_common_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001496 "libc_unwind_static",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001497 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001498 },
1499 shared: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001500 srcs: [":libc_sources_shared"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001501 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001502 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001503 "libc_init_dynamic",
1504 "libc_common_shared",
Ryan Prichardcdf71752020-12-16 03:37:22 -08001505 "libunwind-exported",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001506 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001507 },
1508
Neil Fullera7db90f2019-04-25 09:28:27 +01001509 required: [
MarkDacekd88d7ea2022-06-28 20:14:58 +00001510 "tzdata_prebuilt",
1511 "tz_version_prebuilt", // Version metadata for tzdata to help debugging.
Neil Fullera7db90f2019-04-25 09:28:27 +01001512 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001513
Colin Cross4ce94d22016-11-15 13:15:43 -08001514 // Do not pack libc.so relocations; see http://b/20645321 for details.
1515 pack_relocations: false,
1516
dimitry06016f22018-01-05 11:39:28 +01001517 shared_libs: [
1518 "ld-android",
1519 "libdl",
1520 ],
Jiyong Park3ff116a2019-04-02 23:04:52 +09001521 static_libs: [
1522 "libdl_android",
1523 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001524
1525 nocrt: true,
1526
Dan Willemsen208ae172015-09-16 16:33:27 -07001527 arch: {
1528 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001529 version_script: ":libc.arm.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001530 no_libcrt: true,
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001531
Dan Willemsen208ae172015-09-16 16:33:27 -07001532 shared: {
dimitryc0c0ef62018-12-05 16:33:52 +01001533 srcs: [":libc_sources_shared_arm"],
Dan Willemsen0c657082016-05-12 01:43:07 -07001534 // special for arm
1535 cflags: ["-DCRT_LEGACY_WORKAROUND"],
Elliott Hughes89aada12024-07-01 21:59:04 +00001536 // For backwards compatibility, some arm32 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001537 static_libs: ["libclang_rt.builtins-exported"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001538 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001539
Elliott Hughes89aada12024-07-01 21:59:04 +00001540 ldflags: [
1541 // Since we preserve the debug_frame for libc, do not compress
1542 // in this case to make unwinds as fast as possible.
1543 "-Wl,--compress-debug-sections=none",
1544 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001545 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001546 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001547 version_script: ":libc.arm64.map",
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001548 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001549 riscv64: {
1550 version_script: ":libc.riscv64.map",
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001551 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001552 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001553 version_script: ":libc.x86.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001554 no_libcrt: true,
1555
1556 shared: {
Elliott Hughes89aada12024-07-01 21:59:04 +00001557 // For backwards compatibility, some x86 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001558 static_libs: ["libclang_rt.builtins-exported"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001559 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001560 },
1561 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001562 version_script: ":libc.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001563 },
1564 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +09001565
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001566 apex_available: [
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001567 "com.android.runtime",
1568 ],
1569
Colin Cross7edd0082021-10-28 13:20:35 -07001570 target: {
1571 native_bridge: {
1572 shared: {
1573 installable: false,
1574 },
1575 },
1576 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001577}
1578
Florian Mayerc10d0642023-03-22 16:12:49 -07001579cc_library {
1580 name: "libc",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001581 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001582 "libc_library_defaults",
1583 ],
1584 stubs: {
1585 symbol_file: "libc.map.txt",
1586 versions: [
1587 "29",
1588 "R",
1589 "current",
1590 ],
1591 },
1592 static_ndk_lib: true,
1593 llndk: {
1594 symbol_file: "libc.map.txt",
1595 export_headers_as_system: true,
Dan Alberte9f02e02024-08-28 23:20:20 +00001596 export_llndk_headers: ["libc_headers"],
Florian Mayerc10d0642023-03-22 16:12:49 -07001597 },
Yi Kong26d0af22025-03-26 13:26:19 +09001598 afdo: true,
Florian Mayerc10d0642023-03-22 16:12:49 -07001599}
1600
1601cc_library {
1602 name: "libc_hwasan",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001603 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001604 "libc_library_defaults",
1605 ],
1606 sanitize: {
1607 hwaddress: true,
1608 },
1609 enabled: false,
Florian Mayerff116ed2023-04-14 17:38:53 -07001610 target: {
1611 android_arm64: {
Florian Mayerc10d0642023-03-22 16:12:49 -07001612 enabled: true,
1613 },
1614 },
1615 stem: "libc",
1616 relative_install_path: "hwasan",
1617 // We don't really need the stubs, but this needs to stay to trigger the
1618 // symlink logic in soong.
1619 stubs: {
1620 symbol_file: "libc.map.txt",
1621 },
1622 native_bridge_supported: false,
1623 // It is never correct to depend on this directly. This is only
Kiyoung Kim06a86dc2024-12-02 11:18:51 +09001624 // needed for the runtime apex, and in base_system.mk, and system_image_defaults
1625 // which is default module for soong-defined system image.
1626 visibility: [
1627 "//bionic/apex",
Kiyoung Kim4028fec2025-01-08 14:30:55 +09001628 "//visibility:any_system_partition",
Kiyoung Kim06a86dc2024-12-02 11:18:51 +09001629 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001630}
1631
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001632genrule {
1633 name: "libc.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001634 out: ["libc.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001635 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001636 tools: ["generate-version-script"],
1637 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001638}
1639
1640genrule {
1641 name: "libc.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001642 out: ["libc.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001643 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001644 tools: ["generate-version-script"],
1645 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001646}
1647
1648genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001649 name: "libc.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001650 out: ["libc.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001651 srcs: ["libc.map.txt"],
1652 tools: ["generate-version-script"],
1653 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1654}
1655
1656genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001657 name: "libc.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001658 out: ["libc.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001659 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001660 tools: ["generate-version-script"],
1661 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001662}
1663
1664genrule {
1665 name: "libc.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001666 out: ["libc.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001667 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001668 tools: ["generate-version-script"],
1669 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001670}
1671
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001672// Headers that only other parts of the platform can include.
1673cc_library_headers {
1674 name: "bionic_libc_platform_headers",
Martin Stjernholma2763432020-04-23 16:47:19 +01001675 defaults: ["linux_bionic_supported"],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001676 visibility: [
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001677 "//art:__subpackages__",
Josh Gao97271922019-11-06 13:15:00 -08001678 "//bionic:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001679 "//frameworks:__subpackages__",
Mitch Phillips3309b3d2020-03-25 15:05:48 -07001680 "//external/gwp_asan:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001681 "//external/perfetto:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001682 "//external/scudo:__subpackages__",
Josh Gao5074e7d2019-12-13 13:55:53 -08001683 "//system/core/debuggerd:__subpackages__",
Florian Mayerf5d70ce2022-09-13 13:58:30 -07001684 "//system/core/init:__subpackages__",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001685 "//system/core/libcutils:__subpackages__",
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001686 "//system/memory/libmemunreachable:__subpackages__",
Baligh Uddindb0c6de2020-10-15 04:49:00 +00001687 "//system/unwinding/libunwindstack:__subpackages__",
Peter Collingbourne15418002020-05-12 16:02:50 -07001688 "//tools/security/sanitizer-status:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001689 ],
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001690 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001691 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001692 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001693 vendor_ramdisk_available: true,
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001694 recovery_available: true,
1695 native_bridge_supported: true,
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001696 export_include_dirs: [
1697 "platform",
1698 ],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001699 system_shared_libs: [],
1700 stl: "none",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001701 sdk_version: "current",
Jiyong Park4ede1602020-04-28 18:21:08 +09001702
Steven Moreland0cdf1322020-10-05 21:55:26 +00001703 min_sdk_version: "29",
Jiyong Park4ede1602020-04-28 18:21:08 +09001704 apex_available: [
1705 "//apex_available:platform",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001706 "//apex_available:anyapex",
Jiyong Park4ede1602020-04-28 18:21:08 +09001707 ],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001708}
1709
Logan Chien17af91b2019-01-15 21:19:56 +08001710cc_library_headers {
Dan Albert64a6efc2024-08-29 19:04:59 +00001711 name: "libc_uapi_headers",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001712 visibility: [
1713 "//external/musl",
Alistair Delvabad22722024-10-07 12:52:40 -07001714 "//external/rust/crates/v4l2r/android",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001715 ],
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001716 llndk: {
1717 llndk_headers: true,
1718 },
Logan Chien17af91b2019-01-15 21:19:56 +08001719 host_supported: true,
1720 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001721 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001722 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001723 vendor_ramdisk_available: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001724 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001725 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001726 apex_available: [
1727 "//apex_available:platform",
Jiyong Parkad9946c2020-03-30 18:36:07 +09001728 "//apex_available:anyapex",
1729 ],
Jooyung Han15c32a82020-04-16 18:26:45 +09001730 // used by most APEXes indirectly via libunwind_llvm
1731 min_sdk_version: "apex_inherit",
Logan Chien17af91b2019-01-15 21:19:56 +08001732
1733 no_libcrt: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001734 stl: "none",
1735 system_shared_libs: [],
1736
Peter Collingbournef2b1e032019-12-10 17:41:16 -08001737 // The build system generally requires that any dependencies of a target
1738 // with an sdk_version must have a lower sdk_version. By setting sdk_version
1739 // to 1 we let targets with an sdk_version that need to depend on the libc
1740 // headers but cannot depend on libc itself due to circular dependencies
1741 // (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
1742 // is correct because the headers can support any sdk_version.
1743 sdk_version: "1",
1744
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001745 export_system_include_dirs: [
Logan Chien17af91b2019-01-15 21:19:56 +08001746 "kernel/uapi",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001747 "kernel/android/scsi",
Logan Chien17af91b2019-01-15 21:19:56 +08001748 "kernel/android/uapi",
1749 ],
1750
1751 arch: {
1752 arm: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001753 export_system_include_dirs: ["kernel/uapi/asm-arm"],
Logan Chien17af91b2019-01-15 21:19:56 +08001754 },
1755 arm64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001756 export_system_include_dirs: ["kernel/uapi/asm-arm64"],
Logan Chien17af91b2019-01-15 21:19:56 +08001757 },
Elliott Hughes48e53332022-10-07 20:39:25 +00001758 riscv64: {
1759 export_system_include_dirs: ["kernel/uapi/asm-riscv"],
1760 },
Logan Chien17af91b2019-01-15 21:19:56 +08001761 x86: {
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 x86_64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001765 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001766 },
1767 },
1768}
1769
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001770cc_library_headers {
1771 name: "libc_headers",
1772 host_supported: true,
1773 native_bridge_supported: true,
1774 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001775 product_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001776 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001777 vendor_ramdisk_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001778 recovery_available: true,
1779 sdk_version: "1",
1780
1781 apex_available: [
1782 "//apex_available:platform",
1783 "//apex_available:anyapex",
1784 ],
1785 // used by most APEXes indirectly via libunwind_llvm
1786 min_sdk_version: "apex_inherit",
1787 visibility: [
1788 "//bionic:__subpackages__", // visible to bionic
1789 // ... and only to these places (b/152668052)
1790 "//external/arm-optimized-routines",
1791 "//external/gwp_asan",
1792 "//external/jemalloc_new",
1793 "//external/libunwind_llvm",
Nick Desaulniers942ae552024-02-12 10:26:19 -08001794 "//external/llvm-libc",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001795 "//external/scudo",
1796 "//system/core/property_service/libpropertyinfoparser",
1797 "//system/extras/toolchain-extras",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001798 ],
1799
1800 stl: "none",
1801 no_libcrt: true,
1802 system_shared_libs: [],
1803
1804 target: {
1805 android: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001806 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001807 header_libs: ["libc_uapi_headers"],
1808 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001809 },
1810 linux_bionic: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001811 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001812 header_libs: ["libc_uapi_headers"],
1813 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001814 },
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001815 },
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001816}
1817
Dan Willemsen208ae172015-09-16 16:33:27 -07001818// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001819// libstdc++.so and libstdc++.a.
Dan Willemsen208ae172015-09-16 16:33:27 -07001820// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001821
Dan Willemsen208ae172015-09-16 16:33:27 -07001822cc_library {
Elliott Hughes788075a2024-06-18 12:25:37 +00001823 defaults: [
1824 "libc_defaults",
1825 "bug_24465209_workaround",
1826 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001827 include_dirs: ["bionic/libstdc++/include"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001828 srcs: [
1829 "bionic/__cxa_guard.cpp",
1830 "bionic/__cxa_pure_virtual.cpp",
1831 "bionic/new.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001832 ],
1833 name: "libstdc++",
Dan Albert40f15ec2017-10-27 11:21:20 -07001834 static_ndk_lib: true,
Isaac Chen5e7c90b2017-09-20 14:44:42 +08001835 static_libs: ["libasync_safe"],
Elliott Hughesc2043342023-07-20 20:24:09 +00001836 apex_available: [
1837 "//apex_available:platform",
1838 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001839
Dan Willemsen6b3be172018-12-03 13:57:20 -08001840 static: {
1841 system_shared_libs: [],
1842 },
Colin Crossb5bfe0b2021-07-13 16:26:28 -07001843 target: {
1844 bionic: {
1845 shared: {
1846 system_shared_libs: ["libc"],
1847 },
1848 },
Dan Willemsen6b3be172018-12-03 13:57:20 -08001849 },
1850
Dan Willemsen208ae172015-09-16 16:33:27 -07001851 arch: {
1852 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001853 version_script: ":libstdc++.arm.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001854 },
1855 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001856 version_script: ":libstdc++.arm64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001857 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001858 riscv64: {
1859 version_script: ":libstdc++.riscv64.map",
1860 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001861 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001862 version_script: ":libstdc++.x86.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001863 },
1864 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001865 version_script: ":libstdc++.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001866 },
1867 },
1868}
1869
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001870genrule {
1871 name: "libstdc++.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001872 out: ["libstdc++.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001873 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001874 tools: ["generate-version-script"],
1875 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001876}
1877
1878genrule {
1879 name: "libstdc++.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001880 out: ["libstdc++.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001881 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001882 tools: ["generate-version-script"],
1883 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001884}
1885
1886genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001887 name: "libstdc++.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001888 out: ["libstdc++.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001889 srcs: ["libstdc++.map.txt"],
1890 tools: ["generate-version-script"],
1891 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1892}
1893
1894genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001895 name: "libstdc++.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001896 out: ["libstdc++.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001897 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001898 tools: ["generate-version-script"],
1899 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001900}
1901
1902genrule {
1903 name: "libstdc++.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001904 out: ["libstdc++.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001905 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001906 tools: ["generate-version-script"],
1907 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001908}
1909
1910// ========================================================
1911// crt object files.
1912// ========================================================
1913
Colin Cross50c21ab2015-10-31 23:03:05 -07001914cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001915 name: "crt_and_memtag_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -08001916 defaults: ["linux_bionic_supported"],
Dan Willemsen230a7a42017-04-07 14:09:05 -07001917 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001918 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001919 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001920 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +09001921 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001922 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001923 apex_available: [
1924 "//apex_available:platform",
1925 "//apex_available:anyapex",
1926 ],
Dan Albertdc503f62020-07-15 17:22:18 -07001927 // Generate NDK variants of the CRT objects for every supported API level.
Elliott Hughesd5fde2d2025-03-26 18:13:39 -04001928 min_sdk_version: "21",
Dan Albertdc503f62020-07-15 17:22:18 -07001929 stl: "none",
1930 crt: true,
Elliott Hughesd50a1de2018-02-05 17:30:57 -08001931 cflags: [
1932 "-Wno-gcc-compat",
1933 "-Wall",
1934 "-Werror",
1935 ],
Peter Collingbourne7eb851c2019-09-26 12:16:06 -07001936 sanitize: {
1937 never: true,
1938 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001939}
1940
Colin Cross50c21ab2015-10-31 23:03:05 -07001941cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001942 name: "crt_defaults",
1943 defaults: ["crt_and_memtag_defaults"],
Elliott Hughes2323f5e2025-03-25 09:29:06 -07001944 header_libs: ["libc_headers"],
1945 local_include_dirs: [
1946 "bionic", // crtbegin includes bionic/libc_init_common.h
1947 "private", // crtbrand depends on private/bionic_asm_note.h
1948 ],
Colin Cross02f81372021-07-22 12:02:10 -07001949 system_shared_libs: [],
Colin Cross10d92682021-06-22 13:25:46 -07001950}
1951
1952cc_defaults {
Colin Cross50c21ab2015-10-31 23:03:05 -07001953 name: "crt_so_defaults",
Colin Cross7d7b3682017-11-03 13:38:40 -07001954 defaults: ["crt_defaults"],
Colin Crossab179442018-09-27 11:03:22 -07001955 stl: "none",
Dan Willemsen208ae172015-09-16 16:33:27 -07001956}
1957
Dan Willemsen208ae172015-09-16 16:33:27 -07001958cc_object {
1959 name: "crtbrand",
Elliott Hughes2323f5e2025-03-25 09:29:06 -07001960 defaults: ["crt_so_defaults"],
Elliott Hughes6a30b712024-03-13 23:41:32 +00001961 // crtbrand.S needs to know the platform SDK version.
Dan Willemsen208ae172015-09-16 16:33:27 -07001962 product_variables: {
1963 platform_sdk_version: {
1964 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1965 },
1966 },
1967 srcs: ["arch-common/bionic/crtbrand.S"],
Dan Alberteee46dc2023-04-04 23:27:52 +00001968 // crtbrand is an intermediate artifact, not a final CRT object.
1969 exclude_from_ndk_sysroot: true,
Dan Willemsen208ae172015-09-16 16:33:27 -07001970}
1971
Dan Willemsen208ae172015-09-16 16:33:27 -07001972cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05001973 name: "crtbegin_so",
Colin Cross7d7b3682017-11-03 13:38:40 -07001974 defaults: ["crt_so_defaults"],
Elliott Hughes2323f5e2025-03-25 09:29:06 -07001975 srcs: ["arch-common/bionic/crtbegin_so.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07001976 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07001977 "crtbrand",
1978 ],
1979}
1980
Dan Willemsen208ae172015-09-16 16:33:27 -07001981cc_object {
1982 name: "crtend_so",
Colin Cross7d7b3682017-11-03 13:38:40 -07001983 defaults: ["crt_so_defaults"],
Elliott Hughes2323f5e2025-03-25 09:29:06 -07001984 srcs: ["arch-common/bionic/crtend_so.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001985}
1986
Dan Willemsen208ae172015-09-16 16:33:27 -07001987cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05001988 name: "crtbegin_static",
Elliott Hughes2323f5e2025-03-25 09:29:06 -07001989 defaults: ["crt_defaults"],
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001990 cflags: ["-DCRTBEGIN_STATIC"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001991 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07001992 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07001993 "crtbrand",
1994 ],
Jiyong Park268a6002021-01-12 23:14:37 +09001995 // When using libc.a, we're using the latest library regardless of target API level.
1996 min_sdk_version: "current",
Dan Willemsen208ae172015-09-16 16:33:27 -07001997}
1998
Dan Willemsen208ae172015-09-16 16:33:27 -07001999cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002000 name: "crtbegin_dynamic",
Elliott Hughes2323f5e2025-03-25 09:29:06 -07002001 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002002 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002003 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002004 "crtbrand",
2005 ],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -07002006 target: {
2007 linux_bionic: {
2008 generated_sources: ["host_bionic_linker_asm"],
2009 objs: [
2010 "linker_wrapper",
2011 ],
2012 },
2013 },
Dan Willemsen208ae172015-09-16 16:33:27 -07002014}
2015
Dan Willemsen208ae172015-09-16 16:33:27 -07002016cc_object {
2017 // We rename crtend.o to crtend_android.o to avoid a
2018 // name clash between gcc and bionic.
2019 name: "crtend_android",
Colin Cross50c21ab2015-10-31 23:03:05 -07002020 defaults: ["crt_defaults"],
Elliott Hughes2323f5e2025-03-25 09:29:06 -07002021 srcs: ["arch-common/bionic/crtend.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002022}
Colin Crossbaa48992016-07-13 11:15:21 -07002023
Kalesh Singh862a23d2024-01-09 13:13:50 -08002024cc_object {
2025 name: "crt_pad_segment",
Kalesh Singh862a23d2024-01-09 13:13:50 -08002026 defaults: ["crt_defaults"],
Elliott Hughes2323f5e2025-03-25 09:29:06 -07002027 srcs: ["arch-common/bionic/crt_pad_segment.S"],
Kalesh Singh862a23d2024-01-09 13:13:50 -08002028}
2029
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002030cc_library_static {
2031 name: "note_memtag_heap_async",
Elliott Hughes2323f5e2025-03-25 09:29:06 -07002032 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002033 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002034 arm64: {
2035 srcs: ["arch-arm64/bionic/note_memtag_heap_async.S"],
2036 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002037 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002038 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002039}
2040
2041cc_library_static {
2042 name: "note_memtag_heap_sync",
Elliott Hughes2323f5e2025-03-25 09:29:06 -07002043 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002044 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002045 arm64: {
2046 srcs: ["arch-arm64/bionic/note_memtag_heap_sync.S"],
2047 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002048 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002049 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002050}
2051
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002052// ========================================================
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002053// libc dependencies for baremetal Rust projects.
2054// ========================================================
2055
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002056// This library contains the following unresolved symbols:
2057// __errno
Daniel Verkamp1c040692025-01-31 11:52:14 -08002058// __x86_shared_cache_size_half (x86_64 only)
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002059// abort
2060// async_safe_fatal_va_list
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002061cc_library_static {
2062 name: "librust_baremetal",
Pierre-Clément Tosi9018e5f2024-10-02 15:57:00 +01002063 defaults: ["cc_baremetal_defaults"],
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002064 header_libs: ["libc_headers"],
2065 include_dirs: [
2066 "bionic/libc/async_safe/include",
2067 "bionic/libc/platform",
2068 ],
2069 cflags: [
2070 "-Wall",
2071 "-Werror",
2072 ],
Ravi Kumar Soni406c98d2024-10-15 20:43:55 +05302073 asflags: [
2074 "-DBIONIC_RUST_BAREMETAL",
2075 ],
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002076 srcs: [
2077 "bionic/fortify.cpp",
Pierre-Clément Tosi816176c2022-11-30 14:33:41 +00002078 "bionic/strtol.cpp",
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002079 ],
2080 arch: {
Daniel Verkamp1c040692025-01-31 11:52:14 -08002081 arm: {
2082 enabled: false,
2083 },
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002084 arm64: {
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002085 srcs: [
2086 "arch-arm64/string/__memcpy_chk.S",
2087 ],
2088 },
Daniel Verkamp1c040692025-01-31 11:52:14 -08002089 x86: {
2090 enabled: false,
2091 },
2092 x86_64: {
Daniel Verkamp0c0f92c2025-02-11 10:39:39 -08002093 asflags: [
Ravi Kumar Soni406c98d2024-10-15 20:43:55 +05302094 // Statically choose the SSE2 variants for baremetal,
2095 // where we do not have the dynamic function dispatch
2096 // machinery.
2097 "-D__memcpy_chk_generic=__memcpy_chk",
2098 "-Dmemmove_generic=memmove",
Daniel Verkamp0c0f92c2025-02-11 10:39:39 -08002099 "-Dmemset_generic=memset",
2100 ],
Daniel Verkamp1c040692025-01-31 11:52:14 -08002101 srcs: [
2102 "arch-x86_64/string/sse2-memmove-slm.S",
2103 "arch-x86_64/string/sse2-memset-slm.S",
2104 "arch-x86_64/string/sse2-stpcpy-slm.S",
2105 "arch-x86_64/string/sse2-stpncpy-slm.S",
2106 "arch-x86_64/string/sse2-strcat-slm.S",
2107 "arch-x86_64/string/sse2-strcpy-slm.S",
2108 "arch-x86_64/string/sse2-strlen-slm.S",
2109 "arch-x86_64/string/sse2-strncat-slm.S",
2110 "arch-x86_64/string/sse2-strncpy-slm.S",
2111 "arch-x86_64/string/sse4-memcmp-slm.S",
2112 "arch-x86_64/string/ssse3-strcmp-slm.S",
2113 "arch-x86_64/string/ssse3-strncmp-slm.S",
2114 ],
2115 },
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002116 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002117 whole_static_libs: [
George Burgess IVc5a98e62024-11-18 14:50:32 -07002118 "//external/llvm-libc:llvmlibc",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002119 "libarm-optimized-routines-mem",
Pierre-Clément Tosieb46ac92023-02-01 13:44:57 +00002120 "libc_netbsd",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002121 ],
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002122 system_shared_libs: [],
2123 nocrt: true,
2124 stl: "none",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002125 visibility: [
Jiyong Park072ce532024-07-22 11:20:47 +09002126 "//packages/modules/Virtualization/libs/libvmbase",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002127 ],
Zijun427504a2024-08-15 23:16:27 +00002128
2129 // b/358211032: This library gets linked into a rust rlib. Disable LTO
2130 // until cross-language lto is supported.
2131 lto: {
2132 never: true,
2133 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002134}
2135
2136// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002137// NDK headers.
2138// ========================================================
2139
Dan Albertcce54372024-08-22 18:24:30 +00002140ndk_headers {
Dan Albert22805ea2017-03-22 15:28:05 -07002141 name: "common_libc",
2142 from: "include",
2143 to: "",
Dan Albertcce54372024-08-22 18:24:30 +00002144 srcs: ["include/**/*.h"],
Dan Albert22805ea2017-03-22 15:28:05 -07002145 license: "NOTICE",
Dan Albertcce54372024-08-22 18:24:30 +00002146 // These don't pass the bad verification we do because many of them are
2147 // arch-specific, and they aren't necessarily independently includable.
2148 // That's not much of a problem though, since C-incompaitibilities in the
2149 // UAPI headers should run into problems long before they reach us.
2150 skip_verification: true,
Dan Albert22805ea2017-03-22 15:28:05 -07002151}
Dan Albert4238a352016-06-28 11:18:05 -07002152
2153ndk_headers {
Dan Albert063e86a2016-11-29 11:09:12 -08002154 name: "libc_uapi",
2155 from: "kernel/uapi",
2156 to: "",
2157 srcs: [
2158 "kernel/uapi/asm-generic/**/*.h",
2159 "kernel/uapi/drm/**/*.h",
2160 "kernel/uapi/linux/**/*.h",
2161 "kernel/uapi/misc/**/*.h",
2162 "kernel/uapi/mtd/**/*.h",
2163 "kernel/uapi/rdma/**/*.h",
2164 "kernel/uapi/scsi/**/*.h",
2165 "kernel/uapi/sound/**/*.h",
2166 "kernel/uapi/video/**/*.h",
2167 "kernel/uapi/xen/**/*.h",
2168 ],
Dan Albert92592652016-10-20 01:42:54 -07002169 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002170 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002171}
2172
2173ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002174 name: "libc_kernel_android_uapi_linux",
Dan Albertbae16ef2016-09-14 17:15:48 -07002175 from: "kernel/android/uapi/linux",
2176 to: "linux",
2177 srcs: ["kernel/android/uapi/linux/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002178 license: "NOTICE",
Dan Albertbae16ef2016-09-14 17:15:48 -07002179}
2180
2181ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002182 name: "libc_kernel_android_scsi",
Elliott Hughes50599392017-05-25 17:13:32 -07002183 from: "kernel/android/scsi/scsi",
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002184 to: "scsi",
2185 srcs: ["kernel/android/scsi/**/*.h"],
2186 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002187 skip_verification: true,
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002188}
2189
2190ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002191 name: "libc_asm_arm",
2192 from: "kernel/uapi/asm-arm",
2193 to: "arm-linux-androideabi",
2194 srcs: ["kernel/uapi/asm-arm/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002195 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002196 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002197}
2198
2199ndk_headers {
2200 name: "libc_asm_arm64",
2201 from: "kernel/uapi/asm-arm64",
2202 to: "aarch64-linux-android",
2203 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002204 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002205 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002206}
2207
Lazar Trsic790d2f72017-11-27 11:54:11 +01002208ndk_headers {
Colin Crossbd26e0f2022-10-19 15:03:14 -07002209 name: "libc_asm_riscv64",
2210 from: "kernel/uapi/asm-riscv",
2211 to: "riscv64-linux-android",
2212 srcs: ["kernel/uapi/asm-riscv/**/*.h"],
2213 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002214 skip_verification: true,
Colin Crossbd26e0f2022-10-19 15:03:14 -07002215}
2216
2217ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002218 name: "libc_asm_x86",
2219 from: "kernel/uapi/asm-x86",
2220 to: "i686-linux-android",
2221 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002222 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002223 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002224}
2225
2226ndk_headers {
2227 name: "libc_asm_x86_64",
2228 from: "kernel/uapi/asm-x86",
2229 to: "x86_64-linux-android",
2230 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002231 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002232 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002233}
2234
Dan Albert4238a352016-06-28 11:18:05 -07002235ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002236 name: "libc",
Dan Albert4238a352016-06-28 11:18:05 -07002237 symbol_file: "libc.map.txt",
2238 first_version: "9",
2239}
2240
Dan Albertdf31aff2016-10-06 15:50:41 -07002241ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002242 name: "libstdc++",
Dan Albertdf31aff2016-10-06 15:50:41 -07002243 symbol_file: "libstdc++.map.txt",
2244 first_version: "9",
2245}
2246
Dan Willemsenca056d72018-01-08 14:00:24 -08002247// Export these headers for toolbox to process
2248filegroup {
2249 name: "kernel_input_headers",
2250 srcs: [
2251 "kernel/uapi/linux/input.h",
2252 "kernel/uapi/linux/input-event-codes.h",
2253 ],
2254}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002255
2256// Generate a syscall name / number mapping. These objects are text files
2257// (thanks to the -dD -E flags) and not binary files. They will then be
2258// consumed by the genseccomp.py script and converted into C++ code.
2259cc_defaults {
2260 name: "libseccomp_gen_syscall_nrs_defaults",
2261 recovery_available: true,
2262 srcs: ["seccomp/gen_syscall_nrs.cpp"],
2263 cflags: [
2264 "-dD",
2265 "-E",
2266 "-Wall",
2267 "-Werror",
Ryan Prichardeffe86f2024-12-18 17:07:37 -08002268 // Soong implicitly adds a -c argument that we override with -E.
2269 // Suppress Clang's error about the unused -c argument.
2270 "-Wno-unused-command-line-argument",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002271 "-nostdinc",
2272 ],
2273}
2274
2275cc_object {
2276 name: "libseccomp_gen_syscall_nrs_arm",
2277 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2278 local_include_dirs: [
2279 "kernel/uapi/asm-arm",
2280 "kernel/uapi",
2281 ],
2282}
2283
2284cc_object {
2285 name: "libseccomp_gen_syscall_nrs_arm64",
2286 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2287 local_include_dirs: [
2288 "kernel/uapi/asm-arm64",
2289 "kernel/uapi",
2290 ],
2291}
2292
2293cc_object {
Elliott Hughes704772b2022-10-10 17:06:43 +00002294 name: "libseccomp_gen_syscall_nrs_riscv64",
2295 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2296 local_include_dirs: [
2297 "kernel/uapi/asm-riscv",
2298 "kernel/uapi",
2299 ],
2300}
2301
2302cc_object {
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002303 name: "libseccomp_gen_syscall_nrs_x86",
2304 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2305 srcs: ["seccomp/gen_syscall_nrs_x86.cpp"],
2306 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2307 local_include_dirs: [
2308 "kernel/uapi/asm-x86",
2309 "kernel/uapi",
2310 ],
2311}
2312
2313cc_object {
2314 name: "libseccomp_gen_syscall_nrs_x86_64",
2315 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2316 srcs: ["seccomp/gen_syscall_nrs_x86_64.cpp"],
2317 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2318 local_include_dirs: [
2319 "kernel/uapi/asm-x86",
2320 "kernel/uapi",
2321 ],
2322}
2323
Jingwen Chenca366332021-01-29 05:16:32 -05002324filegroup {
2325 name: "all_kernel_uapi_headers",
2326 srcs: ["kernel/uapi/**/*.h"],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002327}
2328
Martijn Coenen0c6de752019-01-02 12:52:51 +01002329cc_genrule {
2330 name: "func_to_syscall_nrs",
2331 recovery_available: true,
2332 cmd: "$(location genfunctosyscallnrs) --out-dir=$(genDir) $(in)",
2333
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002334 tools: ["genfunctosyscallnrs"],
Martijn Coenen0c6de752019-01-02 12:52:51 +01002335
2336 srcs: [
2337 "SYSCALLS.TXT",
Martijn Coenen0c6de752019-01-02 12:52:51 +01002338 ],
2339
Elliott Hughes704772b2022-10-10 17:06:43 +00002340 arch: {
2341 arm: {
2342 srcs: [
2343 ":libseccomp_gen_syscall_nrs_arm",
2344 ":libseccomp_gen_syscall_nrs_arm64",
2345 ],
2346 },
2347 arm64: {
2348 srcs: [
2349 ":libseccomp_gen_syscall_nrs_arm",
2350 ":libseccomp_gen_syscall_nrs_arm64",
2351 ],
2352 },
2353 riscv64: {
2354 srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
2355 },
2356 x86: {
2357 srcs: [
2358 ":libseccomp_gen_syscall_nrs_x86",
2359 ":libseccomp_gen_syscall_nrs_x86_64",
2360 ],
2361 },
2362 x86_64: {
2363 srcs: [
2364 ":libseccomp_gen_syscall_nrs_x86",
2365 ":libseccomp_gen_syscall_nrs_x86_64",
2366 ],
2367 },
2368 },
2369
Martijn Coenen0c6de752019-01-02 12:52:51 +01002370 out: [
2371 "func_to_syscall_nrs.h",
2372 ],
2373}
2374
Victor Hsiehdbb86702020-06-15 09:29:07 -07002375// SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT = SECCOMP_BLOCKLIST_APP.txt - setresgid*
Martijn Coenenc3752be2019-01-09 16:19:57 +01002376genrule {
Victor Hsiehdbb86702020-06-15 09:29:07 -07002377 name: "generate_app_zygote_blocklist",
2378 out: ["SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT"],
2379 srcs: ["SECCOMP_BLOCKLIST_APP.TXT"],
Elliott Hughes6de2a8b2025-02-14 09:07:45 -08002380 cmd: "grep -v '^setresgid' $(in) > $(out)",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002381}
2382
Yu Liu938ec9b2022-10-17 16:36:30 -07002383filegroup {
2384 name: "seccomp_syscalls_sources_zygote",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002385 srcs: [
2386 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002387 "SECCOMP_ALLOWLIST_COMMON.TXT",
2388 "SECCOMP_ALLOWLIST_APP.TXT",
2389 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002390 "SECCOMP_PRIORITY.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002391 ":generate_app_zygote_blocklist",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002392 ],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002393}
2394
Yu Liu938ec9b2022-10-17 16:36:30 -07002395filegroup {
2396 name: "seccomp_syscalls_sources_app",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002397 srcs: [
2398 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002399 "SECCOMP_ALLOWLIST_COMMON.TXT",
2400 "SECCOMP_ALLOWLIST_APP.TXT",
2401 "SECCOMP_BLOCKLIST_COMMON.TXT",
2402 "SECCOMP_BLOCKLIST_APP.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002403 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002404 ],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002405}
2406
Yu Liu938ec9b2022-10-17 16:36:30 -07002407filegroup {
2408 name: "seccomp_syscalls_sources_system",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002409 srcs: [
2410 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002411 "SECCOMP_ALLOWLIST_COMMON.TXT",
2412 "SECCOMP_ALLOWLIST_SYSTEM.TXT",
2413 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002414 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002415 ],
Yu Liu938ec9b2022-10-17 16:36:30 -07002416}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002417
Yu Liu938ec9b2022-10-17 16:36:30 -07002418cc_genrule {
2419 name: "libseccomp_policy_app_zygote_sources_x86",
2420 recovery_available: true,
2421 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002422 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002423 srcs: [
2424 ":seccomp_syscalls_sources_zygote",
2425 ":libseccomp_gen_syscall_nrs_x86",
2426 ":libseccomp_gen_syscall_nrs_x86_64",
2427 ],
2428 out: [
2429 "x86_app_zygote_policy.cpp",
2430 "x86_64_app_zygote_policy.cpp",
2431 ],
2432 enabled: false,
Yu Liu3a579692022-10-18 03:02:32 +00002433 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002434 x86: {
2435 enabled: true,
2436 },
2437 x86_64: {
2438 enabled: true,
2439 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002440 },
2441}
2442
2443cc_genrule {
2444 name: "libseccomp_policy_app_zygote_sources_arm",
2445 recovery_available: true,
2446 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002447 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002448 srcs: [
2449 ":seccomp_syscalls_sources_zygote",
2450 ":libseccomp_gen_syscall_nrs_arm",
2451 ":libseccomp_gen_syscall_nrs_arm64",
2452 ],
2453 out: [
2454 "arm_app_zygote_policy.cpp",
2455 "arm64_app_zygote_policy.cpp",
2456 ],
2457 enabled: false,
2458 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002459 arm: {
2460 enabled: true,
2461 },
2462 arm64: {
2463 enabled: true,
2464 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002465 },
2466}
2467
2468cc_genrule {
2469 name: "libseccomp_policy_app_zygote_sources_riscv64",
2470 recovery_available: true,
2471 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002472 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002473 srcs: [
2474 ":seccomp_syscalls_sources_zygote",
2475 ":libseccomp_gen_syscall_nrs_riscv64",
2476 ],
2477 out: [
2478 "riscv64_app_zygote_policy.cpp",
2479 ],
2480 enabled: false,
2481 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002482 riscv64: {
2483 enabled: true,
2484 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002485 },
2486}
2487
2488cc_genrule {
2489 name: "libseccomp_policy_app_sources_x86",
2490 recovery_available: true,
2491 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002492 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002493 srcs: [
2494 ":seccomp_syscalls_sources_app",
2495 ":libseccomp_gen_syscall_nrs_x86",
2496 ":libseccomp_gen_syscall_nrs_x86_64",
2497 ],
2498 out: [
2499 "x86_app_policy.cpp",
2500 "x86_64_app_policy.cpp",
2501 ],
2502 enabled: false,
2503 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002504 x86: {
2505 enabled: true,
2506 },
2507 x86_64: {
2508 enabled: true,
2509 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002510 },
2511}
2512
2513cc_genrule {
2514 name: "libseccomp_policy_app_sources_arm",
2515 recovery_available: true,
2516 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002517 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002518 srcs: [
2519 ":seccomp_syscalls_sources_app",
2520 ":libseccomp_gen_syscall_nrs_arm",
2521 ":libseccomp_gen_syscall_nrs_arm64",
2522 ],
2523 out: [
2524 "arm_app_policy.cpp",
2525 "arm64_app_policy.cpp",
2526 ],
2527 enabled: false,
2528 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002529 arm: {
2530 enabled: true,
2531 },
2532 arm64: {
2533 enabled: true,
2534 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002535 },
2536}
2537
2538cc_genrule {
2539 name: "libseccomp_policy_app_sources_riscv64",
2540 recovery_available: true,
2541 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002542 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002543 srcs: [
2544 ":seccomp_syscalls_sources_app",
2545 ":libseccomp_gen_syscall_nrs_riscv64",
2546 ],
2547 out: [
2548 "riscv64_app_policy.cpp",
2549 ],
2550 enabled: false,
2551 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002552 riscv64: {
2553 enabled: true,
2554 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002555 },
2556}
2557
2558cc_genrule {
2559 name: "libseccomp_policy_system_sources_x86",
2560 recovery_available: true,
2561 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002562 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002563 srcs: [
2564 ":seccomp_syscalls_sources_system",
2565 ":libseccomp_gen_syscall_nrs_x86",
2566 ":libseccomp_gen_syscall_nrs_x86_64",
2567 ],
2568 out: [
2569 "x86_system_policy.cpp",
2570 "x86_64_system_policy.cpp",
2571 ],
2572 enabled: false,
2573 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002574 x86: {
2575 enabled: true,
2576 },
2577 x86_64: {
2578 enabled: true,
2579 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002580 },
2581}
2582
2583cc_genrule {
2584 name: "libseccomp_policy_system_sources_arm",
2585 recovery_available: true,
2586 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002587 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002588 srcs: [
2589 ":seccomp_syscalls_sources_system",
2590 ":libseccomp_gen_syscall_nrs_arm",
2591 ":libseccomp_gen_syscall_nrs_arm64",
2592 ],
2593 out: [
2594 "arm_system_policy.cpp",
2595 "arm64_system_policy.cpp",
2596 ],
2597 enabled: false,
2598 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002599 arm: {
2600 enabled: true,
2601 },
2602 arm64: {
2603 enabled: true,
2604 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002605 },
2606}
2607
2608cc_genrule {
2609 name: "libseccomp_policy_system_sources_riscv64",
2610 recovery_available: true,
2611 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002612 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002613 srcs: [
2614 ":seccomp_syscalls_sources_system",
2615 ":libseccomp_gen_syscall_nrs_riscv64",
2616 ],
2617 out: [
2618 "riscv64_system_policy.cpp",
2619 ],
2620 enabled: false,
2621 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002622 riscv64: {
2623 enabled: true,
2624 },
Yu Liu3a579692022-10-18 03:02:32 +00002625 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002626}
2627
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002628cc_library {
2629 name: "libseccomp_policy",
2630 recovery_available: true,
Martijn Coenend269d9b2018-11-08 16:41:42 +01002631 generated_headers: ["func_to_syscall_nrs"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002632
2633 arch: {
2634 arm: {
2635 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002636 "libseccomp_policy_app_sources_arm",
2637 "libseccomp_policy_app_zygote_sources_arm",
2638 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002639 ],
2640 },
2641 arm64: {
2642 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002643 "libseccomp_policy_app_sources_arm",
2644 "libseccomp_policy_app_zygote_sources_arm",
2645 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002646 ],
2647 },
2648 riscv64: {
2649 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002650 "libseccomp_policy_app_sources_riscv64",
2651 "libseccomp_policy_app_zygote_sources_riscv64",
2652 "libseccomp_policy_system_sources_riscv64",
Yu Liu938ec9b2022-10-17 16:36:30 -07002653 ],
2654 },
2655 x86: {
2656 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002657 "libseccomp_policy_app_sources_x86",
2658 "libseccomp_policy_app_zygote_sources_x86",
2659 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002660 ],
2661 },
2662 x86_64: {
2663 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002664 "libseccomp_policy_app_sources_x86",
2665 "libseccomp_policy_app_zygote_sources_x86",
2666 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002667 ],
2668 },
2669 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002670
2671 srcs: [
2672 "seccomp/seccomp_policy.cpp",
2673 ],
2674
2675 export_include_dirs: ["seccomp/include"],
2676 cflags: [
2677 "-Wall",
2678 "-Werror",
2679 ],
2680 shared: {
2681 shared_libs: ["libbase"],
2682 },
2683 static: {
2684 static_libs: ["libbase"],
2685 },
2686}
Christopher Ferrisfc26d712019-02-27 18:07:55 -08002687
Elliott Hughes241a3672025-02-18 13:52:09 -08002688// TODO: add this directly to musl like libexecinfo and libb64?
Colin Cross048f24e2021-09-01 17:26:00 -07002689cc_library_host_static {
2690 name: "libfts",
2691 srcs: [
2692 "bionic/fts.c",
2693 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
2694 ],
2695 export_include_dirs: ["fts/include"],
2696 local_include_dirs: [
2697 "private",
2698 "upstream-openbsd/android/include",
2699 ],
2700 cflags: [
Elliott Hughes241a3672025-02-18 13:52:09 -08002701 "-std=gnu99",
Colin Cross048f24e2021-09-01 17:26:00 -07002702 "-include openbsd-compat.h",
2703 "-Wno-unused-parameter",
2704 ],
2705 enabled: false,
2706 target: {
2707 musl: {
2708 enabled: true,
2709 },
2710 },
Colin Cross2a9843f2022-01-13 12:26:30 -08002711 stl: "none",
2712}
2713
2714cc_library_host_static {
2715 name: "libexecinfo",
2716 visibility: ["//external/musl"],
2717 srcs: ["bionic/execinfo.cpp"],
2718 export_include_dirs: ["execinfo/include"],
2719 local_include_dirs: ["private"],
2720 enabled: false,
2721 target: {
2722 musl: {
2723 enabled: true,
2724 system_shared_libs: [],
2725 header_libs: ["libc_musl_headers"],
2726 },
2727 },
2728 stl: "none",
Colin Cross048f24e2021-09-01 17:26:00 -07002729}
2730
Colin Cross9da85fa2022-01-24 18:20:05 -08002731cc_library_host_static {
2732 name: "libb64",
2733 visibility: ["//external/musl"],
2734 srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
2735 export_include_dirs: ["b64/include"],
2736 local_include_dirs: [
2737 "private",
2738 "upstream-openbsd/android/include",
2739 ],
2740 cflags: [
Elliott Hughes241a3672025-02-18 13:52:09 -08002741 "-std=gnu99",
Colin Cross9da85fa2022-01-24 18:20:05 -08002742 "-include openbsd-compat.h",
2743 ],
2744 enabled: false,
2745 target: {
2746 musl: {
2747 enabled: true,
2748 system_shared_libs: [],
2749 header_libs: ["libc_musl_headers"],
2750 },
2751 },
2752 stl: "none",
2753}
2754
Colin Cross9d4a56e2022-02-03 10:20:32 -08002755// Export kernel uapi headers to be used in the musl sysroot.
2756// Also include the execinfo headers for the libexecinfo and the
2757// b64 headers for libb64 embedded in musl libc.
2758cc_genrule {
2759 name: "libc_musl_sysroot_bionic_headers",
2760 visibility: ["//external/musl"],
2761 host_supported: true,
2762 device_supported: false,
2763 enabled: false,
2764 target: {
2765 musl: {
2766 enabled: true,
2767 },
2768 },
2769 srcs: [
2770 "kernel/uapi/**/*.h",
2771 "kernel/android/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002772 "execinfo/include/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002773 "b64/include/**/*.h",
Cole Faust6ffc0962025-04-30 18:29:15 -07002774 "include/*.h",
Colin Crossaeef9f02022-02-07 21:01:26 -08002775
Colin Crossaeef9f02022-02-07 21:01:26 -08002776 "NOTICE",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002777
2778 ":libc_musl_sysroot_bionic_arch_headers",
2779 ],
2780 out: ["libc_musl_sysroot_bionic_headers.zip"],
2781 tools: [
2782 "soong_zip",
2783 "merge_zips",
2784 "zip2zip",
2785 ],
Colin Crossaeef9f02022-02-07 21:01:26 -08002786 cmd: "BIONIC_LIBC_DIR=$$(dirname $(location NOTICE)) && " +
2787 "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
Colin Crossad33d022022-02-25 18:27:04 -08002788 // NOTICE
2789 " -j -f $(location NOTICE) " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002790 // headers
2791 " -P include " +
Colin Crossaeef9f02022-02-07 21:01:26 -08002792 " -C $${BIONIC_LIBC_DIR}/kernel/uapi " +
2793 " -D $${BIONIC_LIBC_DIR}/kernel/uapi " +
2794 " -C $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2795 " -D $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2796 " -C $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2797 " -D $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2798 " -C $${BIONIC_LIBC_DIR}/execinfo/include " +
2799 " -D $${BIONIC_LIBC_DIR}/execinfo/include " +
2800 " -C $${BIONIC_LIBC_DIR}/b64/include " +
2801 " -D $${BIONIC_LIBC_DIR}/b64/include " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002802 " && " +
Colin Crossad33d022022-02-25 18:27:04 -08002803 "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(genDir)/sysroot-renamed.zip " +
Colin Cross1c0a7a02022-08-11 12:22:26 -07002804 " -x **/BUILD " +
Colin Crossad33d022022-02-25 18:27:04 -08002805 " include/**/*:include/ " +
2806 " NOTICE:NOTICE.bionic " +
2807 " && " +
2808 "$(location merge_zips) $(out) $(location :libc_musl_sysroot_bionic_arch_headers) $(genDir)/sysroot-renamed.zip",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002809}
2810
2811// The architecture-specific bits have to be handled separately because the label varies based
2812// on architecture, which prevents using $(locations) to find them and requires using $(in)
2813// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
2814// genrule.
2815cc_genrule {
2816 name: "libc_musl_sysroot_bionic_arch_headers",
2817 visibility: ["//visibility:private"],
2818 host_supported: true,
2819 device_supported: false,
2820 enabled: false,
2821 target: {
2822 musl: {
2823 enabled: true,
2824 },
2825 },
2826 arch: {
2827 arm: {
2828 srcs: ["kernel/uapi/asm-arm/**/*.h"],
2829 },
2830 arm64: {
2831 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
2832 },
2833 x86: {
2834 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2835 },
2836 x86_64: {
2837 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2838 },
2839 },
2840 out: ["libc_musl_sysroot_bionic_arch_headers.zip"],
2841 tools: ["soong_zip"],
2842 cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/asm -j -D $$(dirname $${includes[0]})",
2843}
Colin Cross290c4952022-10-13 12:51:13 -07002844
2845cc_genrule {
2846 name: "bionic_sysroot_crt_objects",
2847 visibility: ["//visibility:private"],
2848 out: ["bionic_sysroot_crt_objects.zip"],
2849 tools: ["soong_zip"],
2850 srcs: [
2851 ":crtbegin_dynamic",
2852 ":crtbegin_so",
2853 ":crtbegin_static",
2854 ":crtend_android",
2855 ":crtend_so",
2856 ],
2857 cmd: "$(location soong_zip) -o $(out) -j " +
2858 "-f $(location :crtbegin_dynamic) " +
2859 "-f $(location :crtbegin_so) " +
2860 "-f $(location :crtbegin_static) " +
2861 "-f $(location :crtend_android) " +
2862 "-f $(location :crtend_so)",
2863 dist: {
2864 targets: ["bionic_sysroot_crt_objects"],
2865 },
2866 arch: {
2867 arm: {
2868 dist: {
2869 suffix: "_arm",
2870 },
2871 },
2872 arm64: {
2873 dist: {
2874 suffix: "_arm64",
2875 },
2876 },
2877 riscv64: {
2878 dist: {
2879 suffix: "_riscv64",
2880 },
2881 },
2882 x86: {
2883 dist: {
2884 suffix: "_x86",
2885 },
2886 },
2887 x86_64: {
2888 dist: {
2889 suffix: "_x86_64",
2890 },
2891 },
2892 },
2893}
Spandan Das8fce52a2023-09-28 18:00:12 +00002894
Jiyong Park35a280d2024-05-03 16:53:39 +09002895filegroup {
2896 name: "linux_capability_header",
2897 srcs: ["kernel/uapi/linux/capability.h"],
2898}