blob: 165a9217d54432df11a5b37144441e51f40c48a6 [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",
Elliott Hughese1dc4f62021-01-11 11:51:29 -0800357 "-include private/bsd_sys_param.h",
Dan Willemsen208ae172015-09-16 16:33:27 -0700358 ],
359
Dan Willemsen208ae172015-09-16 16:33:27 -0700360 local_include_dirs: [
361 "dns/include",
362 "private",
363 "upstream-netbsd/lib/libc/include",
364 "upstream-netbsd/android/include",
365 ],
366
367 name: "libc_dns",
Dan Willemsen208ae172015-09-16 16:33:27 -0700368}
369
370// ========================================================
371// libc_freebsd.a - upstream FreeBSD C library code
372// ========================================================
373//
374// These files are built with the freebsd-compat.h header file
375// automatically included.
376
377cc_library_static {
Elliott Hughesc2043342023-07-20 20:24:09 +0000378 name: "libc_freebsd_ldexp",
379 defaults: ["libc_defaults"],
380 cflags: ["-Dscalbn=ldexp"],
381 srcs: [":libc_ldexp_srcs"],
382}
383
384cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700385 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700386 srcs: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700387 "upstream-freebsd/lib/libc/stdlib/getopt_long.c",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700388 "upstream-freebsd/lib/libc/stdlib/hcreate.c",
389 "upstream-freebsd/lib/libc/stdlib/hcreate_r.c",
390 "upstream-freebsd/lib/libc/stdlib/hdestroy_r.c",
391 "upstream-freebsd/lib/libc/stdlib/hsearch_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700392 "upstream-freebsd/lib/libc/stdlib/qsort.c",
Elliott Hughes5bae5722024-07-30 12:47:33 -0400393 "upstream-freebsd/lib/libc/stdlib/qsort_r.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700394 "upstream-freebsd/lib/libc/stdlib/quick_exit.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700395 "upstream-freebsd/lib/libc/string/wcpcpy.c",
396 "upstream-freebsd/lib/libc/string/wcpncpy.c",
397 "upstream-freebsd/lib/libc/string/wcscasecmp.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700398 "upstream-freebsd/lib/libc/string/wcscat.c",
399 "upstream-freebsd/lib/libc/string/wcschr.c",
400 "upstream-freebsd/lib/libc/string/wcscmp.c",
401 "upstream-freebsd/lib/libc/string/wcscpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700402 "upstream-freebsd/lib/libc/string/wcscspn.c",
403 "upstream-freebsd/lib/libc/string/wcsdup.c",
404 "upstream-freebsd/lib/libc/string/wcslcat.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700405 "upstream-freebsd/lib/libc/string/wcslen.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700406 "upstream-freebsd/lib/libc/string/wcsncasecmp.c",
407 "upstream-freebsd/lib/libc/string/wcsncat.c",
408 "upstream-freebsd/lib/libc/string/wcsncmp.c",
409 "upstream-freebsd/lib/libc/string/wcsncpy.c",
410 "upstream-freebsd/lib/libc/string/wcsnlen.c",
411 "upstream-freebsd/lib/libc/string/wcspbrk.c",
Dan Willemsen268a6732015-10-15 14:49:45 -0700412 "upstream-freebsd/lib/libc/string/wcsrchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700413 "upstream-freebsd/lib/libc/string/wcsspn.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700414 "upstream-freebsd/lib/libc/string/wcsstr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700415 "upstream-freebsd/lib/libc/string/wcstok.c",
416 "upstream-freebsd/lib/libc/string/wmemchr.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700417 "upstream-freebsd/lib/libc/string/wmemcmp.c",
Elliott Hughes20f33992017-07-13 09:45:00 -0700418 "upstream-freebsd/lib/libc/string/wmemcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700419 "upstream-freebsd/lib/libc/string/wmemmove.c",
Dan Willemsen9c9aa742016-01-15 16:00:57 -0800420 "upstream-freebsd/lib/libc/string/wmemset.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700421 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700422
Colin Cross50c21ab2015-10-31 23:03:05 -0700423 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700424 "-Wno-sign-compare",
Elliott Hughes5702c6f2017-08-31 17:27:05 -0700425 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700426 "-include freebsd-compat.h",
427 ],
428
Dan Willemsen208ae172015-09-16 16:33:27 -0700429 local_include_dirs: [
430 "upstream-freebsd/android/include",
431 ],
432
433 name: "libc_freebsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700434}
435
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700436cc_library_static {
437 defaults: ["libc_defaults"],
438 srcs: [
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700439 "upstream-freebsd/lib/libc/gen/glob.c",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700440 ],
441
442 cflags: [
443 "-Wno-sign-compare",
444 "-include freebsd-compat.h",
Elliott Hughesf1c568d2017-09-26 17:09:07 -0700445 "-Wframe-larger-than=66000",
Elliott Hughes8e547bd2016-08-16 15:57:47 -0700446 ],
447
448 local_include_dirs: [
449 "upstream-freebsd/android/include",
450 ],
451
452 name: "libc_freebsd_large_stack",
453}
454
Dan Willemsen208ae172015-09-16 16:33:27 -0700455// ========================================================
456// libc_netbsd.a - upstream NetBSD C library code
457// ========================================================
458//
459// These files are built with the netbsd-compat.h header file
460// automatically included.
461
462cc_library_static {
463
Colin Cross50c21ab2015-10-31 23:03:05 -0700464 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700465 srcs: [
466 "upstream-netbsd/common/lib/libc/stdlib/random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700467 "upstream-netbsd/lib/libc/gen/nice.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700468 "upstream-netbsd/lib/libc/gen/psignal.c",
469 "upstream-netbsd/lib/libc/gen/utime.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700470 "upstream-netbsd/lib/libc/inet/nsap_addr.c",
471 "upstream-netbsd/lib/libc/regex/regcomp.c",
472 "upstream-netbsd/lib/libc/regex/regerror.c",
473 "upstream-netbsd/lib/libc/regex/regexec.c",
474 "upstream-netbsd/lib/libc/regex/regfree.c",
475 "upstream-netbsd/lib/libc/stdlib/bsearch.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700476 "upstream-netbsd/lib/libc/stdlib/drand48.c",
477 "upstream-netbsd/lib/libc/stdlib/erand48.c",
478 "upstream-netbsd/lib/libc/stdlib/jrand48.c",
479 "upstream-netbsd/lib/libc/stdlib/lcong48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700480 "upstream-netbsd/lib/libc/stdlib/lrand48.c",
481 "upstream-netbsd/lib/libc/stdlib/mrand48.c",
482 "upstream-netbsd/lib/libc/stdlib/nrand48.c",
483 "upstream-netbsd/lib/libc/stdlib/_rand48.c",
484 "upstream-netbsd/lib/libc/stdlib/rand_r.c",
485 "upstream-netbsd/lib/libc/stdlib/reallocarr.c",
486 "upstream-netbsd/lib/libc/stdlib/seed48.c",
487 "upstream-netbsd/lib/libc/stdlib/srand48.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700488 ],
489 multilib: {
490 lib32: {
491 // LP32 cruft
492 srcs: ["upstream-netbsd/common/lib/libc/hash/sha1/sha1.c"],
493 },
494 },
Colin Cross50c21ab2015-10-31 23:03:05 -0700495 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700496 "-Wno-sign-compare",
Dan Willemsen879cec22016-02-29 10:37:56 -0800497 "-Wno-unused-parameter",
Dan Willemsen208ae172015-09-16 16:33:27 -0700498 "-DPOSIX_MISTAKE",
499 "-include netbsd-compat.h",
500 ],
501
Dan Willemsen208ae172015-09-16 16:33:27 -0700502 local_include_dirs: [
503 "upstream-netbsd/android/include",
504 "upstream-netbsd/lib/libc/include",
505 ],
506
507 name: "libc_netbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700508}
509
510// ========================================================
Elliott Hughes968adf92024-02-08 13:15:53 -0800511// libc_openbsd.a - upstream OpenBSD C library code
Dan Willemsen208ae172015-09-16 16:33:27 -0700512// ========================================================
513//
514// These files are built with the openbsd-compat.h header file
515// automatically included.
Dan Willemsen208ae172015-09-16 16:33:27 -0700516cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700517 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700518 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800519 "upstream-openbsd/lib/libc/crypt/arc4random.c",
520 "upstream-openbsd/lib/libc/crypt/arc4random_uniform.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700521 "upstream-openbsd/lib/libc/gen/alarm.c",
522 "upstream-openbsd/lib/libc/gen/ctype_.c",
523 "upstream-openbsd/lib/libc/gen/daemon.c",
524 "upstream-openbsd/lib/libc/gen/err.c",
525 "upstream-openbsd/lib/libc/gen/errx.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700526 "upstream-openbsd/lib/libc/gen/fnmatch.c",
527 "upstream-openbsd/lib/libc/gen/ftok.c",
528 "upstream-openbsd/lib/libc/gen/getprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700529 "upstream-openbsd/lib/libc/gen/setprogname.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700530 "upstream-openbsd/lib/libc/gen/verr.c",
531 "upstream-openbsd/lib/libc/gen/verrx.c",
532 "upstream-openbsd/lib/libc/gen/vwarn.c",
533 "upstream-openbsd/lib/libc/gen/vwarnx.c",
534 "upstream-openbsd/lib/libc/gen/warn.c",
535 "upstream-openbsd/lib/libc/gen/warnx.c",
536 "upstream-openbsd/lib/libc/locale/btowc.c",
537 "upstream-openbsd/lib/libc/locale/mbrlen.c",
538 "upstream-openbsd/lib/libc/locale/mbstowcs.c",
539 "upstream-openbsd/lib/libc/locale/mbtowc.c",
540 "upstream-openbsd/lib/libc/locale/wcscoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700541 "upstream-openbsd/lib/libc/locale/wcstombs.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700542 "upstream-openbsd/lib/libc/locale/wcsxfrm.c",
543 "upstream-openbsd/lib/libc/locale/wctob.c",
544 "upstream-openbsd/lib/libc/locale/wctomb.c",
Elliott Hughes26fda772016-04-06 11:56:41 -0700545 "upstream-openbsd/lib/libc/net/base64.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700546 "upstream-openbsd/lib/libc/net/htonl.c",
547 "upstream-openbsd/lib/libc/net/htons.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700548 "upstream-openbsd/lib/libc/net/inet_lnaof.c",
549 "upstream-openbsd/lib/libc/net/inet_makeaddr.c",
550 "upstream-openbsd/lib/libc/net/inet_netof.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700551 "upstream-openbsd/lib/libc/net/inet_ntoa.c",
552 "upstream-openbsd/lib/libc/net/inet_ntop.c",
553 "upstream-openbsd/lib/libc/net/inet_pton.c",
554 "upstream-openbsd/lib/libc/net/ntohl.c",
555 "upstream-openbsd/lib/libc/net/ntohs.c",
Colin Cross8ce38af2016-01-19 12:50:20 -0800556 "upstream-openbsd/lib/libc/net/res_random.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700557 "upstream-openbsd/lib/libc/stdio/fgetln.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700558 "upstream-openbsd/lib/libc/stdio/fgetwc.c",
559 "upstream-openbsd/lib/libc/stdio/fgetws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700560 "upstream-openbsd/lib/libc/stdio/flags.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700561 "upstream-openbsd/lib/libc/stdio/fputwc.c",
562 "upstream-openbsd/lib/libc/stdio/fputws.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700563 "upstream-openbsd/lib/libc/stdio/fvwrite.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700564 "upstream-openbsd/lib/libc/stdio/fwide.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700565 "upstream-openbsd/lib/libc/stdio/getdelim.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700566 "upstream-openbsd/lib/libc/stdio/gets.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700567 "upstream-openbsd/lib/libc/stdio/makebuf.c",
568 "upstream-openbsd/lib/libc/stdio/mktemp.c",
569 "upstream-openbsd/lib/libc/stdio/open_memstream.c",
570 "upstream-openbsd/lib/libc/stdio/open_wmemstream.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700571 "upstream-openbsd/lib/libc/stdio/rget.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700572 "upstream-openbsd/lib/libc/stdio/setvbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700573 "upstream-openbsd/lib/libc/stdio/ungetc.c",
574 "upstream-openbsd/lib/libc/stdio/ungetwc.c",
575 "upstream-openbsd/lib/libc/stdio/vasprintf.c",
576 "upstream-openbsd/lib/libc/stdio/vdprintf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700577 "upstream-openbsd/lib/libc/stdio/vsscanf.c",
578 "upstream-openbsd/lib/libc/stdio/vswprintf.c",
579 "upstream-openbsd/lib/libc/stdio/vswscanf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700580 "upstream-openbsd/lib/libc/stdio/wbuf.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700581 "upstream-openbsd/lib/libc/stdio/wsetup.c",
582 "upstream-openbsd/lib/libc/stdlib/abs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800583 "upstream-openbsd/lib/libc/stdlib/div.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700584 "upstream-openbsd/lib/libc/stdlib/getenv.c",
Colin Crossb8396102016-04-07 13:24:50 -0700585 "upstream-openbsd/lib/libc/stdlib/getsubopt.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700586 "upstream-openbsd/lib/libc/stdlib/insque.c",
587 "upstream-openbsd/lib/libc/stdlib/imaxabs.c",
588 "upstream-openbsd/lib/libc/stdlib/imaxdiv.c",
589 "upstream-openbsd/lib/libc/stdlib/labs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800590 "upstream-openbsd/lib/libc/stdlib/ldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700591 "upstream-openbsd/lib/libc/stdlib/llabs.c",
Elliott Hughes01809e12019-02-05 16:48:22 -0800592 "upstream-openbsd/lib/libc/stdlib/lldiv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700593 "upstream-openbsd/lib/libc/stdlib/lsearch.c",
Elliott Hughes26b06072020-07-31 11:00:10 -0700594 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700595 "upstream-openbsd/lib/libc/stdlib/remque.c",
596 "upstream-openbsd/lib/libc/stdlib/setenv.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700597 "upstream-openbsd/lib/libc/stdlib/tfind.c",
598 "upstream-openbsd/lib/libc/stdlib/tsearch.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800599 "upstream-openbsd/lib/libc/string/memccpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700600 "upstream-openbsd/lib/libc/string/strcasecmp.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800601 "upstream-openbsd/lib/libc/string/strcasestr.c",
602 "upstream-openbsd/lib/libc/string/strcoll.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700603 "upstream-openbsd/lib/libc/string/strcspn.c",
604 "upstream-openbsd/lib/libc/string/strdup.c",
605 "upstream-openbsd/lib/libc/string/strndup.c",
606 "upstream-openbsd/lib/libc/string/strpbrk.c",
607 "upstream-openbsd/lib/libc/string/strsep.c",
608 "upstream-openbsd/lib/libc/string/strspn.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700609 "upstream-openbsd/lib/libc/string/strtok.c",
Elliott Hughesfbac97a2019-02-04 16:46:24 -0800610 "upstream-openbsd/lib/libc/string/strxfrm.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700611 "upstream-openbsd/lib/libc/string/wcslcpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700612 "upstream-openbsd/lib/libc/string/wcswidth.c",
Colin Cross69bcb8b2021-09-08 13:24:16 -0700613
Elliott Hughesd4c61182024-08-16 17:31:24 -0400614 // These files are originally from OpenBSD,
615 // and benefit from being compiled with openbsd-compat.h.
616 // TODO: clean them up instead.
Colin Cross69bcb8b2021-09-08 13:24:16 -0700617 "bionic/fts.c",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400618 "stdio/vfprintf.cpp",
619 "stdio/vfwprintf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -0700620 ],
621
Elliott Hughes7d136662023-10-27 15:40:32 -0700622 // Each architecture has optimized versions of some routines,
623 // and only includes the portable C versions of ones it's missing.
Dan Willemsen208ae172015-09-16 16:33:27 -0700624 arch: {
625 arm: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700626 srcs: [
627 "upstream-openbsd/lib/libc/string/memchr.c",
628 "upstream-openbsd/lib/libc/string/memrchr.c",
629 "upstream-openbsd/lib/libc/string/stpncpy.c",
630 "upstream-openbsd/lib/libc/string/strlcat.c",
631 "upstream-openbsd/lib/libc/string/strlcpy.c",
632 "upstream-openbsd/lib/libc/string/strncat.c",
633 "upstream-openbsd/lib/libc/string/strncmp.c",
634 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700635 ],
636 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700637 arm64: {
Elliott Hughes7d136662023-10-27 15:40:32 -0700638 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700639 "upstream-openbsd/lib/libc/string/strcat.c",
Elliott Hughesaefe9992023-11-08 12:04:41 -0800640 "upstream-openbsd/lib/libc/string/stpncpy.c",
Elliott Hughes7d136662023-10-27 15:40:32 -0700641 "upstream-openbsd/lib/libc/string/strlcat.c",
642 "upstream-openbsd/lib/libc/string/strlcpy.c",
643 "upstream-openbsd/lib/libc/string/strncat.c",
644 "upstream-openbsd/lib/libc/string/strncpy.c",
Dan Willemsen208ae172015-09-16 16:33:27 -0700645 ],
646 },
Elliott Hughesebc19a92022-10-14 23:25:36 +0000647 riscv64: {
648 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -0700649 "upstream-openbsd/lib/libc/string/memrchr.c",
650 "upstream-openbsd/lib/libc/string/stpncpy.c",
651 "upstream-openbsd/lib/libc/string/strlcat.c",
652 "upstream-openbsd/lib/libc/string/strlcpy.c",
Elliott Hughesebc19a92022-10-14 23:25:36 +0000653 ],
654 },
Dan Willemsen208ae172015-09-16 16:33:27 -0700655 x86: {
Elliott Hughesaefe9992023-11-08 12:04:41 -0800656 srcs: [
657 // x86 has custom implementations of all of these.
658 ],
Elliott Hughes7d136662023-10-27 15:40:32 -0700659 },
660 x86_64: {
661 srcs: [
Colin Cross6ab8f892015-11-23 14:12:15 -0800662 "upstream-openbsd/lib/libc/string/memchr.c",
Colin Cross6ab8f892015-11-23 14:12:15 -0800663 "upstream-openbsd/lib/libc/string/memrchr.c",
Haibo Huangb9244ff2018-08-11 10:12:13 -0700664 "upstream-openbsd/lib/libc/string/strlcat.c",
665 "upstream-openbsd/lib/libc/string/strlcpy.c",
Colin Cross6ab8f892015-11-23 14:12:15 -0800666 ],
Dan Willemsen208ae172015-09-16 16:33:27 -0700667 },
668 },
669
Colin Cross50c21ab2015-10-31 23:03:05 -0700670 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700671 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700672 "-Wno-unused-parameter",
673 "-include openbsd-compat.h",
674 ],
675
Dan Willemsen208ae172015-09-16 16:33:27 -0700676 local_include_dirs: [
677 "private",
Elliott Hughes968adf92024-02-08 13:15:53 -0800678 "stdio",
Elliott Hughesd4c61182024-08-16 17:31:24 -0400679 "upstream-openbsd/android/include/",
680 "upstream-openbsd/lib/libc/gdtoa/",
681 "upstream-openbsd/lib/libc/include/",
682 "upstream-openbsd/lib/libc/stdio/",
Dan Willemsen208ae172015-09-16 16:33:27 -0700683 ],
684
685 name: "libc_openbsd",
Dan Willemsen208ae172015-09-16 16:33:27 -0700686}
687
Elliott Hughes968adf92024-02-08 13:15:53 -0800688cc_library_static {
689 name: "libc_openbsd_large_stack",
690 defaults: ["libc_defaults"],
691 srcs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800692 "upstream-openbsd/lib/libc/string/memmem.c",
693 "upstream-openbsd/lib/libc/string/strstr.c",
694 ],
695 cflags: [
696 "-include openbsd-compat.h",
697 "-Wno-sign-compare",
698 "-Wframe-larger-than=5000",
699 ],
700
701 local_include_dirs: [
Elliott Hughes968adf92024-02-08 13:15:53 -0800702 "upstream-openbsd/android/include/",
Elliott Hughes968adf92024-02-08 13:15:53 -0800703 ],
704}
705
Dan Willemsen208ae172015-09-16 16:33:27 -0700706// ========================================================
707// libc_gdtoa.a - upstream OpenBSD C library gdtoa code
708// ========================================================
709//
710// These files are built with the openbsd-compat.h header file
711// automatically included.
712
713cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700714 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700715 srcs: [
716 "upstream-openbsd/android/gdtoa_support.cpp",
717 "upstream-openbsd/lib/libc/gdtoa/dmisc.c",
718 "upstream-openbsd/lib/libc/gdtoa/dtoa.c",
719 "upstream-openbsd/lib/libc/gdtoa/gdtoa.c",
720 "upstream-openbsd/lib/libc/gdtoa/gethex.c",
721 "upstream-openbsd/lib/libc/gdtoa/gmisc.c",
722 "upstream-openbsd/lib/libc/gdtoa/hd_init.c",
723 "upstream-openbsd/lib/libc/gdtoa/hdtoa.c",
724 "upstream-openbsd/lib/libc/gdtoa/hexnan.c",
725 "upstream-openbsd/lib/libc/gdtoa/ldtoa.c",
726 "upstream-openbsd/lib/libc/gdtoa/misc.c",
727 "upstream-openbsd/lib/libc/gdtoa/smisc.c",
728 "upstream-openbsd/lib/libc/gdtoa/strtod.c",
729 "upstream-openbsd/lib/libc/gdtoa/strtodg.c",
730 "upstream-openbsd/lib/libc/gdtoa/strtof.c",
731 "upstream-openbsd/lib/libc/gdtoa/strtord.c",
732 "upstream-openbsd/lib/libc/gdtoa/sum.c",
733 "upstream-openbsd/lib/libc/gdtoa/ulp.c",
734 ],
735 multilib: {
736 lib64: {
Colin Cross6ab8f892015-11-23 14:12:15 -0800737 srcs: ["upstream-openbsd/lib/libc/gdtoa/strtorQ.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700738 },
739 },
740
Colin Cross50c21ab2015-10-31 23:03:05 -0700741 cflags: [
Dan Willemsen208ae172015-09-16 16:33:27 -0700742 "-Wno-sign-compare",
Dan Willemsen208ae172015-09-16 16:33:27 -0700743 "-include openbsd-compat.h",
744 ],
745
Dan Willemsen208ae172015-09-16 16:33:27 -0700746 local_include_dirs: [
747 "private",
748 "upstream-openbsd/android/include",
749 "upstream-openbsd/lib/libc/include",
750 ],
751
752 name: "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -0700753}
754
755// ========================================================
Pierre-Clément Tosi467e58e2023-02-01 13:44:43 +0000756// libc_fortify.a - container for our FORTIFY
George Burgess IV6cb06872017-07-21 13:28:42 -0700757// implementation details
758// ========================================================
759cc_library_static {
760 defaults: ["libc_defaults"],
George Burgess IVd34b0a92017-07-25 11:43:39 -0700761 srcs: ["bionic/fortify.cpp"],
George Burgess IV6cb06872017-07-21 13:28:42 -0700762
763 name: "libc_fortify",
764
765 // Disable FORTIFY for the compilation of these, so we don't end up having
766 // FORTIFY silently call itself.
Elliott Hughesd50a1de2018-02-05 17:30:57 -0800767 cflags: [
768 "-U_FORTIFY_SOURCE",
769 "-D__BIONIC_DECLARE_FORTIFY_HELPERS",
770 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700771
772 arch: {
773 arm: {
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800774 cflags: [
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800775 "-DRENAME___STRCAT_CHK",
776 "-DRENAME___STRCPY_CHK",
777 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700778 srcs: [
779 "arch-arm/generic/bionic/__memcpy_chk.S",
Haibo Huangf1c8d1a2018-11-27 15:38:47 -0800780
781 "arch-arm/cortex-a15/bionic/__strcat_chk.S",
782 "arch-arm/cortex-a15/bionic/__strcpy_chk.S",
783
784 "arch-arm/cortex-a7/bionic/__strcat_chk.S",
785 "arch-arm/cortex-a7/bionic/__strcpy_chk.S",
786
787 "arch-arm/cortex-a9/bionic/__strcat_chk.S",
788 "arch-arm/cortex-a9/bionic/__strcpy_chk.S",
789
790 "arch-arm/krait/bionic/__strcat_chk.S",
791 "arch-arm/krait/bionic/__strcpy_chk.S",
792
793 "arch-arm/cortex-a53/bionic/__strcat_chk.S",
794 "arch-arm/cortex-a53/bionic/__strcpy_chk.S",
795
Haibo Huang01bfd892018-12-03 15:05:16 -0800796 "arch-arm/cortex-a55/bionic/__strcat_chk.S",
797 "arch-arm/cortex-a55/bionic/__strcpy_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700798 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700799 },
800 arm64: {
801 srcs: [
Elliott Hughes023e4e72022-11-17 19:27:02 +0000802 "arch-arm64/string/__memcpy_chk.S",
803 "arch-arm64/string/__memset_chk.S",
George Burgess IV6cb06872017-07-21 13:28:42 -0700804 ],
George Burgess IV6cb06872017-07-21 13:28:42 -0700805 },
caowenchengab457f92023-03-06 14:57:55 +0800806 riscv64: {
807 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +0000808 "arch-riscv64/string/__memset_chk.S",
809 "arch-riscv64/string/__memcpy_chk.S",
caowenchengab457f92023-03-06 14:57:55 +0800810 ],
811 },
George Burgess IV6cb06872017-07-21 13:28:42 -0700812 },
813}
814
815// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -0700816// libc_bionic.a - home-grown C library code
817// ========================================================
818
819cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -0700820 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -0700821 srcs: [
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800822 "bionic/NetdClientDispatch.cpp",
823 "bionic/__bionic_get_shell_path.cpp",
824 "bionic/__cmsg_nxthdr.cpp",
825 "bionic/__cxa_thread_atexit_impl.cpp",
826 "bionic/__errno.cpp",
827 "bionic/__gnu_basename.cpp",
828 "bionic/__libc_current_sigrtmax.cpp",
829 "bionic/__libc_current_sigrtmin.cpp",
830 "bionic/abort.cpp",
831 "bionic/accept.cpp",
832 "bionic/access.cpp",
Florian Mayerca4749a2024-02-14 12:55:46 -0800833 "bionic/android_crash_detail.cpp",
Josh Gao10ec9282017-04-03 15:13:29 -0700834 "bionic/android_set_abort_message.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000835 "bionic/android_unsafe_frame_pointer_chase.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800836 "bionic/arpa_inet.cpp",
837 "bionic/assert.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000838 "bionic/atexit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800839 "bionic/atof.cpp",
840 "bionic/bionic_allocator.cpp",
841 "bionic/bionic_arc4random.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000842 "bionic/bionic_elf_tls.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800843 "bionic/bionic_futex.cpp",
844 "bionic/bionic_netlink.cpp",
845 "bionic/bionic_systrace.cpp",
846 "bionic/bionic_time_conversions.cpp",
847 "bionic/brk.cpp",
848 "bionic/c16rtomb.cpp",
849 "bionic/c32rtomb.cpp",
850 "bionic/chmod.cpp",
851 "bionic/chown.cpp",
852 "bionic/clearenv.cpp",
853 "bionic/clock.cpp",
854 "bionic/clock_getcpuclockid.cpp",
855 "bionic/clock_nanosleep.cpp",
856 "bionic/clone.cpp",
857 "bionic/ctype.cpp",
858 "bionic/dirent.cpp",
859 "bionic/dup.cpp",
860 "bionic/environ.cpp",
861 "bionic/error.cpp",
862 "bionic/eventfd.cpp",
863 "bionic/exec.cpp",
864 "bionic/execinfo.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -0800865 "bionic/exit.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800866 "bionic/faccessat.cpp",
867 "bionic/fchmod.cpp",
868 "bionic/fchmodat.cpp",
869 "bionic/fcntl.cpp",
870 "bionic/fdsan.cpp",
871 "bionic/fdtrack.cpp",
872 "bionic/ffs.cpp",
873 "bionic/fgetxattr.cpp",
874 "bionic/flistxattr.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000875 "bionic/fork.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800876 "bionic/fpclassify.cpp",
877 "bionic/fsetxattr.cpp",
878 "bionic/ftruncate.cpp",
879 "bionic/ftw.cpp",
880 "bionic/futimens.cpp",
881 "bionic/getcwd.cpp",
882 "bionic/getdomainname.cpp",
883 "bionic/getentropy.cpp",
884 "bionic/gethostname.cpp",
885 "bionic/getloadavg.cpp",
886 "bionic/getpagesize.cpp",
887 "bionic/getpgrp.cpp",
888 "bionic/getpid.cpp",
889 "bionic/getpriority.cpp",
890 "bionic/gettid.cpp",
891 "bionic/get_device_api_level.cpp",
892 "bionic/grp_pwd.cpp",
893 "bionic/grp_pwd_file.cpp",
894 "bionic/heap_zero_init.cpp",
895 "bionic/iconv.cpp",
896 "bionic/icu_wrappers.cpp",
897 "bionic/ifaddrs.cpp",
898 "bionic/inotify_init.cpp",
899 "bionic/ioctl.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800900 "bionic/isatty.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800901 "bionic/killpg.cpp",
902 "bionic/langinfo.cpp",
Elliott Hughes219e6022024-08-27 19:12:08 +0000903 "bionic/lchmod.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800904 "bionic/lchown.cpp",
905 "bionic/lfs64_support.cpp",
906 "bionic/libc_init_common.cpp",
907 "bionic/libgen.cpp",
908 "bionic/link.cpp",
909 "bionic/locale.cpp",
910 "bionic/lockf.cpp",
911 "bionic/lstat.cpp",
912 "bionic/mblen.cpp",
913 "bionic/mbrtoc16.cpp",
914 "bionic/mbrtoc32.cpp",
915 "bionic/mempcpy.cpp",
916 "bionic/memset_explicit.cpp",
917 "bionic/mkdir.cpp",
918 "bionic/mkfifo.cpp",
919 "bionic/mknod.cpp",
920 "bionic/mntent.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800921 "bionic/netdb.cpp",
Elliott Hughes3ed6e722024-02-16 01:18:01 +0000922 "bionic/net_if.cpp",
923 "bionic/netinet_ether.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800924 "bionic/netinet_in.cpp",
925 "bionic/nl_types.cpp",
926 "bionic/open.cpp",
927 "bionic/pathconf.cpp",
928 "bionic/pause.cpp",
929 "bionic/pidfd.cpp",
930 "bionic/pipe.cpp",
931 "bionic/poll.cpp",
932 "bionic/posix_fadvise.cpp",
933 "bionic/posix_fallocate.cpp",
934 "bionic/posix_madvise.cpp",
935 "bionic/posix_timers.cpp",
936 "bionic/preadv_pwritev.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000937 "bionic/pthread_atfork.cpp",
938 "bionic/pthread_attr.cpp",
939 "bionic/pthread_barrier.cpp",
940 "bionic/pthread_cond.cpp",
941 "bionic/pthread_create.cpp",
942 "bionic/pthread_detach.cpp",
943 "bionic/pthread_equal.cpp",
944 "bionic/pthread_exit.cpp",
945 "bionic/pthread_getcpuclockid.cpp",
946 "bionic/pthread_getschedparam.cpp",
947 "bionic/pthread_gettid_np.cpp",
948 "bionic/pthread_internal.cpp",
949 "bionic/pthread_join.cpp",
950 "bionic/pthread_key.cpp",
951 "bionic/pthread_kill.cpp",
952 "bionic/pthread_mutex.cpp",
953 "bionic/pthread_once.cpp",
954 "bionic/pthread_rwlock.cpp",
955 "bionic/pthread_sigqueue.cpp",
956 "bionic/pthread_self.cpp",
957 "bionic/pthread_setname_np.cpp",
958 "bionic/pthread_setschedparam.cpp",
959 "bionic/pthread_spinlock.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800960 "bionic/ptrace.cpp",
961 "bionic/pty.cpp",
962 "bionic/raise.cpp",
963 "bionic/rand.cpp",
964 "bionic/readlink.cpp",
965 "bionic/realpath.cpp",
966 "bionic/reboot.cpp",
967 "bionic/recv.cpp",
968 "bionic/recvmsg.cpp",
969 "bionic/rename.cpp",
970 "bionic/rmdir.cpp",
971 "bionic/scandir.cpp",
Elliott Hughes17e40682024-02-13 16:32:29 -0800972 "bionic/sched_cpualloc.cpp",
973 "bionic/sched_cpucount.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800974 "bionic/sched_getaffinity.cpp",
975 "bionic/sched_getcpu.cpp",
976 "bionic/semaphore.cpp",
977 "bionic/send.cpp",
978 "bionic/setegid.cpp",
979 "bionic/seteuid.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000980 "bionic/setjmp_cookie.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -0800981 "bionic/setpgrp.cpp",
982 "bionic/sigaction.cpp",
983 "bionic/signal.cpp",
984 "bionic/sigprocmask.cpp",
985 "bionic/sleep.cpp",
986 "bionic/socketpair.cpp",
987 "bionic/spawn.cpp",
988 "bionic/stat.cpp",
989 "bionic/stdlib_l.cpp",
990 "bionic/strerror.cpp",
991 "bionic/string_l.cpp",
992 "bionic/strings_l.cpp",
993 "bionic/strsignal.cpp",
994 "bionic/strtol.cpp",
995 "bionic/strtold.cpp",
996 "bionic/swab.cpp",
997 "bionic/symlink.cpp",
998 "bionic/sync_file_range.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +0000999 "bionic/sysconf.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001000 "bionic/sys_epoll.cpp",
1001 "bionic/sys_msg.cpp",
1002 "bionic/sys_sem.cpp",
1003 "bionic/sys_shm.cpp",
1004 "bionic/sys_signalfd.cpp",
1005 "bionic/sys_statfs.cpp",
1006 "bionic/sys_statvfs.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001007 "bionic/sys_thread_properties.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001008 "bionic/sys_time.cpp",
1009 "bionic/sysinfo.cpp",
1010 "bionic/syslog.cpp",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001011 "bionic/sysprop_helpers.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001012 "bionic/system.cpp",
1013 "bionic/system_property_api.cpp",
1014 "bionic/system_property_set.cpp",
1015 "bionic/tdestroy.cpp",
1016 "bionic/termios.cpp",
1017 "bionic/thread_private.cpp",
1018 "bionic/threads.cpp",
1019 "bionic/time.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001020 "bionic/tmpfile.cpp",
1021 "bionic/umount.cpp",
1022 "bionic/unlink.cpp",
1023 "bionic/usleep.cpp",
1024 "bionic/utmp.cpp",
Elliott Hughesb0948922024-01-26 00:28:12 +00001025 "bionic/vdso.cpp",
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001026 "bionic/wait.cpp",
1027 "bionic/wchar.cpp",
1028 "bionic/wchar_l.cpp",
1029 "bionic/wcstod.cpp",
1030 "bionic/wctype.cpp",
1031 "bionic/wcwidth.cpp",
1032 "bionic/wmempcpy.cpp",
1033
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001034 // Forked but not yet cleaned up/rewritten stdio code.
1035 // TODO: finish cleanup.
1036 "stdio/fmemopen.cpp",
1037 "stdio/parsefloat.c",
1038 "stdio/refill.c",
1039 "stdio/stdio.cpp",
1040 "stdio/stdio_ext.cpp",
1041 "stdio/vfscanf.cpp",
1042 "stdio/vfwscanf.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001043 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001044
1045 arch: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001046 arm: {
Elliott Hughes1b61d782019-06-04 10:38:34 -07001047 asflags: libc_common_flags + ["-mno-restrict-it"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001048 srcs: [
Ryan Prichard45024fe2018-12-30 21:10:26 -08001049 "arch-arm/bionic/__aeabi_read_tp.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001050 "arch-arm/bionic/__bionic_clone.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001051 "arch-arm/bionic/__restore.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001052 "arch-arm/bionic/_exit_with_stack_teardown.S",
Yi Kongb410d0e2019-04-22 16:00:46 -07001053 "arch-arm/bionic/atomics_arm.c",
1054 "arch-arm/bionic/bpabi.c",
Yi Kong165b1cf2019-02-13 14:10:10 -08001055 "arch-arm/bionic/libcrt_compat.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001056 "arch-arm/bionic/popcount_tab.c",
Dan Willemsen208ae172015-09-16 16:33:27 -07001057 "arch-arm/bionic/setjmp.S",
1058 "arch-arm/bionic/syscall.S",
1059 "arch-arm/bionic/vfork.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001060
Haibo Huangea9957a2018-11-19 11:00:32 -08001061 "arch-arm/cortex-a7/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001062 "arch-arm/cortex-a7/bionic/memset.S",
1063
1064 "arch-arm/cortex-a9/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001065 "arch-arm/cortex-a9/bionic/memset.S",
1066 "arch-arm/cortex-a9/bionic/stpcpy.S",
1067 "arch-arm/cortex-a9/bionic/strcat.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001068 "arch-arm/cortex-a9/bionic/strcpy.S",
1069 "arch-arm/cortex-a9/bionic/strlen.S",
1070
Elliott Hughesaefe9992023-11-08 12:04:41 -08001071 "arch-arm/cortex-a15/bionic/memcpy.S",
1072 "arch-arm/cortex-a15/bionic/memmove.S",
1073 "arch-arm/cortex-a15/bionic/memset.S",
1074 "arch-arm/cortex-a15/bionic/stpcpy.S",
1075 "arch-arm/cortex-a15/bionic/strcat.S",
1076 "arch-arm/cortex-a15/bionic/strcmp.S",
1077 "arch-arm/cortex-a15/bionic/strcpy.S",
1078 "arch-arm/cortex-a15/bionic/strlen.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001079
1080 "arch-arm/cortex-a53/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001081
Haibo Huang01bfd892018-12-03 15:05:16 -08001082 "arch-arm/cortex-a55/bionic/memcpy.S",
Haibo Huangea9957a2018-11-19 11:00:32 -08001083
Elliott Hughesaefe9992023-11-08 12:04:41 -08001084 "arch-arm/generic/bionic/memcmp.S",
1085 "arch-arm/generic/bionic/memmove.S",
1086 "arch-arm/generic/bionic/memset.S",
1087 "arch-arm/generic/bionic/stpcpy.c",
1088 "arch-arm/generic/bionic/strcat.c",
1089 "arch-arm/generic/bionic/strcmp.S",
1090 "arch-arm/generic/bionic/strcpy.S",
1091 "arch-arm/generic/bionic/strlen.c",
1092
1093 "arch-arm/krait/bionic/memcpy.S",
1094 "arch-arm/krait/bionic/memset.S",
1095
Haibo Huangea9957a2018-11-19 11:00:32 -08001096 "arch-arm/kryo/bionic/memcpy.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001097
1098 "bionic/strchr.cpp",
1099 "bionic/strchrnul.cpp",
1100 "bionic/strnlen.cpp",
1101 "bionic/strrchr.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001102 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001103 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001104 arm64: {
1105 srcs: [
Dan Willemsen3e621712016-02-03 21:48:08 -08001106 "arch-arm64/bionic/__bionic_clone.S",
1107 "arch-arm64/bionic/_exit_with_stack_teardown.S",
1108 "arch-arm64/bionic/setjmp.S",
1109 "arch-arm64/bionic/syscall.S",
1110 "arch-arm64/bionic/vfork.S",
Vaisakh K V83e55842024-03-29 12:47:39 +05301111 "arch-arm64/oryon/memcpy-nt.S",
Vaisakh K V54a61212024-03-29 13:32:45 +05301112 "arch-arm64/oryon/memset-nt.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001113 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001114 },
1115
Elliott Hughesebc19a92022-10-14 23:25:36 +00001116 riscv64: {
1117 srcs: [
1118 "arch-riscv64/bionic/__bionic_clone.S",
1119 "arch-riscv64/bionic/_exit_with_stack_teardown.S",
Elliott Hughese1905ed2022-10-17 23:23:36 +00001120 "arch-riscv64/bionic/setjmp.S",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001121 "arch-riscv64/bionic/syscall.S",
1122 "arch-riscv64/bionic/vfork.S",
Yun Hsiang40a82d02023-05-26 10:10:40 +08001123
Elliott Hughesaefe9992023-11-08 12:04:41 -08001124 "arch-riscv64/string/memchr_v.S",
1125 "arch-riscv64/string/memcmp_v.S",
1126 "arch-riscv64/string/memcpy_v.S",
1127 "arch-riscv64/string/memmove_v.S",
1128 "arch-riscv64/string/memset_v.S",
1129 "arch-riscv64/string/stpcpy_v.S",
1130 "arch-riscv64/string/strcat_v.S",
1131 "arch-riscv64/string/strchr_v.S",
1132 "arch-riscv64/string/strcmp_v.S",
1133 "arch-riscv64/string/strcpy_v.S",
1134 "arch-riscv64/string/strlen_v.S",
1135 "arch-riscv64/string/strncat_v.S",
1136 "arch-riscv64/string/strncmp_v.S",
1137 "arch-riscv64/string/strncpy_v.S",
1138 "arch-riscv64/string/strnlen_v.S",
1139
1140 "arch-riscv64/string/memchr.c",
1141 "arch-riscv64/string/memcmp.c",
1142 "arch-riscv64/string/memcpy.c",
1143 "arch-riscv64/string/memmove.c",
1144 "arch-riscv64/string/memset.c",
1145 "arch-riscv64/string/stpcpy.c",
1146 "arch-riscv64/string/strcat.c",
1147 "arch-riscv64/string/strchr.c",
1148 "arch-riscv64/string/strcmp.c",
1149 "arch-riscv64/string/strcpy.c",
1150 "arch-riscv64/string/strlen.c",
1151 "arch-riscv64/string/strncat.c",
1152 "arch-riscv64/string/strncmp.c",
1153 "arch-riscv64/string/strncpy.c",
1154 "arch-riscv64/string/strnlen.c",
Prashanth Swaminathana4d71022023-10-30 17:35:19 -07001155
Elliott Hughes7d136662023-10-27 15:40:32 -07001156 "bionic/strchrnul.cpp",
1157 "bionic/strrchr.cpp",
Elliott Hughesebc19a92022-10-14 23:25:36 +00001158 ],
1159 },
1160
Dan Willemsen208ae172015-09-16 16:33:27 -07001161 x86: {
1162 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001163 "arch-x86/bionic/__bionic_clone.S",
1164 "arch-x86/bionic/_exit_with_stack_teardown.S",
1165 "arch-x86/bionic/libcrt_compat.c",
Elliott Hughes7d136662023-10-27 15:40:32 -07001166 "arch-x86/bionic/setjmp.S",
1167 "arch-x86/bionic/syscall.S",
1168 "arch-x86/bionic/vfork.S",
1169 "arch-x86/bionic/__x86.get_pc_thunk.S",
1170
Elliott Hughesed777142022-07-25 16:25:11 +00001171 "arch-x86/string/sse2-memchr-atom.S",
1172 "arch-x86/string/sse2-memmove-slm.S",
1173 "arch-x86/string/sse2-memrchr-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001174 "arch-x86/string/sse2-memset-slm.S",
1175 "arch-x86/string/sse2-stpcpy-slm.S",
1176 "arch-x86/string/sse2-stpncpy-slm.S",
1177 "arch-x86/string/sse2-strchr-atom.S",
1178 "arch-x86/string/sse2-strcpy-slm.S",
1179 "arch-x86/string/sse2-strlen-slm.S",
1180 "arch-x86/string/sse2-strncpy-slm.S",
1181 "arch-x86/string/sse2-strnlen-atom.S",
1182 "arch-x86/string/sse2-strrchr-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001183
1184 "arch-x86/string/ssse3-memcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001185 "arch-x86/string/ssse3-strcat-atom.S",
1186 "arch-x86/string/ssse3-strcmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001187 "arch-x86/string/ssse3-strlcat-atom.S",
1188 "arch-x86/string/ssse3-strlcpy-atom.S",
1189 "arch-x86/string/ssse3-strncat-atom.S",
1190 "arch-x86/string/ssse3-strncmp-atom.S",
Elliott Hughesed777142022-07-25 16:25:11 +00001191
1192 "arch-x86/string/sse4-memcmp-slm.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001193
1194 "bionic/strchrnul.cpp",
Dan Willemsen268a6732015-10-15 14:49:45 -07001195 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001196 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001197 x86_64: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001198 srcs: [
Elliott Hughes7d136662023-10-27 15:40:32 -07001199 "arch-x86_64/bionic/__bionic_clone.S",
1200 "arch-x86_64/bionic/_exit_with_stack_teardown.S",
1201 "arch-x86_64/bionic/__restore_rt.S",
1202 "arch-x86_64/bionic/setjmp.S",
1203 "arch-x86_64/bionic/syscall.S",
1204 "arch-x86_64/bionic/vfork.S",
1205
ahs919fb7f2022-06-10 07:11:14 +05301206 "arch-x86_64/string/avx2-memset-kbl.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001207 "arch-x86_64/string/sse2-memmove-slm.S",
1208 "arch-x86_64/string/sse2-memset-slm.S",
1209 "arch-x86_64/string/sse2-stpcpy-slm.S",
1210 "arch-x86_64/string/sse2-stpncpy-slm.S",
1211 "arch-x86_64/string/sse2-strcat-slm.S",
1212 "arch-x86_64/string/sse2-strcpy-slm.S",
Dan Willemsen208ae172015-09-16 16:33:27 -07001213 "arch-x86_64/string/sse2-strlen-slm.S",
1214 "arch-x86_64/string/sse2-strncat-slm.S",
1215 "arch-x86_64/string/sse2-strncpy-slm.S",
1216 "arch-x86_64/string/sse4-memcmp-slm.S",
1217 "arch-x86_64/string/ssse3-strcmp-slm.S",
1218 "arch-x86_64/string/ssse3-strncmp-slm.S",
Elliott Hughesaefe9992023-11-08 12:04:41 -08001219
1220 "bionic/strchr.cpp",
1221 "bionic/strchrnul.cpp",
1222 "bionic/strnlen.cpp",
1223 "bionic/strrchr.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001224 ],
1225 },
Dan Willemsen268a6732015-10-15 14:49:45 -07001226 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001227
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001228 multilib: {
1229 lib32: {
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001230 srcs: [
1231 // off64_t/time64_t support on LP32.
1232 "bionic/legacy_32_bit_support.cpp",
1233 "bionic/time64.c",
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001234 ],
Elliott Hughes2e2b9bc2024-02-07 16:10:23 -08001235 },
1236 },
1237
1238 local_include_dirs: ["stdio"],
1239 generated_headers: ["generated_android_ids"],
1240
1241 whole_static_libs: [
1242 "libsystemproperties",
1243 ],
1244
Colin Cross50c21ab2015-10-31 23:03:05 -07001245 cppflags: ["-Wold-style-cast"],
Dan Willemsen268a6732015-10-15 14:49:45 -07001246 include_dirs: ["bionic/libstdc++/include"],
1247 name: "libc_bionic",
Dan Willemsen268a6732015-10-15 14:49:45 -07001248}
1249
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001250genrule {
1251 name: "generated_android_ids",
Colin Cross35bbed82017-01-17 18:16:07 -08001252 out: ["generated_android_ids.h"],
1253 srcs: [":android_filesystem_config_header"],
Cole Faustb1a0a9d2023-11-28 17:51:16 -08001254 tools: ["fs_config_generator"],
1255 cmd: "$(location fs_config_generator) aidarray $(in) > $(out)",
Elliott Hughes3f6eee92016-12-13 23:47:25 +00001256}
1257
Dan Willemsen268a6732015-10-15 14:49:45 -07001258// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001259// libc_syscalls.a
1260// ========================================================
1261
Elliott Hughes782c4852019-04-16 12:31:00 -07001262genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001263 name: "syscalls-arm",
Elliott Hughes782c4852019-04-16 12:31:00 -07001264 out: ["syscalls-arm.S"],
1265 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001266 tools: ["gensyscalls"],
1267 cmd: "$(location gensyscalls) arm $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001268}
1269
1270genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001271 name: "syscalls-arm64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001272 out: ["syscalls-arm64.S"],
1273 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001274 tools: ["gensyscalls"],
1275 cmd: "$(location gensyscalls) arm64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001276}
1277
1278genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001279 name: "syscalls-riscv64",
Elliott Hughes704772b2022-10-10 17:06:43 +00001280 out: ["syscalls-riscv64.S"],
1281 srcs: ["SYSCALLS.TXT"],
1282 tools: ["gensyscalls"],
1283 cmd: "$(location gensyscalls) riscv64 $(in) > $(out)",
1284}
1285
1286genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001287 name: "syscalls-x86",
Elliott Hughes782c4852019-04-16 12:31:00 -07001288 out: ["syscalls-x86.S"],
1289 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001290 tools: ["gensyscalls"],
1291 cmd: "$(location gensyscalls) x86 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001292}
1293
1294genrule {
Cole Faustf5968d82023-04-11 15:20:19 -07001295 name: "syscalls-x86_64",
Elliott Hughes782c4852019-04-16 12:31:00 -07001296 out: ["syscalls-x86_64.S"],
1297 srcs: ["SYSCALLS.TXT"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001298 tools: ["gensyscalls"],
1299 cmd: "$(location gensyscalls) x86_64 $(in) > $(out)",
Elliott Hughes782c4852019-04-16 12:31:00 -07001300}
1301
Dan Willemsen208ae172015-09-16 16:33:27 -07001302cc_library_static {
Colin Cross27c43c52016-04-07 13:27:24 -07001303 defaults: ["libc_defaults"],
Josh Gao0e0e3702017-10-12 13:34:42 -07001304 srcs: ["bionic/__set_errno.cpp"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001305 arch: {
1306 arm: {
Cole Faustf5968d82023-04-11 15:20:19 -07001307 srcs: [":syscalls-arm"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001308 },
1309 arm64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001310 srcs: [":syscalls-arm64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001311 },
Elliott Hughes704772b2022-10-10 17:06:43 +00001312 riscv64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001313 srcs: [":syscalls-riscv64"],
Elliott Hughes704772b2022-10-10 17:06:43 +00001314 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001315 x86: {
Cole Faustf5968d82023-04-11 15:20:19 -07001316 srcs: [":syscalls-x86"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001317 },
1318 x86_64: {
Cole Faustf5968d82023-04-11 15:20:19 -07001319 srcs: [":syscalls-x86_64"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001320 },
1321 },
1322 name: "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001323}
1324
1325// ========================================================
1326// libc_aeabi.a
1327// This is an LP32 ARM-only library that needs to be built with -fno-builtin
1328// to avoid infinite recursion. For the other architectures we just build an
1329// empty library to keep this makefile simple.
1330// ========================================================
1331
1332cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001333 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001334 arch: {
1335 arm: {
1336 srcs: ["arch-arm/bionic/__aeabi.c"],
1337 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001338 },
1339 name: "libc_aeabi",
Colin Cross50c21ab2015-10-31 23:03:05 -07001340 cflags: ["-fno-builtin"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001341}
1342
1343// ========================================================
Elliott Hughes69bd8e92024-02-09 10:04:26 -08001344// libc_common.a --- everything shared by libc.a and libc.so
Dan Willemsen208ae172015-09-16 16:33:27 -07001345// ========================================================
Elliott Hughesb0948922024-01-26 00:28:12 +00001346
Dan Willemsen208ae172015-09-16 16:33:27 -07001347cc_library_static {
Colin Cross50c21ab2015-10-31 23:03:05 -07001348 defaults: ["libc_defaults"],
Elliott Hughesb0948922024-01-26 00:28:12 +00001349 name: "libc_common",
1350
Dan Willemsen208ae172015-09-16 16:33:27 -07001351 whole_static_libs: [
Peter Collingbourne337a5b32020-02-21 12:11:02 -08001352 "libarm-optimized-routines-string",
Rupert Shuttleworth78f48a52021-03-16 06:39:19 +00001353 "libasync_safe",
Dan Willemsen208ae172015-09-16 16:33:27 -07001354 "libc_bionic",
Ryan Prichard249757b2019-11-01 17:18:28 -07001355 "libc_bootstrap",
Dan Willemsen208ae172015-09-16 16:33:27 -07001356 "libc_dns",
George Burgess IV6cb06872017-07-21 13:28:42 -07001357 "libc_fortify",
Dan Willemsen208ae172015-09-16 16:33:27 -07001358 "libc_freebsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001359 "libc_freebsd_large_stack",
Elliott Hughesc2043342023-07-20 20:24:09 +00001360 "libc_freebsd_ldexp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001361 "libc_gdtoa",
Dan Willemsen208ae172015-09-16 16:33:27 -07001362 "libc_netbsd",
1363 "libc_openbsd",
Elliott Hughes8e547bd2016-08-16 15:57:47 -07001364 "libc_openbsd_large_stack",
Dan Willemsen208ae172015-09-16 16:33:27 -07001365 "libc_syscalls",
Dan Willemsen208ae172015-09-16 16:33:27 -07001366 "libc_tzcode",
Elliott Hughes816fab92016-05-27 17:57:46 -07001367 "libstdc++",
Dan Willemsen208ae172015-09-16 16:33:27 -07001368 ],
1369
1370 arch: {
1371 arm: {
1372 whole_static_libs: ["libc_aeabi"],
1373 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001374 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001375}
1376
1377// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001378// libc_static_dispatch.a/libc_dynamic_dispatch.a --- string/memory "ifuncs"
1379// (Actually ifuncs for libc.so, but a home-grown alternative for libc.a.)
Haibo Huangf71edfa2018-11-12 10:06:56 -08001380// ========================================================
Elliott Hughesadc41712024-08-16 13:08:11 +00001381
1382cc_defaults {
1383 name: "libc_dispatch_defaults",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001384 defaults: ["libc_defaults"],
Haibo Huangb9244ff2018-08-11 10:12:13 -07001385 arch: {
ahs919fb7f2022-06-10 07:11:14 +05301386 x86_64: {
1387 srcs: ["arch-x86_64/dynamic_function_dispatch.cpp"],
1388 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001389 x86: {
1390 srcs: ["arch-x86/dynamic_function_dispatch.cpp"],
1391 },
Haibo Huangea9957a2018-11-19 11:00:32 -08001392 arm: {
Elliott Hughes927fe992019-01-31 22:29:22 +00001393 srcs: ["arch-arm/dynamic_function_dispatch.cpp"],
Haibo Huangea9957a2018-11-19 11:00:32 -08001394 },
Peter Collingbourne900d07d2019-10-28 13:11:00 -07001395 arm64: {
1396 srcs: ["arch-arm64/dynamic_function_dispatch.cpp"],
1397 },
Elliott Hughesaefe9992023-11-08 12:04:41 -08001398 riscv64: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001399 srcs: ["arch-riscv64/dynamic_function_dispatch.cpp"],
Elliott Hughesaefe9992023-11-08 12:04:41 -08001400 },
Haibo Huangb9244ff2018-08-11 10:12:13 -07001401 },
Elliott Hughesadc41712024-08-16 13:08:11 +00001402 // Prevent the compiler from inserting calls to libc/taking the address of
1403 // a jump table from within an ifunc (or, in the static case, code that
1404 // can be executed arbitrarily early).
1405 cflags: [
1406 "-ffreestanding",
1407 "-fno-stack-protector",
1408 "-fno-jump-tables",
1409 ],
1410}
1411
1412cc_library_static {
1413 name: "libc_static_dispatch",
1414 defaults: ["libc_dispatch_defaults"],
1415 cflags: [
1416 "-DBIONIC_STATIC_DISPATCH",
1417 ],
1418}
1419
1420cc_library_static {
1421 name: "libc_dynamic_dispatch",
1422 defaults: ["libc_dispatch_defaults"],
1423 cflags: [
1424 "-DBIONIC_DYNAMIC_DISPATCH",
1425 ],
Ryan Prichard249757b2019-11-01 17:18:28 -07001426}
1427
1428// ========================================================
1429// libc_common_static.a For static binaries.
1430// ========================================================
1431cc_library_static {
1432 defaults: ["libc_defaults"],
1433 name: "libc_common_static",
Haibo Huangb9244ff2018-08-11 10:12:13 -07001434
Haibo Huangf71edfa2018-11-12 10:06:56 -08001435 whole_static_libs: [
1436 "libc_common",
Ryan Prichard249757b2019-11-01 17:18:28 -07001437 "libc_static_dispatch",
1438 ],
1439}
1440
1441// ========================================================
1442// libc_common_shared.a For shared libraries.
1443// ========================================================
1444cc_library_static {
1445 defaults: ["libc_defaults"],
1446 name: "libc_common_shared",
1447
1448 whole_static_libs: [
1449 "libc_common",
1450 "libc_dynamic_dispatch",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001451 ],
1452}
1453
Ryan Prichard22a6a052019-10-10 23:59:30 -07001454// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static
1455// executable.
1456cc_library_static {
1457 name: "libc_unwind_static",
1458 defaults: ["libc_defaults"],
1459 cflags: ["-DLIBC_STATIC"],
1460
1461 srcs: ["bionic/dl_iterate_phdr_static.cpp"],
1462 arch: {
1463 // arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs
1464 arm: {
1465 srcs: ["arch-arm/bionic/exidx_static.c"],
1466 },
1467 },
1468}
1469
Haibo Huangf71edfa2018-11-12 10:06:56 -08001470// ========================================================
Dan Willemsen208ae172015-09-16 16:33:27 -07001471// libc_nomalloc.a
1472// ========================================================
1473//
Ryan Prichard249757b2019-11-01 17:18:28 -07001474// This is a version of the static C library used by the dynamic linker that exclude malloc. It also
1475// excludes functions selected using ifunc's (e.g. for string.h). Link in either
1476// libc_static_dispatch or libc_dynamic_dispatch to provide those functions.
Dan Willemsen208ae172015-09-16 16:33:27 -07001477
1478cc_library_static {
Dimitry Ivanovfc0d4802016-12-06 11:10:09 -08001479 name: "libc_nomalloc",
Colin Cross50c21ab2015-10-31 23:03:05 -07001480 defaults: ["libc_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001481
Colin Crossa3f9fca2016-01-11 13:20:55 -08001482 whole_static_libs: [
Ryan Prichard249757b2019-11-01 17:18:28 -07001483 "libc_common",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001484 "libc_init_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001485 "libc_unwind_static",
Colin Crossa3f9fca2016-01-11 13:20:55 -08001486 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001487}
1488
dimitryc0c0ef62018-12-05 16:33:52 +01001489filegroup {
1490 name: "libc_sources_shared",
1491 srcs: [
1492 "arch-common/bionic/crtbegin_so.c",
1493 "arch-common/bionic/crtbrand.S",
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001494 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001495 "bionic/heap_tagging.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001496 "bionic/icu.cpp",
1497 "bionic/malloc_common.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001498 "bionic/malloc_common_dynamic.cpp",
Ryan Savitski175c8862020-01-02 19:54:57 +00001499 "bionic/android_profiling_dynamic.cpp",
Christopher Ferrise4cdbc42019-02-08 17:30:58 -08001500 "bionic/malloc_heapprofd.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001501 "bionic/malloc_limit.cpp",
Peter Collingbourne570de332019-12-11 10:00:58 -08001502 "bionic/ndk_cruft.cpp",
1503 "bionic/ndk_cruft_data.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001504 "bionic/NetdClient.cpp",
1505 "arch-common/bionic/crtend_so.S",
1506 ],
1507}
1508
1509filegroup {
1510 name: "libc_sources_static",
1511 srcs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001512 "bionic/gwp_asan_wrappers.cpp",
Peter Collingbourne1e110fb2020-01-09 10:48:22 -08001513 "bionic/heap_tagging.cpp",
Elliott Hughes72b0f3b2024-07-02 20:22:35 +00001514 "bionic/icu_static.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001515 "bionic/malloc_common.cpp",
Christopher Ferris1fc5ccf2019-02-15 18:06:15 -08001516 "bionic/malloc_limit.cpp",
dimitryc0c0ef62018-12-05 16:33:52 +01001517 ],
1518}
1519
1520filegroup {
1521 name: "libc_sources_shared_arm",
1522 srcs: [
1523 "arch-arm/bionic/exidx_dynamic.c",
1524 "arch-arm/bionic/atexit_legacy.c",
1525 ],
1526}
1527
Dan Willemsen208ae172015-09-16 16:33:27 -07001528// ========================================================
1529// libc.a + libc.so
1530// ========================================================
Florian Mayerc10d0642023-03-22 16:12:49 -07001531cc_defaults {
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001532 defaults: [
1533 "libc_defaults",
1534 "libc_native_allocator_defaults",
Elliott Hughes788075a2024-06-18 12:25:37 +00001535 "bug_24465209_workaround",
Elliott Hughes89aada12024-07-01 21:59:04 +00001536 "keep_symbols",
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001537 ],
Florian Mayerc10d0642023-03-22 16:12:49 -07001538 name: "libc_library_defaults",
Colin Cross50c21ab2015-10-31 23:03:05 -07001539 product_variables: {
Dan Willemsen208ae172015-09-16 16:33:27 -07001540 platform_sdk_version: {
1541 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
1542 },
1543 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001544 static: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001545 srcs: [":libc_sources_static"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001546 cflags: ["-DLIBC_STATIC"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001547 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001548 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001549 "libc_init_static",
1550 "libc_common_static",
Ryan Prichard22a6a052019-10-10 23:59:30 -07001551 "libc_unwind_static",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001552 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001553 },
1554 shared: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001555 srcs: [":libc_sources_shared"],
Haibo Huangf71edfa2018-11-12 10:06:56 -08001556 whole_static_libs: [
Mitch Phillipsf3968e82020-01-31 19:57:04 -08001557 "gwp_asan",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001558 "libc_init_dynamic",
1559 "libc_common_shared",
Ryan Prichardcdf71752020-12-16 03:37:22 -08001560 "libunwind-exported",
Haibo Huangf71edfa2018-11-12 10:06:56 -08001561 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001562 },
1563
Neil Fullera7db90f2019-04-25 09:28:27 +01001564 required: [
MarkDacekd88d7ea2022-06-28 20:14:58 +00001565 "tzdata_prebuilt",
1566 "tz_version_prebuilt", // Version metadata for tzdata to help debugging.
Neil Fullera7db90f2019-04-25 09:28:27 +01001567 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001568
Colin Cross4ce94d22016-11-15 13:15:43 -08001569 // Do not pack libc.so relocations; see http://b/20645321 for details.
1570 pack_relocations: false,
1571
dimitry06016f22018-01-05 11:39:28 +01001572 shared_libs: [
1573 "ld-android",
1574 "libdl",
1575 ],
Jiyong Park3ff116a2019-04-02 23:04:52 +09001576 static_libs: [
1577 "libdl_android",
1578 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001579
1580 nocrt: true,
1581
Dan Willemsen208ae172015-09-16 16:33:27 -07001582 arch: {
1583 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001584 version_script: ":libc.arm.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001585 no_libcrt: true,
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001586
Dan Willemsen208ae172015-09-16 16:33:27 -07001587 shared: {
dimitryc0c0ef62018-12-05 16:33:52 +01001588 srcs: [":libc_sources_shared_arm"],
Dan Willemsen0c657082016-05-12 01:43:07 -07001589 // special for arm
1590 cflags: ["-DCRT_LEGACY_WORKAROUND"],
Elliott Hughes89aada12024-07-01 21:59:04 +00001591 // For backwards compatibility, some arm32 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001592 static_libs: ["libclang_rt.builtins-exported"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001593 },
Christopher Ferris0c0f6fb2019-05-17 16:22:56 -07001594
Elliott Hughes89aada12024-07-01 21:59:04 +00001595 ldflags: [
1596 // Since we preserve the debug_frame for libc, do not compress
1597 // in this case to make unwinds as fast as possible.
1598 "-Wl,--compress-debug-sections=none",
1599 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001600 },
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001601 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001602 version_script: ":libc.arm64.map",
Dan Willemsen9e6f98f2015-11-03 14:30:57 -08001603 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001604 riscv64: {
1605 version_script: ":libc.riscv64.map",
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001606 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001607 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001608 version_script: ":libc.x86.map",
Ryan Prichardc22562c2021-01-27 17:27:31 -08001609 no_libcrt: true,
1610
1611 shared: {
Elliott Hughes89aada12024-07-01 21:59:04 +00001612 // For backwards compatibility, some x86 builtins are exported from libc.so.
Colin Cross335e27b2022-02-10 11:37:28 -08001613 static_libs: ["libclang_rt.builtins-exported"],
Ryan Prichardc22562c2021-01-27 17:27:31 -08001614 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001615 },
1616 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001617 version_script: ":libc.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001618 },
1619 },
Jiyong Parkc45fe9f2018-12-13 18:26:48 +09001620
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001621 apex_available: [
Jiyong Parke87e0dc2019-10-02 17:09:33 +09001622 "com.android.runtime",
1623 ],
1624
Colin Cross7edd0082021-10-28 13:20:35 -07001625 target: {
1626 native_bridge: {
1627 shared: {
1628 installable: false,
1629 },
1630 },
1631 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001632}
1633
Florian Mayerc10d0642023-03-22 16:12:49 -07001634cc_library {
1635 name: "libc",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001636 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001637 "libc_library_defaults",
1638 ],
1639 stubs: {
1640 symbol_file: "libc.map.txt",
1641 versions: [
1642 "29",
1643 "R",
1644 "current",
1645 ],
1646 },
1647 static_ndk_lib: true,
1648 llndk: {
1649 symbol_file: "libc.map.txt",
1650 export_headers_as_system: true,
Dan Alberte9f02e02024-08-28 23:20:20 +00001651 export_llndk_headers: ["libc_headers"],
Florian Mayerc10d0642023-03-22 16:12:49 -07001652 },
1653}
1654
1655cc_library {
1656 name: "libc_hwasan",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00001657 defaults: [
Florian Mayerc10d0642023-03-22 16:12:49 -07001658 "libc_library_defaults",
1659 ],
1660 sanitize: {
1661 hwaddress: true,
1662 },
1663 enabled: false,
Florian Mayerff116ed2023-04-14 17:38:53 -07001664 target: {
1665 android_arm64: {
Florian Mayerc10d0642023-03-22 16:12:49 -07001666 enabled: true,
1667 },
1668 },
1669 stem: "libc",
1670 relative_install_path: "hwasan",
1671 // We don't really need the stubs, but this needs to stay to trigger the
1672 // symlink logic in soong.
1673 stubs: {
1674 symbol_file: "libc.map.txt",
1675 },
1676 native_bridge_supported: false,
1677 // It is never correct to depend on this directly. This is only
1678 // needed for the runtime apex, and in base_system.mk.
1679 visibility: ["//bionic/apex"],
1680}
1681
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001682genrule {
1683 name: "libc.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001684 out: ["libc.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001685 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001686 tools: ["generate-version-script"],
1687 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001688}
1689
1690genrule {
1691 name: "libc.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001692 out: ["libc.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001693 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001694 tools: ["generate-version-script"],
1695 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001696}
1697
1698genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001699 name: "libc.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001700 out: ["libc.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001701 srcs: ["libc.map.txt"],
1702 tools: ["generate-version-script"],
1703 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1704}
1705
1706genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001707 name: "libc.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001708 out: ["libc.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001709 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001710 tools: ["generate-version-script"],
1711 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001712}
1713
1714genrule {
1715 name: "libc.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001716 out: ["libc.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001717 srcs: ["libc.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001718 tools: ["generate-version-script"],
1719 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001720}
1721
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001722// Headers that only other parts of the platform can include.
1723cc_library_headers {
1724 name: "bionic_libc_platform_headers",
Martin Stjernholma2763432020-04-23 16:47:19 +01001725 defaults: ["linux_bionic_supported"],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001726 visibility: [
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001727 "//art:__subpackages__",
Josh Gao97271922019-11-06 13:15:00 -08001728 "//bionic:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001729 "//frameworks:__subpackages__",
Roman Kiryanov067f5182020-05-07 14:58:30 -07001730 "//device/generic/goldfish-opengl:__subpackages__",
Mitch Phillips3309b3d2020-03-25 15:05:48 -07001731 "//external/gwp_asan:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001732 "//external/perfetto:__subpackages__",
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001733 "//external/scudo:__subpackages__",
Josh Gao5074e7d2019-12-13 13:55:53 -08001734 "//system/core/debuggerd:__subpackages__",
Florian Mayerf5d70ce2022-09-13 13:58:30 -07001735 "//system/core/init:__subpackages__",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001736 "//system/core/libcutils:__subpackages__",
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001737 "//system/memory/libmemunreachable:__subpackages__",
Baligh Uddindb0c6de2020-10-15 04:49:00 +00001738 "//system/unwinding/libunwindstack:__subpackages__",
Peter Collingbourne15418002020-05-12 16:02:50 -07001739 "//tools/security/sanitizer-status:__subpackages__",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001740 ],
Peter Collingbourne6a363f72020-01-13 10:39:33 -08001741 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001742 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001743 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001744 vendor_ramdisk_available: true,
Christopher Ferrisc5d3a432019-09-25 17:50:36 -07001745 recovery_available: true,
1746 native_bridge_supported: true,
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001747 export_include_dirs: [
1748 "platform",
1749 ],
Christopher Ferrise55e5ee2019-10-01 17:54:42 -07001750 system_shared_libs: [],
1751 stl: "none",
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001752 sdk_version: "current",
Jiyong Park4ede1602020-04-28 18:21:08 +09001753
Steven Moreland0cdf1322020-10-05 21:55:26 +00001754 min_sdk_version: "29",
Jiyong Park4ede1602020-04-28 18:21:08 +09001755 apex_available: [
1756 "//apex_available:platform",
Steven Moreland0cdf1322020-10-05 21:55:26 +00001757 "//apex_available:anyapex",
Jiyong Park4ede1602020-04-28 18:21:08 +09001758 ],
Christopher Ferris2b0638e2019-09-11 19:05:29 -07001759}
1760
Logan Chien17af91b2019-01-15 21:19:56 +08001761cc_library_headers {
Dan Albert64a6efc2024-08-29 19:04:59 +00001762 name: "libc_uapi_headers",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001763 visibility: [
1764 "//external/musl",
Alistair Delvabad22722024-10-07 12:52:40 -07001765 "//external/rust/crates/v4l2r/android",
Colin Cross5d50dbb2021-06-29 11:35:29 -07001766 ],
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001767 llndk: {
1768 llndk_headers: true,
1769 },
Logan Chien17af91b2019-01-15 21:19:56 +08001770 host_supported: true,
1771 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001772 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001773 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001774 vendor_ramdisk_available: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001775 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001776 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001777 apex_available: [
1778 "//apex_available:platform",
Jiyong Parkad9946c2020-03-30 18:36:07 +09001779 "//apex_available:anyapex",
1780 ],
Jooyung Han15c32a82020-04-16 18:26:45 +09001781 // used by most APEXes indirectly via libunwind_llvm
1782 min_sdk_version: "apex_inherit",
Logan Chien17af91b2019-01-15 21:19:56 +08001783
1784 no_libcrt: true,
Logan Chien17af91b2019-01-15 21:19:56 +08001785 stl: "none",
1786 system_shared_libs: [],
1787
Peter Collingbournef2b1e032019-12-10 17:41:16 -08001788 // The build system generally requires that any dependencies of a target
1789 // with an sdk_version must have a lower sdk_version. By setting sdk_version
1790 // to 1 we let targets with an sdk_version that need to depend on the libc
1791 // headers but cannot depend on libc itself due to circular dependencies
1792 // (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
1793 // is correct because the headers can support any sdk_version.
1794 sdk_version: "1",
1795
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001796 export_system_include_dirs: [
Logan Chien17af91b2019-01-15 21:19:56 +08001797 "kernel/uapi",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001798 "kernel/android/scsi",
Logan Chien17af91b2019-01-15 21:19:56 +08001799 "kernel/android/uapi",
1800 ],
1801
1802 arch: {
1803 arm: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001804 export_system_include_dirs: ["kernel/uapi/asm-arm"],
Logan Chien17af91b2019-01-15 21:19:56 +08001805 },
1806 arm64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001807 export_system_include_dirs: ["kernel/uapi/asm-arm64"],
Logan Chien17af91b2019-01-15 21:19:56 +08001808 },
Elliott Hughes48e53332022-10-07 20:39:25 +00001809 riscv64: {
1810 export_system_include_dirs: ["kernel/uapi/asm-riscv"],
1811 },
Logan Chien17af91b2019-01-15 21:19:56 +08001812 x86: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001813 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001814 },
1815 x86_64: {
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001816 export_system_include_dirs: ["kernel/uapi/asm-x86"],
Logan Chien17af91b2019-01-15 21:19:56 +08001817 },
1818 },
1819}
1820
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001821cc_library_headers {
1822 name: "libc_headers",
1823 host_supported: true,
1824 native_bridge_supported: true,
1825 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001826 product_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001827 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001828 vendor_ramdisk_available: true,
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001829 recovery_available: true,
1830 sdk_version: "1",
1831
1832 apex_available: [
1833 "//apex_available:platform",
1834 "//apex_available:anyapex",
1835 ],
1836 // used by most APEXes indirectly via libunwind_llvm
1837 min_sdk_version: "apex_inherit",
1838 visibility: [
1839 "//bionic:__subpackages__", // visible to bionic
1840 // ... and only to these places (b/152668052)
1841 "//external/arm-optimized-routines",
1842 "//external/gwp_asan",
1843 "//external/jemalloc_new",
1844 "//external/libunwind_llvm",
Nick Desaulniers942ae552024-02-12 10:26:19 -08001845 "//external/llvm-libc",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001846 "//external/scudo",
1847 "//system/core/property_service/libpropertyinfoparser",
1848 "//system/extras/toolchain-extras",
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001849 ],
1850
1851 stl: "none",
1852 no_libcrt: true,
1853 system_shared_libs: [],
1854
1855 target: {
1856 android: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001857 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001858 header_libs: ["libc_uapi_headers"],
1859 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001860 },
1861 linux_bionic: {
Colin Crossa0a4a6c2021-03-02 10:23:04 -08001862 export_system_include_dirs: ["include"],
Dan Albert64a6efc2024-08-29 19:04:59 +00001863 header_libs: ["libc_uapi_headers"],
1864 export_header_lib_headers: ["libc_uapi_headers"],
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001865 },
Rupert Shuttleworthfd648682021-02-16 03:27:05 +00001866 },
Martin Stjernholm82d84bc2020-04-06 20:32:09 +01001867}
1868
Dan Willemsen208ae172015-09-16 16:33:27 -07001869// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001870// libstdc++.so and libstdc++.a.
Dan Willemsen208ae172015-09-16 16:33:27 -07001871// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001872
Dan Willemsen208ae172015-09-16 16:33:27 -07001873cc_library {
Elliott Hughes788075a2024-06-18 12:25:37 +00001874 defaults: [
1875 "libc_defaults",
1876 "bug_24465209_workaround",
1877 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001878 include_dirs: ["bionic/libstdc++/include"],
Dan Willemsen208ae172015-09-16 16:33:27 -07001879 srcs: [
1880 "bionic/__cxa_guard.cpp",
1881 "bionic/__cxa_pure_virtual.cpp",
1882 "bionic/new.cpp",
Dan Willemsen208ae172015-09-16 16:33:27 -07001883 ],
1884 name: "libstdc++",
Dan Albert40f15ec2017-10-27 11:21:20 -07001885 static_ndk_lib: true,
Isaac Chen5e7c90b2017-09-20 14:44:42 +08001886 static_libs: ["libasync_safe"],
Elliott Hughesc2043342023-07-20 20:24:09 +00001887 apex_available: [
1888 "//apex_available:platform",
1889 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07001890
Dan Willemsen6b3be172018-12-03 13:57:20 -08001891 static: {
1892 system_shared_libs: [],
1893 },
Colin Crossb5bfe0b2021-07-13 16:26:28 -07001894 target: {
1895 bionic: {
1896 shared: {
1897 system_shared_libs: ["libc"],
1898 },
1899 },
Dan Willemsen6b3be172018-12-03 13:57:20 -08001900 },
1901
Dan Willemsen208ae172015-09-16 16:33:27 -07001902 arch: {
1903 arm: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001904 version_script: ":libstdc++.arm.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001905 },
1906 arm64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001907 version_script: ":libstdc++.arm64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001908 },
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001909 riscv64: {
1910 version_script: ":libstdc++.riscv64.map",
1911 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001912 x86: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001913 version_script: ":libstdc++.x86.map",
Dimitry Ivanov6cc8d472016-07-28 13:52:17 -07001914 },
1915 x86_64: {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001916 version_script: ":libstdc++.x86_64.map",
Dan Willemsen208ae172015-09-16 16:33:27 -07001917 },
1918 },
1919}
1920
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001921genrule {
1922 name: "libstdc++.arm.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001923 out: ["libstdc++.arm.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001924 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001925 tools: ["generate-version-script"],
1926 cmd: "$(location generate-version-script) arm $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001927}
1928
1929genrule {
1930 name: "libstdc++.arm64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001931 out: ["libstdc++.arm64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001932 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001933 tools: ["generate-version-script"],
1934 cmd: "$(location generate-version-script) arm64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001935}
1936
1937genrule {
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001938 name: "libstdc++.riscv64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001939 out: ["libstdc++.riscv64.map.txt"],
Elliott Hughes604ab0f2022-10-17 19:58:22 +00001940 srcs: ["libstdc++.map.txt"],
1941 tools: ["generate-version-script"],
1942 cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
1943}
1944
1945genrule {
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001946 name: "libstdc++.x86.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001947 out: ["libstdc++.x86.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001948 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001949 tools: ["generate-version-script"],
1950 cmd: "$(location generate-version-script) x86 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001951}
1952
1953genrule {
1954 name: "libstdc++.x86_64.map",
Cole Faustf5968d82023-04-11 15:20:19 -07001955 out: ["libstdc++.x86_64.map.txt"],
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001956 srcs: ["libstdc++.map.txt"],
Elliott Hughes291f98a2022-06-30 23:35:11 +00001957 tools: ["generate-version-script"],
1958 cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
Elliott Hughesd19b3c52018-09-06 16:04:08 -07001959}
1960
1961// ========================================================
1962// crt object files.
1963// ========================================================
1964
Colin Cross50c21ab2015-10-31 23:03:05 -07001965cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001966 name: "crt_and_memtag_defaults",
Dan Willemsen7ec52b12016-11-28 17:02:25 -08001967 defaults: ["linux_bionic_supported"],
Dan Willemsen230a7a42017-04-07 14:09:05 -07001968 vendor_available: true,
Justin Yun869a0fa2020-11-11 15:16:11 +09001969 product_available: true,
Yifan Hong5a39cee2020-01-21 16:43:56 -08001970 ramdisk_available: true,
Yifan Hongb04490d2020-10-21 18:36:36 -07001971 vendor_ramdisk_available: true,
Jiyong Park5603c6e2018-04-27 21:53:11 +09001972 recovery_available: true,
dimitry7f048802019-05-03 15:57:34 +02001973 native_bridge_supported: true,
Jiyong Park922a5c72020-03-07 17:35:02 +09001974 apex_available: [
1975 "//apex_available:platform",
1976 "//apex_available:anyapex",
1977 ],
Dan Albertdc503f62020-07-15 17:22:18 -07001978 // Generate NDK variants of the CRT objects for every supported API level.
1979 min_sdk_version: "16",
1980 stl: "none",
1981 crt: true,
Elliott Hughesd50a1de2018-02-05 17:30:57 -08001982 cflags: [
1983 "-Wno-gcc-compat",
1984 "-Wall",
1985 "-Werror",
1986 ],
Peter Collingbourne7eb851c2019-09-26 12:16:06 -07001987 sanitize: {
1988 never: true,
1989 },
Dan Willemsen208ae172015-09-16 16:33:27 -07001990}
1991
Colin Cross50c21ab2015-10-31 23:03:05 -07001992cc_defaults {
Colin Cross10d92682021-06-22 13:25:46 -07001993 name: "crt_defaults",
1994 defaults: ["crt_and_memtag_defaults"],
Colin Cross02f81372021-07-22 12:02:10 -07001995 system_shared_libs: [],
Colin Cross10d92682021-06-22 13:25:46 -07001996}
1997
1998cc_defaults {
Colin Cross50c21ab2015-10-31 23:03:05 -07001999 name: "crt_so_defaults",
Colin Cross7d7b3682017-11-03 13:38:40 -07002000 defaults: ["crt_defaults"],
Colin Crossab179442018-09-27 11:03:22 -07002001 stl: "none",
Dan Willemsen208ae172015-09-16 16:33:27 -07002002}
2003
Dan Willemsen208ae172015-09-16 16:33:27 -07002004cc_object {
2005 name: "crtbrand",
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002006 local_include_dirs: [
Jingwen Chen7e13cf22021-02-23 00:43:01 -05002007 "private", // crtbrand.S depends on private/bionic_asm_note.h
2008 ],
Elliott Hughes6a30b712024-03-13 23:41:32 +00002009 // crtbrand.S needs to know the platform SDK version.
Dan Willemsen208ae172015-09-16 16:33:27 -07002010 product_variables: {
2011 platform_sdk_version: {
2012 asflags: ["-DPLATFORM_SDK_VERSION=%d"],
2013 },
2014 },
2015 srcs: ["arch-common/bionic/crtbrand.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002016
Colin Cross7d7b3682017-11-03 13:38:40 -07002017 defaults: ["crt_so_defaults"],
Dan Alberteee46dc2023-04-04 23:27:52 +00002018 // crtbrand is an intermediate artifact, not a final CRT object.
2019 exclude_from_ndk_sysroot: true,
Dan Willemsen208ae172015-09-16 16:33:27 -07002020}
2021
Dan Willemsen208ae172015-09-16 16:33:27 -07002022cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002023 name: "crtbegin_so",
Dan Willemsen208ae172015-09-16 16:33:27 -07002024 local_include_dirs: ["include"],
2025 srcs: ["arch-common/bionic/crtbegin_so.c"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002026
Colin Cross7d7b3682017-11-03 13:38:40 -07002027 defaults: ["crt_so_defaults"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002028 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002029 "crtbrand",
2030 ],
2031}
2032
Dan Willemsen208ae172015-09-16 16:33:27 -07002033cc_object {
2034 name: "crtend_so",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002035 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002036 "private", // crtend_so.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002037 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002038 srcs: ["arch-common/bionic/crtend_so.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002039
Colin Cross7d7b3682017-11-03 13:38:40 -07002040 defaults: ["crt_so_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002041}
2042
Dan Willemsen208ae172015-09-16 16:33:27 -07002043cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002044 name: "crtbegin_static",
2045
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002046 local_include_dirs: [
2047 "include",
2048 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2049 ],
Liz Kammere718dd72021-03-09 15:00:06 -05002050
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002051 cflags: ["-DCRTBEGIN_STATIC"],
Yabin Cui744cfd32023-08-24 13:20:23 -07002052
Dan Willemsen208ae172015-09-16 16:33:27 -07002053 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002054 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002055 "crtbrand",
2056 ],
Colin Cross50c21ab2015-10-31 23:03:05 -07002057 defaults: ["crt_defaults"],
Jiyong Park268a6002021-01-12 23:14:37 +09002058 // When using libc.a, we're using the latest library regardless of target API level.
2059 min_sdk_version: "current",
Dan Willemsen208ae172015-09-16 16:33:27 -07002060}
2061
Dan Willemsen208ae172015-09-16 16:33:27 -07002062cc_object {
Liz Kammere718dd72021-03-09 15:00:06 -05002063 name: "crtbegin_dynamic",
2064
Jingwen Chen0b1611e2021-02-18 23:22:03 -05002065 local_include_dirs: [
2066 "include",
2067 "bionic", // crtbegin.c includes bionic/libc_init_common.h
2068 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002069 srcs: ["arch-common/bionic/crtbegin.c"],
Colin Cross77d57bf2016-04-11 14:34:18 -07002070 objs: [
Dan Willemsen208ae172015-09-16 16:33:27 -07002071 "crtbrand",
2072 ],
Dan Willemsen7ccc50d2017-09-18 21:28:14 -07002073 target: {
2074 linux_bionic: {
2075 generated_sources: ["host_bionic_linker_asm"],
2076 objs: [
2077 "linker_wrapper",
2078 ],
2079 },
2080 },
Colin Cross50c21ab2015-10-31 23:03:05 -07002081 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002082}
2083
Dan Willemsen208ae172015-09-16 16:33:27 -07002084cc_object {
2085 // We rename crtend.o to crtend_android.o to avoid a
2086 // name clash between gcc and bionic.
2087 name: "crtend_android",
Liz Kammeraab2ad72021-03-15 18:03:24 -04002088 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002089 "private", // crtend.S depends on private/bionic_asm_arm64.h
Liz Kammeraab2ad72021-03-15 18:03:24 -04002090 ],
Dan Willemsen208ae172015-09-16 16:33:27 -07002091 srcs: ["arch-common/bionic/crtend.S"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002092
Colin Cross50c21ab2015-10-31 23:03:05 -07002093 defaults: ["crt_defaults"],
Dan Willemsen208ae172015-09-16 16:33:27 -07002094}
Colin Crossbaa48992016-07-13 11:15:21 -07002095
Kalesh Singh862a23d2024-01-09 13:13:50 -08002096cc_object {
2097 name: "crt_pad_segment",
2098 local_include_dirs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002099 "private", // crt_pad_segment.S depends on private/bionic_asm_note.h
Kalesh Singh862a23d2024-01-09 13:13:50 -08002100 ],
2101 srcs: ["arch-common/bionic/crt_pad_segment.S"],
2102
2103 defaults: ["crt_defaults"],
2104}
2105
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002106cc_library_static {
2107 name: "note_memtag_heap_async",
2108 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002109 arm64: {
2110 srcs: ["arch-arm64/bionic/note_memtag_heap_async.S"],
2111 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002112 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002113 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002114
Colin Cross10d92682021-06-22 13:25:46 -07002115 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002116}
2117
2118cc_library_static {
2119 name: "note_memtag_heap_sync",
2120 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002121 arm64: {
2122 srcs: ["arch-arm64/bionic/note_memtag_heap_sync.S"],
2123 },
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002124 },
Mitch Phillips22c90752021-03-03 15:39:57 -08002125 sdk_version: "minimum",
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002126
Colin Cross10d92682021-06-22 13:25:46 -07002127 defaults: ["crt_and_memtag_defaults"],
Evgenii Stepanov8564b8d2020-12-15 13:55:32 -08002128}
2129
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002130// ========================================================
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002131// libc dependencies for baremetal Rust projects.
2132// ========================================================
2133
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002134// This library contains the following unresolved symbols:
2135// __errno
2136// abort
2137// async_safe_fatal_va_list
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002138cc_library_static {
2139 name: "librust_baremetal",
Pierre-Clément Tosi9018e5f2024-10-02 15:57:00 +01002140 defaults: ["cc_baremetal_defaults"],
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002141 header_libs: ["libc_headers"],
2142 include_dirs: [
2143 "bionic/libc/async_safe/include",
2144 "bionic/libc/platform",
2145 ],
2146 cflags: [
2147 "-Wall",
2148 "-Werror",
2149 ],
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002150 srcs: [
2151 "bionic/fortify.cpp",
Pierre-Clément Tosi816176c2022-11-30 14:33:41 +00002152 "bionic/strtol.cpp",
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002153 ],
2154 arch: {
2155 arm64: {
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002156 srcs: [
2157 "arch-arm64/string/__memcpy_chk.S",
2158 ],
2159 },
caowencheng9a39eb32023-03-20 16:24:41 +08002160 riscv64: {
2161 srcs: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002162 "arch-riscv64/string/__memcpy_chk.S",
caowencheng9a39eb32023-03-20 16:24:41 +08002163 ],
2164 },
Pierre-Clément Tosi199a62e2022-12-09 19:00:44 +00002165 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002166 whole_static_libs: [
2167 "libarm-optimized-routines-mem",
Pierre-Clément Tosieb46ac92023-02-01 13:44:57 +00002168 "libc_netbsd",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002169 ],
Pierre-Clément Tosi3af57992023-01-03 17:57:42 +00002170 system_shared_libs: [],
2171 nocrt: true,
2172 stl: "none",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002173 visibility: [
Jiyong Park072ce532024-07-22 11:20:47 +09002174 "//packages/modules/Virtualization/libs/libvmbase",
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002175 ],
Zijun427504a2024-08-15 23:16:27 +00002176
2177 // b/358211032: This library gets linked into a rust rlib. Disable LTO
2178 // until cross-language lto is supported.
2179 lto: {
2180 never: true,
2181 },
Pierre-Clément Tosi74a14582022-12-09 18:49:29 +00002182}
2183
2184// ========================================================
Elliott Hughesd19b3c52018-09-06 16:04:08 -07002185// NDK headers.
2186// ========================================================
2187
Dan Albertcce54372024-08-22 18:24:30 +00002188ndk_headers {
Dan Albert22805ea2017-03-22 15:28:05 -07002189 name: "common_libc",
2190 from: "include",
2191 to: "",
Dan Albertcce54372024-08-22 18:24:30 +00002192 srcs: ["include/**/*.h"],
Dan Albert22805ea2017-03-22 15:28:05 -07002193 license: "NOTICE",
Dan Albertcce54372024-08-22 18:24:30 +00002194 // These don't pass the bad verification we do because many of them are
2195 // arch-specific, and they aren't necessarily independently includable.
2196 // That's not much of a problem though, since C-incompaitibilities in the
2197 // UAPI headers should run into problems long before they reach us.
2198 skip_verification: true,
Dan Albert22805ea2017-03-22 15:28:05 -07002199}
Dan Albert4238a352016-06-28 11:18:05 -07002200
2201ndk_headers {
Dan Albert063e86a2016-11-29 11:09:12 -08002202 name: "libc_uapi",
2203 from: "kernel/uapi",
2204 to: "",
2205 srcs: [
2206 "kernel/uapi/asm-generic/**/*.h",
2207 "kernel/uapi/drm/**/*.h",
2208 "kernel/uapi/linux/**/*.h",
2209 "kernel/uapi/misc/**/*.h",
2210 "kernel/uapi/mtd/**/*.h",
2211 "kernel/uapi/rdma/**/*.h",
2212 "kernel/uapi/scsi/**/*.h",
2213 "kernel/uapi/sound/**/*.h",
2214 "kernel/uapi/video/**/*.h",
2215 "kernel/uapi/xen/**/*.h",
2216 ],
Dan Albert92592652016-10-20 01:42:54 -07002217 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002218 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002219}
2220
2221ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002222 name: "libc_kernel_android_uapi_linux",
Dan Albertbae16ef2016-09-14 17:15:48 -07002223 from: "kernel/android/uapi/linux",
2224 to: "linux",
2225 srcs: ["kernel/android/uapi/linux/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002226 license: "NOTICE",
Dan Albertbae16ef2016-09-14 17:15:48 -07002227}
2228
2229ndk_headers {
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002230 name: "libc_kernel_android_scsi",
Elliott Hughes50599392017-05-25 17:13:32 -07002231 from: "kernel/android/scsi/scsi",
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002232 to: "scsi",
2233 srcs: ["kernel/android/scsi/**/*.h"],
2234 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002235 skip_verification: true,
Elliott Hughes2fad0d52017-04-27 16:26:55 -07002236}
2237
2238ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002239 name: "libc_asm_arm",
2240 from: "kernel/uapi/asm-arm",
2241 to: "arm-linux-androideabi",
2242 srcs: ["kernel/uapi/asm-arm/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002243 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002244 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002245}
2246
2247ndk_headers {
2248 name: "libc_asm_arm64",
2249 from: "kernel/uapi/asm-arm64",
2250 to: "aarch64-linux-android",
2251 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002252 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002253 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002254}
2255
Lazar Trsic790d2f72017-11-27 11:54:11 +01002256ndk_headers {
Colin Crossbd26e0f2022-10-19 15:03:14 -07002257 name: "libc_asm_riscv64",
2258 from: "kernel/uapi/asm-riscv",
2259 to: "riscv64-linux-android",
2260 srcs: ["kernel/uapi/asm-riscv/**/*.h"],
2261 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002262 skip_verification: true,
Colin Crossbd26e0f2022-10-19 15:03:14 -07002263}
2264
2265ndk_headers {
Dan Albert4238a352016-06-28 11:18:05 -07002266 name: "libc_asm_x86",
2267 from: "kernel/uapi/asm-x86",
2268 to: "i686-linux-android",
2269 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002270 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002271 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002272}
2273
2274ndk_headers {
2275 name: "libc_asm_x86_64",
2276 from: "kernel/uapi/asm-x86",
2277 to: "x86_64-linux-android",
2278 srcs: ["kernel/uapi/asm-x86/**/*.h"],
Dan Albert92592652016-10-20 01:42:54 -07002279 license: "NOTICE",
Dan Albert6aa62772024-08-13 22:01:23 +00002280 skip_verification: true,
Dan Albert4238a352016-06-28 11:18:05 -07002281}
2282
Dan Albert4238a352016-06-28 11:18:05 -07002283ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002284 name: "libc",
Dan Albert4238a352016-06-28 11:18:05 -07002285 symbol_file: "libc.map.txt",
2286 first_version: "9",
2287}
2288
Dan Albertdf31aff2016-10-06 15:50:41 -07002289ndk_library {
Dan Willemsen51a9bf12017-04-07 14:09:18 -07002290 name: "libstdc++",
Dan Albertdf31aff2016-10-06 15:50:41 -07002291 symbol_file: "libstdc++.map.txt",
2292 first_version: "9",
2293}
2294
Dan Willemsenca056d72018-01-08 14:00:24 -08002295// Export these headers for toolbox to process
2296filegroup {
2297 name: "kernel_input_headers",
2298 srcs: [
2299 "kernel/uapi/linux/input.h",
2300 "kernel/uapi/linux/input-event-codes.h",
2301 ],
2302}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002303
2304// Generate a syscall name / number mapping. These objects are text files
2305// (thanks to the -dD -E flags) and not binary files. They will then be
2306// consumed by the genseccomp.py script and converted into C++ code.
2307cc_defaults {
2308 name: "libseccomp_gen_syscall_nrs_defaults",
2309 recovery_available: true,
2310 srcs: ["seccomp/gen_syscall_nrs.cpp"],
2311 cflags: [
2312 "-dD",
2313 "-E",
2314 "-Wall",
2315 "-Werror",
2316 "-nostdinc",
2317 ],
2318}
2319
2320cc_object {
2321 name: "libseccomp_gen_syscall_nrs_arm",
2322 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2323 local_include_dirs: [
2324 "kernel/uapi/asm-arm",
2325 "kernel/uapi",
2326 ],
2327}
2328
2329cc_object {
2330 name: "libseccomp_gen_syscall_nrs_arm64",
2331 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2332 local_include_dirs: [
2333 "kernel/uapi/asm-arm64",
2334 "kernel/uapi",
2335 ],
2336}
2337
2338cc_object {
Elliott Hughes704772b2022-10-10 17:06:43 +00002339 name: "libseccomp_gen_syscall_nrs_riscv64",
2340 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2341 local_include_dirs: [
2342 "kernel/uapi/asm-riscv",
2343 "kernel/uapi",
2344 ],
2345}
2346
2347cc_object {
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002348 name: "libseccomp_gen_syscall_nrs_x86",
2349 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2350 srcs: ["seccomp/gen_syscall_nrs_x86.cpp"],
2351 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2352 local_include_dirs: [
2353 "kernel/uapi/asm-x86",
2354 "kernel/uapi",
2355 ],
2356}
2357
2358cc_object {
2359 name: "libseccomp_gen_syscall_nrs_x86_64",
2360 defaults: ["libseccomp_gen_syscall_nrs_defaults"],
2361 srcs: ["seccomp/gen_syscall_nrs_x86_64.cpp"],
2362 exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
2363 local_include_dirs: [
2364 "kernel/uapi/asm-x86",
2365 "kernel/uapi",
2366 ],
2367}
2368
Jingwen Chenca366332021-01-29 05:16:32 -05002369filegroup {
2370 name: "all_kernel_uapi_headers",
2371 srcs: ["kernel/uapi/**/*.h"],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002372}
2373
Martijn Coenen0c6de752019-01-02 12:52:51 +01002374cc_genrule {
2375 name: "func_to_syscall_nrs",
2376 recovery_available: true,
2377 cmd: "$(location genfunctosyscallnrs) --out-dir=$(genDir) $(in)",
2378
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002379 tools: ["genfunctosyscallnrs"],
Martijn Coenen0c6de752019-01-02 12:52:51 +01002380
2381 srcs: [
2382 "SYSCALLS.TXT",
Martijn Coenen0c6de752019-01-02 12:52:51 +01002383 ],
2384
Elliott Hughes704772b2022-10-10 17:06:43 +00002385 arch: {
2386 arm: {
2387 srcs: [
2388 ":libseccomp_gen_syscall_nrs_arm",
2389 ":libseccomp_gen_syscall_nrs_arm64",
2390 ],
2391 },
2392 arm64: {
2393 srcs: [
2394 ":libseccomp_gen_syscall_nrs_arm",
2395 ":libseccomp_gen_syscall_nrs_arm64",
2396 ],
2397 },
2398 riscv64: {
2399 srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
2400 },
2401 x86: {
2402 srcs: [
2403 ":libseccomp_gen_syscall_nrs_x86",
2404 ":libseccomp_gen_syscall_nrs_x86_64",
2405 ],
2406 },
2407 x86_64: {
2408 srcs: [
2409 ":libseccomp_gen_syscall_nrs_x86",
2410 ":libseccomp_gen_syscall_nrs_x86_64",
2411 ],
2412 },
2413 },
2414
Martijn Coenen0c6de752019-01-02 12:52:51 +01002415 out: [
2416 "func_to_syscall_nrs.h",
2417 ],
2418}
2419
Victor Hsiehdbb86702020-06-15 09:29:07 -07002420// SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT = SECCOMP_BLOCKLIST_APP.txt - setresgid*
Martijn Coenenc3752be2019-01-09 16:19:57 +01002421genrule {
Victor Hsiehdbb86702020-06-15 09:29:07 -07002422 name: "generate_app_zygote_blocklist",
2423 out: ["SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT"],
2424 srcs: ["SECCOMP_BLOCKLIST_APP.TXT"],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002425 cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)",
2426}
2427
Yu Liu938ec9b2022-10-17 16:36:30 -07002428filegroup {
2429 name: "seccomp_syscalls_sources_zygote",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002430 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",
Bram Bonnéacadd092020-05-06 13:49:55 +02002435 "SECCOMP_PRIORITY.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002436 ":generate_app_zygote_blocklist",
Martijn Coenenc3752be2019-01-09 16:19:57 +01002437 ],
Martijn Coenenc3752be2019-01-09 16:19:57 +01002438}
2439
Yu Liu938ec9b2022-10-17 16:36:30 -07002440filegroup {
2441 name: "seccomp_syscalls_sources_app",
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_APP.TXT",
2446 "SECCOMP_BLOCKLIST_COMMON.TXT",
2447 "SECCOMP_BLOCKLIST_APP.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002448 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002449 ],
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002450}
2451
Yu Liu938ec9b2022-10-17 16:36:30 -07002452filegroup {
2453 name: "seccomp_syscalls_sources_system",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002454 srcs: [
2455 "SYSCALLS.TXT",
Victor Hsiehdbb86702020-06-15 09:29:07 -07002456 "SECCOMP_ALLOWLIST_COMMON.TXT",
2457 "SECCOMP_ALLOWLIST_SYSTEM.TXT",
2458 "SECCOMP_BLOCKLIST_COMMON.TXT",
Bram Bonnéacadd092020-05-06 13:49:55 +02002459 "SECCOMP_PRIORITY.TXT",
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002460 ],
Yu Liu938ec9b2022-10-17 16:36:30 -07002461}
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002462
Yu Liu938ec9b2022-10-17 16:36:30 -07002463cc_genrule {
2464 name: "libseccomp_policy_app_zygote_sources_x86",
2465 recovery_available: true,
2466 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002467 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002468 srcs: [
2469 ":seccomp_syscalls_sources_zygote",
2470 ":libseccomp_gen_syscall_nrs_x86",
2471 ":libseccomp_gen_syscall_nrs_x86_64",
2472 ],
2473 out: [
2474 "x86_app_zygote_policy.cpp",
2475 "x86_64_app_zygote_policy.cpp",
2476 ],
2477 enabled: false,
Yu Liu3a579692022-10-18 03:02:32 +00002478 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002479 x86: {
2480 enabled: true,
2481 },
2482 x86_64: {
2483 enabled: true,
2484 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002485 },
2486}
2487
2488cc_genrule {
2489 name: "libseccomp_policy_app_zygote_sources_arm",
2490 recovery_available: true,
2491 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002492 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002493 srcs: [
2494 ":seccomp_syscalls_sources_zygote",
2495 ":libseccomp_gen_syscall_nrs_arm",
2496 ":libseccomp_gen_syscall_nrs_arm64",
2497 ],
2498 out: [
2499 "arm_app_zygote_policy.cpp",
2500 "arm64_app_zygote_policy.cpp",
2501 ],
2502 enabled: false,
2503 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002504 arm: {
2505 enabled: true,
2506 },
2507 arm64: {
2508 enabled: true,
2509 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002510 },
2511}
2512
2513cc_genrule {
2514 name: "libseccomp_policy_app_zygote_sources_riscv64",
2515 recovery_available: true,
2516 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002517 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002518 srcs: [
2519 ":seccomp_syscalls_sources_zygote",
2520 ":libseccomp_gen_syscall_nrs_riscv64",
2521 ],
2522 out: [
2523 "riscv64_app_zygote_policy.cpp",
2524 ],
2525 enabled: false,
2526 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002527 riscv64: {
2528 enabled: true,
2529 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002530 },
2531}
2532
2533cc_genrule {
2534 name: "libseccomp_policy_app_sources_x86",
2535 recovery_available: true,
2536 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002537 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002538 srcs: [
2539 ":seccomp_syscalls_sources_app",
2540 ":libseccomp_gen_syscall_nrs_x86",
2541 ":libseccomp_gen_syscall_nrs_x86_64",
2542 ],
2543 out: [
2544 "x86_app_policy.cpp",
2545 "x86_64_app_policy.cpp",
2546 ],
2547 enabled: false,
2548 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002549 x86: {
2550 enabled: true,
2551 },
2552 x86_64: {
2553 enabled: true,
2554 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002555 },
2556}
2557
2558cc_genrule {
2559 name: "libseccomp_policy_app_sources_arm",
2560 recovery_available: true,
2561 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002562 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002563 srcs: [
2564 ":seccomp_syscalls_sources_app",
2565 ":libseccomp_gen_syscall_nrs_arm",
2566 ":libseccomp_gen_syscall_nrs_arm64",
2567 ],
2568 out: [
2569 "arm_app_policy.cpp",
2570 "arm64_app_policy.cpp",
2571 ],
2572 enabled: false,
2573 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002574 arm: {
2575 enabled: true,
2576 },
2577 arm64: {
2578 enabled: true,
2579 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002580 },
2581}
2582
2583cc_genrule {
2584 name: "libseccomp_policy_app_sources_riscv64",
2585 recovery_available: true,
2586 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002587 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002588 srcs: [
2589 ":seccomp_syscalls_sources_app",
2590 ":libseccomp_gen_syscall_nrs_riscv64",
2591 ],
2592 out: [
2593 "riscv64_app_policy.cpp",
2594 ],
2595 enabled: false,
2596 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002597 riscv64: {
2598 enabled: true,
2599 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002600 },
2601}
2602
2603cc_genrule {
2604 name: "libseccomp_policy_system_sources_x86",
2605 recovery_available: true,
2606 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002607 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002608 srcs: [
2609 ":seccomp_syscalls_sources_system",
2610 ":libseccomp_gen_syscall_nrs_x86",
2611 ":libseccomp_gen_syscall_nrs_x86_64",
2612 ],
2613 out: [
2614 "x86_system_policy.cpp",
2615 "x86_64_system_policy.cpp",
2616 ],
2617 enabled: false,
2618 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002619 x86: {
2620 enabled: true,
2621 },
2622 x86_64: {
2623 enabled: true,
2624 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002625 },
2626}
2627
2628cc_genrule {
2629 name: "libseccomp_policy_system_sources_arm",
2630 recovery_available: true,
2631 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002632 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002633 srcs: [
2634 ":seccomp_syscalls_sources_system",
2635 ":libseccomp_gen_syscall_nrs_arm",
2636 ":libseccomp_gen_syscall_nrs_arm64",
2637 ],
2638 out: [
2639 "arm_system_policy.cpp",
2640 "arm64_system_policy.cpp",
2641 ],
2642 enabled: false,
2643 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002644 arm: {
2645 enabled: true,
2646 },
2647 arm64: {
2648 enabled: true,
2649 },
Yu Liu938ec9b2022-10-17 16:36:30 -07002650 },
2651}
2652
2653cc_genrule {
2654 name: "libseccomp_policy_system_sources_riscv64",
2655 recovery_available: true,
2656 cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002657 tools: ["genseccomp"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002658 srcs: [
2659 ":seccomp_syscalls_sources_system",
2660 ":libseccomp_gen_syscall_nrs_riscv64",
2661 ],
2662 out: [
2663 "riscv64_system_policy.cpp",
2664 ],
2665 enabled: false,
2666 arch: {
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002667 riscv64: {
2668 enabled: true,
2669 },
Yu Liu3a579692022-10-18 03:02:32 +00002670 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002671}
2672
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002673cc_library {
2674 name: "libseccomp_policy",
2675 recovery_available: true,
Martijn Coenend269d9b2018-11-08 16:41:42 +01002676 generated_headers: ["func_to_syscall_nrs"],
Yu Liu938ec9b2022-10-17 16:36:30 -07002677
2678 arch: {
2679 arm: {
2680 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002681 "libseccomp_policy_app_sources_arm",
2682 "libseccomp_policy_app_zygote_sources_arm",
2683 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002684 ],
2685 },
2686 arm64: {
2687 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002688 "libseccomp_policy_app_sources_arm",
2689 "libseccomp_policy_app_zygote_sources_arm",
2690 "libseccomp_policy_system_sources_arm",
Yu Liu938ec9b2022-10-17 16:36:30 -07002691 ],
2692 },
2693 riscv64: {
2694 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002695 "libseccomp_policy_app_sources_riscv64",
2696 "libseccomp_policy_app_zygote_sources_riscv64",
2697 "libseccomp_policy_system_sources_riscv64",
Yu Liu938ec9b2022-10-17 16:36:30 -07002698 ],
2699 },
2700 x86: {
2701 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002702 "libseccomp_policy_app_sources_x86",
2703 "libseccomp_policy_app_zygote_sources_x86",
2704 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002705 ],
2706 },
2707 x86_64: {
2708 generated_sources: [
Elliott Hughes1eacc0e2024-01-19 19:05:36 +00002709 "libseccomp_policy_app_sources_x86",
2710 "libseccomp_policy_app_zygote_sources_x86",
2711 "libseccomp_policy_system_sources_x86",
Yu Liu938ec9b2022-10-17 16:36:30 -07002712 ],
2713 },
2714 },
Luis Hector Chavezfa09b3c2018-08-03 20:53:28 -07002715
2716 srcs: [
2717 "seccomp/seccomp_policy.cpp",
2718 ],
2719
2720 export_include_dirs: ["seccomp/include"],
2721 cflags: [
2722 "-Wall",
2723 "-Werror",
2724 ],
2725 shared: {
2726 shared_libs: ["libbase"],
2727 },
2728 static: {
2729 static_libs: ["libbase"],
2730 },
2731}
Christopher Ferrisfc26d712019-02-27 18:07:55 -08002732
Colin Cross048f24e2021-09-01 17:26:00 -07002733cc_library_host_static {
2734 name: "libfts",
2735 srcs: [
2736 "bionic/fts.c",
2737 "upstream-openbsd/lib/libc/stdlib/recallocarray.c",
2738 ],
2739 export_include_dirs: ["fts/include"],
2740 local_include_dirs: [
2741 "private",
2742 "upstream-openbsd/android/include",
2743 ],
2744 cflags: [
2745 "-include openbsd-compat.h",
2746 "-Wno-unused-parameter",
2747 ],
2748 enabled: false,
2749 target: {
2750 musl: {
2751 enabled: true,
2752 },
2753 },
Colin Cross2a9843f2022-01-13 12:26:30 -08002754 stl: "none",
2755}
2756
2757cc_library_host_static {
2758 name: "libexecinfo",
2759 visibility: ["//external/musl"],
2760 srcs: ["bionic/execinfo.cpp"],
2761 export_include_dirs: ["execinfo/include"],
2762 local_include_dirs: ["private"],
2763 enabled: false,
2764 target: {
2765 musl: {
2766 enabled: true,
2767 system_shared_libs: [],
2768 header_libs: ["libc_musl_headers"],
2769 },
2770 },
2771 stl: "none",
Colin Cross048f24e2021-09-01 17:26:00 -07002772}
2773
Colin Cross9da85fa2022-01-24 18:20:05 -08002774cc_library_host_static {
2775 name: "libb64",
2776 visibility: ["//external/musl"],
2777 srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
2778 export_include_dirs: ["b64/include"],
2779 local_include_dirs: [
2780 "private",
2781 "upstream-openbsd/android/include",
2782 ],
2783 cflags: [
2784 "-include openbsd-compat.h",
2785 ],
2786 enabled: false,
2787 target: {
2788 musl: {
2789 enabled: true,
2790 system_shared_libs: [],
2791 header_libs: ["libc_musl_headers"],
2792 },
2793 },
2794 stl: "none",
2795}
2796
Colin Cross9d4a56e2022-02-03 10:20:32 -08002797// Export kernel uapi headers to be used in the musl sysroot.
2798// Also include the execinfo headers for the libexecinfo and the
2799// b64 headers for libb64 embedded in musl libc.
2800cc_genrule {
2801 name: "libc_musl_sysroot_bionic_headers",
2802 visibility: ["//external/musl"],
2803 host_supported: true,
2804 device_supported: false,
2805 enabled: false,
2806 target: {
2807 musl: {
2808 enabled: true,
2809 },
2810 },
2811 srcs: [
2812 "kernel/uapi/**/*.h",
2813 "kernel/android/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002814 "execinfo/include/**/*.h",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002815 "b64/include/**/*.h",
Colin Crossaeef9f02022-02-07 21:01:26 -08002816
Colin Crossaeef9f02022-02-07 21:01:26 -08002817 "NOTICE",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002818
2819 ":libc_musl_sysroot_bionic_arch_headers",
2820 ],
2821 out: ["libc_musl_sysroot_bionic_headers.zip"],
2822 tools: [
2823 "soong_zip",
2824 "merge_zips",
2825 "zip2zip",
2826 ],
Colin Crossaeef9f02022-02-07 21:01:26 -08002827 cmd: "BIONIC_LIBC_DIR=$$(dirname $(location NOTICE)) && " +
2828 "$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
Colin Crossad33d022022-02-25 18:27:04 -08002829 // NOTICE
2830 " -j -f $(location NOTICE) " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002831 // headers
2832 " -P include " +
Colin Crossaeef9f02022-02-07 21:01:26 -08002833 " -C $${BIONIC_LIBC_DIR}/kernel/uapi " +
2834 " -D $${BIONIC_LIBC_DIR}/kernel/uapi " +
2835 " -C $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2836 " -D $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
2837 " -C $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2838 " -D $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
2839 " -C $${BIONIC_LIBC_DIR}/execinfo/include " +
2840 " -D $${BIONIC_LIBC_DIR}/execinfo/include " +
2841 " -C $${BIONIC_LIBC_DIR}/b64/include " +
2842 " -D $${BIONIC_LIBC_DIR}/b64/include " +
Colin Cross9d4a56e2022-02-03 10:20:32 -08002843 " && " +
Colin Crossad33d022022-02-25 18:27:04 -08002844 "$(location zip2zip) -i $(genDir)/sysroot.zip -o $(genDir)/sysroot-renamed.zip " +
Colin Cross1c0a7a02022-08-11 12:22:26 -07002845 " -x **/BUILD " +
Colin Crossad33d022022-02-25 18:27:04 -08002846 " include/**/*:include/ " +
2847 " NOTICE:NOTICE.bionic " +
2848 " && " +
2849 "$(location merge_zips) $(out) $(location :libc_musl_sysroot_bionic_arch_headers) $(genDir)/sysroot-renamed.zip",
Colin Cross9d4a56e2022-02-03 10:20:32 -08002850}
2851
2852// The architecture-specific bits have to be handled separately because the label varies based
2853// on architecture, which prevents using $(locations) to find them and requires using $(in)
2854// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
2855// genrule.
2856cc_genrule {
2857 name: "libc_musl_sysroot_bionic_arch_headers",
2858 visibility: ["//visibility:private"],
2859 host_supported: true,
2860 device_supported: false,
2861 enabled: false,
2862 target: {
2863 musl: {
2864 enabled: true,
2865 },
2866 },
2867 arch: {
2868 arm: {
2869 srcs: ["kernel/uapi/asm-arm/**/*.h"],
2870 },
2871 arm64: {
2872 srcs: ["kernel/uapi/asm-arm64/**/*.h"],
2873 },
2874 x86: {
2875 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2876 },
2877 x86_64: {
2878 srcs: ["kernel/uapi/asm-x86/**/*.h"],
2879 },
2880 },
2881 out: ["libc_musl_sysroot_bionic_arch_headers.zip"],
2882 tools: ["soong_zip"],
2883 cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/asm -j -D $$(dirname $${includes[0]})",
2884}
Colin Cross290c4952022-10-13 12:51:13 -07002885
2886cc_genrule {
2887 name: "bionic_sysroot_crt_objects",
2888 visibility: ["//visibility:private"],
2889 out: ["bionic_sysroot_crt_objects.zip"],
2890 tools: ["soong_zip"],
2891 srcs: [
2892 ":crtbegin_dynamic",
2893 ":crtbegin_so",
2894 ":crtbegin_static",
2895 ":crtend_android",
2896 ":crtend_so",
2897 ],
2898 cmd: "$(location soong_zip) -o $(out) -j " +
2899 "-f $(location :crtbegin_dynamic) " +
2900 "-f $(location :crtbegin_so) " +
2901 "-f $(location :crtbegin_static) " +
2902 "-f $(location :crtend_android) " +
2903 "-f $(location :crtend_so)",
2904 dist: {
2905 targets: ["bionic_sysroot_crt_objects"],
2906 },
2907 arch: {
2908 arm: {
2909 dist: {
2910 suffix: "_arm",
2911 },
2912 },
2913 arm64: {
2914 dist: {
2915 suffix: "_arm64",
2916 },
2917 },
2918 riscv64: {
2919 dist: {
2920 suffix: "_riscv64",
2921 },
2922 },
2923 x86: {
2924 dist: {
2925 suffix: "_x86",
2926 },
2927 },
2928 x86_64: {
2929 dist: {
2930 suffix: "_x86_64",
2931 },
2932 },
2933 },
2934}
Spandan Das8fce52a2023-09-28 18:00:12 +00002935
Jiyong Park35a280d2024-05-03 16:53:39 +09002936filegroup {
2937 name: "linux_capability_header",
2938 srcs: ["kernel/uapi/linux/capability.h"],
2939}