blob: 8407a60958561895df9aac19439f2a6015298b2e [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: [
625 "upstream-openbsd/lib/libc/string/memchr.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700626 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700627 "upstream-openbsd/lib/libc/string/strncat.c",
628 "upstream-openbsd/lib/libc/string/strncmp.c",
629 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700630 ],
631 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700632 arm64: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700633 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700634 "upstream-openbsd/lib/libc/string/strcat.c",
Elliott Hughesaefe9992023-11-08 12:04:41 -0800635 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700636 "upstream-openbsd/lib/libc/string/strncat.c",
637 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700638 ],
639 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000640 riscv64: {
641 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700642 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughesebc19a92022-10-14 23:25:36 +0000643 ],
644 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700645 x86: {
Elliott Hughesaefe9992023-11-08 12:04:41 -0800646 srcs: [
647 // x86 has custom implementations of all of these.
648 ],
Elliott Hughes7d136662023-10-27 15:40:32 -0700649 },
650 x86_64: {
651 srcs: [
George Burgess IV414bfb32024-11-19 09:00:39 -0700652 // x86_64 has custom/llvm-libc implementations of all of these.
Colin Cross6ab8f892015-11-23 14:12:15 -0800653 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700654 },
655 },
656
Colin Cross50c21ab2015-10-31 23:03:05 -0700657 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700658 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700659 "-Wno-unused-parameter",
660 "-include openbsd-compat.h",
661 ],
662
Dan Willemsen208ae172015-09-16 16:33:27 -0700663 local_include_dirs: [
664 "private",
Elliott Hughes968adf92024-02-08 13:15:53 -0800665 "stdio",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400666 "upstream-openbsd/android/include/",
667 "upstream-openbsd/lib/libc/gdtoa/",
668 "upstream-openbsd/lib/libc/include/",
669 "upstream-openbsd/lib/libc/stdio/",
Dan Willemsen208ae172015-09-16 16:33:27 -0700670 ],
671
672 name: "libc_openbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700673}
674
Elliott Hughes968adf92024-02-08 13:15:53 -0800675cc_library_static {
676 name: "libc_openbsd_large_stack",
677 defaults: ["libc_defaults"],
678 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800679 "upstream-openbsd/lib/libc/string/memmem.c",
680 "upstream-openbsd/lib/libc/string/strstr.c",
681 ],
682 cflags: [
683 "-include openbsd-compat.h",
684 "-Wno-sign-compare",
685 "-Wframe-larger-than=5000",
686 ],
687
688 local_include_dirs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800689 "upstream-openbsd/android/include/",
Elliott Hughes968adf92024-02-08 13:15:53 -0800690 ],
691}
692
Dan Willemsen208ae172015-09-16 16:33:27 -0700693// ========================================================
694// libc_gdtoa.a - upstream OpenBSD C library gdtoa code
695// ========================================================
696//
697// These files are built with the openbsd-compat.h header file
698// automatically included.
699
700cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700701 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700702 srcs: [
703 "upstream-openbsd/android/gdtoa_support.cpp",
704 "upstream-openbsd/lib/libc/gdtoa/dmisc.c",
705 "upstream-openbsd/lib/libc/gdtoa/dtoa.c",
706 "upstream-openbsd/lib/libc/gdtoa/gdtoa.c",
707 "upstream-openbsd/lib/libc/gdtoa/gethex.c",
708 "upstream-openbsd/lib/libc/gdtoa/gmisc.c",
709 "upstream-openbsd/lib/libc/gdtoa/hd_init.c",
710 "upstream-openbsd/lib/libc/gdtoa/hdtoa.c",
711 "upstream-openbsd/lib/libc/gdtoa/hexnan.c",
712 "upstream-openbsd/lib/libc/gdtoa/ldtoa.c",
713 "upstream-openbsd/lib/libc/gdtoa/misc.c",
714 "upstream-openbsd/lib/libc/gdtoa/smisc.c",
715 "upstream-openbsd/lib/libc/gdtoa/strtod.c",
716 "upstream-openbsd/lib/libc/gdtoa/strtodg.c",
717 "upstream-openbsd/lib/libc/gdtoa/strtof.c",
718 "upstream-openbsd/lib/libc/gdtoa/strtord.c",
719 "upstream-openbsd/lib/libc/gdtoa/sum.c",
720 "upstream-openbsd/lib/libc/gdtoa/ulp.c",
721 ],
722 multilib: {
723 lib64: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800724 srcs: ["upstream-openbsd/lib/libc/gdtoa/strtorQ.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700725 },
726 },
727
Colin Cross50c21ab2015-10-31 23:03:05 -0700728 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700729 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700730 "-include openbsd-compat.h",
731 ],
732
Dan Willemsen208ae172015-09-16 16:33:27 -0700733 local_include_dirs: [
734 "private",
735 "upstream-openbsd/android/include",
736 "upstream-openbsd/lib/libc/include",
737 ],
738
739 name: "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -0700740}
741
742// ========================================================
Pierre-Clément Tosi467e58e2023-02-01 13:44:43 +0000743// libc_fortify.a - container for our FORTIFY
George Burgess IV6cb06872017-07-21 13:28:42 -0700744// implementation details
745// ========================================================
746cc_library_static {
747 defaults: ["libc_defaults"],
George Burgess IVd34b0a92017-07-25 11:43:39 -0700748 srcs: ["bionic/fortify.cpp"],
George Burgess IV6cb06872017-07-21 13:28:42 -0700749
750 name: "libc_fortify",
751
752 // Disable FORTIFY for the compilation of these, so we don't end up having
753 // FORTIFY silently call itself.
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800754 cflags: [
755 "-U_FORTIFY_SOURCE",
756 "-D__BIONIC_DECLARE_FORTIFY_HELPERS",
757 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700758
759 arch: {
760 arm: {
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800761 cflags: [
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800762 "-DRENAME___STRCAT_CHK",
763 "-DRENAME___STRCPY_CHK",
764 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700765 srcs: [
766 "arch-arm/generic/bionic/__memcpy_chk.S",
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800767
768 "arch-arm/cortex-a15/bionic/__strcat_chk.S",
769 "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
770
771 "arch-arm/cortex-a7/bionic/__strcat_chk.S",
772 "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
773
774 "arch-arm/cortex-a9/bionic/__strcat_chk.S",
775 "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
776
777 "arch-arm/krait/bionic/__strcat_chk.S",
778 "arch-arm/krait/bionic/__strcpy_chk.S",
779
780 "arch-arm/cortex-a53/bionic/__strcat_chk.S",
781 "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
782
Haibo Huang01bfd892018-12-03 15:05:16 -0800783 "arch-arm/cortex-a55/bionic/__strcat_chk.S",
784 "arch-arm/cortex-a55/bionic/__strcpy_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700785 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700786 },
787 arm64: {
788 srcs: [
Elliott Hughes023e4e72022-11-17 19:27:02 +0000789 "arch-arm64/string/__memcpy_chk.S",
790 "arch-arm64/string/__memset_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700791 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700792 },
caowenchengab457f92023-03-06 14:57:55 +0800793 riscv64: {
794 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000795 "arch-riscv64/string/__memset_chk.S",
796 "arch-riscv64/string/__memcpy_chk.S",
caowenchengab457f92023-03-06 14:57:55 +0800797 ],
798 },
George Burgess IV6cb06872017-07-21 13:28:42 -0700799 },
800}
801
802// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -0700803// libc_bionic.a - home-grown C library code
804// ========================================================
805
806cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700807 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700808 srcs: [
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800809 "bionic/NetdClientDispatch.cpp",
810 "bionic/__bionic_get_shell_path.cpp",
811 "bionic/__cmsg_nxthdr.cpp",
812 "bionic/__cxa_thread_atexit_impl.cpp",
813 "bionic/__errno.cpp",
814 "bionic/__gnu_basename.cpp",
815 "bionic/__libc_current_sigrtmax.cpp",
816 "bionic/__libc_current_sigrtmin.cpp",
817 "bionic/abort.cpp",
818 "bionic/accept.cpp",
819 "bionic/access.cpp",
Florian Mayerca4749a2024-02-14 12:55:46 -0800820 "bionic/android_crash_detail.cpp",
Josh Gao10ec9282017-04-03 15:13:29 -0700821 "bionic/android_set_abort_message.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000822 "bionic/android_unsafe_frame_pointer_chase.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800823 "bionic/arpa_inet.cpp",
824 "bionic/assert.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000825 "bionic/atexit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800826 "bionic/atof.cpp",
827 "bionic/bionic_allocator.cpp",
828 "bionic/bionic_arc4random.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000829 "bionic/bionic_elf_tls.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800830 "bionic/bionic_futex.cpp",
831 "bionic/bionic_netlink.cpp",
832 "bionic/bionic_systrace.cpp",
833 "bionic/bionic_time_conversions.cpp",
834 "bionic/brk.cpp",
835 "bionic/c16rtomb.cpp",
836 "bionic/c32rtomb.cpp",
837 "bionic/chmod.cpp",
838 "bionic/chown.cpp",
839 "bionic/clearenv.cpp",
840 "bionic/clock.cpp",
841 "bionic/clock_getcpuclockid.cpp",
842 "bionic/clock_nanosleep.cpp",
843 "bionic/clone.cpp",
844 "bionic/ctype.cpp",
845 "bionic/dirent.cpp",
846 "bionic/dup.cpp",
847 "bionic/environ.cpp",
848 "bionic/error.cpp",
849 "bionic/eventfd.cpp",
850 "bionic/exec.cpp",
851 "bionic/execinfo.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800852 "bionic/exit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800853 "bionic/faccessat.cpp",
854 "bionic/fchmod.cpp",
855 "bionic/fchmodat.cpp",
856 "bionic/fcntl.cpp",
857 "bionic/fdsan.cpp",
858 "bionic/fdtrack.cpp",
859 "bionic/ffs.cpp",
860 "bionic/fgetxattr.cpp",
861 "bionic/flistxattr.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000862 "bionic/fork.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800863 "bionic/fpclassify.cpp",
864 "bionic/fsetxattr.cpp",
865 "bionic/ftruncate.cpp",
866 "bionic/ftw.cpp",
867 "bionic/futimens.cpp",
868 "bionic/getcwd.cpp",
869 "bionic/getdomainname.cpp",
870 "bionic/getentropy.cpp",
871 "bionic/gethostname.cpp",
872 "bionic/getloadavg.cpp",
873 "bionic/getpagesize.cpp",
874 "bionic/getpgrp.cpp",
875 "bionic/getpid.cpp",
876 "bionic/getpriority.cpp",
877 "bionic/gettid.cpp",
878 "bionic/get_device_api_level.cpp",
879 "bionic/grp_pwd.cpp",
880 "bionic/grp_pwd_file.cpp",
881 "bionic/heap_zero_init.cpp",
882 "bionic/iconv.cpp",
883 "bionic/icu_wrappers.cpp",
884 "bionic/ifaddrs.cpp",
885 "bionic/inotify_init.cpp",
886 "bionic/ioctl.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800887 "bionic/isatty.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800888 "bionic/killpg.cpp",
889 "bionic/langinfo.cpp",
Elliott Hughes219e6022024-08-27 19:12:08 +0000890 "bionic/lchmod.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800891 "bionic/lchown.cpp",
892 "bionic/lfs64_support.cpp",
893 "bionic/libc_init_common.cpp",
894 "bionic/libgen.cpp",
895 "bionic/link.cpp",
896 "bionic/locale.cpp",
897 "bionic/lockf.cpp",
898 "bionic/lstat.cpp",
899 "bionic/mblen.cpp",
900 "bionic/mbrtoc16.cpp",
901 "bionic/mbrtoc32.cpp",
902 "bionic/mempcpy.cpp",
903 "bionic/memset_explicit.cpp",
904 "bionic/mkdir.cpp",
905 "bionic/mkfifo.cpp",
906 "bionic/mknod.cpp",
907 "bionic/mntent.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800908 "bionic/netdb.cpp",
Elliott Hughes3ed6e722024-02-16 01:18:01 +0000909 "bionic/net_if.cpp",
910 "bionic/netinet_ether.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800911 "bionic/netinet_in.cpp",
912 "bionic/nl_types.cpp",
913 "bionic/open.cpp",
914 "bionic/pathconf.cpp",
915 "bionic/pause.cpp",
916 "bionic/pidfd.cpp",
917 "bionic/pipe.cpp",
918 "bionic/poll.cpp",
919 "bionic/posix_fadvise.cpp",
920 "bionic/posix_fallocate.cpp",
921 "bionic/posix_madvise.cpp",
922 "bionic/posix_timers.cpp",
923 "bionic/preadv_pwritev.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000924 "bionic/pthread_atfork.cpp",
925 "bionic/pthread_attr.cpp",
926 "bionic/pthread_barrier.cpp",
927 "bionic/pthread_cond.cpp",
928 "bionic/pthread_create.cpp",
929 "bionic/pthread_detach.cpp",
930 "bionic/pthread_equal.cpp",
931 "bionic/pthread_exit.cpp",
Elliott Hughese117d6e2024-11-14 17:31:13 +0000932 "bionic/pthread_getaffinity.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000933 "bionic/pthread_getcpuclockid.cpp",
934 "bionic/pthread_getschedparam.cpp",
935 "bionic/pthread_gettid_np.cpp",
936 "bionic/pthread_internal.cpp",
937 "bionic/pthread_join.cpp",
938 "bionic/pthread_key.cpp",
939 "bionic/pthread_kill.cpp",
940 "bionic/pthread_mutex.cpp",
941 "bionic/pthread_once.cpp",
942 "bionic/pthread_rwlock.cpp",
943 "bionic/pthread_sigqueue.cpp",
944 "bionic/pthread_self.cpp",
945 "bionic/pthread_setname_np.cpp",
Elliott Hughese117d6e2024-11-14 17:31:13 +0000946 "bionic/pthread_setaffinity.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000947 "bionic/pthread_setschedparam.cpp",
948 "bionic/pthread_spinlock.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800949 "bionic/ptrace.cpp",
950 "bionic/pty.cpp",
951 "bionic/raise.cpp",
952 "bionic/rand.cpp",
953 "bionic/readlink.cpp",
954 "bionic/realpath.cpp",
955 "bionic/reboot.cpp",
956 "bionic/recv.cpp",
957 "bionic/recvmsg.cpp",
958 "bionic/rename.cpp",
959 "bionic/rmdir.cpp",
960 "bionic/scandir.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800961 "bionic/sched_cpualloc.cpp",
962 "bionic/sched_cpucount.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800963 "bionic/sched_getaffinity.cpp",
964 "bionic/sched_getcpu.cpp",
965 "bionic/semaphore.cpp",
966 "bionic/send.cpp",
967 "bionic/setegid.cpp",
968 "bionic/seteuid.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000969 "bionic/setjmp_cookie.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800970 "bionic/setpgrp.cpp",
971 "bionic/sigaction.cpp",
972 "bionic/signal.cpp",
973 "bionic/sigprocmask.cpp",
974 "bionic/sleep.cpp",
975 "bionic/socketpair.cpp",
976 "bionic/spawn.cpp",
977 "bionic/stat.cpp",
978 "bionic/stdlib_l.cpp",
979 "bionic/strerror.cpp",
980 "bionic/string_l.cpp",
981 "bionic/strings_l.cpp",
982 "bionic/strsignal.cpp",
983 "bionic/strtol.cpp",
984 "bionic/strtold.cpp",
985 "bionic/swab.cpp",
986 "bionic/symlink.cpp",
987 "bionic/sync_file_range.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000988 "bionic/sysconf.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800989 "bionic/sys_epoll.cpp",
990 "bionic/sys_msg.cpp",
991 "bionic/sys_sem.cpp",
992 "bionic/sys_shm.cpp",
993 "bionic/sys_signalfd.cpp",
994 "bionic/sys_statfs.cpp",
995 "bionic/sys_statvfs.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000996 "bionic/sys_thread_properties.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800997 "bionic/sys_time.cpp",
998 "bionic/sysinfo.cpp",
999 "bionic/syslog.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001000 "bionic/sysprop_helpers.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001001 "bionic/system.cpp",
1002 "bionic/system_property_api.cpp",
1003 "bionic/system_property_set.cpp",
1004 "bionic/tdestroy.cpp",
1005 "bionic/termios.cpp",
1006 "bionic/thread_private.cpp",
1007 "bionic/threads.cpp",
1008 "bionic/time.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001009 "bionic/tmpfile.cpp",
1010 "bionic/umount.cpp",
1011 "bionic/unlink.cpp",
1012 "bionic/usleep.cpp",
1013 "bionic/utmp.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001014 "bionic/vdso.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001015 "bionic/wait.cpp",
1016 "bionic/wchar.cpp",
1017 "bionic/wchar_l.cpp",
1018 "bionic/wcstod.cpp",
1019 "bionic/wctype.cpp",
1020 "bionic/wcwidth.cpp",
1021 "bionic/wmempcpy.cpp",
1022
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001023 // Forked but not yet cleaned up/rewritten stdio code.
1024 // TODO: finish cleanup.
1025 "stdio/fmemopen.cpp",
1026 "stdio/parsefloat.c",
1027 "stdio/refill.c",
1028 "stdio/stdio.cpp",
1029 "stdio/stdio_ext.cpp",
1030 "stdio/vfscanf.cpp",
1031 "stdio/vfwscanf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001032 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001033
1034 arch: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001035 arm: {
Elliott Hughes1b61d782019-06-04 10:38:34 -07001036 asflags: libc_common_flags + ["-mno-restrict-it"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001037 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -08001038 "arch-arm/bionic/__aeabi_read_tp.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001039 "arch-arm/bionic/__bionic_clone.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001040 "arch-arm/bionic/__restore.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001041 "arch-arm/bionic/_exit_with_stack_teardown.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001042 "arch-arm/bionic/atomics_arm.c",
1043 "arch-arm/bionic/bpabi.c",
Yi Kong165b1cf2019-02-13 14:10:10 -08001044 "arch-arm/bionic/libcrt_compat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001045 "arch-arm/bionic/popcount_tab.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001046 "arch-arm/bionic/setjmp.S",
1047 "arch-arm/bionic/syscall.S",
1048 "arch-arm/bionic/vfork.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001049
Haibo Huangea9957a2018-11-19 11:00:32 -08001050 "arch-arm/cortex-a7/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001051 "arch-arm/cortex-a7/bionic/memset.S",
1052
1053 "arch-arm/cortex-a9/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001054 "arch-arm/cortex-a9/bionic/memset.S",
1055 "arch-arm/cortex-a9/bionic/stpcpy.S",
1056 "arch-arm/cortex-a9/bionic/strcat.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001057 "arch-arm/cortex-a9/bionic/strcpy.S",
1058 "arch-arm/cortex-a9/bionic/strlen.S",
1059
Elliott Hughesaefe9992023-11-08 12:04:41 -08001060 "arch-arm/cortex-a15/bionic/memcpy.S",
1061 "arch-arm/cortex-a15/bionic/memmove.S",
1062 "arch-arm/cortex-a15/bionic/memset.S",
1063 "arch-arm/cortex-a15/bionic/stpcpy.S",
1064 "arch-arm/cortex-a15/bionic/strcat.S",
1065 "arch-arm/cortex-a15/bionic/strcmp.S",
1066 "arch-arm/cortex-a15/bionic/strcpy.S",
1067 "arch-arm/cortex-a15/bionic/strlen.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001068
1069 "arch-arm/cortex-a53/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001070
Haibo Huang01bfd892018-12-03 15:05:16 -08001071 "arch-arm/cortex-a55/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001072
Elliott Hughesaefe9992023-11-08 12:04:41 -08001073 "arch-arm/generic/bionic/memcmp.S",
1074 "arch-arm/generic/bionic/memmove.S",
1075 "arch-arm/generic/bionic/memset.S",
1076 "arch-arm/generic/bionic/stpcpy.c",
1077 "arch-arm/generic/bionic/strcat.c",
1078 "arch-arm/generic/bionic/strcmp.S",
1079 "arch-arm/generic/bionic/strcpy.S",
1080 "arch-arm/generic/bionic/strlen.c",
1081
1082 "arch-arm/krait/bionic/memcpy.S",
1083 "arch-arm/krait/bionic/memset.S",
1084
Haibo Huangea9957a2018-11-19 11:00:32 -08001085 "arch-arm/kryo/bionic/memcpy.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001086
1087 "bionic/strchr.cpp",
1088 "bionic/strchrnul.cpp",
1089 "bionic/strnlen.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001090 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001091 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001092 arm64: {
1093 srcs: [
Dan Willemsen3e621712016-02-03 21:48:08 -08001094 "arch-arm64/bionic/__bionic_clone.S",
1095 "arch-arm64/bionic/_exit_with_stack_teardown.S",
1096 "arch-arm64/bionic/setjmp.S",
1097 "arch-arm64/bionic/syscall.S",
1098 "arch-arm64/bionic/vfork.S",
Vaisakh K V83e55842024-03-29 12:47:39 +05301099 "arch-arm64/oryon/memcpy-nt.S",
Vaisakh K V54a61212024-03-29 13:32:45 +05301100 "arch-arm64/oryon/memset-nt.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001101 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001102 },
1103
Elliott Hughesebc19a92022-10-14 23:25:36 +00001104 riscv64: {
1105 srcs: [
1106 "arch-riscv64/bionic/__bionic_clone.S",
1107 "arch-riscv64/bionic/_exit_with_stack_teardown.S",
Elliott Hughese1905ed2022-10-17 23:23:36 +00001108 "arch-riscv64/bionic/setjmp.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001109 "arch-riscv64/bionic/syscall.S",
1110 "arch-riscv64/bionic/vfork.S",
Yun Hsiang40a82d02023-05-26 10:10:40 +08001111
Elliott Hughesaefe9992023-11-08 12:04:41 -08001112 "arch-riscv64/string/memchr_v.S",
1113 "arch-riscv64/string/memcmp_v.S",
1114 "arch-riscv64/string/memcpy_v.S",
1115 "arch-riscv64/string/memmove_v.S",
1116 "arch-riscv64/string/memset_v.S",
1117 "arch-riscv64/string/stpcpy_v.S",
1118 "arch-riscv64/string/strcat_v.S",
1119 "arch-riscv64/string/strchr_v.S",
1120 "arch-riscv64/string/strcmp_v.S",
1121 "arch-riscv64/string/strcpy_v.S",
1122 "arch-riscv64/string/strlen_v.S",
1123 "arch-riscv64/string/strncat_v.S",
1124 "arch-riscv64/string/strncmp_v.S",
1125 "arch-riscv64/string/strncpy_v.S",
1126 "arch-riscv64/string/strnlen_v.S",
1127
1128 "arch-riscv64/string/memchr.c",
1129 "arch-riscv64/string/memcmp.c",
1130 "arch-riscv64/string/memcpy.c",
1131 "arch-riscv64/string/memmove.c",
1132 "arch-riscv64/string/memset.c",
1133 "arch-riscv64/string/stpcpy.c",
1134 "arch-riscv64/string/strcat.c",
1135 "arch-riscv64/string/strchr.c",
1136 "arch-riscv64/string/strcmp.c",
1137 "arch-riscv64/string/strcpy.c",
1138 "arch-riscv64/string/strlen.c",
1139 "arch-riscv64/string/strncat.c",
1140 "arch-riscv64/string/strncmp.c",
1141 "arch-riscv64/string/strncpy.c",
1142 "arch-riscv64/string/strnlen.c",
Prashanth Swaminathana4d71022023-10-30 17:35:19 -07001143
Elliott Hughes7d136662023-10-27 15:40:32 -07001144 "bionic/strchrnul.cpp",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001145 ],
1146 },
1147
Dan Willemsen208ae172015-09-16 16:33:27 -07001148 x86: {
1149 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001150 "arch-x86/bionic/__bionic_clone.S",
1151 "arch-x86/bionic/_exit_with_stack_teardown.S",
1152 "arch-x86/bionic/libcrt_compat.c",
Elliott Hughes7d136662023-10-27 15:40:32 -07001153 "arch-x86/bionic/setjmp.S",
1154 "arch-x86/bionic/syscall.S",
1155 "arch-x86/bionic/vfork.S",
1156 "arch-x86/bionic/__x86.get_pc_thunk.S",
1157
Elliott Hughesed777142022-07-25 16:25:11 +00001158 "arch-x86/string/sse2-memchr-atom.S",
1159 "arch-x86/string/sse2-memmove-slm.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001160 "arch-x86/string/sse2-memset-slm.S",
1161 "arch-x86/string/sse2-stpcpy-slm.S",
1162 "arch-x86/string/sse2-stpncpy-slm.S",
1163 "arch-x86/string/sse2-strchr-atom.S",
1164 "arch-x86/string/sse2-strcpy-slm.S",
1165 "arch-x86/string/sse2-strlen-slm.S",
1166 "arch-x86/string/sse2-strncpy-slm.S",
1167 "arch-x86/string/sse2-strnlen-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001168
1169 "arch-x86/string/ssse3-memcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001170 "arch-x86/string/ssse3-strcat-atom.S",
1171 "arch-x86/string/ssse3-strcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001172 "arch-x86/string/ssse3-strncat-atom.S",
1173 "arch-x86/string/ssse3-strncmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001174
1175 "arch-x86/string/sse4-memcmp-slm.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001176
1177 "bionic/strchrnul.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001178 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001179 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001180 x86_64: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001181 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001182 "arch-x86_64/bionic/__bionic_clone.S",
1183 "arch-x86_64/bionic/_exit_with_stack_teardown.S",
1184 "arch-x86_64/bionic/__restore_rt.S",
1185 "arch-x86_64/bionic/setjmp.S",
1186 "arch-x86_64/bionic/syscall.S",
1187 "arch-x86_64/bionic/vfork.S",
1188
ahs919fb7f2022-06-10 07:11:14 +05301189 "arch-x86_64/string/avx2-memset-kbl.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001190 "arch-x86_64/string/sse2-memmove-slm.S",
1191 "arch-x86_64/string/sse2-memset-slm.S",
1192 "arch-x86_64/string/sse2-stpcpy-slm.S",
1193 "arch-x86_64/string/sse2-stpncpy-slm.S",
1194 "arch-x86_64/string/sse2-strcat-slm.S",
1195 "arch-x86_64/string/sse2-strcpy-slm.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001196 "arch-x86_64/string/sse2-strlen-slm.S",
1197 "arch-x86_64/string/sse2-strncat-slm.S",
1198 "arch-x86_64/string/sse2-strncpy-slm.S",
1199 "arch-x86_64/string/sse4-memcmp-slm.S",
1200 "arch-x86_64/string/ssse3-strcmp-slm.S",
1201 "arch-x86_64/string/ssse3-strncmp-slm.S",
1202 ],
1203 },
Dan Willemsen268a6732015-10-15 14:49:45 -07001204 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001205
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001206 multilib: {
1207 lib32: {
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001208 srcs: [
1209 // off64_t/time64_t support on LP32.
1210 "bionic/legacy_32_bit_support.cpp",
1211 "bionic/time64.c",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001212 ],
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001213 },
1214 },
1215
1216 local_include_dirs: ["stdio"],
1217 generated_headers: ["generated_android_ids"],
1218
1219 whole_static_libs: [
George Burgess IVc5a98e62024-11-18 14:50:32 -07001220 "//external/llvm-libc:llvmlibc",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001221 "libsystemproperties",
1222 ],
1223
Colin Cross50c21ab2015-10-31 23:03:05 -07001224 cppflags: ["-Wold-style-cast"],
Dan Willemsen268a6732015-10-15 14:49:45 -07001225 include_dirs: ["bionic/libstdc++/include"],
1226 name: "libc_bionic",
Dan Willemsen268a6732015-10-15 14:49:45 -07001227}
1228
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001229genrule {
1230 name: "generated_android_ids",
Colin Cross35bbed82017-01-17 18:16:07 -08001231 out: ["generated_android_ids.h"],
1232 srcs: [":android_filesystem_config_header"],
Cole Faustb1a0a9d2023-11-28 17:51:16 -08001233 tools: ["fs_config_generator"],
1234 cmd: "$(location fs_config_generator) aidarray $(in) > $(out)",
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001235}
1236
Dan Willemsen268a6732015-10-15 14:49:45 -07001237// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001238// libc_syscalls.a
1239// ========================================================
1240
Elliott Hughes782c4852019-04-16 12:31:00 -07001241genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001242 name: "syscalls-arm",
Elliott Hughes782c4852019-04-16 12:31:00 -07001243 out: ["syscalls-arm.S"],
1244 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001245 tools: ["gensyscalls"],
1246 cmd: "$(location gensyscalls) arm $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001247}
1248
1249genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001250 name: "syscalls-arm64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001251 out: ["syscalls-arm64.S"],
1252 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001253 tools: ["gensyscalls"],
1254 cmd: "$(location gensyscalls) arm64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001255}
1256
1257genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001258 name: "syscalls-riscv64",
Elliott Hughes704772b2022-10-10 17:06:43 +00001259 out: ["syscalls-riscv64.S"],
1260 srcs: ["SYSCALLS.TXT"],
1261 tools: ["gensyscalls"],
1262 cmd: "$(location gensyscalls) riscv64 $(in) > $(out)",
1263}
1264
1265genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001266 name: "syscalls-x86",
Elliott Hughes782c4852019-04-16 12:31:00 -07001267 out: ["syscalls-x86.S"],
1268 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001269 tools: ["gensyscalls"],
1270 cmd: "$(location gensyscalls) x86 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001271}
1272
1273genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001274 name: "syscalls-x86_64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001275 out: ["syscalls-x86_64.S"],
1276 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001277 tools: ["gensyscalls"],
1278 cmd: "$(location gensyscalls) x86_64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001279}
1280
Dan Willemsen208ae172015-09-16 16:33:27 -07001281cc_library_static {
Colin Cross27c43c52016-04-07 13:27:24 -07001282 defaults: ["libc_defaults"],
Josh Gao0e0e3702017-10-12 13:34:42 -07001283 srcs: ["bionic/__set_errno.cpp"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001284 arch: {
1285 arm: {
Cole Faustf5968d82023-04-11 15:20:19 -07001286 srcs: [":syscalls-arm"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001287 },
1288 arm64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001289 srcs: [":syscalls-arm64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001290 },
Elliott Hughes704772b2022-10-10 17:06:43 +00001291 riscv64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001292 srcs: [":syscalls-riscv64"],
Elliott Hughes704772b2022-10-10 17:06:43 +00001293 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001294 x86: {
Cole Faustf5968d82023-04-11 15:20:19 -07001295 srcs: [":syscalls-x86"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001296 },
1297 x86_64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001298 srcs: [":syscalls-x86_64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001299 },
1300 },
1301 name: "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001302}
1303
1304// ========================================================
1305// libc_aeabi.a
1306// This is an LP32 ARM-only library that needs to be built with -fno-builtin
1307// to avoid infinite recursion. For the other architectures we just build an
1308// empty library to keep this makefile simple.
1309// ========================================================
1310
1311cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001312 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001313 arch: {
1314 arm: {
1315 srcs: ["arch-arm/bionic/__aeabi.c"],
1316 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001317 },
1318 name: "libc_aeabi",
Colin Cross50c21ab2015-10-31 23:03:05 -07001319 cflags: ["-fno-builtin"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001320}
1321
1322// ========================================================
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001323// libc_common.a --- everything shared by libc.a and libc.so
Dan Willemsen208ae172015-09-16 16:33:27 -07001324// ========================================================
Elliott Hughesb0948922024-01-26 00:28:12 +00001325
Dan Willemsen208ae172015-09-16 16:33:27 -07001326cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001327 defaults: ["libc_defaults"],
Elliott Hughesb0948922024-01-26 00:28:12 +00001328 name: "libc_common",
1329
Dan Willemsen208ae172015-09-16 16:33:27 -07001330 whole_static_libs: [
Peter Collingbourne337a5b32020-02-21 12:11:02 -08001331 "libarm-optimized-routines-string",
Rupert Shuttleworth78f48a52021-03-16 06:39:19 +00001332 "libasync_safe",
Dan Willemsen208ae172015-09-16 16:33:27 -07001333 "libc_bionic",
Ryan Prichard249757b2019-11-01 17:18:28 -07001334 "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -07001335 "libc_dns",
George Burgess IV6cb06872017-07-21 13:28:42 -07001336 "libc_fortify",
Dan Willemsen208ae172015-09-16 16:33:27 -07001337 "libc_freebsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001338 "libc_freebsd_large_stack",
Elliott Hughesc2043342023-07-20 20:24:09 +00001339 "libc_freebsd_ldexp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001340 "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -07001341 "libc_netbsd",
1342 "libc_openbsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001343 "libc_openbsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001344 "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001345 "libc_tzcode",
Elliott Hughes816fab92016-05-27 17:57:46 -07001346 "libstdc++",
Dan Willemsen208ae172015-09-16 16:33:27 -07001347 ],
1348
1349 arch: {
1350 arm: {
1351 whole_static_libs: ["libc_aeabi"],
1352 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001353 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001354}
1355
1356// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001357// libc_static_dispatch.a/libc_dynamic_dispatch.a --- string/memory "ifuncs"
1358// (Actually ifuncs for libc.so, but a home-grown alternative for libc.a.)
Haibo Huangf71edfa2018-11-12 10:06:56 -08001359// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001360
1361cc_defaults {
1362 name: "libc_dispatch_defaults",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001363 defaults: ["libc_defaults"],
Haibo Huangb9244ff2018-08-11 10:12:13 -07001364 arch: {
ahs919fb7f2022-06-10 07:11:14 +05301365 x86_64: {
1366 srcs: ["arch-x86_64/dynamic_function_dispatch.cpp"],
1367 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001368 x86: {
1369 srcs: ["arch-x86/dynamic_function_dispatch.cpp"],
1370 },
Haibo Huangea9957a2018-11-19 11:00:32 -08001371 arm: {
Elliott Hughes927fe992019-01-31 22:29:22 +00001372 srcs: ["arch-arm/dynamic_function_dispatch.cpp"],
Haibo Huangea9957a2018-11-19 11:00:32 -08001373 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001374 arm64: {
1375 srcs: ["arch-arm64/dynamic_function_dispatch.cpp"],
1376 },
Elliott Hughesaefe9992023-11-08 12:04:41 -08001377 riscv64: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001378 srcs: ["arch-riscv64/dynamic_function_dispatch.cpp"],
Elliott Hughesaefe9992023-11-08 12:04:41 -08001379 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001380 },
Elliott Hughesadc41712024-08-16 13:08:11 +00001381 // Prevent the compiler from inserting calls to libc/taking the address of
1382 // a jump table from within an ifunc (or, in the static case, code that
1383 // can be executed arbitrarily early).
1384 cflags: [
1385 "-ffreestanding",
1386 "-fno-stack-protector",
1387 "-fno-jump-tables",
1388 ],
1389}
1390
1391cc_library_static {
1392 name: "libc_static_dispatch",
1393 defaults: ["libc_dispatch_defaults"],
1394 cflags: [
1395 "-DBIONIC_STATIC_DISPATCH",
1396 ],
1397}
1398
1399cc_library_static {
1400 name: "libc_dynamic_dispatch",
1401 defaults: ["libc_dispatch_defaults"],
1402 cflags: [
1403 "-DBIONIC_DYNAMIC_DISPATCH",
1404 ],
Ryan Prichard249757b2019-11-01 17:18:28 -07001405}
1406
1407// ========================================================
1408// libc_common_static.a For static binaries.
1409// ========================================================
1410cc_library_static {
1411 defaults: ["libc_defaults"],
1412 name: "libc_common_static",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001413
Haibo Huangf71edfa2018-11-12 10:06:56 -08001414 whole_static_libs: [
1415 "libc_common",
Ryan Prichard249757b2019-11-01 17:18:28 -07001416 "libc_static_dispatch",
1417 ],
1418}
1419
1420// ========================================================
1421// libc_common_shared.a For shared libraries.
1422// ========================================================
1423cc_library_static {
1424 defaults: ["libc_defaults"],
1425 name: "libc_common_shared",
1426
1427 whole_static_libs: [
1428 "libc_common",
1429 "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001430 ],
1431}
1432
Ryan Prichard22a6a052019-10-10 23:59:30 -07001433// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static
1434// executable.
1435cc_library_static {
1436 name: "libc_unwind_static",
1437 defaults: ["libc_defaults"],
1438 cflags: ["-DLIBC_STATIC"],
1439
1440 srcs: ["bionic/dl_iterate_phdr_static.cpp"],
1441 arch: {
1442 // arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs
1443 arm: {
1444 srcs: ["arch-arm/bionic/exidx_static.c"],
1445 },
1446 },
1447}
1448
Haibo Huangf71edfa2018-11-12 10:06:56 -08001449// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001450// libc_nomalloc.a
1451// ========================================================
1452//
Ryan Prichard249757b2019-11-01 17:18:28 -07001453// This is a version of the static C library used by the dynamic linker that exclude malloc. It also
1454// excludes functions selected using ifunc's (e.g. for string.h). Link in either
1455// libc_static_dispatch or libc_dynamic_dispatch to provide those functions.
Dan Willemsen208ae172015-09-16 16:33:27 -07001456
1457cc_library_static {
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -08001458 name: "libc_nomalloc",
Colin Cross50c21ab2015-10-31 23:03:05 -07001459 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001460
Colin Crossa3f9fca2016-01-11 13:20:55 -08001461 whole_static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -07001462 "libc_common",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001463 "libc_init_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001464 "libc_unwind_static",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001465 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001466}
1467
dimitryc0c0ef62018-12-05 16:33:52 +01001468filegroup {
1469 name: "libc_sources_shared",
1470 srcs: [
1471 "arch-common/bionic/crtbegin_so.c",
1472 "arch-common/bionic/crtbrand.S",
Christopher Ferris0ac5da02024-11-07 06:59:33 +00001473 "bionic/android_mallopt.cpp",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001474 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001475 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001476 "bionic/icu.cpp",
1477 "bionic/malloc_common.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001478 "bionic/malloc_common_dynamic.cpp",
Ryan Savitski175c8862020-01-02 19:54:57 +00001479 "bionic/android_profiling_dynamic.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001480 "bionic/malloc_heapprofd.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001481 "bionic/malloc_limit.cpp",
Peter Collingbourne570de332019-12-11 10:00:58 -08001482 "bionic/ndk_cruft.cpp",
1483 "bionic/ndk_cruft_data.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001484 "bionic/NetdClient.cpp",
1485 "arch-common/bionic/crtend_so.S",
1486 ],
1487}
1488
1489filegroup {
1490 name: "libc_sources_static",
1491 srcs: [
Christopher Ferris0ac5da02024-11-07 06:59:33 +00001492 "bionic/android_mallopt.cpp",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001493 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001494 "bionic/heap_tagging.cpp",
Elliott Hughes72b0f3b2024-07-02 20:22:35 +00001495 "bionic/icu_static.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001496 "bionic/malloc_common.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001497 "bionic/malloc_limit.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001498 ],
1499}
1500
1501filegroup {
1502 name: "libc_sources_shared_arm",
1503 srcs: [
1504 "arch-arm/bionic/exidx_dynamic.c",
1505 "arch-arm/bionic/atexit_legacy.c",
1506 ],
1507}
1508
Dan Willemsen208ae172015-09-16 16:33:27 -07001509// ========================================================
1510// libc.a + libc.so
1511// ========================================================
Florian Mayerc10d0642023-03-22 16:12:49 -07001512cc_defaults {
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001513 defaults: [
1514 "libc_defaults",
1515 "libc_native_allocator_defaults",
Elliott Hughes788075a2024-06-18 12:25:37 +00001516 "bug_24465209_workaround",
Elliott Hughes89aada12024-07-01 21:59:04 +00001517 "keep_symbols",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001518 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001519 name: "libc_library_defaults",
Colin Cross50c21ab2015-10-31 23:03:05 -07001520 product_variables: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001521 platform_sdk_version: {
1522 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1523 },
1524 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001525 static: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001526 srcs: [":libc_sources_static"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001527 cflags: ["-DLIBC_STATIC"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001528 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001529 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001530 "libc_init_static",
1531 "libc_common_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001532 "libc_unwind_static",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001533 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001534 },
1535 shared: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001536 srcs: [":libc_sources_shared"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001537 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001538 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001539 "libc_init_dynamic",
1540 "libc_common_shared",
Ryan Prichardcdf71752020-12-16 03:37:22 -08001541 "libunwind-exported",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001542 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001543 },
1544
Neil Fullera7db90f2019-04-25 09:28:27 +01001545 required: [
MarkDacekd88d7ea2022-06-28 20:14:58 +00001546 "tzdata_prebuilt",
1547 "tz_version_prebuilt", // Version metadata for tzdata to help debugging.
Neil Fullera7db90f2019-04-25 09:28:27 +01001548 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001549
Colin Cross4ce94d22016-11-15 13:15:43 -08001550 // Do not pack libc.so relocations; see http://b/20645321 for details.
1551 pack_relocations: false,
1552
dimitry06016f22018-01-05 11:39:28 +01001553 shared_libs: [
1554 "ld-android",
1555 "libdl",
1556 ],
Jiyong Park3ff116a2019-04-02 23:04:52 +09001557 static_libs: [
1558 "libdl_android",
1559 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001560
1561 nocrt: true,
1562
Dan Willemsen208ae172015-09-16 16:33:27 -07001563 arch: {
1564 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001565 version_script: ":libc.arm.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001566 no_libcrt: true,
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001567
Dan Willemsen208ae172015-09-16 16:33:27 -07001568 shared: {
dimitryc0c0ef62018-12-05 16:33:52 +01001569 srcs: [":libc_sources_shared_arm"],
Dan Willemsen0c657082016-05-12 01:43:07 -07001570 // special for arm
1571 cflags: ["-DCRT_LEGACY_WORKAROUND"],
Elliott Hughes89aada12024-07-01 21:59:04 +00001572 // For backwards compatibility, some arm32 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001573 static_libs: ["libclang_rt.builtins-exported"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001574 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001575
Elliott Hughes89aada12024-07-01 21:59:04 +00001576 ldflags: [
1577 // Since we preserve the debug_frame for libc, do not compress
1578 // in this case to make unwinds as fast as possible.
1579 "-Wl,--compress-debug-sections=none",
1580 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001581 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001582 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001583 version_script: ":libc.arm64.map",
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001584 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001585 riscv64: {
1586 version_script: ":libc.riscv64.map",
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001587 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001588 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001589 version_script: ":libc.x86.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001590 no_libcrt: true,
1591
1592 shared: {
Elliott Hughes89aada12024-07-01 21:59:04 +00001593 // For backwards compatibility, some x86 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001594 static_libs: ["libclang_rt.builtins-exported"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001595 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001596 },
1597 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001598 version_script: ":libc.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001599 },
1600 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +09001601
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001602 apex_available: [
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001603 "com.android.runtime",
1604 ],
1605
Colin Cross7edd0082021-10-28 13:20:35 -07001606 target: {
1607 native_bridge: {
1608 shared: {
1609 installable: false,
1610 },
1611 },
1612 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001613}
1614
Florian Mayerc10d0642023-03-22 16:12:49 -07001615cc_library {
1616 name: "libc",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001617 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001618 "libc_library_defaults",
1619 ],
1620 stubs: {
1621 symbol_file: "libc.map.txt",
1622 versions: [
1623 "29",
1624 "R",
1625 "current",
1626 ],
1627 },
1628 static_ndk_lib: true,
1629 llndk: {
1630 symbol_file: "libc.map.txt",
1631 export_headers_as_system: true,
Dan Alberte9f02e02024-08-28 23:20:20 +00001632 export_llndk_headers: ["libc_headers"],
Florian Mayerc10d0642023-03-22 16:12:49 -07001633 },
1634}
1635
1636cc_library {
1637 name: "libc_hwasan",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001638 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001639 "libc_library_defaults",
1640 ],
1641 sanitize: {
1642 hwaddress: true,
1643 },
1644 enabled: false,
Florian Mayerff116ed2023-04-14 17:38:53 -07001645 target: {
1646 android_arm64: {
Florian Mayerc10d0642023-03-22 16:12:49 -07001647 enabled: true,
1648 },
1649 },
1650 stem: "libc",
1651 relative_install_path: "hwasan",
1652 // We don't really need the stubs, but this needs to stay to trigger the
1653 // symlink logic in soong.
1654 stubs: {
1655 symbol_file: "libc.map.txt",
1656 },
1657 native_bridge_supported: false,
1658 // It is never correct to depend on this directly. This is only
Kiyoung Kim06a86dc2024-12-02 11:18:51 +09001659 // needed for the runtime apex, and in base_system.mk, and system_image_defaults
1660 // which is default module for soong-defined system image.
1661 visibility: [
1662 "//bionic/apex",
1663 "//build/make/target/product/generic",
1664 //TODO(b/381985636) : Remove visibility to Soong-defined GSI once resolved
1665 "//build/make/target/product/gsi",
1666 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001667}
1668
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001669genrule {
1670 name: "libc.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001671 out: ["libc.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001672 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001673 tools: ["generate-version-script"],
1674 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001675}
1676
1677genrule {
1678 name: "libc.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001679 out: ["libc.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001680 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001681 tools: ["generate-version-script"],
1682 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001683}
1684
1685genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001686 name: "libc.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001687 out: ["libc.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001688 srcs: ["libc.map.txt"],
1689 tools: ["generate-version-script"],
1690 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1691}
1692
1693genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001694 name: "libc.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001695 out: ["libc.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001696 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001697 tools: ["generate-version-script"],
1698 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001699}
1700
1701genrule {
1702 name: "libc.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001703 out: ["libc.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001704 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001705 tools: ["generate-version-script"],
1706 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001707}
1708
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001709// Headers that only other parts of the platform can include.
1710cc_library_headers {
1711 name: "bionic_libc_platform_headers",
Martin Stjernholma2763432020-04-23 16:47:19 +01001712 defaults: ["linux_bionic_supported"],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001713 visibility: [
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001714 "//art:__subpackages__",
Josh Gao97271922019-11-06 13:15:00 -08001715 "//bionic:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001716 "//frameworks:__subpackages__",
Roman Kiryanov067f5182020-05-07 14:58:30 -07001717 "//device/generic/goldfish-opengl:__subpackages__",
Mitch Phillips3309b3d2020-03-25 15:05:48 -07001718 "//external/gwp_asan:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001719 "//external/perfetto:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001720 "//external/scudo:__subpackages__",
Josh Gao5074e7d2019-12-13 13:55:53 -08001721 "//system/core/debuggerd:__subpackages__",
Florian Mayerf5d70ce2022-09-13 13:58:30 -07001722 "//system/core/init:__subpackages__",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001723 "//system/core/libcutils:__subpackages__",
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001724 "//system/memory/libmemunreachable:__subpackages__",
Baligh Uddindb0c6de2020-10-15 04:49:00 +00001725 "//system/unwinding/libunwindstack:__subpackages__",
Peter Collingbourne15418002020-05-12 16:02:50 -07001726 "//tools/security/sanitizer-status:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001727 ],
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001728 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001729 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001730 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001731 vendor_ramdisk_available: true,
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001732 recovery_available: true,
1733 native_bridge_supported: true,
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001734 export_include_dirs: [
1735 "platform",
1736 ],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001737 system_shared_libs: [],
1738 stl: "none",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001739 sdk_version: "current",
Jiyong Park4ede1602020-04-28 18:21:08 +09001740
Steven Moreland0cdf1322020-10-05 21:55:26 +00001741 min_sdk_version: "29",
Jiyong Park4ede1602020-04-28 18:21:08 +09001742 apex_available: [
1743 "//apex_available:platform",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001744 "//apex_available:anyapex",
Jiyong Park4ede1602020-04-28 18:21:08 +09001745 ],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001746}
1747
Logan Chien17af91b2019-01-15 21:19:56 +08001748cc_library_headers {
Dan Albert64a6efc2024-08-29 19:04:59 +00001749 name: "libc_uapi_headers",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001750 visibility: [
1751 "//external/musl",
Alistair Delvabad22722024-10-07 12:52:40 -07001752 "//external/rust/crates/v4l2r/android",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001753 ],
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001754 llndk: {
1755 llndk_headers: true,
1756 },
Logan Chien17af91b2019-01-15 21:19:56 +08001757 host_supported: true,
1758 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001759 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001760 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001761 vendor_ramdisk_available: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001762 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001763 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001764 apex_available: [
1765 "//apex_available:platform",
Jiyong Parkad9946c2020-03-30 18:36:07 +09001766 "//apex_available:anyapex",
1767 ],
Jooyung Han15c32a82020-04-16 18:26:45 +09001768 // used by most APEXes indirectly via libunwind_llvm
1769 min_sdk_version: "apex_inherit",
Logan Chien17af91b2019-01-15 21:19:56 +08001770
1771 no_libcrt: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001772 stl: "none",
1773 system_shared_libs: [],
1774
Peter Collingbournef2b1e032019-12-10 17:41:16 -08001775 // The build system generally requires that any dependencies of a target
1776 // with an sdk_version must have a lower sdk_version. By setting sdk_version
1777 // to 1 we let targets with an sdk_version that need to depend on the libc
1778 // headers but cannot depend on libc itself due to circular dependencies
1779 // (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
1780 // is correct because the headers can support any sdk_version.
1781 sdk_version: "1",
1782
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001783 export_system_include_dirs: [
Logan Chien17af91b2019-01-15 21:19:56 +08001784 "kernel/uapi",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001785 "kernel/android/scsi",
Logan Chien17af91b2019-01-15 21:19:56 +08001786 "kernel/android/uapi",
1787 ],
1788
1789 arch: {
1790 arm: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001791 export_system_include_dirs: ["kernel/uapi/asm-arm"],
Logan Chien17af91b2019-01-15 21:19:56 +08001792 },
1793 arm64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001794 export_system_include_dirs: ["kernel/uapi/asm-arm64"],
Logan Chien17af91b2019-01-15 21:19:56 +08001795 },
Elliott Hughes48e53332022-10-07 20:39:25 +00001796 riscv64: {
1797 export_system_include_dirs: ["kernel/uapi/asm-riscv"],
1798 },
Logan Chien17af91b2019-01-15 21:19:56 +08001799 x86: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001800 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001801 },
1802 x86_64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001803 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001804 },
1805 },
1806}
1807
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001808cc_library_headers {
1809 name: "libc_headers",
1810 host_supported: true,
1811 native_bridge_supported: true,
1812 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001813 product_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001814 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001815 vendor_ramdisk_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001816 recovery_available: true,
1817 sdk_version: "1",
1818
1819 apex_available: [
1820 "//apex_available:platform",
1821 "//apex_available:anyapex",
1822 ],
1823 // used by most APEXes indirectly via libunwind_llvm
1824 min_sdk_version: "apex_inherit",
1825 visibility: [
1826 "//bionic:__subpackages__", // visible to bionic
1827 // ... and only to these places (b/152668052)
1828 "//external/arm-optimized-routines",
1829 "//external/gwp_asan",
1830 "//external/jemalloc_new",
1831 "//external/libunwind_llvm",
Nick Desaulniers942ae552024-02-12 10:26:19 -08001832 "//external/llvm-libc",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001833 "//external/scudo",
1834 "//system/core/property_service/libpropertyinfoparser",
1835 "//system/extras/toolchain-extras",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001836 ],
1837
1838 stl: "none",
1839 no_libcrt: true,
1840 system_shared_libs: [],
1841
1842 target: {
1843 android: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001844 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001845 header_libs: ["libc_uapi_headers"],
1846 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001847 },
1848 linux_bionic: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001849 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001850 header_libs: ["libc_uapi_headers"],
1851 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001852 },
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001853 },
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001854}
1855
Dan Willemsen208ae172015-09-16 16:33:27 -07001856// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001857// libstdc++.so and libstdc++.a.
Dan Willemsen208ae172015-09-16 16:33:27 -07001858// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001859
Dan Willemsen208ae172015-09-16 16:33:27 -07001860cc_library {
Elliott Hughes788075a2024-06-18 12:25:37 +00001861 defaults: [
1862 "libc_defaults",
1863 "bug_24465209_workaround",
1864 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001865 include_dirs: ["bionic/libstdc++/include"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001866 srcs: [
1867 "bionic/__cxa_guard.cpp",
1868 "bionic/__cxa_pure_virtual.cpp",
1869 "bionic/new.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001870 ],
1871 name: "libstdc++",
Dan Albert40f15ec2017-10-27 11:21:20 -07001872 static_ndk_lib: true,
Isaac Chen5e7c90b2017-09-20 14:44:42 +08001873 static_libs: ["libasync_safe"],
Elliott Hughesc2043342023-07-20 20:24:09 +00001874 apex_available: [
1875 "//apex_available:platform",
1876 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001877
Dan Willemsen6b3be172018-12-03 13:57:20 -08001878 static: {
1879 system_shared_libs: [],
1880 },
Colin Crossb5bfe0b2021-07-13 16:26:28 -07001881 target: {
1882 bionic: {
1883 shared: {
1884 system_shared_libs: ["libc"],
1885 },
1886 },
Dan Willemsen6b3be172018-12-03 13:57:20 -08001887 },
1888
Dan Willemsen208ae172015-09-16 16:33:27 -07001889 arch: {
1890 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001891 version_script: ":libstdc++.arm.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001892 },
1893 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001894 version_script: ":libstdc++.arm64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001895 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001896 riscv64: {
1897 version_script: ":libstdc++.riscv64.map",
1898 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001899 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001900 version_script: ":libstdc++.x86.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001901 },
1902 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001903 version_script: ":libstdc++.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001904 },
1905 },
1906}
1907
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001908genrule {
1909 name: "libstdc++.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001910 out: ["libstdc++.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001911 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001912 tools: ["generate-version-script"],
1913 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001914}
1915
1916genrule {
1917 name: "libstdc++.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001918 out: ["libstdc++.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001919 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001920 tools: ["generate-version-script"],
1921 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001922}
1923
1924genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001925 name: "libstdc++.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001926 out: ["libstdc++.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001927 srcs: ["libstdc++.map.txt"],
1928 tools: ["generate-version-script"],
1929 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1930}
1931
1932genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001933 name: "libstdc++.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001934 out: ["libstdc++.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001935 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001936 tools: ["generate-version-script"],
1937 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001938}
1939
1940genrule {
1941 name: "libstdc++.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001942 out: ["libstdc++.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001943 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001944 tools: ["generate-version-script"],
1945 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001946}
1947
1948// ========================================================
1949// crt object files.
1950// ========================================================
1951
Colin Cross50c21ab2015-10-31 23:03:05 -07001952cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001953 name: "crt_and_memtag_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -08001954 defaults: ["linux_bionic_supported"],
Dan Willemsen230a7a42017-04-07 14:09:05 -07001955 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001956 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001957 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001958 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +09001959 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001960 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001961 apex_available: [
1962 "//apex_available:platform",
1963 "//apex_available:anyapex",
1964 ],
Dan Albertdc503f62020-07-15 17:22:18 -07001965 // Generate NDK variants of the CRT objects for every supported API level.
1966 min_sdk_version: "16",
1967 stl: "none",
1968 crt: true,
Elliott Hughesd50a1de2018-02-05 17:30:57 -08001969 cflags: [
1970 "-Wno-gcc-compat",
1971 "-Wall",
1972 "-Werror",
1973 ],
Peter Collingbourne7eb851c2019-09-26 12:16:06 -07001974 sanitize: {
1975 never: true,
1976 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001977}
1978
Colin Cross50c21ab2015-10-31 23:03:05 -07001979cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001980 name: "crt_defaults",
1981 defaults: ["crt_and_memtag_defaults"],
Colin Cross02f81372021-07-22 12:02:10 -07001982 system_shared_libs: [],
Colin Cross10d92682021-06-22 13:25:46 -07001983}
1984
1985cc_defaults {
Colin Cross50c21ab2015-10-31 23:03:05 -07001986 name: "crt_so_defaults",
Colin Cross7d7b3682017-11-03 13:38:40 -07001987 defaults: ["crt_defaults"],
Colin Crossab179442018-09-27 11:03:22 -07001988 stl: "none",
Dan Willemsen208ae172015-09-16 16:33:27 -07001989}
1990
Dan Willemsen208ae172015-09-16 16:33:27 -07001991cc_object {
1992 name: "crtbrand",
Jingwen Chen7e13cf22021-02-23 00:43:01 -05001993 local_include_dirs: [
Jingwen Chen7e13cf22021-02-23 00:43:01 -05001994 "private", // crtbrand.S depends on private/bionic_asm_note.h
1995 ],
Elliott Hughes6a30b712024-03-13 23:41:32 +00001996 // crtbrand.S needs to know the platform SDK version.
Dan Willemsen208ae172015-09-16 16:33:27 -07001997 product_variables: {
1998 platform_sdk_version: {
1999 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
2000 },
2001 },
2002 srcs: ["arch-common/bionic/crtbrand.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002003
Colin Cross7d7b3682017-11-03 13:38:40 -07002004 defaults: ["crt_so_defaults"],
Dan Alberteee46dc2023-04-04 23:27:52 +00002005 // crtbrand is an intermediate artifact, not a final CRT object.
2006 exclude_from_ndk_sysroot: true,
Dan Willemsen208ae172015-09-16 16:33:27 -07002007}
2008
Dan Willemsen208ae172015-09-16 16:33:27 -07002009cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002010 name: "crtbegin_so",
Dan Willemsen208ae172015-09-16 16:33:27 -07002011 local_include_dirs: ["include"],
2012 srcs: ["arch-common/bionic/crtbegin_so.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002013
Colin Cross7d7b3682017-11-03 13:38:40 -07002014 defaults: ["crt_so_defaults"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002015 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002016 "crtbrand",
2017 ],
2018}
2019
Dan Willemsen208ae172015-09-16 16:33:27 -07002020cc_object {
2021 name: "crtend_so",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002022 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002023 "private", // crtend_so.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002024 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002025 srcs: ["arch-common/bionic/crtend_so.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002026
Colin Cross7d7b3682017-11-03 13:38:40 -07002027 defaults: ["crt_so_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002028}
2029
Dan Willemsen208ae172015-09-16 16:33:27 -07002030cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002031 name: "crtbegin_static",
2032
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002033 local_include_dirs: [
2034 "include",
2035 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2036 ],
Liz Kammere718dd72021-03-09 15:00:06 -05002037
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002038 cflags: ["-DCRTBEGIN_STATIC"],
Yabin Cui744cfd32023-08-24 13:20:23 -07002039
Dan Willemsen208ae172015-09-16 16:33:27 -07002040 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002041 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002042 "crtbrand",
2043 ],
Colin Cross50c21ab2015-10-31 23:03:05 -07002044 defaults: ["crt_defaults"],
Jiyong Park268a6002021-01-12 23:14:37 +09002045 // When using libc.a, we're using the latest library regardless of target API level.
2046 min_sdk_version: "current",
Dan Willemsen208ae172015-09-16 16:33:27 -07002047}
2048
Dan Willemsen208ae172015-09-16 16:33:27 -07002049cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002050 name: "crtbegin_dynamic",
2051
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002052 local_include_dirs: [
2053 "include",
2054 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2055 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002056 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002057 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002058 "crtbrand",
2059 ],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -07002060 target: {
2061 linux_bionic: {
2062 generated_sources: ["host_bionic_linker_asm"],
2063 objs: [
2064 "linker_wrapper",
2065 ],
2066 },
2067 },
Colin Cross50c21ab2015-10-31 23:03:05 -07002068 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002069}
2070
Dan Willemsen208ae172015-09-16 16:33:27 -07002071cc_object {
2072 // We rename crtend.o to crtend_android.o to avoid a
2073 // name clash between gcc and bionic.
2074 name: "crtend_android",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002075 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002076 "private", // crtend.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002077 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002078 srcs: ["arch-common/bionic/crtend.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002079
Colin Cross50c21ab2015-10-31 23:03:05 -07002080 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002081}
Colin Crossbaa48992016-07-13 11:15:21 -07002082
Kalesh Singh862a23d2024-01-09 13:13:50 -08002083cc_object {
2084 name: "crt_pad_segment",
2085 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002086 "private", // crt_pad_segment.S depends on private/bionic_asm_note.h
Kalesh Singh862a23d2024-01-09 13:13:50 -08002087 ],
2088 srcs: ["arch-common/bionic/crt_pad_segment.S"],
2089
2090 defaults: ["crt_defaults"],
2091}
2092
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002093cc_library_static {
2094 name: "note_memtag_heap_async",
2095 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002096 arm64: {
2097 srcs: ["arch-arm64/bionic/note_memtag_heap_async.S"],
2098 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002099 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002100 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002101
Colin Cross10d92682021-06-22 13:25:46 -07002102 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002103}
2104
2105cc_library_static {
2106 name: "note_memtag_heap_sync",
2107 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002108 arm64: {
2109 srcs: ["arch-arm64/bionic/note_memtag_heap_sync.S"],
2110 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002111 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002112 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002113
Colin Cross10d92682021-06-22 13:25:46 -07002114 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002115}
2116
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002117// ========================================================
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002118// libc dependencies for baremetal Rust projects.
2119// ========================================================
2120
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002121// This library contains the following unresolved symbols:
2122// __errno
2123// abort
2124// async_safe_fatal_va_list
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002125cc_library_static {
2126 name: "librust_baremetal",
Pierre-Clément Tosi9018e5f2024-10-02 15:57:00 +01002127 defaults: ["cc_baremetal_defaults"],
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002128 header_libs: ["libc_headers"],
2129 include_dirs: [
2130 "bionic/libc/async_safe/include",
2131 "bionic/libc/platform",
2132 ],
2133 cflags: [
2134 "-Wall",
2135 "-Werror",
2136 ],
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002137 srcs: [
2138 "bionic/fortify.cpp",
Pierre-Clément Tosi816176c2022-11-30 14:33:41 +00002139 "bionic/strtol.cpp",
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002140 ],
2141 arch: {
2142 arm64: {
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002143 srcs: [
2144 "arch-arm64/string/__memcpy_chk.S",
2145 ],
2146 },
caowencheng9a39eb32023-03-20 16:24:41 +08002147 riscv64: {
2148 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002149 "arch-riscv64/string/__memcpy_chk.S",
caowencheng9a39eb32023-03-20 16:24:41 +08002150 ],
2151 },
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002152 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002153 whole_static_libs: [
George Burgess IVc5a98e62024-11-18 14:50:32 -07002154 "//external/llvm-libc:llvmlibc",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002155 "libarm-optimized-routines-mem",
Pierre-Clément Tosieb46ac92023-02-01 13:44:57 +00002156 "libc_netbsd",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002157 ],
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002158 system_shared_libs: [],
2159 nocrt: true,
2160 stl: "none",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002161 visibility: [
Jiyong Park072ce532024-07-22 11:20:47 +09002162 "//packages/modules/Virtualization/libs/libvmbase",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002163 ],
Zijun427504a2024-08-15 23:16:27 +00002164
2165 // b/358211032: This library gets linked into a rust rlib. Disable LTO
2166 // until cross-language lto is supported.
2167 lto: {
2168 never: true,
2169 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002170}
2171
2172// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002173// NDK headers.
2174// ========================================================
2175
Dan Albertcce54372024-08-22 18:24:30 +00002176ndk_headers {
Dan Albert22805ea2017-03-22 15:28:05 -07002177 name: "common_libc",
2178 from: "include",
2179 to: "",
Dan Albertcce54372024-08-22 18:24:30 +00002180 srcs: ["include/**/*.h"],
Dan Albert22805ea2017-03-22 15:28:05 -07002181 license: "NOTICE",
Dan Albertcce54372024-08-22 18:24:30 +00002182 // These don't pass the bad verification we do because many of them are
2183 // arch-specific, and they aren't necessarily independently includable.
2184 // That's not much of a problem though, since C-incompaitibilities in the
2185 // UAPI headers should run into problems long before they reach us.
2186 skip_verification: true,
Dan Albert22805ea2017-03-22 15:28:05 -07002187}
Dan Albert4238a352016-06-28 11:18:05 -07002188
2189ndk_headers {
Dan Albert063e86a2016-11-29 11:09:12 -08002190 name: "libc_uapi",
2191 from: "kernel/uapi",
2192 to: "",
2193 srcs: [
2194 "kernel/uapi/asm-generic/**/*.h",
2195 "kernel/uapi/drm/**/*.h",
2196 "kernel/uapi/linux/**/*.h",
2197 "kernel/uapi/misc/**/*.h",
2198 "kernel/uapi/mtd/**/*.h",
2199 "kernel/uapi/rdma/**/*.h",
2200 "kernel/uapi/scsi/**/*.h",
2201 "kernel/uapi/sound/**/*.h",
2202 "kernel/uapi/video/**/*.h",
2203 "kernel/uapi/xen/**/*.h",
2204 ],
Dan Albert92592652016-10-20 01:42:54 -07002205 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002206 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002207}
2208
2209ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002210 name: "libc_kernel_android_uapi_linux",
Dan Albertbae16ef2016-09-14 17:15:48 -07002211 from: "kernel/android/uapi/linux",
2212 to: "linux",
2213 srcs: ["kernel/android/uapi/linux/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002214 license: "NOTICE",
Dan Albertbae16ef2016-09-14 17:15:48 -07002215}
2216
2217ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002218 name: "libc_kernel_android_scsi",
Elliott Hughes50599392017-05-25 17:13:32 -07002219 from: "kernel/android/scsi/scsi",
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002220 to: "scsi",
2221 srcs: ["kernel/android/scsi/**/*.h"],
2222 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002223 skip_verification: true,
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002224}
2225
2226ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002227 name: "libc_asm_arm",
2228 from: "kernel/uapi/asm-arm",
2229 to: "arm-linux-androideabi",
2230 srcs: ["kernel/uapi/asm-arm/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002231 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002232 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002233}
2234
2235ndk_headers {
2236 name: "libc_asm_arm64",
2237 from: "kernel/uapi/asm-arm64",
2238 to: "aarch64-linux-android",
2239 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002240 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002241 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002242}
2243
Lazar Trsic790d2f72017-11-27 11:54:11 +01002244ndk_headers {
Colin Crossbd26e0f2022-10-19 15:03:14 -07002245 name: "libc_asm_riscv64",
2246 from: "kernel/uapi/asm-riscv",
2247 to: "riscv64-linux-android",
2248 srcs: ["kernel/uapi/asm-riscv/**/*.h"],
2249 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002250 skip_verification: true,
Colin Crossbd26e0f2022-10-19 15:03:14 -07002251}
2252
2253ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002254 name: "libc_asm_x86",
2255 from: "kernel/uapi/asm-x86",
2256 to: "i686-linux-android",
2257 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002258 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002259 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002260}
2261
2262ndk_headers {
2263 name: "libc_asm_x86_64",
2264 from: "kernel/uapi/asm-x86",
2265 to: "x86_64-linux-android",
2266 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002267 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002268 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002269}
2270
Dan Albert4238a352016-06-28 11:18:05 -07002271ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002272 name: "libc",
Dan Albert4238a352016-06-28 11:18:05 -07002273 symbol_file: "libc.map.txt",
2274 first_version: "9",
2275}
2276
Dan Albertdf31aff2016-10-06 15:50:41 -07002277ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002278 name: "libstdc++",
Dan Albertdf31aff2016-10-06 15:50:41 -07002279 symbol_file: "libstdc++.map.txt",
2280 first_version: "9",
2281}
2282
Dan Willemsenca056d72018-01-08 14:00:24 -08002283// Export these headers for toolbox to process
2284filegroup {
2285 name: "kernel_input_headers",
2286 srcs: [
2287 "kernel/uapi/linux/input.h",
2288 "kernel/uapi/linux/input-event-codes.h",
2289 ],
2290}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002291
2292// Generate a syscall name / number mapping. These objects are text files
2293// (thanks to the -dD -E flags) and not binary files. They will then be
2294// consumed by the genseccomp.py script and converted into C++ code.
2295cc_defaults {
2296 name: "libseccomp_gen_syscall_nrs_defaults",
2297 recovery_available: true,
2298 srcs: ["seccomp/gen_syscall_nrs.cpp"],
2299 cflags: [
2300 "-dD",
2301 "-E",
2302 "-Wall",
2303 "-Werror",
2304 "-nostdinc",
2305 ],
2306}
2307
2308cc_object {
2309 name: "libseccomp_gen_syscall_nrs_arm",
2310 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2311 local_include_dirs: [
2312 "kernel/uapi/asm-arm",
2313 "kernel/uapi",
2314 ],
2315}
2316
2317cc_object {
2318 name: "libseccomp_gen_syscall_nrs_arm64",
2319 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2320 local_include_dirs: [
2321 "kernel/uapi/asm-arm64",
2322 "kernel/uapi",
2323 ],
2324}
2325
2326cc_object {
Elliott Hughes704772b2022-10-10 17:06:43 +00002327 name: "libseccomp_gen_syscall_nrs_riscv64",
2328 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2329 local_include_dirs: [
2330 "kernel/uapi/asm-riscv",
2331 "kernel/uapi",
2332 ],
2333}
2334
2335cc_object {
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002336 name: "libseccomp_gen_syscall_nrs_x86",
2337 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2338 srcs: ["seccomp/gen_syscall_nrs_x86.cpp"],
2339 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2340 local_include_dirs: [
2341 "kernel/uapi/asm-x86",
2342 "kernel/uapi",
2343 ],
2344}
2345
2346cc_object {
2347 name: "libseccomp_gen_syscall_nrs_x86_64",
2348 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2349 srcs: ["seccomp/gen_syscall_nrs_x86_64.cpp"],
2350 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2351 local_include_dirs: [
2352 "kernel/uapi/asm-x86",
2353 "kernel/uapi",
2354 ],
2355}
2356
Jingwen Chenca366332021-01-29 05:16:32 -05002357filegroup {
2358 name: "all_kernel_uapi_headers",
2359 srcs: ["kernel/uapi/**/*.h"],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002360}
2361
Martijn Coenen0c6de752019-01-02 12:52:51 +01002362cc_genrule {
2363 name: "func_to_syscall_nrs",
2364 recovery_available: true,
2365 cmd: "$(location genfunctosyscallnrs) --out-dir=$(genDir) $(in)",
2366
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002367 tools: ["genfunctosyscallnrs"],
Martijn Coenen0c6de752019-01-02 12:52:51 +01002368
2369 srcs: [
2370 "SYSCALLS.TXT",
Martijn Coenen0c6de752019-01-02 12:52:51 +01002371 ],
2372
Elliott Hughes704772b2022-10-10 17:06:43 +00002373 arch: {
2374 arm: {
2375 srcs: [
2376 ":libseccomp_gen_syscall_nrs_arm",
2377 ":libseccomp_gen_syscall_nrs_arm64",
2378 ],
2379 },
2380 arm64: {
2381 srcs: [
2382 ":libseccomp_gen_syscall_nrs_arm",
2383 ":libseccomp_gen_syscall_nrs_arm64",
2384 ],
2385 },
2386 riscv64: {
2387 srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
2388 },
2389 x86: {
2390 srcs: [
2391 ":libseccomp_gen_syscall_nrs_x86",
2392 ":libseccomp_gen_syscall_nrs_x86_64",
2393 ],
2394 },
2395 x86_64: {
2396 srcs: [
2397 ":libseccomp_gen_syscall_nrs_x86",
2398 ":libseccomp_gen_syscall_nrs_x86_64",
2399 ],
2400 },
2401 },
2402
Martijn Coenen0c6de752019-01-02 12:52:51 +01002403 out: [
2404 "func_to_syscall_nrs.h",
2405 ],
2406}
2407
Victor Hsiehdbb86702020-06-15 09:29:07 -07002408// SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT = SECCOMP_BLOCKLIST_APP.txt - setresgid*
Martijn Coenenc3752be2019-01-09 16:19:57 +01002409genrule {
Victor Hsiehdbb86702020-06-15 09:29:07 -07002410 name: "generate_app_zygote_blocklist",
2411 out: ["SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT"],
2412 srcs: ["SECCOMP_BLOCKLIST_APP.TXT"],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002413 cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)",
2414}
2415
Yu Liu938ec9b2022-10-17 16:36:30 -07002416filegroup {
2417 name: "seccomp_syscalls_sources_zygote",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002418 srcs: [
2419 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002420 "SECCOMP_ALLOWLIST_COMMON.TXT",
2421 "SECCOMP_ALLOWLIST_APP.TXT",
2422 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002423 "SECCOMP_PRIORITY.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002424 ":generate_app_zygote_blocklist",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002425 ],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002426}
2427
Yu Liu938ec9b2022-10-17 16:36:30 -07002428filegroup {
2429 name: "seccomp_syscalls_sources_app",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002430 srcs: [
2431 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002432 "SECCOMP_ALLOWLIST_COMMON.TXT",
2433 "SECCOMP_ALLOWLIST_APP.TXT",
2434 "SECCOMP_BLOCKLIST_COMMON.TXT",
2435 "SECCOMP_BLOCKLIST_APP.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002436 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002437 ],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002438}
2439
Yu Liu938ec9b2022-10-17 16:36:30 -07002440filegroup {
2441 name: "seccomp_syscalls_sources_system",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002442 srcs: [
2443 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002444 "SECCOMP_ALLOWLIST_COMMON.TXT",
2445 "SECCOMP_ALLOWLIST_SYSTEM.TXT",
2446 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002447 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002448 ],
Yu Liu938ec9b2022-10-17 16:36:30 -07002449}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002450
Yu Liu938ec9b2022-10-17 16:36:30 -07002451cc_genrule {
2452 name: "libseccomp_policy_app_zygote_sources_x86",
2453 recovery_available: true,
2454 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002455 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002456 srcs: [
2457 ":seccomp_syscalls_sources_zygote",
2458 ":libseccomp_gen_syscall_nrs_x86",
2459 ":libseccomp_gen_syscall_nrs_x86_64",
2460 ],
2461 out: [
2462 "x86_app_zygote_policy.cpp",
2463 "x86_64_app_zygote_policy.cpp",
2464 ],
2465 enabled: false,
Yu Liu3a579692022-10-18 03:02:32 +00002466 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002467 x86: {
2468 enabled: true,
2469 },
2470 x86_64: {
2471 enabled: true,
2472 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002473 },
2474}
2475
2476cc_genrule {
2477 name: "libseccomp_policy_app_zygote_sources_arm",
2478 recovery_available: true,
2479 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002480 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002481 srcs: [
2482 ":seccomp_syscalls_sources_zygote",
2483 ":libseccomp_gen_syscall_nrs_arm",
2484 ":libseccomp_gen_syscall_nrs_arm64",
2485 ],
2486 out: [
2487 "arm_app_zygote_policy.cpp",
2488 "arm64_app_zygote_policy.cpp",
2489 ],
2490 enabled: false,
2491 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002492 arm: {
2493 enabled: true,
2494 },
2495 arm64: {
2496 enabled: true,
2497 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002498 },
2499}
2500
2501cc_genrule {
2502 name: "libseccomp_policy_app_zygote_sources_riscv64",
2503 recovery_available: true,
2504 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002505 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002506 srcs: [
2507 ":seccomp_syscalls_sources_zygote",
2508 ":libseccomp_gen_syscall_nrs_riscv64",
2509 ],
2510 out: [
2511 "riscv64_app_zygote_policy.cpp",
2512 ],
2513 enabled: false,
2514 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002515 riscv64: {
2516 enabled: true,
2517 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002518 },
2519}
2520
2521cc_genrule {
2522 name: "libseccomp_policy_app_sources_x86",
2523 recovery_available: true,
2524 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002525 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002526 srcs: [
2527 ":seccomp_syscalls_sources_app",
2528 ":libseccomp_gen_syscall_nrs_x86",
2529 ":libseccomp_gen_syscall_nrs_x86_64",
2530 ],
2531 out: [
2532 "x86_app_policy.cpp",
2533 "x86_64_app_policy.cpp",
2534 ],
2535 enabled: false,
2536 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002537 x86: {
2538 enabled: true,
2539 },
2540 x86_64: {
2541 enabled: true,
2542 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002543 },
2544}
2545
2546cc_genrule {
2547 name: "libseccomp_policy_app_sources_arm",
2548 recovery_available: true,
2549 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002550 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002551 srcs: [
2552 ":seccomp_syscalls_sources_app",
2553 ":libseccomp_gen_syscall_nrs_arm",
2554 ":libseccomp_gen_syscall_nrs_arm64",
2555 ],
2556 out: [
2557 "arm_app_policy.cpp",
2558 "arm64_app_policy.cpp",
2559 ],
2560 enabled: false,
2561 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002562 arm: {
2563 enabled: true,
2564 },
2565 arm64: {
2566 enabled: true,
2567 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002568 },
2569}
2570
2571cc_genrule {
2572 name: "libseccomp_policy_app_sources_riscv64",
2573 recovery_available: true,
2574 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002575 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002576 srcs: [
2577 ":seccomp_syscalls_sources_app",
2578 ":libseccomp_gen_syscall_nrs_riscv64",
2579 ],
2580 out: [
2581 "riscv64_app_policy.cpp",
2582 ],
2583 enabled: false,
2584 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002585 riscv64: {
2586 enabled: true,
2587 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002588 },
2589}
2590
2591cc_genrule {
2592 name: "libseccomp_policy_system_sources_x86",
2593 recovery_available: true,
2594 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002595 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002596 srcs: [
2597 ":seccomp_syscalls_sources_system",
2598 ":libseccomp_gen_syscall_nrs_x86",
2599 ":libseccomp_gen_syscall_nrs_x86_64",
2600 ],
2601 out: [
2602 "x86_system_policy.cpp",
2603 "x86_64_system_policy.cpp",
2604 ],
2605 enabled: false,
2606 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002607 x86: {
2608 enabled: true,
2609 },
2610 x86_64: {
2611 enabled: true,
2612 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002613 },
2614}
2615
2616cc_genrule {
2617 name: "libseccomp_policy_system_sources_arm",
2618 recovery_available: true,
2619 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002620 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002621 srcs: [
2622 ":seccomp_syscalls_sources_system",
2623 ":libseccomp_gen_syscall_nrs_arm",
2624 ":libseccomp_gen_syscall_nrs_arm64",
2625 ],
2626 out: [
2627 "arm_system_policy.cpp",
2628 "arm64_system_policy.cpp",
2629 ],
2630 enabled: false,
2631 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002632 arm: {
2633 enabled: true,
2634 },
2635 arm64: {
2636 enabled: true,
2637 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002638 },
2639}
2640
2641cc_genrule {
2642 name: "libseccomp_policy_system_sources_riscv64",
2643 recovery_available: true,
2644 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002645 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002646 srcs: [
2647 ":seccomp_syscalls_sources_system",
2648 ":libseccomp_gen_syscall_nrs_riscv64",
2649 ],
2650 out: [
2651 "riscv64_system_policy.cpp",
2652 ],
2653 enabled: false,
2654 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002655 riscv64: {
2656 enabled: true,
2657 },
Yu Liu3a579692022-10-18 03:02:32 +00002658 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002659}
2660
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002661cc_library {
2662 name: "libseccomp_policy",
2663 recovery_available: true,
Martijn Coenend269d9b2018-11-08 16:41:42 +01002664 generated_headers: ["func_to_syscall_nrs"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002665
2666 arch: {
2667 arm: {
2668 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002669 "libseccomp_policy_app_sources_arm",
2670 "libseccomp_policy_app_zygote_sources_arm",
2671 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002672 ],
2673 },
2674 arm64: {
2675 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002676 "libseccomp_policy_app_sources_arm",
2677 "libseccomp_policy_app_zygote_sources_arm",
2678 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002679 ],
2680 },
2681 riscv64: {
2682 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002683 "libseccomp_policy_app_sources_riscv64",
2684 "libseccomp_policy_app_zygote_sources_riscv64",
2685 "libseccomp_policy_system_sources_riscv64",
Yu Liu938ec9b2022-10-17 16:36:30 -07002686 ],
2687 },
2688 x86: {
2689 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002690 "libseccomp_policy_app_sources_x86",
2691 "libseccomp_policy_app_zygote_sources_x86",
2692 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002693 ],
2694 },
2695 x86_64: {
2696 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002697 "libseccomp_policy_app_sources_x86",
2698 "libseccomp_policy_app_zygote_sources_x86",
2699 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002700 ],
2701 },
2702 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002703
2704 srcs: [
2705 "seccomp/seccomp_policy.cpp",
2706 ],
2707
2708 export_include_dirs: ["seccomp/include"],
2709 cflags: [
2710 "-Wall",
2711 "-Werror",
2712 ],
2713 shared: {
2714 shared_libs: ["libbase"],
2715 },
2716 static: {
2717 static_libs: ["libbase"],
2718 },
2719}
Christopher Ferrisfc26d712019-02-27 18:07:55 -08002720
Colin Cross048f24e2021-09-01 17:26:00 -07002721cc_library_host_static {
2722 name: "libfts",
2723 srcs: [
2724 "bionic/fts.c",
2725 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
2726 ],
2727 export_include_dirs: ["fts/include"],
2728 local_include_dirs: [
2729 "private",
2730 "upstream-openbsd/android/include",
2731 ],
2732 cflags: [
2733 "-include openbsd-compat.h",
2734 "-Wno-unused-parameter",
2735 ],
2736 enabled: false,
2737 target: {
2738 musl: {
2739 enabled: true,
2740 },
2741 },
Colin Cross2a9843f2022-01-13 12:26:30 -08002742 stl: "none",
2743}
2744
2745cc_library_host_static {
2746 name: "libexecinfo",
2747 visibility: ["//external/musl"],
2748 srcs: ["bionic/execinfo.cpp"],
2749 export_include_dirs: ["execinfo/include"],
2750 local_include_dirs: ["private"],
2751 enabled: false,
2752 target: {
2753 musl: {
2754 enabled: true,
2755 system_shared_libs: [],
2756 header_libs: ["libc_musl_headers"],
2757 },
2758 },
2759 stl: "none",
Colin Cross048f24e2021-09-01 17:26:00 -07002760}
2761
Colin Cross9da85fa2022-01-24 18:20:05 -08002762cc_library_host_static {
2763 name: "libb64",
2764 visibility: ["//external/musl"],
2765 srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
2766 export_include_dirs: ["b64/include"],
2767 local_include_dirs: [
2768 "private",
2769 "upstream-openbsd/android/include",
2770 ],
2771 cflags: [
2772 "-include openbsd-compat.h",
2773 ],
2774 enabled: false,
2775 target: {
2776 musl: {
2777 enabled: true,
2778 system_shared_libs: [],
2779 header_libs: ["libc_musl_headers"],
2780 },
2781 },
2782 stl: "none",
2783}
2784
Colin Cross9d4a56e2022-02-03 10:20:32 -08002785// Export kernel uapi headers to be used in the musl sysroot.
2786// Also include the execinfo headers for the libexecinfo and the
2787// b64 headers for libb64 embedded in musl libc.
2788cc_genrule {
2789 name: "libc_musl_sysroot_bionic_headers",
2790 visibility: ["//external/musl"],
2791 host_supported: true,
2792 device_supported: false,
2793 enabled: false,
2794 target: {
2795 musl: {
2796 enabled: true,
2797 },
2798 },
2799 srcs: [
2800 "kernel/uapi/**/*.h",
2801 "kernel/android/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002802 "execinfo/include/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002803 "b64/include/**/*.h",
Colin Crossaeef9f02022-02-07 21:01:26 -08002804
Colin Crossaeef9f02022-02-07 21:01:26 -08002805 "NOTICE",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002806
2807 ":libc_musl_sysroot_bionic_arch_headers",
2808 ],
2809 out: ["libc_musl_sysroot_bionic_headers.zip"],
2810 tools: [
2811 "soong_zip",
2812 "merge_zips",
2813 "zip2zip",
2814 ],
Colin Crossaeef9f02022-02-07 21:01:26 -08002815 cmd: "BIONIC_LIBC_DIR=$$(dirname $(location NOTICE)) && " +
2816 "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
Colin Crossad33d022022-02-25 18:27:04 -08002817 // NOTICE
2818 " -j -f $(location NOTICE) " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002819 // headers
2820 " -P include " +
Colin Crossaeef9f02022-02-07 21:01:26 -08002821 " -C $${BIONIC_LIBC_DIR}/kernel/uapi " +
2822 " -D $${BIONIC_LIBC_DIR}/kernel/uapi " +
2823 " -C $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2824 " -D $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2825 " -C $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2826 " -D $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2827 " -C $${BIONIC_LIBC_DIR}/execinfo/include " +
2828 " -D $${BIONIC_LIBC_DIR}/execinfo/include " +
2829 " -C $${BIONIC_LIBC_DIR}/b64/include " +
2830 " -D $${BIONIC_LIBC_DIR}/b64/include " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002831 " && " +
Colin Crossad33d022022-02-25 18:27:04 -08002832 "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(genDir)/sysroot-renamed.zip " +
Colin Cross1c0a7a02022-08-11 12:22:26 -07002833 " -x **/BUILD " +
Colin Crossad33d022022-02-25 18:27:04 -08002834 " include/**/*:include/ " +
2835 " NOTICE:NOTICE.bionic " +
2836 " && " +
2837 "$(location merge_zips) $(out) $(location :libc_musl_sysroot_bionic_arch_headers) $(genDir)/sysroot-renamed.zip",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002838}
2839
2840// The architecture-specific bits have to be handled separately because the label varies based
2841// on architecture, which prevents using $(locations) to find them and requires using $(in)
2842// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
2843// genrule.
2844cc_genrule {
2845 name: "libc_musl_sysroot_bionic_arch_headers",
2846 visibility: ["//visibility:private"],
2847 host_supported: true,
2848 device_supported: false,
2849 enabled: false,
2850 target: {
2851 musl: {
2852 enabled: true,
2853 },
2854 },
2855 arch: {
2856 arm: {
2857 srcs: ["kernel/uapi/asm-arm/**/*.h"],
2858 },
2859 arm64: {
2860 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
2861 },
2862 x86: {
2863 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2864 },
2865 x86_64: {
2866 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2867 },
2868 },
2869 out: ["libc_musl_sysroot_bionic_arch_headers.zip"],
2870 tools: ["soong_zip"],
2871 cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/asm -j -D $$(dirname $${includes[0]})",
2872}
Colin Cross290c4952022-10-13 12:51:13 -07002873
2874cc_genrule {
2875 name: "bionic_sysroot_crt_objects",
2876 visibility: ["//visibility:private"],
2877 out: ["bionic_sysroot_crt_objects.zip"],
2878 tools: ["soong_zip"],
2879 srcs: [
2880 ":crtbegin_dynamic",
2881 ":crtbegin_so",
2882 ":crtbegin_static",
2883 ":crtend_android",
2884 ":crtend_so",
2885 ],
2886 cmd: "$(location soong_zip) -o $(out) -j " +
2887 "-f $(location :crtbegin_dynamic) " +
2888 "-f $(location :crtbegin_so) " +
2889 "-f $(location :crtbegin_static) " +
2890 "-f $(location :crtend_android) " +
2891 "-f $(location :crtend_so)",
2892 dist: {
2893 targets: ["bionic_sysroot_crt_objects"],
2894 },
2895 arch: {
2896 arm: {
2897 dist: {
2898 suffix: "_arm",
2899 },
2900 },
2901 arm64: {
2902 dist: {
2903 suffix: "_arm64",
2904 },
2905 },
2906 riscv64: {
2907 dist: {
2908 suffix: "_riscv64",
2909 },
2910 },
2911 x86: {
2912 dist: {
2913 suffix: "_x86",
2914 },
2915 },
2916 x86_64: {
2917 dist: {
2918 suffix: "_x86_64",
2919 },
2920 },
2921 },
2922}
Spandan Das8fce52a2023-09-28 18:00:12 +00002923
Jiyong Park35a280d2024-05-03 16:53:39 +09002924filegroup {
2925 name: "linux_capability_header",
2926 srcs: ["kernel/uapi/linux/capability.h"],
2927}