blob: d91498348fe8047f53053c56614354000d32722f [file] [log] [blame]
Bob Badouraa7d8352021-02-19 13:06:22 -08001package {
2 default_applicable_licenses: ["bionic_libc_license"],
3}
4
5license {
6 name: "bionic_libc_license",
7 visibility: [":__subpackages__"],
8 license_kinds: [
9 "SPDX-license-identifier-Apache-2.0",
10 "SPDX-license-identifier-BSD",
11 "SPDX-license-identifier-ISC",
12 "SPDX-license-identifier-MIT",
13 "legacy_notice",
14 "legacy_unencumbered",
15 ],
16 license_text: [
17 "NOTICE",
18 ],
19}
20
Elliott Hughes53cf3482016-08-09 13:06:41 -070021libc_common_flags = [
22 "-D_LIBC=1",
Elliott Hughes25f17e42018-02-12 15:48:01 -080023 "-D__BIONIC_LP32_USE_STAT64",
Elliott Hughes53cf3482016-08-09 13:06:41 -070024 "-Wall",
25 "-Wextra",
26 "-Wunused",
Elliott Hughes3048a362018-01-19 17:58:07 -080027 "-Wno-char-subscripts",
Elliott Hughes53cf3482016-08-09 13:06:41 -070028 "-Wno-deprecated-declarations",
Elliott Hughesb348d5c2017-07-24 16:53:11 -070029 "-Wno-gcc-compat",
Elliott Hughes8e547bd2016-08-16 15:57:47 -070030 "-Wframe-larger-than=2048",
Christopher Ferris1de7a482023-09-12 11:06:29 -070031 "-Wno-reorder-init-list",
Elliott Hughes53cf3482016-08-09 13:06:41 -070032
33 // Try to catch typical 32-bit assumptions that break with 64-bit pointers.
34 "-Werror=pointer-to-int-cast",
35 "-Werror=int-to-pointer-cast",
36 "-Werror=type-limits",
37 "-Werror",
Ryan Prichard8f419572018-02-20 17:09:05 -080038
39 // Clang's exit-time destructor registration hides __dso_handle, but
40 // __dso_handle needs to have default visibility on ARM32. See b/73485611.
41 "-Wexit-time-destructors",
Mitch Phillipsf3968e82020-01-31 19:57:04 -080042
Elliott Hughesa13d0662021-12-02 14:42:16 -080043 // We know clang does a lot of harm by rewriting what we've said, and sadly
44 // never see any good it does, so let's just ask it to do what we say...
45 // (The specific motivating example was clang turning a loop that would only
46 // ever touch 0, 1, or 2 bytes into a call to memset, which was never going
47 // to amortize.)
48 "-fno-builtin",
Elliott Hughes53cf3482016-08-09 13:06:41 -070049]
50
Dan Willemsen208ae172015-09-16 16:33:27 -070051// Define some common cflags
52// ========================================================
Colin Cross50c21ab2015-10-31 23:03:05 -070053cc_defaults {
54 name: "libc_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -080055 defaults: ["linux_bionic_supported"],
Christopher Ferrisb5425052024-04-23 17:15:39 -070056 cflags: libc_common_flags + [
57 "-DUSE_SCUDO",
58 ],
Elliott Hughes53cf3482016-08-09 13:06:41 -070059 asflags: libc_common_flags,
Colin Cross50c21ab2015-10-31 23:03:05 -070060 conlyflags: ["-std=gnu99"],
61 cppflags: [],
Christopher Ferris7a3681e2017-04-24 17:48:32 -070062 include_dirs: [
63 "bionic/libc/async_safe/include",
Peter Collingbourne5d3aa862020-09-11 15:05:17 -070064 "bionic/libc/platform",
Tom Cherry379ed1e2020-09-17 09:36:25 -070065 // For android_filesystem_config.h.
66 "system/core/libcutils/include",
Christopher Ferris7a3681e2017-04-24 17:48:32 -070067 ],
Colin Cross50c21ab2015-10-31 23:03:05 -070068
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010069 header_libs: [
70 "libc_headers",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +000071 "liblog_headers", // needed by bionic/libc/async_safe/include
Martin Stjernholm82d84bc2020-04-06 20:32:09 +010072 ],
73 export_header_lib_headers: [
74 "libc_headers",
75 ],
Mitch Phillipsf3968e82020-01-31 19:57:04 -080076
Colin Cross50c21ab2015-10-31 23:03:05 -070077 stl: "none",
78 system_shared_libs: [],
Colin Cross27c43c52016-04-07 13:27:24 -070079 sanitize: {
Evgenii Stepanovbe551f52018-08-13 16:46:15 -070080 address: false,
81 integer_overflow: false,
Mitch Phillipsdfde0ee2019-05-01 14:26:13 -070082 // TODO(b/132640749): Fix broken fuzzer support.
83 fuzzer: false,
Colin Cross27c43c52016-04-07 13:27:24 -070084 },
Yifan Hong5a39cee2020-01-21 16:43:56 -080085 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -070086 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +090087 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +020088 native_bridge_supported: true,
Ivan Lozanof17fd1d2018-11-27 07:56:17 -080089
Peter Collingbournee99912f2019-11-01 15:37:00 -070090 product_variables: {
Evgenii Stepanov5a73e032020-04-29 14:59:44 -070091 malloc_zero_contents: {
92 cflags: ["-DSCUDO_ZERO_CONTENTS"],
93 },
94 malloc_pattern_fill_contents: {
95 cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
96 },
Christopher Ferrisb5425052024-04-23 17:15:39 -070097 malloc_low_memory: {
98 cflags: ["-UUSE_SCUDO"],
Steven Morelandfb65ee42020-07-31 00:18:38 +000099 },
Peter Collingbournee99912f2019-11-01 15:37:00 -0700100 },
Yi Kong9e33b762021-10-29 02:43:22 +0800101
102 lto: {
103 never: true,
104 },
Elliott Hughesc2043342023-07-20 20:24:09 +0000105
106 apex_available: ["com.android.runtime"],
Elliott Hughes7d136662023-10-27 15:40:32 -0700107
108 tidy_disabled_srcs: ["upstream-*/**/*.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700109}
110
Elliott Hughes788075a2024-06-18 12:25:37 +0000111// Workaround for b/24465209.
112// We're unlikely to be able to remove this before we just
113// remove ILP32 support completely.
114// Note that we also still have `pack_relocations: false`
115// for both libc and libm, even on LP64.
116// ========================================================
117cc_defaults {
118 name: "bug_24465209_workaround",
Elliott Hughesfeb94732024-06-18 19:44:18 +0000119 target: {
120 android_arm: {
Elliott Hughes788075a2024-06-18 12:25:37 +0000121 pack_relocations: false,
122 ldflags: ["-Wl,--hash-style=both"],
123 },
Elliott Hughesfeb94732024-06-18 19:44:18 +0000124 android_x86: {
Elliott Hughes788075a2024-06-18 12:25:37 +0000125 pack_relocations: false,
126 ldflags: ["-Wl,--hash-style=both"],
Elliott Hughesb4e02782024-06-21 11:35:18 +0000127 },
Elliott Hughes788075a2024-06-18 12:25:37 +0000128 },
129}
130
Elliott Hughes89aada12024-07-01 21:59:04 +0000131// Leave the symbols in the shared library so that stack unwinders can produce
132// meaningful name resolution. This is a bit more ugly than it sounds because
133// arm32 is a bit broken.
134// ========================================================
135cc_defaults {
136 name: "keep_symbols",
137 arch: {
138 arm: {
139 // arm32 does not produce complete exidx unwind information,
140 // so keep the .debug_frame which is relatively small and does
141 // include needed unwind information.
142 // See b/132992102 for details.
143 strip: {
144 keep_symbols_and_debug_frame: true,
145 },
146 },
147 arm64: {
148 strip: {
149 keep_symbols: true,
150 },
151 },
152 riscv64: {
153 strip: {
154 keep_symbols: true,
155 },
156 },
157 x86: {
158 strip: {
159 keep_symbols: true,
160 },
161 },
162 x86_64: {
163 strip: {
164 keep_symbols: true,
165 },
166 },
167 },
168}
169
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700170// Defaults for native allocator libs/includes to make it
171// easier to change.
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700172// ========================================================
173cc_defaults {
174 name: "libc_native_allocator_defaults",
175
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700176 whole_static_libs: [
Christopher Ferrisb5425052024-04-23 17:15:39 -0700177 "libscudo",
178 ],
179 cflags: [
180 "-DUSE_SCUDO",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700181 ],
Mitch Phillipsf3968e82020-01-31 19:57:04 -0800182 header_libs: ["gwp_asan_headers"],
Christopher Ferrisb5425052024-04-23 17:15:39 -0700183 product_variables: {
184 malloc_low_memory: {
185 cflags: ["-UUSE_SCUDO"],
186 whole_static_libs: [
187 "libjemalloc5",
188 "libc_jemalloc_wrapper",
189 ],
190 exclude_static_libs: [
191 "libscudo",
192 ],
193 },
194 },
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700195}
196
197// Functions not implemented by jemalloc directly, or that need to
198// be modified for Android.
199cc_library_static {
200 name: "libc_jemalloc_wrapper",
201 defaults: ["libc_defaults"],
202 srcs: ["bionic/jemalloc_wrapper.cpp"],
203 cflags: ["-fvisibility=hidden"],
204
Christopher Ferris4df29ed2020-01-24 18:06:42 -0800205 // Used to pull in the jemalloc include directory so that if the
206 // library is removed, the include directory is also removed.
207 static_libs: ["libjemalloc5"],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -0700208}
209
Dan Willemsen208ae172015-09-16 16:33:27 -0700210// ========================================================
Ryan Prichard249757b2019-11-01 17:18:28 -0700211// libc_bootstrap.a - -fno-stack-protector and -ffreestanding
Dan Willemsen208ae172015-09-16 16:33:27 -0700212// ========================================================
213//
Ryan Prichard249757b2019-11-01 17:18:28 -0700214// Code that implements the stack protector (or that runs before TLS has been set up) needs to be
215// compiled with -fno-stack-protector, since it accesses the stack canary TLS slot. In the linker,
216// some of this code runs before ifunc resolvers have made string.h functions work, so compile with
217// -ffreestanding.
Dan Willemsen208ae172015-09-16 16:33:27 -0700218
219cc_library_static {
220
Colin Crossa3f9fca2016-01-11 13:20:55 -0800221 srcs: [
222 "bionic/__libc_init_main_thread.cpp",
223 "bionic/__stack_chk_fail.cpp",
Ryan Prichard249757b2019-11-01 17:18:28 -0700224 "bionic/bionic_call_ifunc_resolver.cpp",
225 "bionic/getauxval.cpp",
Colin Crossa3f9fca2016-01-11 13:20:55 -0800226 ],
227 arch: {
228 arm64: {
229 srcs: ["arch-arm64/bionic/__set_tls.c"],
230 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000231 riscv64: {
232 srcs: ["arch-riscv64/bionic/__set_tls.c"],
233 },
Colin Crossa3f9fca2016-01-11 13:20:55 -0800234 x86: {
Ryan Prichard27475b52018-05-17 17:14:18 -0700235 srcs: [
236 "arch-x86/bionic/__libc_init_sysinfo.cpp",
Pirama Arumuga Nainar7b89be72021-02-12 15:09:49 -0800237 "arch-x86/bionic/__libc_int0x80.S",
Ryan Prichard27475b52018-05-17 17:14:18 -0700238 "arch-x86/bionic/__set_tls.cpp",
239 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800240 },
241 x86_64: {
242 srcs: ["arch-x86_64/bionic/__set_tls.c"],
243 },
244 },
245
Colin Cross50c21ab2015-10-31 23:03:05 -0700246 defaults: ["libc_defaults"],
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000247 cflags: [
248 "-fno-stack-protector",
249 "-ffreestanding",
250 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700251 name: "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -0700252}
253
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800254filegroup {
255 name: "elf_note_sources",
256 srcs: ["bionic/elf_note.cpp"],
257}
258
Ryan Prichard249757b2019-11-01 17:18:28 -0700259// libc_init_static.cpp and libc_init_dynamic.cpp need to be built without stack protector.
260// libc_init_static.cpp sets up TLS for static executables, and libc_init_dynamic.cpp initializes
261// the stack protector global variable.
Colin Crossa3f9fca2016-01-11 13:20:55 -0800262
263cc_library_static {
264 name: "libc_init_static",
265 defaults: ["libc_defaults"],
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800266 srcs: [
Florian Mayera6e9dcf2024-11-06 12:41:22 -0800267 "bionic/libc_init_mte.cpp",
Kalesh Singhf0050fb2023-12-15 10:02:01 -0800268 "bionic/libc_init_static.cpp",
269 ":elf_note_sources",
270 ],
Ryan Prichard249757b2019-11-01 17:18:28 -0700271 cflags: [
272 "-fno-stack-protector",
273
274 // Compile libc_init_static.cpp with -ffreestanding, because some of its code is called
275 // from the linker before ifunc resolvers have made string.h functions available.
276 "-ffreestanding",
277 ],
Colin Crossa3f9fca2016-01-11 13:20:55 -0800278}
279
Stephen Cranef4b1cbd2017-05-09 14:27:43 -0700280cc_library_static {
281 name: "libc_init_dynamic",
282 defaults: ["libc_defaults"],
283 srcs: ["bionic/libc_init_dynamic.cpp"],
284 cflags: ["-fno-stack-protector"],
285}
Colin Crossa3f9fca2016-01-11 13:20:55 -0800286
Dan Willemsen208ae172015-09-16 16:33:27 -0700287// ========================================================
288// libc_tzcode.a - upstream 'tzcode' code
289// ========================================================
290
291cc_library_static {
292
Colin Cross50c21ab2015-10-31 23:03:05 -0700293 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700294 srcs: [
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800295 "tzcode/**/*.c",
Elliott Hughes0e8616a2017-04-11 14:44:51 -0700296 "tzcode/bionic.cpp",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700297 // tzcode doesn't include strptime, so we use a fork of the
298 // OpenBSD code which needs this global data.
Elliott Hughesd3627a42022-12-06 22:24:27 +0000299 "upstream-openbsd/lib/libc/locale/_def_time.c",
Elliott Hughes2bd43162023-06-15 13:17:08 -0700300 // tzcode doesn't include wcsftime, so we use the FreeBSD code.
301 "upstream-freebsd/lib/libc/locale/wcsftime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700302 ],
303
Colin Cross50c21ab2015-10-31 23:03:05 -0700304 cflags: [
Dan Willemsen268a6732015-10-15 14:49:45 -0700305 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700306 // Don't use ridiculous amounts of stack.
307 "-DALL_STATE",
308 // Include tzsetwall, timelocal, timegm, time2posix, and posix2time.
309 "-DSTD_INSPIRED",
Colin Crossa35d23d2015-11-19 13:32:49 -0800310 // Obviously, we want to be thread-safe.
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000311 "-DTHREAD_SAFE=1",
Dan Willemsen208ae172015-09-16 16:33:27 -0700312 // The name of the tm_gmtoff field in our struct tm.
313 "-DTM_GMTOFF=tm_gmtoff",
Elliott Hughes31fc69f2023-06-20 15:36:11 -0700314 // Android uses a system property instead of /etc/localtime, so make callers crash.
Almaz Mingaleeva52a0da2022-02-28 16:55:50 +0000315 "-DTZDEFAULT=NULL",
Dan Willemsen208ae172015-09-16 16:33:27 -0700316 // Where we store our tzdata.
Colin Cross7b294952016-09-29 14:08:13 -0700317 "-DTZDIR=\"/system/usr/share/zoneinfo\"",
Elliott Hughes0a610d02016-07-29 14:04:17 -0700318 // Include `tzname`, `timezone`, and `daylight` globals.
319 "-DHAVE_POSIX_DECLS=0",
Almaz Mingaleev5411aff2022-02-11 12:27:12 +0000320 "-DUSG_COMPAT=2",
321 "-DHAVE_TZNAME=2",
322 // stdbool.h is available
323 "-DHAVE_STDBOOL_H",
Colin Crossa35d23d2015-11-19 13:32:49 -0800324 // Use the empty string (instead of " ") as the timezone abbreviation
325 // fallback.
Colin Cross7b294952016-09-29 14:08:13 -0700326 "-DWILDABBR=\"\"",
Dan Willemsen208ae172015-09-16 16:33:27 -0700327 "-Dlint",
328 ],
329
Elliott Hughes2bd43162023-06-15 13:17:08 -0700330 local_include_dirs: [
331 "tzcode/",
332 "upstream-freebsd/android/include",
333 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700334 name: "libc_tzcode",
Dan Willemsen208ae172015-09-16 16:33:27 -0700335}
336
337// ========================================================
338// libc_dns.a - modified NetBSD DNS code
339// ========================================================
340
341cc_library_static {
342
Colin Cross50c21ab2015-10-31 23:03:05 -0700343 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700344 srcs: [
Elliott Hughesd0bbfa82021-04-08 11:58:51 -0700345 "dns/**/*.c*",
Dan Willemsen208ae172015-09-16 16:33:27 -0700346
347 "upstream-netbsd/lib/libc/isc/ev_streams.c",
348 "upstream-netbsd/lib/libc/isc/ev_timers.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700349 ],
350
Colin Cross50c21ab2015-10-31 23:03:05 -0700351 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700352 "-DANDROID_CHANGES",
353 "-DINET6",
Dan Willemsen208ae172015-09-16 16:33:27 -0700354 "-Wno-unused-parameter",
355 "-include netbsd-compat.h",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700356 "-Wframe-larger-than=66000",
Dan Willemsen208ae172015-09-16 16:33:27 -0700357 ],
358
Dan Willemsen208ae172015-09-16 16:33:27 -0700359 local_include_dirs: [
360 "dns/include",
361 "private",
362 "upstream-netbsd/lib/libc/include",
363 "upstream-netbsd/android/include",
364 ],
365
366 name: "libc_dns",
Dan Willemsen208ae172015-09-16 16:33:27 -0700367}
368
369// ========================================================
370// libc_freebsd.a - upstream FreeBSD C library code
371// ========================================================
372//
373// These files are built with the freebsd-compat.h header file
374// automatically included.
375
376cc_library_static {
Elliott Hughesc2043342023-07-20 20:24:09 +0000377 name: "libc_freebsd_ldexp",
378 defaults: ["libc_defaults"],
379 cflags: ["-Dscalbn=ldexp"],
380 srcs: [":libc_ldexp_srcs"],
381}
382
383cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700384 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700385 srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700386 "upstream-freebsd/lib/libc/stdlib/getopt_long.c",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700387 "upstream-freebsd/lib/libc/stdlib/hcreate.c",
388 "upstream-freebsd/lib/libc/stdlib/hcreate_r.c",
389 "upstream-freebsd/lib/libc/stdlib/hdestroy_r.c",
390 "upstream-freebsd/lib/libc/stdlib/hsearch_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700391 "upstream-freebsd/lib/libc/stdlib/qsort.c",
Elliott Hughes5bae5722024-07-30 12:47:33 -0400392 "upstream-freebsd/lib/libc/stdlib/qsort_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700393 "upstream-freebsd/lib/libc/stdlib/quick_exit.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700394 "upstream-freebsd/lib/libc/string/wcpcpy.c",
395 "upstream-freebsd/lib/libc/string/wcpncpy.c",
396 "upstream-freebsd/lib/libc/string/wcscasecmp.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700397 "upstream-freebsd/lib/libc/string/wcscat.c",
398 "upstream-freebsd/lib/libc/string/wcschr.c",
399 "upstream-freebsd/lib/libc/string/wcscmp.c",
400 "upstream-freebsd/lib/libc/string/wcscpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700401 "upstream-freebsd/lib/libc/string/wcscspn.c",
402 "upstream-freebsd/lib/libc/string/wcsdup.c",
403 "upstream-freebsd/lib/libc/string/wcslcat.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700404 "upstream-freebsd/lib/libc/string/wcslen.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700405 "upstream-freebsd/lib/libc/string/wcsncasecmp.c",
406 "upstream-freebsd/lib/libc/string/wcsncat.c",
407 "upstream-freebsd/lib/libc/string/wcsncmp.c",
408 "upstream-freebsd/lib/libc/string/wcsncpy.c",
409 "upstream-freebsd/lib/libc/string/wcsnlen.c",
410 "upstream-freebsd/lib/libc/string/wcspbrk.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700411 "upstream-freebsd/lib/libc/string/wcsrchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700412 "upstream-freebsd/lib/libc/string/wcsspn.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700413 "upstream-freebsd/lib/libc/string/wcsstr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700414 "upstream-freebsd/lib/libc/string/wcstok.c",
415 "upstream-freebsd/lib/libc/string/wmemchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700416 "upstream-freebsd/lib/libc/string/wmemcmp.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700417 "upstream-freebsd/lib/libc/string/wmemcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700418 "upstream-freebsd/lib/libc/string/wmemmove.c",
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800419 "upstream-freebsd/lib/libc/string/wmemset.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700420 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700421
Colin Cross50c21ab2015-10-31 23:03:05 -0700422 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700423 "-Wno-sign-compare",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700424 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700425 "-include freebsd-compat.h",
426 ],
427
Dan Willemsen208ae172015-09-16 16:33:27 -0700428 local_include_dirs: [
429 "upstream-freebsd/android/include",
430 ],
431
432 name: "libc_freebsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700433}
434
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700435cc_library_static {
436 defaults: ["libc_defaults"],
437 srcs: [
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700438 "upstream-freebsd/lib/libc/gen/glob.c",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700439 ],
440
441 cflags: [
442 "-Wno-sign-compare",
443 "-include freebsd-compat.h",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700444 "-Wframe-larger-than=66000",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700445 ],
446
447 local_include_dirs: [
448 "upstream-freebsd/android/include",
449 ],
450
451 name: "libc_freebsd_large_stack",
452}
453
Dan Willemsen208ae172015-09-16 16:33:27 -0700454// ========================================================
455// libc_netbsd.a - upstream NetBSD C library code
456// ========================================================
457//
458// These files are built with the netbsd-compat.h header file
459// automatically included.
460
461cc_library_static {
462
Colin Cross50c21ab2015-10-31 23:03:05 -0700463 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700464 srcs: [
465 "upstream-netbsd/common/lib/libc/stdlib/random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700466 "upstream-netbsd/lib/libc/gen/nice.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700467 "upstream-netbsd/lib/libc/gen/psignal.c",
468 "upstream-netbsd/lib/libc/gen/utime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700469 "upstream-netbsd/lib/libc/inet/nsap_addr.c",
470 "upstream-netbsd/lib/libc/regex/regcomp.c",
471 "upstream-netbsd/lib/libc/regex/regerror.c",
472 "upstream-netbsd/lib/libc/regex/regexec.c",
473 "upstream-netbsd/lib/libc/regex/regfree.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700474 "upstream-netbsd/lib/libc/stdlib/drand48.c",
475 "upstream-netbsd/lib/libc/stdlib/erand48.c",
476 "upstream-netbsd/lib/libc/stdlib/jrand48.c",
477 "upstream-netbsd/lib/libc/stdlib/lcong48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700478 "upstream-netbsd/lib/libc/stdlib/lrand48.c",
479 "upstream-netbsd/lib/libc/stdlib/mrand48.c",
480 "upstream-netbsd/lib/libc/stdlib/nrand48.c",
481 "upstream-netbsd/lib/libc/stdlib/_rand48.c",
482 "upstream-netbsd/lib/libc/stdlib/rand_r.c",
483 "upstream-netbsd/lib/libc/stdlib/reallocarr.c",
484 "upstream-netbsd/lib/libc/stdlib/seed48.c",
485 "upstream-netbsd/lib/libc/stdlib/srand48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700486 ],
487 multilib: {
488 lib32: {
489 // LP32 cruft
490 srcs: ["upstream-netbsd/common/lib/libc/hash/sha1/sha1.c"],
491 },
492 },
Colin Cross50c21ab2015-10-31 23:03:05 -0700493 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700494 "-Wno-sign-compare",
Dan Willemsen879cec22016-02-29 10:37:56 -0800495 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700496 "-DPOSIX_MISTAKE",
497 "-include netbsd-compat.h",
498 ],
499
Dan Willemsen208ae172015-09-16 16:33:27 -0700500 local_include_dirs: [
501 "upstream-netbsd/android/include",
502 "upstream-netbsd/lib/libc/include",
503 ],
504
505 name: "libc_netbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700506}
507
508// ========================================================
Elliott Hughes968adf92024-02-08 13:15:53 -0800509// libc_openbsd.a - upstream OpenBSD C library code
Dan Willemsen208ae172015-09-16 16:33:27 -0700510// ========================================================
511//
512// These files are built with the openbsd-compat.h header file
513// automatically included.
Dan Willemsen208ae172015-09-16 16:33:27 -0700514cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700515 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700516 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800517 "upstream-openbsd/lib/libc/crypt/arc4random.c",
518 "upstream-openbsd/lib/libc/crypt/arc4random_uniform.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700519 "upstream-openbsd/lib/libc/gen/alarm.c",
520 "upstream-openbsd/lib/libc/gen/ctype_.c",
521 "upstream-openbsd/lib/libc/gen/daemon.c",
522 "upstream-openbsd/lib/libc/gen/err.c",
523 "upstream-openbsd/lib/libc/gen/errx.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700524 "upstream-openbsd/lib/libc/gen/fnmatch.c",
525 "upstream-openbsd/lib/libc/gen/ftok.c",
526 "upstream-openbsd/lib/libc/gen/getprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700527 "upstream-openbsd/lib/libc/gen/setprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700528 "upstream-openbsd/lib/libc/gen/verr.c",
529 "upstream-openbsd/lib/libc/gen/verrx.c",
530 "upstream-openbsd/lib/libc/gen/vwarn.c",
531 "upstream-openbsd/lib/libc/gen/vwarnx.c",
532 "upstream-openbsd/lib/libc/gen/warn.c",
533 "upstream-openbsd/lib/libc/gen/warnx.c",
534 "upstream-openbsd/lib/libc/locale/btowc.c",
535 "upstream-openbsd/lib/libc/locale/mbrlen.c",
536 "upstream-openbsd/lib/libc/locale/mbstowcs.c",
537 "upstream-openbsd/lib/libc/locale/mbtowc.c",
538 "upstream-openbsd/lib/libc/locale/wcscoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700539 "upstream-openbsd/lib/libc/locale/wcstombs.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700540 "upstream-openbsd/lib/libc/locale/wcsxfrm.c",
541 "upstream-openbsd/lib/libc/locale/wctob.c",
542 "upstream-openbsd/lib/libc/locale/wctomb.c",
Elliott Hughes26fda772016-04-06 11:56:41 -0700543 "upstream-openbsd/lib/libc/net/base64.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700544 "upstream-openbsd/lib/libc/net/htonl.c",
545 "upstream-openbsd/lib/libc/net/htons.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700546 "upstream-openbsd/lib/libc/net/inet_lnaof.c",
547 "upstream-openbsd/lib/libc/net/inet_makeaddr.c",
548 "upstream-openbsd/lib/libc/net/inet_netof.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700549 "upstream-openbsd/lib/libc/net/inet_ntoa.c",
550 "upstream-openbsd/lib/libc/net/inet_ntop.c",
551 "upstream-openbsd/lib/libc/net/inet_pton.c",
552 "upstream-openbsd/lib/libc/net/ntohl.c",
553 "upstream-openbsd/lib/libc/net/ntohs.c",
Colin Cross8ce38af2016-01-19 12:50:20 -0800554 "upstream-openbsd/lib/libc/net/res_random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700555 "upstream-openbsd/lib/libc/stdio/fgetln.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700556 "upstream-openbsd/lib/libc/stdio/fgetwc.c",
557 "upstream-openbsd/lib/libc/stdio/fgetws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700558 "upstream-openbsd/lib/libc/stdio/flags.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700559 "upstream-openbsd/lib/libc/stdio/fputwc.c",
560 "upstream-openbsd/lib/libc/stdio/fputws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700561 "upstream-openbsd/lib/libc/stdio/fvwrite.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700562 "upstream-openbsd/lib/libc/stdio/fwide.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700563 "upstream-openbsd/lib/libc/stdio/getdelim.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700564 "upstream-openbsd/lib/libc/stdio/gets.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700565 "upstream-openbsd/lib/libc/stdio/makebuf.c",
566 "upstream-openbsd/lib/libc/stdio/mktemp.c",
567 "upstream-openbsd/lib/libc/stdio/open_memstream.c",
568 "upstream-openbsd/lib/libc/stdio/open_wmemstream.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700569 "upstream-openbsd/lib/libc/stdio/rget.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700570 "upstream-openbsd/lib/libc/stdio/setvbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700571 "upstream-openbsd/lib/libc/stdio/ungetc.c",
572 "upstream-openbsd/lib/libc/stdio/ungetwc.c",
573 "upstream-openbsd/lib/libc/stdio/vasprintf.c",
574 "upstream-openbsd/lib/libc/stdio/vdprintf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700575 "upstream-openbsd/lib/libc/stdio/vsscanf.c",
576 "upstream-openbsd/lib/libc/stdio/vswprintf.c",
577 "upstream-openbsd/lib/libc/stdio/vswscanf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700578 "upstream-openbsd/lib/libc/stdio/wbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700579 "upstream-openbsd/lib/libc/stdio/wsetup.c",
580 "upstream-openbsd/lib/libc/stdlib/abs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800581 "upstream-openbsd/lib/libc/stdlib/div.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700582 "upstream-openbsd/lib/libc/stdlib/getenv.c",
Colin Crossb8396102016-04-07 13:24:50 -0700583 "upstream-openbsd/lib/libc/stdlib/getsubopt.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700584 "upstream-openbsd/lib/libc/stdlib/insque.c",
585 "upstream-openbsd/lib/libc/stdlib/imaxabs.c",
586 "upstream-openbsd/lib/libc/stdlib/imaxdiv.c",
587 "upstream-openbsd/lib/libc/stdlib/labs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800588 "upstream-openbsd/lib/libc/stdlib/ldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700589 "upstream-openbsd/lib/libc/stdlib/llabs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800590 "upstream-openbsd/lib/libc/stdlib/lldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700591 "upstream-openbsd/lib/libc/stdlib/lsearch.c",
Elliott Hughes26b06072020-07-31 11:00:10 -0700592 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700593 "upstream-openbsd/lib/libc/stdlib/remque.c",
594 "upstream-openbsd/lib/libc/stdlib/setenv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700595 "upstream-openbsd/lib/libc/stdlib/tfind.c",
596 "upstream-openbsd/lib/libc/stdlib/tsearch.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800597 "upstream-openbsd/lib/libc/string/memccpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700598 "upstream-openbsd/lib/libc/string/strcasecmp.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800599 "upstream-openbsd/lib/libc/string/strcasestr.c",
600 "upstream-openbsd/lib/libc/string/strcoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700601 "upstream-openbsd/lib/libc/string/strcspn.c",
602 "upstream-openbsd/lib/libc/string/strdup.c",
603 "upstream-openbsd/lib/libc/string/strndup.c",
604 "upstream-openbsd/lib/libc/string/strpbrk.c",
605 "upstream-openbsd/lib/libc/string/strsep.c",
606 "upstream-openbsd/lib/libc/string/strspn.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700607 "upstream-openbsd/lib/libc/string/strtok.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800608 "upstream-openbsd/lib/libc/string/strxfrm.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700609 "upstream-openbsd/lib/libc/string/wcslcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700610 "upstream-openbsd/lib/libc/string/wcswidth.c",
Colin Cross69bcb8b2021-09-08 13:24:16 -0700611
Elliott Hughesd4c61182024-08-16 17:31:24 -0400612 // These files are originally from OpenBSD,
613 // and benefit from being compiled with openbsd-compat.h.
614 // TODO: clean them up instead.
Colin Cross69bcb8b2021-09-08 13:24:16 -0700615 "bionic/fts.c",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400616 "stdio/vfprintf.cpp",
617 "stdio/vfwprintf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700618 ],
619
Elliott Hughes7d136662023-10-27 15:40:32 -0700620 // Each architecture has optimized versions of some routines,
621 // and only includes the portable C versions of ones it's missing.
Dan Willemsen208ae172015-09-16 16:33:27 -0700622 arch: {
623 arm: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700624 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700625 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700626 "upstream-openbsd/lib/libc/string/strncat.c",
627 "upstream-openbsd/lib/libc/string/strncmp.c",
628 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700629 ],
630 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700631 arm64: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700632 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700633 "upstream-openbsd/lib/libc/string/strcat.c",
Elliott Hughesaefe9992023-11-08 12:04:41 -0800634 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700635 "upstream-openbsd/lib/libc/string/strncat.c",
636 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700637 ],
638 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000639 riscv64: {
640 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700641 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughesebc19a92022-10-14 23:25:36 +0000642 ],
643 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700644 x86: {
Elliott Hughesaefe9992023-11-08 12:04:41 -0800645 srcs: [
646 // x86 has custom implementations of all of these.
647 ],
Elliott Hughes7d136662023-10-27 15:40:32 -0700648 },
649 x86_64: {
650 srcs: [
George Burgess IV414bfb32024-11-19 09:00:39 -0700651 // x86_64 has custom/llvm-libc implementations of all of these.
Colin Cross6ab8f892015-11-23 14:12:15 -0800652 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700653 },
654 },
655
Colin Cross50c21ab2015-10-31 23:03:05 -0700656 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700657 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700658 "-Wno-unused-parameter",
659 "-include openbsd-compat.h",
660 ],
661
Dan Willemsen208ae172015-09-16 16:33:27 -0700662 local_include_dirs: [
663 "private",
Elliott Hughes968adf92024-02-08 13:15:53 -0800664 "stdio",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400665 "upstream-openbsd/android/include/",
666 "upstream-openbsd/lib/libc/gdtoa/",
667 "upstream-openbsd/lib/libc/include/",
668 "upstream-openbsd/lib/libc/stdio/",
Dan Willemsen208ae172015-09-16 16:33:27 -0700669 ],
670
671 name: "libc_openbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700672}
673
Elliott Hughes968adf92024-02-08 13:15:53 -0800674cc_library_static {
675 name: "libc_openbsd_large_stack",
676 defaults: ["libc_defaults"],
677 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800678 "upstream-openbsd/lib/libc/string/memmem.c",
679 "upstream-openbsd/lib/libc/string/strstr.c",
680 ],
681 cflags: [
682 "-include openbsd-compat.h",
683 "-Wno-sign-compare",
684 "-Wframe-larger-than=5000",
685 ],
686
687 local_include_dirs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800688 "upstream-openbsd/android/include/",
Elliott Hughes968adf92024-02-08 13:15:53 -0800689 ],
690}
691
Dan Willemsen208ae172015-09-16 16:33:27 -0700692// ========================================================
693// libc_gdtoa.a - upstream OpenBSD C library gdtoa code
694// ========================================================
695//
696// These files are built with the openbsd-compat.h header file
697// automatically included.
698
699cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700700 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700701 srcs: [
702 "upstream-openbsd/android/gdtoa_support.cpp",
703 "upstream-openbsd/lib/libc/gdtoa/dmisc.c",
704 "upstream-openbsd/lib/libc/gdtoa/dtoa.c",
705 "upstream-openbsd/lib/libc/gdtoa/gdtoa.c",
706 "upstream-openbsd/lib/libc/gdtoa/gethex.c",
707 "upstream-openbsd/lib/libc/gdtoa/gmisc.c",
708 "upstream-openbsd/lib/libc/gdtoa/hd_init.c",
709 "upstream-openbsd/lib/libc/gdtoa/hdtoa.c",
710 "upstream-openbsd/lib/libc/gdtoa/hexnan.c",
711 "upstream-openbsd/lib/libc/gdtoa/ldtoa.c",
712 "upstream-openbsd/lib/libc/gdtoa/misc.c",
713 "upstream-openbsd/lib/libc/gdtoa/smisc.c",
714 "upstream-openbsd/lib/libc/gdtoa/strtod.c",
715 "upstream-openbsd/lib/libc/gdtoa/strtodg.c",
716 "upstream-openbsd/lib/libc/gdtoa/strtof.c",
717 "upstream-openbsd/lib/libc/gdtoa/strtord.c",
718 "upstream-openbsd/lib/libc/gdtoa/sum.c",
719 "upstream-openbsd/lib/libc/gdtoa/ulp.c",
720 ],
721 multilib: {
722 lib64: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800723 srcs: ["upstream-openbsd/lib/libc/gdtoa/strtorQ.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700724 },
725 },
726
Colin Cross50c21ab2015-10-31 23:03:05 -0700727 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700728 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700729 "-include openbsd-compat.h",
730 ],
731
Dan Willemsen208ae172015-09-16 16:33:27 -0700732 local_include_dirs: [
733 "private",
734 "upstream-openbsd/android/include",
735 "upstream-openbsd/lib/libc/include",
736 ],
737
738 name: "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -0700739}
740
741// ========================================================
Pierre-Clément Tosi467e58e2023-02-01 13:44:43 +0000742// libc_fortify.a - container for our FORTIFY
George Burgess IV6cb06872017-07-21 13:28:42 -0700743// implementation details
744// ========================================================
745cc_library_static {
746 defaults: ["libc_defaults"],
George Burgess IVd34b0a92017-07-25 11:43:39 -0700747 srcs: ["bionic/fortify.cpp"],
George Burgess IV6cb06872017-07-21 13:28:42 -0700748
749 name: "libc_fortify",
750
751 // Disable FORTIFY for the compilation of these, so we don't end up having
752 // FORTIFY silently call itself.
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800753 cflags: [
754 "-U_FORTIFY_SOURCE",
755 "-D__BIONIC_DECLARE_FORTIFY_HELPERS",
756 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700757
758 arch: {
759 arm: {
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800760 cflags: [
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800761 "-DRENAME___STRCAT_CHK",
762 "-DRENAME___STRCPY_CHK",
763 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700764 srcs: [
765 "arch-arm/generic/bionic/__memcpy_chk.S",
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800766
767 "arch-arm/cortex-a15/bionic/__strcat_chk.S",
768 "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
769
770 "arch-arm/cortex-a7/bionic/__strcat_chk.S",
771 "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
772
773 "arch-arm/cortex-a9/bionic/__strcat_chk.S",
774 "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
775
776 "arch-arm/krait/bionic/__strcat_chk.S",
777 "arch-arm/krait/bionic/__strcpy_chk.S",
778
779 "arch-arm/cortex-a53/bionic/__strcat_chk.S",
780 "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
781
Haibo Huang01bfd892018-12-03 15:05:16 -0800782 "arch-arm/cortex-a55/bionic/__strcat_chk.S",
783 "arch-arm/cortex-a55/bionic/__strcpy_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700784 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700785 },
786 arm64: {
787 srcs: [
Elliott Hughes023e4e72022-11-17 19:27:02 +0000788 "arch-arm64/string/__memcpy_chk.S",
789 "arch-arm64/string/__memset_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700790 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700791 },
caowenchengab457f92023-03-06 14:57:55 +0800792 riscv64: {
793 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000794 "arch-riscv64/string/__memset_chk.S",
795 "arch-riscv64/string/__memcpy_chk.S",
caowenchengab457f92023-03-06 14:57:55 +0800796 ],
797 },
George Burgess IV6cb06872017-07-21 13:28:42 -0700798 },
799}
800
801// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -0700802// libc_bionic.a - home-grown C library code
803// ========================================================
804
805cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700806 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700807 srcs: [
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800808 "bionic/NetdClientDispatch.cpp",
809 "bionic/__bionic_get_shell_path.cpp",
810 "bionic/__cmsg_nxthdr.cpp",
811 "bionic/__cxa_thread_atexit_impl.cpp",
812 "bionic/__errno.cpp",
813 "bionic/__gnu_basename.cpp",
814 "bionic/__libc_current_sigrtmax.cpp",
815 "bionic/__libc_current_sigrtmin.cpp",
816 "bionic/abort.cpp",
817 "bionic/accept.cpp",
818 "bionic/access.cpp",
Florian Mayerca4749a2024-02-14 12:55:46 -0800819 "bionic/android_crash_detail.cpp",
Josh Gao10ec9282017-04-03 15:13:29 -0700820 "bionic/android_set_abort_message.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000821 "bionic/android_unsafe_frame_pointer_chase.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800822 "bionic/arpa_inet.cpp",
823 "bionic/assert.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000824 "bionic/atexit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800825 "bionic/atof.cpp",
826 "bionic/bionic_allocator.cpp",
827 "bionic/bionic_arc4random.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000828 "bionic/bionic_elf_tls.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800829 "bionic/bionic_futex.cpp",
830 "bionic/bionic_netlink.cpp",
831 "bionic/bionic_systrace.cpp",
832 "bionic/bionic_time_conversions.cpp",
833 "bionic/brk.cpp",
834 "bionic/c16rtomb.cpp",
835 "bionic/c32rtomb.cpp",
836 "bionic/chmod.cpp",
837 "bionic/chown.cpp",
838 "bionic/clearenv.cpp",
839 "bionic/clock.cpp",
840 "bionic/clock_getcpuclockid.cpp",
841 "bionic/clock_nanosleep.cpp",
842 "bionic/clone.cpp",
843 "bionic/ctype.cpp",
844 "bionic/dirent.cpp",
845 "bionic/dup.cpp",
846 "bionic/environ.cpp",
847 "bionic/error.cpp",
848 "bionic/eventfd.cpp",
849 "bionic/exec.cpp",
850 "bionic/execinfo.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800851 "bionic/exit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800852 "bionic/faccessat.cpp",
853 "bionic/fchmod.cpp",
854 "bionic/fchmodat.cpp",
855 "bionic/fcntl.cpp",
856 "bionic/fdsan.cpp",
857 "bionic/fdtrack.cpp",
858 "bionic/ffs.cpp",
859 "bionic/fgetxattr.cpp",
860 "bionic/flistxattr.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000861 "bionic/fork.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800862 "bionic/fpclassify.cpp",
863 "bionic/fsetxattr.cpp",
864 "bionic/ftruncate.cpp",
865 "bionic/ftw.cpp",
866 "bionic/futimens.cpp",
867 "bionic/getcwd.cpp",
868 "bionic/getdomainname.cpp",
869 "bionic/getentropy.cpp",
870 "bionic/gethostname.cpp",
871 "bionic/getloadavg.cpp",
872 "bionic/getpagesize.cpp",
873 "bionic/getpgrp.cpp",
874 "bionic/getpid.cpp",
875 "bionic/getpriority.cpp",
876 "bionic/gettid.cpp",
877 "bionic/get_device_api_level.cpp",
878 "bionic/grp_pwd.cpp",
879 "bionic/grp_pwd_file.cpp",
880 "bionic/heap_zero_init.cpp",
881 "bionic/iconv.cpp",
882 "bionic/icu_wrappers.cpp",
883 "bionic/ifaddrs.cpp",
884 "bionic/inotify_init.cpp",
885 "bionic/ioctl.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800886 "bionic/isatty.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800887 "bionic/killpg.cpp",
888 "bionic/langinfo.cpp",
Elliott Hughes219e6022024-08-27 19:12:08 +0000889 "bionic/lchmod.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800890 "bionic/lchown.cpp",
891 "bionic/lfs64_support.cpp",
892 "bionic/libc_init_common.cpp",
893 "bionic/libgen.cpp",
894 "bionic/link.cpp",
895 "bionic/locale.cpp",
896 "bionic/lockf.cpp",
897 "bionic/lstat.cpp",
898 "bionic/mblen.cpp",
899 "bionic/mbrtoc16.cpp",
900 "bionic/mbrtoc32.cpp",
901 "bionic/mempcpy.cpp",
902 "bionic/memset_explicit.cpp",
903 "bionic/mkdir.cpp",
904 "bionic/mkfifo.cpp",
905 "bionic/mknod.cpp",
906 "bionic/mntent.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800907 "bionic/netdb.cpp",
Elliott Hughes3ed6e722024-02-16 01:18:01 +0000908 "bionic/net_if.cpp",
909 "bionic/netinet_ether.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800910 "bionic/netinet_in.cpp",
911 "bionic/nl_types.cpp",
912 "bionic/open.cpp",
913 "bionic/pathconf.cpp",
914 "bionic/pause.cpp",
915 "bionic/pidfd.cpp",
916 "bionic/pipe.cpp",
917 "bionic/poll.cpp",
918 "bionic/posix_fadvise.cpp",
919 "bionic/posix_fallocate.cpp",
920 "bionic/posix_madvise.cpp",
921 "bionic/posix_timers.cpp",
922 "bionic/preadv_pwritev.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000923 "bionic/pthread_atfork.cpp",
924 "bionic/pthread_attr.cpp",
925 "bionic/pthread_barrier.cpp",
926 "bionic/pthread_cond.cpp",
927 "bionic/pthread_create.cpp",
928 "bionic/pthread_detach.cpp",
929 "bionic/pthread_equal.cpp",
930 "bionic/pthread_exit.cpp",
Elliott Hughese117d6e2024-11-14 17:31:13 +0000931 "bionic/pthread_getaffinity.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000932 "bionic/pthread_getcpuclockid.cpp",
933 "bionic/pthread_getschedparam.cpp",
934 "bionic/pthread_gettid_np.cpp",
935 "bionic/pthread_internal.cpp",
936 "bionic/pthread_join.cpp",
937 "bionic/pthread_key.cpp",
938 "bionic/pthread_kill.cpp",
939 "bionic/pthread_mutex.cpp",
940 "bionic/pthread_once.cpp",
941 "bionic/pthread_rwlock.cpp",
942 "bionic/pthread_sigqueue.cpp",
943 "bionic/pthread_self.cpp",
944 "bionic/pthread_setname_np.cpp",
Elliott Hughese117d6e2024-11-14 17:31:13 +0000945 "bionic/pthread_setaffinity.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000946 "bionic/pthread_setschedparam.cpp",
947 "bionic/pthread_spinlock.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800948 "bionic/ptrace.cpp",
949 "bionic/pty.cpp",
950 "bionic/raise.cpp",
951 "bionic/rand.cpp",
952 "bionic/readlink.cpp",
953 "bionic/realpath.cpp",
954 "bionic/reboot.cpp",
955 "bionic/recv.cpp",
956 "bionic/recvmsg.cpp",
957 "bionic/rename.cpp",
958 "bionic/rmdir.cpp",
959 "bionic/scandir.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800960 "bionic/sched_cpualloc.cpp",
961 "bionic/sched_cpucount.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800962 "bionic/sched_getaffinity.cpp",
963 "bionic/sched_getcpu.cpp",
964 "bionic/semaphore.cpp",
965 "bionic/send.cpp",
966 "bionic/setegid.cpp",
967 "bionic/seteuid.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000968 "bionic/setjmp_cookie.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800969 "bionic/setpgrp.cpp",
970 "bionic/sigaction.cpp",
971 "bionic/signal.cpp",
972 "bionic/sigprocmask.cpp",
973 "bionic/sleep.cpp",
974 "bionic/socketpair.cpp",
975 "bionic/spawn.cpp",
976 "bionic/stat.cpp",
977 "bionic/stdlib_l.cpp",
978 "bionic/strerror.cpp",
979 "bionic/string_l.cpp",
980 "bionic/strings_l.cpp",
981 "bionic/strsignal.cpp",
982 "bionic/strtol.cpp",
983 "bionic/strtold.cpp",
984 "bionic/swab.cpp",
985 "bionic/symlink.cpp",
986 "bionic/sync_file_range.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000987 "bionic/sysconf.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800988 "bionic/sys_epoll.cpp",
989 "bionic/sys_msg.cpp",
990 "bionic/sys_sem.cpp",
991 "bionic/sys_shm.cpp",
992 "bionic/sys_signalfd.cpp",
993 "bionic/sys_statfs.cpp",
994 "bionic/sys_statvfs.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000995 "bionic/sys_thread_properties.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800996 "bionic/sys_time.cpp",
997 "bionic/sysinfo.cpp",
998 "bionic/syslog.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800999 "bionic/sysprop_helpers.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001000 "bionic/system.cpp",
1001 "bionic/system_property_api.cpp",
1002 "bionic/system_property_set.cpp",
1003 "bionic/tdestroy.cpp",
1004 "bionic/termios.cpp",
1005 "bionic/thread_private.cpp",
1006 "bionic/threads.cpp",
1007 "bionic/time.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001008 "bionic/tmpfile.cpp",
1009 "bionic/umount.cpp",
1010 "bionic/unlink.cpp",
1011 "bionic/usleep.cpp",
1012 "bionic/utmp.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001013 "bionic/vdso.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001014 "bionic/wait.cpp",
1015 "bionic/wchar.cpp",
1016 "bionic/wchar_l.cpp",
1017 "bionic/wcstod.cpp",
1018 "bionic/wctype.cpp",
1019 "bionic/wcwidth.cpp",
1020 "bionic/wmempcpy.cpp",
1021
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001022 // Forked but not yet cleaned up/rewritten stdio code.
1023 // TODO: finish cleanup.
1024 "stdio/fmemopen.cpp",
1025 "stdio/parsefloat.c",
1026 "stdio/refill.c",
1027 "stdio/stdio.cpp",
1028 "stdio/stdio_ext.cpp",
1029 "stdio/vfscanf.cpp",
1030 "stdio/vfwscanf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001031 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001032
1033 arch: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001034 arm: {
Elliott Hughes1b61d782019-06-04 10:38:34 -07001035 asflags: libc_common_flags + ["-mno-restrict-it"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001036 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -08001037 "arch-arm/bionic/__aeabi_read_tp.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001038 "arch-arm/bionic/__bionic_clone.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001039 "arch-arm/bionic/__restore.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001040 "arch-arm/bionic/_exit_with_stack_teardown.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001041 "arch-arm/bionic/atomics_arm.c",
1042 "arch-arm/bionic/bpabi.c",
Yi Kong165b1cf2019-02-13 14:10:10 -08001043 "arch-arm/bionic/libcrt_compat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001044 "arch-arm/bionic/popcount_tab.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001045 "arch-arm/bionic/setjmp.S",
1046 "arch-arm/bionic/syscall.S",
1047 "arch-arm/bionic/vfork.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001048
Haibo Huangea9957a2018-11-19 11:00:32 -08001049 "arch-arm/cortex-a7/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001050 "arch-arm/cortex-a7/bionic/memset.S",
1051
1052 "arch-arm/cortex-a9/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001053 "arch-arm/cortex-a9/bionic/memset.S",
1054 "arch-arm/cortex-a9/bionic/stpcpy.S",
1055 "arch-arm/cortex-a9/bionic/strcat.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001056 "arch-arm/cortex-a9/bionic/strcpy.S",
1057 "arch-arm/cortex-a9/bionic/strlen.S",
1058
Elliott Hughesaefe9992023-11-08 12:04:41 -08001059 "arch-arm/cortex-a15/bionic/memcpy.S",
1060 "arch-arm/cortex-a15/bionic/memmove.S",
1061 "arch-arm/cortex-a15/bionic/memset.S",
1062 "arch-arm/cortex-a15/bionic/stpcpy.S",
1063 "arch-arm/cortex-a15/bionic/strcat.S",
1064 "arch-arm/cortex-a15/bionic/strcmp.S",
1065 "arch-arm/cortex-a15/bionic/strcpy.S",
1066 "arch-arm/cortex-a15/bionic/strlen.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001067
1068 "arch-arm/cortex-a53/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001069
Haibo Huang01bfd892018-12-03 15:05:16 -08001070 "arch-arm/cortex-a55/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001071
Elliott Hughesaefe9992023-11-08 12:04:41 -08001072 "arch-arm/generic/bionic/memcmp.S",
1073 "arch-arm/generic/bionic/memmove.S",
1074 "arch-arm/generic/bionic/memset.S",
1075 "arch-arm/generic/bionic/stpcpy.c",
1076 "arch-arm/generic/bionic/strcat.c",
1077 "arch-arm/generic/bionic/strcmp.S",
1078 "arch-arm/generic/bionic/strcpy.S",
1079 "arch-arm/generic/bionic/strlen.c",
1080
1081 "arch-arm/krait/bionic/memcpy.S",
1082 "arch-arm/krait/bionic/memset.S",
1083
Haibo Huangea9957a2018-11-19 11:00:32 -08001084 "arch-arm/kryo/bionic/memcpy.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001085 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001086 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001087 arm64: {
1088 srcs: [
Dan Willemsen3e621712016-02-03 21:48:08 -08001089 "arch-arm64/bionic/__bionic_clone.S",
1090 "arch-arm64/bionic/_exit_with_stack_teardown.S",
1091 "arch-arm64/bionic/setjmp.S",
1092 "arch-arm64/bionic/syscall.S",
1093 "arch-arm64/bionic/vfork.S",
Vaisakh K V83e55842024-03-29 12:47:39 +05301094 "arch-arm64/oryon/memcpy-nt.S",
Vaisakh K V54a61212024-03-29 13:32:45 +05301095 "arch-arm64/oryon/memset-nt.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001096 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001097 },
1098
Elliott Hughesebc19a92022-10-14 23:25:36 +00001099 riscv64: {
1100 srcs: [
1101 "arch-riscv64/bionic/__bionic_clone.S",
1102 "arch-riscv64/bionic/_exit_with_stack_teardown.S",
Elliott Hughese1905ed2022-10-17 23:23:36 +00001103 "arch-riscv64/bionic/setjmp.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001104 "arch-riscv64/bionic/syscall.S",
1105 "arch-riscv64/bionic/vfork.S",
Yun Hsiang40a82d02023-05-26 10:10:40 +08001106
Elliott Hughesaefe9992023-11-08 12:04:41 -08001107 "arch-riscv64/string/memchr_v.S",
1108 "arch-riscv64/string/memcmp_v.S",
1109 "arch-riscv64/string/memcpy_v.S",
1110 "arch-riscv64/string/memmove_v.S",
1111 "arch-riscv64/string/memset_v.S",
1112 "arch-riscv64/string/stpcpy_v.S",
1113 "arch-riscv64/string/strcat_v.S",
1114 "arch-riscv64/string/strchr_v.S",
1115 "arch-riscv64/string/strcmp_v.S",
1116 "arch-riscv64/string/strcpy_v.S",
1117 "arch-riscv64/string/strlen_v.S",
1118 "arch-riscv64/string/strncat_v.S",
1119 "arch-riscv64/string/strncmp_v.S",
1120 "arch-riscv64/string/strncpy_v.S",
1121 "arch-riscv64/string/strnlen_v.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001122 ],
1123 },
1124
Dan Willemsen208ae172015-09-16 16:33:27 -07001125 x86: {
1126 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001127 "arch-x86/bionic/__bionic_clone.S",
1128 "arch-x86/bionic/_exit_with_stack_teardown.S",
1129 "arch-x86/bionic/libcrt_compat.c",
Elliott Hughes7d136662023-10-27 15:40:32 -07001130 "arch-x86/bionic/setjmp.S",
1131 "arch-x86/bionic/syscall.S",
1132 "arch-x86/bionic/vfork.S",
1133 "arch-x86/bionic/__x86.get_pc_thunk.S",
1134
Elliott Hughesed777142022-07-25 16:25:11 +00001135 "arch-x86/string/sse2-memmove-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001136 "arch-x86/string/sse2-memset-slm.S",
1137 "arch-x86/string/sse2-stpcpy-slm.S",
1138 "arch-x86/string/sse2-stpncpy-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001139 "arch-x86/string/sse2-strcpy-slm.S",
1140 "arch-x86/string/sse2-strlen-slm.S",
1141 "arch-x86/string/sse2-strncpy-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001142
1143 "arch-x86/string/ssse3-memcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001144 "arch-x86/string/ssse3-strcat-atom.S",
1145 "arch-x86/string/ssse3-strcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001146 "arch-x86/string/ssse3-strncat-atom.S",
1147 "arch-x86/string/ssse3-strncmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001148
1149 "arch-x86/string/sse4-memcmp-slm.S",
Dan Willemsen268a6732015-10-15 14:49:45 -07001150 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001151 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001152 x86_64: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001153 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001154 "arch-x86_64/bionic/__bionic_clone.S",
1155 "arch-x86_64/bionic/_exit_with_stack_teardown.S",
1156 "arch-x86_64/bionic/__restore_rt.S",
1157 "arch-x86_64/bionic/setjmp.S",
1158 "arch-x86_64/bionic/syscall.S",
1159 "arch-x86_64/bionic/vfork.S",
1160
ahs919fb7f2022-06-10 07:11:14 +05301161 "arch-x86_64/string/avx2-memset-kbl.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001162 "arch-x86_64/string/sse2-memmove-slm.S",
1163 "arch-x86_64/string/sse2-memset-slm.S",
1164 "arch-x86_64/string/sse2-stpcpy-slm.S",
1165 "arch-x86_64/string/sse2-stpncpy-slm.S",
1166 "arch-x86_64/string/sse2-strcat-slm.S",
1167 "arch-x86_64/string/sse2-strcpy-slm.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001168 "arch-x86_64/string/sse2-strlen-slm.S",
1169 "arch-x86_64/string/sse2-strncat-slm.S",
1170 "arch-x86_64/string/sse2-strncpy-slm.S",
1171 "arch-x86_64/string/sse4-memcmp-slm.S",
1172 "arch-x86_64/string/ssse3-strcmp-slm.S",
1173 "arch-x86_64/string/ssse3-strncmp-slm.S",
1174 ],
1175 },
Dan Willemsen268a6732015-10-15 14:49:45 -07001176 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001177
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001178 multilib: {
1179 lib32: {
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001180 srcs: [
1181 // off64_t/time64_t support on LP32.
1182 "bionic/legacy_32_bit_support.cpp",
1183 "bionic/time64.c",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001184 ],
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001185 },
1186 },
1187
1188 local_include_dirs: ["stdio"],
1189 generated_headers: ["generated_android_ids"],
1190
1191 whole_static_libs: [
George Burgess IVc5a98e62024-11-18 14:50:32 -07001192 "//external/llvm-libc:llvmlibc",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001193 "libsystemproperties",
1194 ],
1195
Colin Cross50c21ab2015-10-31 23:03:05 -07001196 cppflags: ["-Wold-style-cast"],
Dan Willemsen268a6732015-10-15 14:49:45 -07001197 include_dirs: ["bionic/libstdc++/include"],
1198 name: "libc_bionic",
Dan Willemsen268a6732015-10-15 14:49:45 -07001199}
1200
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001201genrule {
1202 name: "generated_android_ids",
Colin Cross35bbed82017-01-17 18:16:07 -08001203 out: ["generated_android_ids.h"],
1204 srcs: [":android_filesystem_config_header"],
Cole Faustb1a0a9d2023-11-28 17:51:16 -08001205 tools: ["fs_config_generator"],
1206 cmd: "$(location fs_config_generator) aidarray $(in) > $(out)",
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001207}
1208
Dan Willemsen268a6732015-10-15 14:49:45 -07001209// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001210// libc_syscalls.a
1211// ========================================================
1212
Elliott Hughes782c4852019-04-16 12:31:00 -07001213genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001214 name: "syscalls-arm",
Elliott Hughes782c4852019-04-16 12:31:00 -07001215 out: ["syscalls-arm.S"],
1216 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001217 tools: ["gensyscalls"],
1218 cmd: "$(location gensyscalls) arm $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001219}
1220
1221genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001222 name: "syscalls-arm64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001223 out: ["syscalls-arm64.S"],
1224 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001225 tools: ["gensyscalls"],
1226 cmd: "$(location gensyscalls) arm64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001227}
1228
1229genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001230 name: "syscalls-riscv64",
Elliott Hughes704772b2022-10-10 17:06:43 +00001231 out: ["syscalls-riscv64.S"],
1232 srcs: ["SYSCALLS.TXT"],
1233 tools: ["gensyscalls"],
1234 cmd: "$(location gensyscalls) riscv64 $(in) > $(out)",
1235}
1236
1237genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001238 name: "syscalls-x86",
Elliott Hughes782c4852019-04-16 12:31:00 -07001239 out: ["syscalls-x86.S"],
1240 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001241 tools: ["gensyscalls"],
1242 cmd: "$(location gensyscalls) x86 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001243}
1244
1245genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001246 name: "syscalls-x86_64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001247 out: ["syscalls-x86_64.S"],
1248 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001249 tools: ["gensyscalls"],
1250 cmd: "$(location gensyscalls) x86_64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001251}
1252
Dan Willemsen208ae172015-09-16 16:33:27 -07001253cc_library_static {
Colin Cross27c43c52016-04-07 13:27:24 -07001254 defaults: ["libc_defaults"],
Josh Gao0e0e3702017-10-12 13:34:42 -07001255 srcs: ["bionic/__set_errno.cpp"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001256 arch: {
1257 arm: {
Cole Faustf5968d82023-04-11 15:20:19 -07001258 srcs: [":syscalls-arm"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001259 },
1260 arm64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001261 srcs: [":syscalls-arm64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001262 },
Elliott Hughes704772b2022-10-10 17:06:43 +00001263 riscv64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001264 srcs: [":syscalls-riscv64"],
Elliott Hughes704772b2022-10-10 17:06:43 +00001265 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001266 x86: {
Cole Faustf5968d82023-04-11 15:20:19 -07001267 srcs: [":syscalls-x86"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001268 },
1269 x86_64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001270 srcs: [":syscalls-x86_64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001271 },
1272 },
1273 name: "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001274}
1275
1276// ========================================================
1277// libc_aeabi.a
1278// This is an LP32 ARM-only library that needs to be built with -fno-builtin
1279// to avoid infinite recursion. For the other architectures we just build an
1280// empty library to keep this makefile simple.
1281// ========================================================
1282
1283cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001284 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001285 arch: {
1286 arm: {
1287 srcs: ["arch-arm/bionic/__aeabi.c"],
1288 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001289 },
1290 name: "libc_aeabi",
Colin Cross50c21ab2015-10-31 23:03:05 -07001291 cflags: ["-fno-builtin"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001292}
1293
1294// ========================================================
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001295// libc_common.a --- everything shared by libc.a and libc.so
Dan Willemsen208ae172015-09-16 16:33:27 -07001296// ========================================================
Elliott Hughesb0948922024-01-26 00:28:12 +00001297
Dan Willemsen208ae172015-09-16 16:33:27 -07001298cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001299 defaults: ["libc_defaults"],
Elliott Hughesb0948922024-01-26 00:28:12 +00001300 name: "libc_common",
1301
Dan Willemsen208ae172015-09-16 16:33:27 -07001302 whole_static_libs: [
Peter Collingbourne337a5b32020-02-21 12:11:02 -08001303 "libarm-optimized-routines-string",
Rupert Shuttleworth78f48a52021-03-16 06:39:19 +00001304 "libasync_safe",
Dan Willemsen208ae172015-09-16 16:33:27 -07001305 "libc_bionic",
Ryan Prichard249757b2019-11-01 17:18:28 -07001306 "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -07001307 "libc_dns",
George Burgess IV6cb06872017-07-21 13:28:42 -07001308 "libc_fortify",
Dan Willemsen208ae172015-09-16 16:33:27 -07001309 "libc_freebsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001310 "libc_freebsd_large_stack",
Elliott Hughesc2043342023-07-20 20:24:09 +00001311 "libc_freebsd_ldexp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001312 "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -07001313 "libc_netbsd",
1314 "libc_openbsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001315 "libc_openbsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001316 "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001317 "libc_tzcode",
Elliott Hughes816fab92016-05-27 17:57:46 -07001318 "libstdc++",
Dan Willemsen208ae172015-09-16 16:33:27 -07001319 ],
1320
1321 arch: {
1322 arm: {
1323 whole_static_libs: ["libc_aeabi"],
1324 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001325 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001326}
1327
1328// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001329// libc_static_dispatch.a/libc_dynamic_dispatch.a --- string/memory "ifuncs"
1330// (Actually ifuncs for libc.so, but a home-grown alternative for libc.a.)
Haibo Huangf71edfa2018-11-12 10:06:56 -08001331// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001332
1333cc_defaults {
1334 name: "libc_dispatch_defaults",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001335 defaults: ["libc_defaults"],
Haibo Huangb9244ff2018-08-11 10:12:13 -07001336 arch: {
ahs919fb7f2022-06-10 07:11:14 +05301337 x86_64: {
1338 srcs: ["arch-x86_64/dynamic_function_dispatch.cpp"],
1339 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001340 x86: {
1341 srcs: ["arch-x86/dynamic_function_dispatch.cpp"],
1342 },
Haibo Huangea9957a2018-11-19 11:00:32 -08001343 arm: {
Elliott Hughes927fe992019-01-31 22:29:22 +00001344 srcs: ["arch-arm/dynamic_function_dispatch.cpp"],
Haibo Huangea9957a2018-11-19 11:00:32 -08001345 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001346 arm64: {
1347 srcs: ["arch-arm64/dynamic_function_dispatch.cpp"],
1348 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001349 },
Elliott Hughesadc41712024-08-16 13:08:11 +00001350 // Prevent the compiler from inserting calls to libc/taking the address of
1351 // a jump table from within an ifunc (or, in the static case, code that
1352 // can be executed arbitrarily early).
1353 cflags: [
1354 "-ffreestanding",
1355 "-fno-stack-protector",
1356 "-fno-jump-tables",
1357 ],
1358}
1359
1360cc_library_static {
1361 name: "libc_static_dispatch",
1362 defaults: ["libc_dispatch_defaults"],
1363 cflags: [
1364 "-DBIONIC_STATIC_DISPATCH",
1365 ],
1366}
1367
1368cc_library_static {
1369 name: "libc_dynamic_dispatch",
1370 defaults: ["libc_dispatch_defaults"],
1371 cflags: [
1372 "-DBIONIC_DYNAMIC_DISPATCH",
1373 ],
Ryan Prichard249757b2019-11-01 17:18:28 -07001374}
1375
1376// ========================================================
1377// libc_common_static.a For static binaries.
1378// ========================================================
1379cc_library_static {
1380 defaults: ["libc_defaults"],
1381 name: "libc_common_static",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001382
Haibo Huangf71edfa2018-11-12 10:06:56 -08001383 whole_static_libs: [
1384 "libc_common",
Ryan Prichard249757b2019-11-01 17:18:28 -07001385 "libc_static_dispatch",
1386 ],
1387}
1388
1389// ========================================================
1390// libc_common_shared.a For shared libraries.
1391// ========================================================
1392cc_library_static {
1393 defaults: ["libc_defaults"],
1394 name: "libc_common_shared",
1395
1396 whole_static_libs: [
1397 "libc_common",
1398 "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001399 ],
1400}
1401
Ryan Prichard22a6a052019-10-10 23:59:30 -07001402// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static
1403// executable.
1404cc_library_static {
1405 name: "libc_unwind_static",
1406 defaults: ["libc_defaults"],
1407 cflags: ["-DLIBC_STATIC"],
1408
1409 srcs: ["bionic/dl_iterate_phdr_static.cpp"],
1410 arch: {
1411 // arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs
1412 arm: {
1413 srcs: ["arch-arm/bionic/exidx_static.c"],
1414 },
1415 },
1416}
1417
Haibo Huangf71edfa2018-11-12 10:06:56 -08001418// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001419// libc_nomalloc.a
1420// ========================================================
1421//
Ryan Prichard249757b2019-11-01 17:18:28 -07001422// This is a version of the static C library used by the dynamic linker that exclude malloc. It also
1423// excludes functions selected using ifunc's (e.g. for string.h). Link in either
1424// libc_static_dispatch or libc_dynamic_dispatch to provide those functions.
Dan Willemsen208ae172015-09-16 16:33:27 -07001425
1426cc_library_static {
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -08001427 name: "libc_nomalloc",
Colin Cross50c21ab2015-10-31 23:03:05 -07001428 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001429
Colin Crossa3f9fca2016-01-11 13:20:55 -08001430 whole_static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -07001431 "libc_common",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001432 "libc_init_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001433 "libc_unwind_static",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001434 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001435}
1436
dimitryc0c0ef62018-12-05 16:33:52 +01001437filegroup {
1438 name: "libc_sources_shared",
1439 srcs: [
1440 "arch-common/bionic/crtbegin_so.c",
1441 "arch-common/bionic/crtbrand.S",
Christopher Ferris0ac5da02024-11-07 06:59:33 +00001442 "bionic/android_mallopt.cpp",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001443 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001444 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001445 "bionic/icu.cpp",
1446 "bionic/malloc_common.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001447 "bionic/malloc_common_dynamic.cpp",
Ryan Savitski175c8862020-01-02 19:54:57 +00001448 "bionic/android_profiling_dynamic.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001449 "bionic/malloc_heapprofd.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001450 "bionic/malloc_limit.cpp",
Peter Collingbourne570de332019-12-11 10:00:58 -08001451 "bionic/ndk_cruft.cpp",
1452 "bionic/ndk_cruft_data.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001453 "bionic/NetdClient.cpp",
1454 "arch-common/bionic/crtend_so.S",
1455 ],
1456}
1457
1458filegroup {
1459 name: "libc_sources_static",
1460 srcs: [
Christopher Ferris0ac5da02024-11-07 06:59:33 +00001461 "bionic/android_mallopt.cpp",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001462 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001463 "bionic/heap_tagging.cpp",
Elliott Hughes72b0f3b2024-07-02 20:22:35 +00001464 "bionic/icu_static.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001465 "bionic/malloc_common.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001466 "bionic/malloc_limit.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001467 ],
1468}
1469
1470filegroup {
1471 name: "libc_sources_shared_arm",
1472 srcs: [
1473 "arch-arm/bionic/exidx_dynamic.c",
1474 "arch-arm/bionic/atexit_legacy.c",
1475 ],
1476}
1477
Dan Willemsen208ae172015-09-16 16:33:27 -07001478// ========================================================
1479// libc.a + libc.so
1480// ========================================================
Florian Mayerc10d0642023-03-22 16:12:49 -07001481cc_defaults {
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001482 defaults: [
1483 "libc_defaults",
1484 "libc_native_allocator_defaults",
Elliott Hughes788075a2024-06-18 12:25:37 +00001485 "bug_24465209_workaround",
Elliott Hughes89aada12024-07-01 21:59:04 +00001486 "keep_symbols",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001487 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001488 name: "libc_library_defaults",
Colin Cross50c21ab2015-10-31 23:03:05 -07001489 product_variables: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001490 platform_sdk_version: {
1491 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1492 },
1493 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001494 static: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001495 srcs: [":libc_sources_static"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001496 cflags: ["-DLIBC_STATIC"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001497 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001498 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001499 "libc_init_static",
1500 "libc_common_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001501 "libc_unwind_static",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001502 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001503 },
1504 shared: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001505 srcs: [":libc_sources_shared"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001506 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001507 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001508 "libc_init_dynamic",
1509 "libc_common_shared",
Ryan Prichardcdf71752020-12-16 03:37:22 -08001510 "libunwind-exported",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001511 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001512 },
1513
Neil Fullera7db90f2019-04-25 09:28:27 +01001514 required: [
MarkDacekd88d7ea2022-06-28 20:14:58 +00001515 "tzdata_prebuilt",
1516 "tz_version_prebuilt", // Version metadata for tzdata to help debugging.
Neil Fullera7db90f2019-04-25 09:28:27 +01001517 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001518
Colin Cross4ce94d22016-11-15 13:15:43 -08001519 // Do not pack libc.so relocations; see http://b/20645321 for details.
1520 pack_relocations: false,
1521
dimitry06016f22018-01-05 11:39:28 +01001522 shared_libs: [
1523 "ld-android",
1524 "libdl",
1525 ],
Jiyong Park3ff116a2019-04-02 23:04:52 +09001526 static_libs: [
1527 "libdl_android",
1528 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001529
1530 nocrt: true,
1531
Dan Willemsen208ae172015-09-16 16:33:27 -07001532 arch: {
1533 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001534 version_script: ":libc.arm.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001535 no_libcrt: true,
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001536
Dan Willemsen208ae172015-09-16 16:33:27 -07001537 shared: {
dimitryc0c0ef62018-12-05 16:33:52 +01001538 srcs: [":libc_sources_shared_arm"],
Dan Willemsen0c657082016-05-12 01:43:07 -07001539 // special for arm
1540 cflags: ["-DCRT_LEGACY_WORKAROUND"],
Elliott Hughes89aada12024-07-01 21:59:04 +00001541 // For backwards compatibility, some arm32 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001542 static_libs: ["libclang_rt.builtins-exported"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001543 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001544
Elliott Hughes89aada12024-07-01 21:59:04 +00001545 ldflags: [
1546 // Since we preserve the debug_frame for libc, do not compress
1547 // in this case to make unwinds as fast as possible.
1548 "-Wl,--compress-debug-sections=none",
1549 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001550 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001551 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001552 version_script: ":libc.arm64.map",
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001553 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001554 riscv64: {
1555 version_script: ":libc.riscv64.map",
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001556 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001557 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001558 version_script: ":libc.x86.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001559 no_libcrt: true,
1560
1561 shared: {
Elliott Hughes89aada12024-07-01 21:59:04 +00001562 // For backwards compatibility, some x86 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001563 static_libs: ["libclang_rt.builtins-exported"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001564 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001565 },
1566 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001567 version_script: ":libc.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001568 },
1569 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +09001570
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001571 apex_available: [
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001572 "com.android.runtime",
1573 ],
1574
Colin Cross7edd0082021-10-28 13:20:35 -07001575 target: {
1576 native_bridge: {
1577 shared: {
1578 installable: false,
1579 },
1580 },
1581 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001582}
1583
Florian Mayerc10d0642023-03-22 16:12:49 -07001584cc_library {
1585 name: "libc",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001586 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001587 "libc_library_defaults",
1588 ],
1589 stubs: {
1590 symbol_file: "libc.map.txt",
1591 versions: [
1592 "29",
1593 "R",
1594 "current",
1595 ],
1596 },
1597 static_ndk_lib: true,
1598 llndk: {
1599 symbol_file: "libc.map.txt",
1600 export_headers_as_system: true,
Dan Alberte9f02e02024-08-28 23:20:20 +00001601 export_llndk_headers: ["libc_headers"],
Florian Mayerc10d0642023-03-22 16:12:49 -07001602 },
1603}
1604
1605cc_library {
1606 name: "libc_hwasan",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001607 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001608 "libc_library_defaults",
1609 ],
1610 sanitize: {
1611 hwaddress: true,
1612 },
1613 enabled: false,
Florian Mayerff116ed2023-04-14 17:38:53 -07001614 target: {
1615 android_arm64: {
Florian Mayerc10d0642023-03-22 16:12:49 -07001616 enabled: true,
1617 },
1618 },
1619 stem: "libc",
1620 relative_install_path: "hwasan",
1621 // We don't really need the stubs, but this needs to stay to trigger the
1622 // symlink logic in soong.
1623 stubs: {
1624 symbol_file: "libc.map.txt",
1625 },
1626 native_bridge_supported: false,
1627 // It is never correct to depend on this directly. This is only
Kiyoung Kim06a86dc2024-12-02 11:18:51 +09001628 // needed for the runtime apex, and in base_system.mk, and system_image_defaults
1629 // which is default module for soong-defined system image.
1630 visibility: [
1631 "//bionic/apex",
1632 "//build/make/target/product/generic",
1633 //TODO(b/381985636) : Remove visibility to Soong-defined GSI once resolved
1634 "//build/make/target/product/gsi",
1635 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001636}
1637
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001638genrule {
1639 name: "libc.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001640 out: ["libc.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001641 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001642 tools: ["generate-version-script"],
1643 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001644}
1645
1646genrule {
1647 name: "libc.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001648 out: ["libc.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001649 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001650 tools: ["generate-version-script"],
1651 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001652}
1653
1654genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001655 name: "libc.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001656 out: ["libc.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001657 srcs: ["libc.map.txt"],
1658 tools: ["generate-version-script"],
1659 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1660}
1661
1662genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001663 name: "libc.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001664 out: ["libc.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001665 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001666 tools: ["generate-version-script"],
1667 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001668}
1669
1670genrule {
1671 name: "libc.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001672 out: ["libc.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001673 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001674 tools: ["generate-version-script"],
1675 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001676}
1677
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001678// Headers that only other parts of the platform can include.
1679cc_library_headers {
1680 name: "bionic_libc_platform_headers",
Martin Stjernholma2763432020-04-23 16:47:19 +01001681 defaults: ["linux_bionic_supported"],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001682 visibility: [
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001683 "//art:__subpackages__",
Josh Gao97271922019-11-06 13:15:00 -08001684 "//bionic:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001685 "//frameworks:__subpackages__",
Roman Kiryanov067f5182020-05-07 14:58:30 -07001686 "//device/generic/goldfish-opengl:__subpackages__",
Mitch Phillips3309b3d2020-03-25 15:05:48 -07001687 "//external/gwp_asan:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001688 "//external/perfetto:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001689 "//external/scudo:__subpackages__",
Josh Gao5074e7d2019-12-13 13:55:53 -08001690 "//system/core/debuggerd:__subpackages__",
Florian Mayerf5d70ce2022-09-13 13:58:30 -07001691 "//system/core/init:__subpackages__",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001692 "//system/core/libcutils:__subpackages__",
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001693 "//system/memory/libmemunreachable:__subpackages__",
Baligh Uddindb0c6de2020-10-15 04:49:00 +00001694 "//system/unwinding/libunwindstack:__subpackages__",
Peter Collingbourne15418002020-05-12 16:02:50 -07001695 "//tools/security/sanitizer-status:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001696 ],
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001697 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001698 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001699 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001700 vendor_ramdisk_available: true,
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001701 recovery_available: true,
1702 native_bridge_supported: true,
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001703 export_include_dirs: [
1704 "platform",
1705 ],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001706 system_shared_libs: [],
1707 stl: "none",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001708 sdk_version: "current",
Jiyong Park4ede1602020-04-28 18:21:08 +09001709
Steven Moreland0cdf1322020-10-05 21:55:26 +00001710 min_sdk_version: "29",
Jiyong Park4ede1602020-04-28 18:21:08 +09001711 apex_available: [
1712 "//apex_available:platform",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001713 "//apex_available:anyapex",
Jiyong Park4ede1602020-04-28 18:21:08 +09001714 ],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001715}
1716
Logan Chien17af91b2019-01-15 21:19:56 +08001717cc_library_headers {
Dan Albert64a6efc2024-08-29 19:04:59 +00001718 name: "libc_uapi_headers",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001719 visibility: [
1720 "//external/musl",
Alistair Delvabad22722024-10-07 12:52:40 -07001721 "//external/rust/crates/v4l2r/android",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001722 ],
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001723 llndk: {
1724 llndk_headers: true,
1725 },
Logan Chien17af91b2019-01-15 21:19:56 +08001726 host_supported: true,
1727 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001728 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001729 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001730 vendor_ramdisk_available: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001731 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001732 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001733 apex_available: [
1734 "//apex_available:platform",
Jiyong Parkad9946c2020-03-30 18:36:07 +09001735 "//apex_available:anyapex",
1736 ],
Jooyung Han15c32a82020-04-16 18:26:45 +09001737 // used by most APEXes indirectly via libunwind_llvm
1738 min_sdk_version: "apex_inherit",
Logan Chien17af91b2019-01-15 21:19:56 +08001739
1740 no_libcrt: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001741 stl: "none",
1742 system_shared_libs: [],
1743
Peter Collingbournef2b1e032019-12-10 17:41:16 -08001744 // The build system generally requires that any dependencies of a target
1745 // with an sdk_version must have a lower sdk_version. By setting sdk_version
1746 // to 1 we let targets with an sdk_version that need to depend on the libc
1747 // headers but cannot depend on libc itself due to circular dependencies
1748 // (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
1749 // is correct because the headers can support any sdk_version.
1750 sdk_version: "1",
1751
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001752 export_system_include_dirs: [
Logan Chien17af91b2019-01-15 21:19:56 +08001753 "kernel/uapi",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001754 "kernel/android/scsi",
Logan Chien17af91b2019-01-15 21:19:56 +08001755 "kernel/android/uapi",
1756 ],
1757
1758 arch: {
1759 arm: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001760 export_system_include_dirs: ["kernel/uapi/asm-arm"],
Logan Chien17af91b2019-01-15 21:19:56 +08001761 },
1762 arm64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001763 export_system_include_dirs: ["kernel/uapi/asm-arm64"],
Logan Chien17af91b2019-01-15 21:19:56 +08001764 },
Elliott Hughes48e53332022-10-07 20:39:25 +00001765 riscv64: {
1766 export_system_include_dirs: ["kernel/uapi/asm-riscv"],
1767 },
Logan Chien17af91b2019-01-15 21:19:56 +08001768 x86: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001769 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001770 },
1771 x86_64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001772 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001773 },
1774 },
1775}
1776
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001777cc_library_headers {
1778 name: "libc_headers",
1779 host_supported: true,
1780 native_bridge_supported: true,
1781 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001782 product_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001783 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001784 vendor_ramdisk_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001785 recovery_available: true,
1786 sdk_version: "1",
1787
1788 apex_available: [
1789 "//apex_available:platform",
1790 "//apex_available:anyapex",
1791 ],
1792 // used by most APEXes indirectly via libunwind_llvm
1793 min_sdk_version: "apex_inherit",
1794 visibility: [
1795 "//bionic:__subpackages__", // visible to bionic
1796 // ... and only to these places (b/152668052)
1797 "//external/arm-optimized-routines",
1798 "//external/gwp_asan",
1799 "//external/jemalloc_new",
1800 "//external/libunwind_llvm",
Nick Desaulniers942ae552024-02-12 10:26:19 -08001801 "//external/llvm-libc",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001802 "//external/scudo",
1803 "//system/core/property_service/libpropertyinfoparser",
1804 "//system/extras/toolchain-extras",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001805 ],
1806
1807 stl: "none",
1808 no_libcrt: true,
1809 system_shared_libs: [],
1810
1811 target: {
1812 android: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001813 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001814 header_libs: ["libc_uapi_headers"],
1815 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001816 },
1817 linux_bionic: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001818 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001819 header_libs: ["libc_uapi_headers"],
1820 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001821 },
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001822 },
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001823}
1824
Dan Willemsen208ae172015-09-16 16:33:27 -07001825// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001826// libstdc++.so and libstdc++.a.
Dan Willemsen208ae172015-09-16 16:33:27 -07001827// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001828
Dan Willemsen208ae172015-09-16 16:33:27 -07001829cc_library {
Elliott Hughes788075a2024-06-18 12:25:37 +00001830 defaults: [
1831 "libc_defaults",
1832 "bug_24465209_workaround",
1833 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001834 include_dirs: ["bionic/libstdc++/include"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001835 srcs: [
1836 "bionic/__cxa_guard.cpp",
1837 "bionic/__cxa_pure_virtual.cpp",
1838 "bionic/new.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001839 ],
1840 name: "libstdc++",
Dan Albert40f15ec2017-10-27 11:21:20 -07001841 static_ndk_lib: true,
Isaac Chen5e7c90b2017-09-20 14:44:42 +08001842 static_libs: ["libasync_safe"],
Elliott Hughesc2043342023-07-20 20:24:09 +00001843 apex_available: [
1844 "//apex_available:platform",
1845 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001846
Dan Willemsen6b3be172018-12-03 13:57:20 -08001847 static: {
1848 system_shared_libs: [],
1849 },
Colin Crossb5bfe0b2021-07-13 16:26:28 -07001850 target: {
1851 bionic: {
1852 shared: {
1853 system_shared_libs: ["libc"],
1854 },
1855 },
Dan Willemsen6b3be172018-12-03 13:57:20 -08001856 },
1857
Dan Willemsen208ae172015-09-16 16:33:27 -07001858 arch: {
1859 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001860 version_script: ":libstdc++.arm.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001861 },
1862 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001863 version_script: ":libstdc++.arm64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001864 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001865 riscv64: {
1866 version_script: ":libstdc++.riscv64.map",
1867 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001868 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001869 version_script: ":libstdc++.x86.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001870 },
1871 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001872 version_script: ":libstdc++.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001873 },
1874 },
1875}
1876
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001877genrule {
1878 name: "libstdc++.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001879 out: ["libstdc++.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001880 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001881 tools: ["generate-version-script"],
1882 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001883}
1884
1885genrule {
1886 name: "libstdc++.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001887 out: ["libstdc++.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001888 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001889 tools: ["generate-version-script"],
1890 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001891}
1892
1893genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001894 name: "libstdc++.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001895 out: ["libstdc++.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001896 srcs: ["libstdc++.map.txt"],
1897 tools: ["generate-version-script"],
1898 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1899}
1900
1901genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001902 name: "libstdc++.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001903 out: ["libstdc++.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001904 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001905 tools: ["generate-version-script"],
1906 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001907}
1908
1909genrule {
1910 name: "libstdc++.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001911 out: ["libstdc++.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001912 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001913 tools: ["generate-version-script"],
1914 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001915}
1916
1917// ========================================================
1918// crt object files.
1919// ========================================================
1920
Colin Cross50c21ab2015-10-31 23:03:05 -07001921cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001922 name: "crt_and_memtag_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -08001923 defaults: ["linux_bionic_supported"],
Dan Willemsen230a7a42017-04-07 14:09:05 -07001924 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001925 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001926 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001927 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +09001928 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001929 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001930 apex_available: [
1931 "//apex_available:platform",
1932 "//apex_available:anyapex",
1933 ],
Dan Albertdc503f62020-07-15 17:22:18 -07001934 // Generate NDK variants of the CRT objects for every supported API level.
1935 min_sdk_version: "16",
1936 stl: "none",
1937 crt: true,
Elliott Hughesd50a1de2018-02-05 17:30:57 -08001938 cflags: [
1939 "-Wno-gcc-compat",
1940 "-Wall",
1941 "-Werror",
1942 ],
Peter Collingbourne7eb851c2019-09-26 12:16:06 -07001943 sanitize: {
1944 never: true,
1945 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001946}
1947
Colin Cross50c21ab2015-10-31 23:03:05 -07001948cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001949 name: "crt_defaults",
1950 defaults: ["crt_and_memtag_defaults"],
Colin Cross02f81372021-07-22 12:02:10 -07001951 system_shared_libs: [],
Colin Cross10d92682021-06-22 13:25:46 -07001952}
1953
1954cc_defaults {
Colin Cross50c21ab2015-10-31 23:03:05 -07001955 name: "crt_so_defaults",
Colin Cross7d7b3682017-11-03 13:38:40 -07001956 defaults: ["crt_defaults"],
Colin Crossab179442018-09-27 11:03:22 -07001957 stl: "none",
Dan Willemsen208ae172015-09-16 16:33:27 -07001958}
1959
Dan Willemsen208ae172015-09-16 16:33:27 -07001960cc_object {
1961 name: "crtbrand",
Jingwen Chen7e13cf22021-02-23 00:43:01 -05001962 local_include_dirs: [
Jingwen Chen7e13cf22021-02-23 00:43:01 -05001963 "private", // crtbrand.S depends on private/bionic_asm_note.h
1964 ],
Elliott Hughes6a30b712024-03-13 23:41:32 +00001965 // crtbrand.S needs to know the platform SDK version.
Dan Willemsen208ae172015-09-16 16:33:27 -07001966 product_variables: {
1967 platform_sdk_version: {
1968 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1969 },
1970 },
1971 srcs: ["arch-common/bionic/crtbrand.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001972
Colin Cross7d7b3682017-11-03 13:38:40 -07001973 defaults: ["crt_so_defaults"],
Dan Alberteee46dc2023-04-04 23:27:52 +00001974 // crtbrand is an intermediate artifact, not a final CRT object.
1975 exclude_from_ndk_sysroot: true,
Dan Willemsen208ae172015-09-16 16:33:27 -07001976}
1977
Dan Willemsen208ae172015-09-16 16:33:27 -07001978cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05001979 name: "crtbegin_so",
Dan Willemsen208ae172015-09-16 16:33:27 -07001980 local_include_dirs: ["include"],
1981 srcs: ["arch-common/bionic/crtbegin_so.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001982
Colin Cross7d7b3682017-11-03 13:38:40 -07001983 defaults: ["crt_so_defaults"],
Colin Cross77d57bf2016-04-11 14:34:18 -07001984 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07001985 "crtbrand",
1986 ],
1987}
1988
Dan Willemsen208ae172015-09-16 16:33:27 -07001989cc_object {
1990 name: "crtend_so",
Liz Kammeraab2ad72021-03-15 18:03:24 -04001991 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001992 "private", // crtend_so.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04001993 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001994 srcs: ["arch-common/bionic/crtend_so.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001995
Colin Cross7d7b3682017-11-03 13:38:40 -07001996 defaults: ["crt_so_defaults"],
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_static",
2001
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002002 local_include_dirs: [
2003 "include",
2004 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2005 ],
Liz Kammere718dd72021-03-09 15:00:06 -05002006
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002007 cflags: ["-DCRTBEGIN_STATIC"],
Yabin Cui744cfd32023-08-24 13:20:23 -07002008
Dan Willemsen208ae172015-09-16 16:33:27 -07002009 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002010 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002011 "crtbrand",
2012 ],
Colin Cross50c21ab2015-10-31 23:03:05 -07002013 defaults: ["crt_defaults"],
Jiyong Park268a6002021-01-12 23:14:37 +09002014 // When using libc.a, we're using the latest library regardless of target API level.
2015 min_sdk_version: "current",
Dan Willemsen208ae172015-09-16 16:33:27 -07002016}
2017
Dan Willemsen208ae172015-09-16 16:33:27 -07002018cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002019 name: "crtbegin_dynamic",
2020
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002021 local_include_dirs: [
2022 "include",
2023 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2024 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002025 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002026 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002027 "crtbrand",
2028 ],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -07002029 target: {
2030 linux_bionic: {
2031 generated_sources: ["host_bionic_linker_asm"],
2032 objs: [
2033 "linker_wrapper",
2034 ],
2035 },
2036 },
Colin Cross50c21ab2015-10-31 23:03:05 -07002037 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002038}
2039
Dan Willemsen208ae172015-09-16 16:33:27 -07002040cc_object {
2041 // We rename crtend.o to crtend_android.o to avoid a
2042 // name clash between gcc and bionic.
2043 name: "crtend_android",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002044 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002045 "private", // crtend.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002046 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002047 srcs: ["arch-common/bionic/crtend.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002048
Colin Cross50c21ab2015-10-31 23:03:05 -07002049 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002050}
Colin Crossbaa48992016-07-13 11:15:21 -07002051
Kalesh Singh862a23d2024-01-09 13:13:50 -08002052cc_object {
2053 name: "crt_pad_segment",
2054 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002055 "private", // crt_pad_segment.S depends on private/bionic_asm_note.h
Kalesh Singh862a23d2024-01-09 13:13:50 -08002056 ],
2057 srcs: ["arch-common/bionic/crt_pad_segment.S"],
2058
2059 defaults: ["crt_defaults"],
2060}
2061
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002062cc_library_static {
2063 name: "note_memtag_heap_async",
2064 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002065 arm64: {
2066 srcs: ["arch-arm64/bionic/note_memtag_heap_async.S"],
2067 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002068 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002069 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002070
Colin Cross10d92682021-06-22 13:25:46 -07002071 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002072}
2073
2074cc_library_static {
2075 name: "note_memtag_heap_sync",
2076 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002077 arm64: {
2078 srcs: ["arch-arm64/bionic/note_memtag_heap_sync.S"],
2079 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002080 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002081 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002082
Colin Cross10d92682021-06-22 13:25:46 -07002083 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002084}
2085
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002086// ========================================================
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002087// libc dependencies for baremetal Rust projects.
2088// ========================================================
2089
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002090// This library contains the following unresolved symbols:
2091// __errno
2092// abort
2093// async_safe_fatal_va_list
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002094cc_library_static {
2095 name: "librust_baremetal",
Pierre-Clément Tosi9018e5f2024-10-02 15:57:00 +01002096 defaults: ["cc_baremetal_defaults"],
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002097 header_libs: ["libc_headers"],
2098 include_dirs: [
2099 "bionic/libc/async_safe/include",
2100 "bionic/libc/platform",
2101 ],
2102 cflags: [
2103 "-Wall",
2104 "-Werror",
2105 ],
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002106 srcs: [
2107 "bionic/fortify.cpp",
Pierre-Clément Tosi816176c2022-11-30 14:33:41 +00002108 "bionic/strtol.cpp",
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002109 ],
2110 arch: {
2111 arm64: {
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002112 srcs: [
2113 "arch-arm64/string/__memcpy_chk.S",
2114 ],
2115 },
caowencheng9a39eb32023-03-20 16:24:41 +08002116 riscv64: {
2117 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002118 "arch-riscv64/string/__memcpy_chk.S",
caowencheng9a39eb32023-03-20 16:24:41 +08002119 ],
2120 },
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002121 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002122 whole_static_libs: [
George Burgess IVc5a98e62024-11-18 14:50:32 -07002123 "//external/llvm-libc:llvmlibc",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002124 "libarm-optimized-routines-mem",
Pierre-Clément Tosieb46ac92023-02-01 13:44:57 +00002125 "libc_netbsd",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002126 ],
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002127 system_shared_libs: [],
2128 nocrt: true,
2129 stl: "none",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002130 visibility: [
Jiyong Park072ce532024-07-22 11:20:47 +09002131 "//packages/modules/Virtualization/libs/libvmbase",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002132 ],
Zijun427504a2024-08-15 23:16:27 +00002133
2134 // b/358211032: This library gets linked into a rust rlib. Disable LTO
2135 // until cross-language lto is supported.
2136 lto: {
2137 never: true,
2138 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002139}
2140
2141// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002142// NDK headers.
2143// ========================================================
2144
Dan Albertcce54372024-08-22 18:24:30 +00002145ndk_headers {
Dan Albert22805ea2017-03-22 15:28:05 -07002146 name: "common_libc",
2147 from: "include",
2148 to: "",
Dan Albertcce54372024-08-22 18:24:30 +00002149 srcs: ["include/**/*.h"],
Dan Albert22805ea2017-03-22 15:28:05 -07002150 license: "NOTICE",
Dan Albertcce54372024-08-22 18:24:30 +00002151 // These don't pass the bad verification we do because many of them are
2152 // arch-specific, and they aren't necessarily independently includable.
2153 // That's not much of a problem though, since C-incompaitibilities in the
2154 // UAPI headers should run into problems long before they reach us.
2155 skip_verification: true,
Dan Albert22805ea2017-03-22 15:28:05 -07002156}
Dan Albert4238a352016-06-28 11:18:05 -07002157
2158ndk_headers {
Dan Albert063e86a2016-11-29 11:09:12 -08002159 name: "libc_uapi",
2160 from: "kernel/uapi",
2161 to: "",
2162 srcs: [
2163 "kernel/uapi/asm-generic/**/*.h",
2164 "kernel/uapi/drm/**/*.h",
2165 "kernel/uapi/linux/**/*.h",
2166 "kernel/uapi/misc/**/*.h",
2167 "kernel/uapi/mtd/**/*.h",
2168 "kernel/uapi/rdma/**/*.h",
2169 "kernel/uapi/scsi/**/*.h",
2170 "kernel/uapi/sound/**/*.h",
2171 "kernel/uapi/video/**/*.h",
2172 "kernel/uapi/xen/**/*.h",
2173 ],
Dan Albert92592652016-10-20 01:42:54 -07002174 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002175 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002176}
2177
2178ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002179 name: "libc_kernel_android_uapi_linux",
Dan Albertbae16ef2016-09-14 17:15:48 -07002180 from: "kernel/android/uapi/linux",
2181 to: "linux",
2182 srcs: ["kernel/android/uapi/linux/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002183 license: "NOTICE",
Dan Albertbae16ef2016-09-14 17:15:48 -07002184}
2185
2186ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002187 name: "libc_kernel_android_scsi",
Elliott Hughes50599392017-05-25 17:13:32 -07002188 from: "kernel/android/scsi/scsi",
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002189 to: "scsi",
2190 srcs: ["kernel/android/scsi/**/*.h"],
2191 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002192 skip_verification: true,
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002193}
2194
2195ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002196 name: "libc_asm_arm",
2197 from: "kernel/uapi/asm-arm",
2198 to: "arm-linux-androideabi",
2199 srcs: ["kernel/uapi/asm-arm/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002200 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002201 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002202}
2203
2204ndk_headers {
2205 name: "libc_asm_arm64",
2206 from: "kernel/uapi/asm-arm64",
2207 to: "aarch64-linux-android",
2208 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002209 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002210 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002211}
2212
Lazar Trsic790d2f72017-11-27 11:54:11 +01002213ndk_headers {
Colin Crossbd26e0f2022-10-19 15:03:14 -07002214 name: "libc_asm_riscv64",
2215 from: "kernel/uapi/asm-riscv",
2216 to: "riscv64-linux-android",
2217 srcs: ["kernel/uapi/asm-riscv/**/*.h"],
2218 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002219 skip_verification: true,
Colin Crossbd26e0f2022-10-19 15:03:14 -07002220}
2221
2222ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002223 name: "libc_asm_x86",
2224 from: "kernel/uapi/asm-x86",
2225 to: "i686-linux-android",
2226 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002227 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002228 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002229}
2230
2231ndk_headers {
2232 name: "libc_asm_x86_64",
2233 from: "kernel/uapi/asm-x86",
2234 to: "x86_64-linux-android",
2235 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002236 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002237 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002238}
2239
Dan Albert4238a352016-06-28 11:18:05 -07002240ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002241 name: "libc",
Dan Albert4238a352016-06-28 11:18:05 -07002242 symbol_file: "libc.map.txt",
2243 first_version: "9",
2244}
2245
Dan Albertdf31aff2016-10-06 15:50:41 -07002246ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002247 name: "libstdc++",
Dan Albertdf31aff2016-10-06 15:50:41 -07002248 symbol_file: "libstdc++.map.txt",
2249 first_version: "9",
2250}
2251
Dan Willemsenca056d72018-01-08 14:00:24 -08002252// Export these headers for toolbox to process
2253filegroup {
2254 name: "kernel_input_headers",
2255 srcs: [
2256 "kernel/uapi/linux/input.h",
2257 "kernel/uapi/linux/input-event-codes.h",
2258 ],
2259}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002260
2261// Generate a syscall name / number mapping. These objects are text files
2262// (thanks to the -dD -E flags) and not binary files. They will then be
2263// consumed by the genseccomp.py script and converted into C++ code.
2264cc_defaults {
2265 name: "libseccomp_gen_syscall_nrs_defaults",
2266 recovery_available: true,
2267 srcs: ["seccomp/gen_syscall_nrs.cpp"],
2268 cflags: [
2269 "-dD",
2270 "-E",
2271 "-Wall",
2272 "-Werror",
Ryan Prichardeffe86f2024-12-18 17:07:37 -08002273 // Soong implicitly adds a -c argument that we override with -E.
2274 // Suppress Clang's error about the unused -c argument.
2275 "-Wno-unused-command-line-argument",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002276 "-nostdinc",
2277 ],
2278}
2279
2280cc_object {
2281 name: "libseccomp_gen_syscall_nrs_arm",
2282 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2283 local_include_dirs: [
2284 "kernel/uapi/asm-arm",
2285 "kernel/uapi",
2286 ],
2287}
2288
2289cc_object {
2290 name: "libseccomp_gen_syscall_nrs_arm64",
2291 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2292 local_include_dirs: [
2293 "kernel/uapi/asm-arm64",
2294 "kernel/uapi",
2295 ],
2296}
2297
2298cc_object {
Elliott Hughes704772b2022-10-10 17:06:43 +00002299 name: "libseccomp_gen_syscall_nrs_riscv64",
2300 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2301 local_include_dirs: [
2302 "kernel/uapi/asm-riscv",
2303 "kernel/uapi",
2304 ],
2305}
2306
2307cc_object {
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002308 name: "libseccomp_gen_syscall_nrs_x86",
2309 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2310 srcs: ["seccomp/gen_syscall_nrs_x86.cpp"],
2311 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2312 local_include_dirs: [
2313 "kernel/uapi/asm-x86",
2314 "kernel/uapi",
2315 ],
2316}
2317
2318cc_object {
2319 name: "libseccomp_gen_syscall_nrs_x86_64",
2320 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2321 srcs: ["seccomp/gen_syscall_nrs_x86_64.cpp"],
2322 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2323 local_include_dirs: [
2324 "kernel/uapi/asm-x86",
2325 "kernel/uapi",
2326 ],
2327}
2328
Jingwen Chenca366332021-01-29 05:16:32 -05002329filegroup {
2330 name: "all_kernel_uapi_headers",
2331 srcs: ["kernel/uapi/**/*.h"],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002332}
2333
Martijn Coenen0c6de752019-01-02 12:52:51 +01002334cc_genrule {
2335 name: "func_to_syscall_nrs",
2336 recovery_available: true,
2337 cmd: "$(location genfunctosyscallnrs) --out-dir=$(genDir) $(in)",
2338
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002339 tools: ["genfunctosyscallnrs"],
Martijn Coenen0c6de752019-01-02 12:52:51 +01002340
2341 srcs: [
2342 "SYSCALLS.TXT",
Martijn Coenen0c6de752019-01-02 12:52:51 +01002343 ],
2344
Elliott Hughes704772b2022-10-10 17:06:43 +00002345 arch: {
2346 arm: {
2347 srcs: [
2348 ":libseccomp_gen_syscall_nrs_arm",
2349 ":libseccomp_gen_syscall_nrs_arm64",
2350 ],
2351 },
2352 arm64: {
2353 srcs: [
2354 ":libseccomp_gen_syscall_nrs_arm",
2355 ":libseccomp_gen_syscall_nrs_arm64",
2356 ],
2357 },
2358 riscv64: {
2359 srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
2360 },
2361 x86: {
2362 srcs: [
2363 ":libseccomp_gen_syscall_nrs_x86",
2364 ":libseccomp_gen_syscall_nrs_x86_64",
2365 ],
2366 },
2367 x86_64: {
2368 srcs: [
2369 ":libseccomp_gen_syscall_nrs_x86",
2370 ":libseccomp_gen_syscall_nrs_x86_64",
2371 ],
2372 },
2373 },
2374
Martijn Coenen0c6de752019-01-02 12:52:51 +01002375 out: [
2376 "func_to_syscall_nrs.h",
2377 ],
2378}
2379
Victor Hsiehdbb86702020-06-15 09:29:07 -07002380// SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT = SECCOMP_BLOCKLIST_APP.txt - setresgid*
Martijn Coenenc3752be2019-01-09 16:19:57 +01002381genrule {
Victor Hsiehdbb86702020-06-15 09:29:07 -07002382 name: "generate_app_zygote_blocklist",
2383 out: ["SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT"],
2384 srcs: ["SECCOMP_BLOCKLIST_APP.TXT"],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002385 cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)",
2386}
2387
Yu Liu938ec9b2022-10-17 16:36:30 -07002388filegroup {
2389 name: "seccomp_syscalls_sources_zygote",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002390 srcs: [
2391 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002392 "SECCOMP_ALLOWLIST_COMMON.TXT",
2393 "SECCOMP_ALLOWLIST_APP.TXT",
2394 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002395 "SECCOMP_PRIORITY.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002396 ":generate_app_zygote_blocklist",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002397 ],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002398}
2399
Yu Liu938ec9b2022-10-17 16:36:30 -07002400filegroup {
2401 name: "seccomp_syscalls_sources_app",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002402 srcs: [
2403 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002404 "SECCOMP_ALLOWLIST_COMMON.TXT",
2405 "SECCOMP_ALLOWLIST_APP.TXT",
2406 "SECCOMP_BLOCKLIST_COMMON.TXT",
2407 "SECCOMP_BLOCKLIST_APP.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002408 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002409 ],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002410}
2411
Yu Liu938ec9b2022-10-17 16:36:30 -07002412filegroup {
2413 name: "seccomp_syscalls_sources_system",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002414 srcs: [
2415 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002416 "SECCOMP_ALLOWLIST_COMMON.TXT",
2417 "SECCOMP_ALLOWLIST_SYSTEM.TXT",
2418 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002419 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002420 ],
Yu Liu938ec9b2022-10-17 16:36:30 -07002421}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002422
Yu Liu938ec9b2022-10-17 16:36:30 -07002423cc_genrule {
2424 name: "libseccomp_policy_app_zygote_sources_x86",
2425 recovery_available: true,
2426 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002427 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002428 srcs: [
2429 ":seccomp_syscalls_sources_zygote",
2430 ":libseccomp_gen_syscall_nrs_x86",
2431 ":libseccomp_gen_syscall_nrs_x86_64",
2432 ],
2433 out: [
2434 "x86_app_zygote_policy.cpp",
2435 "x86_64_app_zygote_policy.cpp",
2436 ],
2437 enabled: false,
Yu Liu3a579692022-10-18 03:02:32 +00002438 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002439 x86: {
2440 enabled: true,
2441 },
2442 x86_64: {
2443 enabled: true,
2444 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002445 },
2446}
2447
2448cc_genrule {
2449 name: "libseccomp_policy_app_zygote_sources_arm",
2450 recovery_available: true,
2451 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002452 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002453 srcs: [
2454 ":seccomp_syscalls_sources_zygote",
2455 ":libseccomp_gen_syscall_nrs_arm",
2456 ":libseccomp_gen_syscall_nrs_arm64",
2457 ],
2458 out: [
2459 "arm_app_zygote_policy.cpp",
2460 "arm64_app_zygote_policy.cpp",
2461 ],
2462 enabled: false,
2463 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002464 arm: {
2465 enabled: true,
2466 },
2467 arm64: {
2468 enabled: true,
2469 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002470 },
2471}
2472
2473cc_genrule {
2474 name: "libseccomp_policy_app_zygote_sources_riscv64",
2475 recovery_available: true,
2476 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002477 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002478 srcs: [
2479 ":seccomp_syscalls_sources_zygote",
2480 ":libseccomp_gen_syscall_nrs_riscv64",
2481 ],
2482 out: [
2483 "riscv64_app_zygote_policy.cpp",
2484 ],
2485 enabled: false,
2486 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002487 riscv64: {
2488 enabled: true,
2489 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002490 },
2491}
2492
2493cc_genrule {
2494 name: "libseccomp_policy_app_sources_x86",
2495 recovery_available: true,
2496 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002497 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002498 srcs: [
2499 ":seccomp_syscalls_sources_app",
2500 ":libseccomp_gen_syscall_nrs_x86",
2501 ":libseccomp_gen_syscall_nrs_x86_64",
2502 ],
2503 out: [
2504 "x86_app_policy.cpp",
2505 "x86_64_app_policy.cpp",
2506 ],
2507 enabled: false,
2508 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002509 x86: {
2510 enabled: true,
2511 },
2512 x86_64: {
2513 enabled: true,
2514 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002515 },
2516}
2517
2518cc_genrule {
2519 name: "libseccomp_policy_app_sources_arm",
2520 recovery_available: true,
2521 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002522 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002523 srcs: [
2524 ":seccomp_syscalls_sources_app",
2525 ":libseccomp_gen_syscall_nrs_arm",
2526 ":libseccomp_gen_syscall_nrs_arm64",
2527 ],
2528 out: [
2529 "arm_app_policy.cpp",
2530 "arm64_app_policy.cpp",
2531 ],
2532 enabled: false,
2533 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002534 arm: {
2535 enabled: true,
2536 },
2537 arm64: {
2538 enabled: true,
2539 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002540 },
2541}
2542
2543cc_genrule {
2544 name: "libseccomp_policy_app_sources_riscv64",
2545 recovery_available: true,
2546 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002547 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002548 srcs: [
2549 ":seccomp_syscalls_sources_app",
2550 ":libseccomp_gen_syscall_nrs_riscv64",
2551 ],
2552 out: [
2553 "riscv64_app_policy.cpp",
2554 ],
2555 enabled: false,
2556 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002557 riscv64: {
2558 enabled: true,
2559 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002560 },
2561}
2562
2563cc_genrule {
2564 name: "libseccomp_policy_system_sources_x86",
2565 recovery_available: true,
2566 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002567 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002568 srcs: [
2569 ":seccomp_syscalls_sources_system",
2570 ":libseccomp_gen_syscall_nrs_x86",
2571 ":libseccomp_gen_syscall_nrs_x86_64",
2572 ],
2573 out: [
2574 "x86_system_policy.cpp",
2575 "x86_64_system_policy.cpp",
2576 ],
2577 enabled: false,
2578 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002579 x86: {
2580 enabled: true,
2581 },
2582 x86_64: {
2583 enabled: true,
2584 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002585 },
2586}
2587
2588cc_genrule {
2589 name: "libseccomp_policy_system_sources_arm",
2590 recovery_available: true,
2591 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002592 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002593 srcs: [
2594 ":seccomp_syscalls_sources_system",
2595 ":libseccomp_gen_syscall_nrs_arm",
2596 ":libseccomp_gen_syscall_nrs_arm64",
2597 ],
2598 out: [
2599 "arm_system_policy.cpp",
2600 "arm64_system_policy.cpp",
2601 ],
2602 enabled: false,
2603 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002604 arm: {
2605 enabled: true,
2606 },
2607 arm64: {
2608 enabled: true,
2609 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002610 },
2611}
2612
2613cc_genrule {
2614 name: "libseccomp_policy_system_sources_riscv64",
2615 recovery_available: true,
2616 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002617 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002618 srcs: [
2619 ":seccomp_syscalls_sources_system",
2620 ":libseccomp_gen_syscall_nrs_riscv64",
2621 ],
2622 out: [
2623 "riscv64_system_policy.cpp",
2624 ],
2625 enabled: false,
2626 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002627 riscv64: {
2628 enabled: true,
2629 },
Yu Liu3a579692022-10-18 03:02:32 +00002630 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002631}
2632
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002633cc_library {
2634 name: "libseccomp_policy",
2635 recovery_available: true,
Martijn Coenend269d9b2018-11-08 16:41:42 +01002636 generated_headers: ["func_to_syscall_nrs"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002637
2638 arch: {
2639 arm: {
2640 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002641 "libseccomp_policy_app_sources_arm",
2642 "libseccomp_policy_app_zygote_sources_arm",
2643 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002644 ],
2645 },
2646 arm64: {
2647 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002648 "libseccomp_policy_app_sources_arm",
2649 "libseccomp_policy_app_zygote_sources_arm",
2650 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002651 ],
2652 },
2653 riscv64: {
2654 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002655 "libseccomp_policy_app_sources_riscv64",
2656 "libseccomp_policy_app_zygote_sources_riscv64",
2657 "libseccomp_policy_system_sources_riscv64",
Yu Liu938ec9b2022-10-17 16:36:30 -07002658 ],
2659 },
2660 x86: {
2661 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002662 "libseccomp_policy_app_sources_x86",
2663 "libseccomp_policy_app_zygote_sources_x86",
2664 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002665 ],
2666 },
2667 x86_64: {
2668 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002669 "libseccomp_policy_app_sources_x86",
2670 "libseccomp_policy_app_zygote_sources_x86",
2671 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002672 ],
2673 },
2674 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002675
2676 srcs: [
2677 "seccomp/seccomp_policy.cpp",
2678 ],
2679
2680 export_include_dirs: ["seccomp/include"],
2681 cflags: [
2682 "-Wall",
2683 "-Werror",
2684 ],
2685 shared: {
2686 shared_libs: ["libbase"],
2687 },
2688 static: {
2689 static_libs: ["libbase"],
2690 },
2691}
Christopher Ferrisfc26d712019-02-27 18:07:55 -08002692
Colin Cross048f24e2021-09-01 17:26:00 -07002693cc_library_host_static {
2694 name: "libfts",
2695 srcs: [
2696 "bionic/fts.c",
2697 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
2698 ],
2699 export_include_dirs: ["fts/include"],
2700 local_include_dirs: [
2701 "private",
2702 "upstream-openbsd/android/include",
2703 ],
2704 cflags: [
2705 "-include openbsd-compat.h",
2706 "-Wno-unused-parameter",
2707 ],
2708 enabled: false,
2709 target: {
2710 musl: {
2711 enabled: true,
2712 },
2713 },
Colin Cross2a9843f2022-01-13 12:26:30 -08002714 stl: "none",
2715}
2716
2717cc_library_host_static {
2718 name: "libexecinfo",
2719 visibility: ["//external/musl"],
2720 srcs: ["bionic/execinfo.cpp"],
2721 export_include_dirs: ["execinfo/include"],
2722 local_include_dirs: ["private"],
2723 enabled: false,
2724 target: {
2725 musl: {
2726 enabled: true,
2727 system_shared_libs: [],
2728 header_libs: ["libc_musl_headers"],
2729 },
2730 },
2731 stl: "none",
Colin Cross048f24e2021-09-01 17:26:00 -07002732}
2733
Colin Cross9da85fa2022-01-24 18:20:05 -08002734cc_library_host_static {
2735 name: "libb64",
2736 visibility: ["//external/musl"],
2737 srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
2738 export_include_dirs: ["b64/include"],
2739 local_include_dirs: [
2740 "private",
2741 "upstream-openbsd/android/include",
2742 ],
2743 cflags: [
2744 "-include openbsd-compat.h",
2745 ],
2746 enabled: false,
2747 target: {
2748 musl: {
2749 enabled: true,
2750 system_shared_libs: [],
2751 header_libs: ["libc_musl_headers"],
2752 },
2753 },
2754 stl: "none",
2755}
2756
Colin Cross9d4a56e2022-02-03 10:20:32 -08002757// Export kernel uapi headers to be used in the musl sysroot.
2758// Also include the execinfo headers for the libexecinfo and the
2759// b64 headers for libb64 embedded in musl libc.
2760cc_genrule {
2761 name: "libc_musl_sysroot_bionic_headers",
2762 visibility: ["//external/musl"],
2763 host_supported: true,
2764 device_supported: false,
2765 enabled: false,
2766 target: {
2767 musl: {
2768 enabled: true,
2769 },
2770 },
2771 srcs: [
2772 "kernel/uapi/**/*.h",
2773 "kernel/android/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002774 "execinfo/include/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002775 "b64/include/**/*.h",
Colin Crossaeef9f02022-02-07 21:01:26 -08002776
Colin Crossaeef9f02022-02-07 21:01:26 -08002777 "NOTICE",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002778
2779 ":libc_musl_sysroot_bionic_arch_headers",
2780 ],
2781 out: ["libc_musl_sysroot_bionic_headers.zip"],
2782 tools: [
2783 "soong_zip",
2784 "merge_zips",
2785 "zip2zip",
2786 ],
Colin Crossaeef9f02022-02-07 21:01:26 -08002787 cmd: "BIONIC_LIBC_DIR=$$(dirname $(location NOTICE)) && " +
2788 "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
Colin Crossad33d022022-02-25 18:27:04 -08002789 // NOTICE
2790 " -j -f $(location NOTICE) " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002791 // headers
2792 " -P include " +
Colin Crossaeef9f02022-02-07 21:01:26 -08002793 " -C $${BIONIC_LIBC_DIR}/kernel/uapi " +
2794 " -D $${BIONIC_LIBC_DIR}/kernel/uapi " +
2795 " -C $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2796 " -D $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2797 " -C $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2798 " -D $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2799 " -C $${BIONIC_LIBC_DIR}/execinfo/include " +
2800 " -D $${BIONIC_LIBC_DIR}/execinfo/include " +
2801 " -C $${BIONIC_LIBC_DIR}/b64/include " +
2802 " -D $${BIONIC_LIBC_DIR}/b64/include " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002803 " && " +
Colin Crossad33d022022-02-25 18:27:04 -08002804 "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(genDir)/sysroot-renamed.zip " +
Colin Cross1c0a7a02022-08-11 12:22:26 -07002805 " -x **/BUILD " +
Colin Crossad33d022022-02-25 18:27:04 -08002806 " include/**/*:include/ " +
2807 " NOTICE:NOTICE.bionic " +
2808 " && " +
2809 "$(location merge_zips) $(out) $(location :libc_musl_sysroot_bionic_arch_headers) $(genDir)/sysroot-renamed.zip",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002810}
2811
2812// The architecture-specific bits have to be handled separately because the label varies based
2813// on architecture, which prevents using $(locations) to find them and requires using $(in)
2814// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
2815// genrule.
2816cc_genrule {
2817 name: "libc_musl_sysroot_bionic_arch_headers",
2818 visibility: ["//visibility:private"],
2819 host_supported: true,
2820 device_supported: false,
2821 enabled: false,
2822 target: {
2823 musl: {
2824 enabled: true,
2825 },
2826 },
2827 arch: {
2828 arm: {
2829 srcs: ["kernel/uapi/asm-arm/**/*.h"],
2830 },
2831 arm64: {
2832 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
2833 },
2834 x86: {
2835 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2836 },
2837 x86_64: {
2838 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2839 },
2840 },
2841 out: ["libc_musl_sysroot_bionic_arch_headers.zip"],
2842 tools: ["soong_zip"],
2843 cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/asm -j -D $$(dirname $${includes[0]})",
2844}
Colin Cross290c4952022-10-13 12:51:13 -07002845
2846cc_genrule {
2847 name: "bionic_sysroot_crt_objects",
2848 visibility: ["//visibility:private"],
2849 out: ["bionic_sysroot_crt_objects.zip"],
2850 tools: ["soong_zip"],
2851 srcs: [
2852 ":crtbegin_dynamic",
2853 ":crtbegin_so",
2854 ":crtbegin_static",
2855 ":crtend_android",
2856 ":crtend_so",
2857 ],
2858 cmd: "$(location soong_zip) -o $(out) -j " +
2859 "-f $(location :crtbegin_dynamic) " +
2860 "-f $(location :crtbegin_so) " +
2861 "-f $(location :crtbegin_static) " +
2862 "-f $(location :crtend_android) " +
2863 "-f $(location :crtend_so)",
2864 dist: {
2865 targets: ["bionic_sysroot_crt_objects"],
2866 },
2867 arch: {
2868 arm: {
2869 dist: {
2870 suffix: "_arm",
2871 },
2872 },
2873 arm64: {
2874 dist: {
2875 suffix: "_arm64",
2876 },
2877 },
2878 riscv64: {
2879 dist: {
2880 suffix: "_riscv64",
2881 },
2882 },
2883 x86: {
2884 dist: {
2885 suffix: "_x86",
2886 },
2887 },
2888 x86_64: {
2889 dist: {
2890 suffix: "_x86_64",
2891 },
2892 },
2893 },
2894}
Spandan Das8fce52a2023-09-28 18:00:12 +00002895
Jiyong Park35a280d2024-05-03 16:53:39 +09002896filegroup {
2897 name: "linux_capability_header",
2898 srcs: ["kernel/uapi/linux/capability.h"],
2899}