platform_bionic/libc/Android.bp

3044 lines
88 KiB
Text
Raw Normal View History

// Define the common source files for all the libc instances
// =========================================================
package {
default_applicable_licenses: ["bionic_libc_license"],
}
license {
name: "bionic_libc_license",
visibility: [":__subpackages__"],
license_kinds: [
"SPDX-license-identifier-Apache-2.0",
"SPDX-license-identifier-BSD",
"SPDX-license-identifier-ISC",
"SPDX-license-identifier-MIT",
"legacy_notice",
"legacy_unencumbered",
],
license_text: [
"NOTICE",
],
}
libc_common_src_files = [
"bionic/ether_aton.c",
"bionic/ether_ntoa.c",
"bionic/exit.cpp",
"bionic/initgroups.c",
"bionic/isatty.c",
"bionic/sched_cpualloc.c",
"bionic/sched_cpucount.c",
[GWP-ASan] Provide runtime configuration through an env var + sysprop. This patch introduces GWP-ASan system properties and environment variables to control the internal sampling rates of GWP-ASan. This can be used for: 1. "Torture testing" the system, i.e. running it under an extremely high sampling rate under GWP-ASan. 2. Increasing sampling remotely to allow further crash report collection of rare issues. There are three sets of system properites: 1. libc.debug.gwp_asan.*.system_default: Default values for native executables and system apps. 2. libc.debug.gwp_asan.*.app_default: Default values for non-system apps, and 3. libc.debug.gwp_asan.*.<basename/app_name>: Default values for an individual app or native process. There are three variables that can be changed: 1. The allocation sampling rate (default: 2500) - using the environment variable GWP_ASAN_SAMPLE_RATE or the libc.debug.gwp_asan.sample_rate.* system property. 2. The process sampling rate (default: 128 for system apps/processes, 1 for opted-in apps) - using the environment variable GWP_ASAN_PROCESS_SAMPLING or the libc.debug.gwp_asan.process_sampling.* system property, 3. The number of slots available (default: 32) - using the environment variable GWP_ASAN_MAX_ALLOCS or the libc.debug.gwp_asan.max_allocs.* system property. If not specified, #3 will be calculated as a ratio of the default |2500 SampleRate : 32 slots|. So, a sample rate of "1250" (i.e. twice as frequent sampling) will result in a doubling of the max_allocs to "64". Bug: 219651032 Test: atest bionic-unit-tests Change-Id: Idb40a2a4d074e01ce3c4e635ad639a91a32d570f
2020-12-01 00:04:14 +01:00
"bionic/sysprop_helpers.cpp",
"stdio/fmemopen.cpp",
"stdio/parsefloat.c",
"stdio/refill.c",
"stdio/stdio.cpp",
"stdio/stdio_ext.cpp",
"stdio/vfscanf.cpp",
"stdio/vfwscanf.cpp",
]
// off64_t/time64_t support on LP32.
// ========================================================
libc_common_src_files_32 = [
"bionic/legacy_32_bit_support.cpp",
"bionic/time64.c",
]
libc_common_flags = [
"-D_LIBC=1",
"-D__BIONIC_LP32_USE_STAT64",
"-Wall",
"-Wextra",
"-Wunused",
"-Wno-char-subscripts",
"-Wno-deprecated-declarations",
"-Wno-gcc-compat",
"-Wframe-larger-than=2048",
"-Wno-reorder-init-list",
// Try to catch typical 32-bit assumptions that break with 64-bit pointers.
"-Werror=pointer-to-int-cast",
"-Werror=int-to-pointer-cast",
"-Werror=type-limits",
"-Werror",
// Clang's exit-time destructor registration hides __dso_handle, but
// __dso_handle needs to have default visibility on ARM32. See b/73485611.
"-Wexit-time-destructors",
// We know clang does a lot of harm by rewriting what we've said, and sadly
// never see any good it does, so let's just ask it to do what we say...
// (The specific motivating example was clang turning a loop that would only
// ever touch 0, 1, or 2 bytes into a call to memset, which was never going
// to amortize.)
"-fno-builtin",
]
// Define some common cflags
// ========================================================
cc_defaults {
name: "libc_defaults",
defaults: ["linux_bionic_supported"],
cflags: libc_common_flags,
asflags: libc_common_flags,
conlyflags: ["-std=gnu99"],
cppflags: [],
include_dirs: [
"bionic/libc/async_safe/include",
"bionic/libc/platform",
// For android_filesystem_config.h.
"system/core/libcutils/include",
],
header_libs: [
"libc_headers",
"liblog_headers", // needed by bionic/libc/async_safe/include
],
export_header_lib_headers: [
"libc_headers",
],
stl: "none",
system_shared_libs: [],
sanitize: {
address: false,
integer_overflow: false,
// TODO(b/132640749): Fix broken fuzzer support.
fuzzer: false,
},
ramdisk_available: true,
vendor_ramdisk_available: true,
recovery_available: true,
native_bridge_supported: true,
// lld complains about duplicate symbols in libcrt and libgcc. Suppress the
// warning since this is intended right now.
ldflags: ["-Wl,-z,muldefs"],
product_variables: {
malloc_zero_contents: {
cflags: ["-DSCUDO_ZERO_CONTENTS"],
},
malloc_pattern_fill_contents: {
cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
},
malloc_not_svelte: {
cflags: ["-DUSE_SCUDO"],
},
},
lto: {
never: true,
},
apex_available: ["com.android.runtime"],
tidy_disabled_srcs: ["upstream-*/**/*.c"],
}
libc_scudo_product_variables = {
malloc_not_svelte: {
cflags: ["-DUSE_SCUDO"],
whole_static_libs: ["libscudo"],
exclude_static_libs: [
"libjemalloc5",
"libc_jemalloc_wrapper",
],
},
}
// Defaults for native allocator libs/includes to make it
// easier to change.
// To disable scudo for the non-svelte config remove the line:
// product_variables: libc_scudo_product_variables,
// in the cc_defaults below.
// ========================================================
cc_defaults {
name: "libc_native_allocator_defaults",
whole_static_libs: [
"libjemalloc5",
"libc_jemalloc_wrapper",
],
header_libs: ["gwp_asan_headers"],
product_variables: libc_scudo_product_variables,
}
// Functions not implemented by jemalloc directly, or that need to
// be modified for Android.
cc_library_static {
name: "libc_jemalloc_wrapper",
defaults: ["libc_defaults"],
srcs: ["bionic/jemalloc_wrapper.cpp"],
cflags: ["-fvisibility=hidden"],
// Used to pull in the jemalloc include directory so that if the
// library is removed, the include directory is also removed.
static_libs: ["libjemalloc5"],
}
// ========================================================
// libc_bootstrap.a - -fno-stack-protector and -ffreestanding
// ========================================================
//
// Code that implements the stack protector (or that runs before TLS has been set up) needs to be
// compiled with -fno-stack-protector, since it accesses the stack canary TLS slot. In the linker,
// some of this code runs before ifunc resolvers have made string.h functions work, so compile with
// -ffreestanding.
cc_library_static {
srcs: [
"bionic/__libc_init_main_thread.cpp",
"bionic/__stack_chk_fail.cpp",
"bionic/bionic_call_ifunc_resolver.cpp",
"bionic/getauxval.cpp",
],
arch: {
arm64: {
srcs: ["arch-arm64/bionic/__set_tls.c"],
},
riscv64: {
srcs: ["arch-riscv64/bionic/__set_tls.c"],
},
x86: {
srcs: [
"arch-x86/bionic/__libc_init_sysinfo.cpp",
"arch-x86/bionic/__libc_int0x80.S",
"arch-x86/bionic/__set_tls.cpp",
],
},
x86_64: {
srcs: ["arch-x86_64/bionic/__set_tls.c"],
},
},
defaults: ["libc_defaults"],
cflags: [
"-fno-stack-protector",
"-ffreestanding",
],
name: "libc_bootstrap",
}
filegroup {
name: "elf_note_sources",
srcs: ["bionic/elf_note.cpp"],
}
// libc_init_static.cpp and libc_init_dynamic.cpp need to be built without stack protector.
// libc_init_static.cpp sets up TLS for static executables, and libc_init_dynamic.cpp initializes
// the stack protector global variable.
cc_library_static {
name: "libc_init_static",
defaults: ["libc_defaults"],
srcs: [
"bionic/libc_init_static.cpp",
":elf_note_sources",
],
cflags: [
"-fno-stack-protector",
// Compile libc_init_static.cpp with -ffreestanding, because some of its code is called
// from the linker before ifunc resolvers have made string.h functions available.
"-ffreestanding",
],
}
cc_library_static {
name: "libc_init_dynamic",
defaults: ["libc_defaults"],
srcs: ["bionic/libc_init_dynamic.cpp"],
cflags: ["-fno-stack-protector"],
}
// ========================================================
// libc_tzcode.a - upstream 'tzcode' code
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
srcs: [
"tzcode/**/*.c",
"tzcode/bionic.cpp",
Expose tzalloc()/localtime_rz()/mktime_z()/tzfree(). * Rationale The question often comes up of how to use multiple time zones in C code. If you're single-threaded, you can just use setenv() to manipulate $TZ. toybox does this, for example. But that's not thread-safe in two distinct ways: firstly, getenv() is not thread-safe with respect to modifications to the environment (and between the way putenv() is specified and the existence of environ, it's not obvious how to fully fix that), and secondly the _caller_ needs to ensure that no other threads are using tzset() or any function that behaves "as if" tzset() was called (which is neither easy to determine nor easy to ensure). This isn't a bigger problem because most of the time the right answer is to stop pretending that libc is at all suitable for any i18n, and switch to icu4c instead. (The NDK icu4c headers do not include ucal_*, so this is not a realistic option for most applications.) But what if you're somewhere in between? Like the rust chrono library, for example? What then? Currently their "least worst" option is to reinvent the entire wheel and read our tzdata files. Which isn't a great solution for anyone, for obvious maintainability reasons. So it's probably time we broke the catch-22 here and joined NetBSD in offering a less broken API than standard C has for the last 40 years. Sure, any would-be caller will have to have a separate "is this Android?" and even "is this API level >= 35?" path, but that will fix itself sometime in the 2030s when developers can just assume "yes, it is", whereas if we keep putting off exposing anything, this problem never gets solved. (No-one's bothered to try to implement the std::chrono::time_zone functionality in libc++ yet, but they'll face a similar problem if/when they do.) * Implementation The good news is that tzcode already implements these functions, so there's relatively little here. I've chosen not to expose `struct state` because `struct __timezone_t` makes for clearer error messages, given that compiler diagnostics will show the underlying type name (`struct __timezone_t*`) rather than the typedef name (`timezone_t`) that's used in calling code. I've moved us over to FreeBSD's wcsftime() rather than keep the OpenBSD one building --- I've long wanted to only have one implementation here, and FreeBSD is already doing the "convert back and forth, calling the non-wide function in the middle" dance that I'd hoped to get round to doing myself someday. This should mean that our strftime() and wcsftime() behaviors can't easily diverge in future, plus macOS/iOS are mostly FreeBSD, so any bugs will likely be interoperable with the other major mobile operating system, so there's something nice for everyone there! The FreeBSD wcsftime() implementation includes a wcsftime_l() implementation, so that's one stub we can remove. The flip side of that is that it uses mbsrtowcs_l() and wcsrtombs_l() which we didn't previously have. So expose those as aliases of mbsrtowcs() and wcsrtombs(). Bug: https://github.com/chronotope/chrono/issues/499 Test: treehugger Change-Id: Iee1b9d763ead15eef3d2c33666b3403b68940c3c
2023-06-15 22:17:08 +02:00
// tzcode doesn't include strptime, so we use a fork of the
// OpenBSD code which needs this global data.
"upstream-openbsd/lib/libc/locale/_def_time.c",
Expose tzalloc()/localtime_rz()/mktime_z()/tzfree(). * Rationale The question often comes up of how to use multiple time zones in C code. If you're single-threaded, you can just use setenv() to manipulate $TZ. toybox does this, for example. But that's not thread-safe in two distinct ways: firstly, getenv() is not thread-safe with respect to modifications to the environment (and between the way putenv() is specified and the existence of environ, it's not obvious how to fully fix that), and secondly the _caller_ needs to ensure that no other threads are using tzset() or any function that behaves "as if" tzset() was called (which is neither easy to determine nor easy to ensure). This isn't a bigger problem because most of the time the right answer is to stop pretending that libc is at all suitable for any i18n, and switch to icu4c instead. (The NDK icu4c headers do not include ucal_*, so this is not a realistic option for most applications.) But what if you're somewhere in between? Like the rust chrono library, for example? What then? Currently their "least worst" option is to reinvent the entire wheel and read our tzdata files. Which isn't a great solution for anyone, for obvious maintainability reasons. So it's probably time we broke the catch-22 here and joined NetBSD in offering a less broken API than standard C has for the last 40 years. Sure, any would-be caller will have to have a separate "is this Android?" and even "is this API level >= 35?" path, but that will fix itself sometime in the 2030s when developers can just assume "yes, it is", whereas if we keep putting off exposing anything, this problem never gets solved. (No-one's bothered to try to implement the std::chrono::time_zone functionality in libc++ yet, but they'll face a similar problem if/when they do.) * Implementation The good news is that tzcode already implements these functions, so there's relatively little here. I've chosen not to expose `struct state` because `struct __timezone_t` makes for clearer error messages, given that compiler diagnostics will show the underlying type name (`struct __timezone_t*`) rather than the typedef name (`timezone_t`) that's used in calling code. I've moved us over to FreeBSD's wcsftime() rather than keep the OpenBSD one building --- I've long wanted to only have one implementation here, and FreeBSD is already doing the "convert back and forth, calling the non-wide function in the middle" dance that I'd hoped to get round to doing myself someday. This should mean that our strftime() and wcsftime() behaviors can't easily diverge in future, plus macOS/iOS are mostly FreeBSD, so any bugs will likely be interoperable with the other major mobile operating system, so there's something nice for everyone there! The FreeBSD wcsftime() implementation includes a wcsftime_l() implementation, so that's one stub we can remove. The flip side of that is that it uses mbsrtowcs_l() and wcsrtombs_l() which we didn't previously have. So expose those as aliases of mbsrtowcs() and wcsrtombs(). Bug: https://github.com/chronotope/chrono/issues/499 Test: treehugger Change-Id: Iee1b9d763ead15eef3d2c33666b3403b68940c3c
2023-06-15 22:17:08 +02:00
// tzcode doesn't include wcsftime, so we use the FreeBSD code.
"upstream-freebsd/lib/libc/locale/wcsftime.c",
],
cflags: [
"-Wno-unused-parameter",
// Don't use ridiculous amounts of stack.
"-DALL_STATE",
// Include tzsetwall, timelocal, timegm, time2posix, and posix2time.
"-DSTD_INSPIRED",
// Obviously, we want to be thread-safe.
"-DTHREAD_SAFE=1",
// The name of the tm_gmtoff field in our struct tm.
"-DTM_GMTOFF=tm_gmtoff",
// Android uses a system property instead of /etc/localtime, so make callers crash.
"-DTZDEFAULT=NULL",
// Where we store our tzdata.
"-DTZDIR=\"/system/usr/share/zoneinfo\"",
// Include `tzname`, `timezone`, and `daylight` globals.
"-DHAVE_POSIX_DECLS=0",
"-DUSG_COMPAT=2",
"-DHAVE_TZNAME=2",
// stdbool.h is available
"-DHAVE_STDBOOL_H",
// Use the empty string (instead of " ") as the timezone abbreviation
// fallback.
"-DWILDABBR=\"\"",
"-Dlint",
],
Expose tzalloc()/localtime_rz()/mktime_z()/tzfree(). * Rationale The question often comes up of how to use multiple time zones in C code. If you're single-threaded, you can just use setenv() to manipulate $TZ. toybox does this, for example. But that's not thread-safe in two distinct ways: firstly, getenv() is not thread-safe with respect to modifications to the environment (and between the way putenv() is specified and the existence of environ, it's not obvious how to fully fix that), and secondly the _caller_ needs to ensure that no other threads are using tzset() or any function that behaves "as if" tzset() was called (which is neither easy to determine nor easy to ensure). This isn't a bigger problem because most of the time the right answer is to stop pretending that libc is at all suitable for any i18n, and switch to icu4c instead. (The NDK icu4c headers do not include ucal_*, so this is not a realistic option for most applications.) But what if you're somewhere in between? Like the rust chrono library, for example? What then? Currently their "least worst" option is to reinvent the entire wheel and read our tzdata files. Which isn't a great solution for anyone, for obvious maintainability reasons. So it's probably time we broke the catch-22 here and joined NetBSD in offering a less broken API than standard C has for the last 40 years. Sure, any would-be caller will have to have a separate "is this Android?" and even "is this API level >= 35?" path, but that will fix itself sometime in the 2030s when developers can just assume "yes, it is", whereas if we keep putting off exposing anything, this problem never gets solved. (No-one's bothered to try to implement the std::chrono::time_zone functionality in libc++ yet, but they'll face a similar problem if/when they do.) * Implementation The good news is that tzcode already implements these functions, so there's relatively little here. I've chosen not to expose `struct state` because `struct __timezone_t` makes for clearer error messages, given that compiler diagnostics will show the underlying type name (`struct __timezone_t*`) rather than the typedef name (`timezone_t`) that's used in calling code. I've moved us over to FreeBSD's wcsftime() rather than keep the OpenBSD one building --- I've long wanted to only have one implementation here, and FreeBSD is already doing the "convert back and forth, calling the non-wide function in the middle" dance that I'd hoped to get round to doing myself someday. This should mean that our strftime() and wcsftime() behaviors can't easily diverge in future, plus macOS/iOS are mostly FreeBSD, so any bugs will likely be interoperable with the other major mobile operating system, so there's something nice for everyone there! The FreeBSD wcsftime() implementation includes a wcsftime_l() implementation, so that's one stub we can remove. The flip side of that is that it uses mbsrtowcs_l() and wcsrtombs_l() which we didn't previously have. So expose those as aliases of mbsrtowcs() and wcsrtombs(). Bug: https://github.com/chronotope/chrono/issues/499 Test: treehugger Change-Id: Iee1b9d763ead15eef3d2c33666b3403b68940c3c
2023-06-15 22:17:08 +02:00
local_include_dirs: [
"tzcode/",
"upstream-freebsd/android/include",
],
name: "libc_tzcode",
}
// ========================================================
// libc_dns.a - modified NetBSD DNS code
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
srcs: [
"dns/**/*.c*",
"upstream-netbsd/lib/libc/isc/ev_streams.c",
"upstream-netbsd/lib/libc/isc/ev_timers.c",
],
cflags: [
"-DANDROID_CHANGES",
"-DINET6",
"-Wno-unused-parameter",
"-include netbsd-compat.h",
"-Wframe-larger-than=66000",
"-include private/bsd_sys_param.h",
],
local_include_dirs: [
"dns/include",
"private",
"upstream-netbsd/lib/libc/include",
"upstream-netbsd/android/include",
],
name: "libc_dns",
}
// ========================================================
// libc_freebsd.a - upstream FreeBSD C library code
// ========================================================
//
// These files are built with the freebsd-compat.h header file
// automatically included.
cc_library_static {
name: "libc_freebsd_ldexp",
defaults: ["libc_defaults"],
cflags: ["-Dscalbn=ldexp"],
srcs: [":libc_ldexp_srcs"],
}
cc_library_static {
defaults: ["libc_defaults"],
srcs: [
"upstream-freebsd/lib/libc/stdlib/getopt_long.c",
"upstream-freebsd/lib/libc/stdlib/hcreate.c",
"upstream-freebsd/lib/libc/stdlib/hcreate_r.c",
"upstream-freebsd/lib/libc/stdlib/hdestroy_r.c",
"upstream-freebsd/lib/libc/stdlib/hsearch_r.c",
"upstream-freebsd/lib/libc/stdlib/qsort.c",
"upstream-freebsd/lib/libc/stdlib/quick_exit.c",
"upstream-freebsd/lib/libc/string/wcpcpy.c",
"upstream-freebsd/lib/libc/string/wcpncpy.c",
"upstream-freebsd/lib/libc/string/wcscasecmp.c",
"upstream-freebsd/lib/libc/string/wcscat.c",
"upstream-freebsd/lib/libc/string/wcschr.c",
"upstream-freebsd/lib/libc/string/wcscmp.c",
"upstream-freebsd/lib/libc/string/wcscpy.c",
"upstream-freebsd/lib/libc/string/wcscspn.c",
"upstream-freebsd/lib/libc/string/wcsdup.c",
"upstream-freebsd/lib/libc/string/wcslcat.c",
"upstream-freebsd/lib/libc/string/wcslen.c",
"upstream-freebsd/lib/libc/string/wcsncasecmp.c",
"upstream-freebsd/lib/libc/string/wcsncat.c",
"upstream-freebsd/lib/libc/string/wcsncmp.c",
"upstream-freebsd/lib/libc/string/wcsncpy.c",
"upstream-freebsd/lib/libc/string/wcsnlen.c",
"upstream-freebsd/lib/libc/string/wcspbrk.c",
"upstream-freebsd/lib/libc/string/wcsrchr.c",
"upstream-freebsd/lib/libc/string/wcsspn.c",
"upstream-freebsd/lib/libc/string/wcsstr.c",
"upstream-freebsd/lib/libc/string/wcstok.c",
"upstream-freebsd/lib/libc/string/wmemchr.c",
"upstream-freebsd/lib/libc/string/wmemcmp.c",
"upstream-freebsd/lib/libc/string/wmemcpy.c",
"upstream-freebsd/lib/libc/string/wmemmove.c",
"upstream-freebsd/lib/libc/string/wmemset.c",
],
arch: {
x86: {
exclude_srcs: [
"upstream-freebsd/lib/libc/string/wcschr.c",
"upstream-freebsd/lib/libc/string/wcscmp.c",
"upstream-freebsd/lib/libc/string/wcslen.c",
"upstream-freebsd/lib/libc/string/wcsrchr.c",
"upstream-freebsd/lib/libc/string/wmemcmp.c",
"upstream-freebsd/lib/libc/string/wcscat.c",
"upstream-freebsd/lib/libc/string/wcscpy.c",
"upstream-freebsd/lib/libc/string/wmemcmp.c",
],
},
},
cflags: [
"-Wno-sign-compare",
"-Wno-unused-parameter",
"-include freebsd-compat.h",
],
local_include_dirs: [
"upstream-freebsd/android/include",
],
name: "libc_freebsd",
}
cc_library_static {
defaults: ["libc_defaults"],
srcs: [
"upstream-freebsd/lib/libc/gen/glob.c",
],
cflags: [
"-Wno-sign-compare",
"-include freebsd-compat.h",
"-Wframe-larger-than=66000",
],
local_include_dirs: [
"upstream-freebsd/android/include",
],
name: "libc_freebsd_large_stack",
}
// ========================================================
// libc_netbsd.a - upstream NetBSD C library code
// ========================================================
//
// These files are built with the netbsd-compat.h header file
// automatically included.
cc_library_static {
defaults: ["libc_defaults"],
srcs: [
"upstream-netbsd/common/lib/libc/stdlib/random.c",
"upstream-netbsd/lib/libc/gen/nice.c",
"upstream-netbsd/lib/libc/gen/psignal.c",
"upstream-netbsd/lib/libc/gen/utime.c",
"upstream-netbsd/lib/libc/inet/nsap_addr.c",
"upstream-netbsd/lib/libc/regex/regcomp.c",
"upstream-netbsd/lib/libc/regex/regerror.c",
"upstream-netbsd/lib/libc/regex/regexec.c",
"upstream-netbsd/lib/libc/regex/regfree.c",
"upstream-netbsd/lib/libc/stdlib/bsearch.c",
"upstream-netbsd/lib/libc/stdlib/drand48.c",
"upstream-netbsd/lib/libc/stdlib/erand48.c",
"upstream-netbsd/lib/libc/stdlib/jrand48.c",
"upstream-netbsd/lib/libc/stdlib/lcong48.c",
"upstream-netbsd/lib/libc/stdlib/lrand48.c",
"upstream-netbsd/lib/libc/stdlib/mrand48.c",
"upstream-netbsd/lib/libc/stdlib/nrand48.c",
"upstream-netbsd/lib/libc/stdlib/_rand48.c",
"upstream-netbsd/lib/libc/stdlib/rand_r.c",
"upstream-netbsd/lib/libc/stdlib/reallocarr.c",
"upstream-netbsd/lib/libc/stdlib/seed48.c",
"upstream-netbsd/lib/libc/stdlib/srand48.c",
],
multilib: {
lib32: {
// LP32 cruft
srcs: ["upstream-netbsd/common/lib/libc/hash/sha1/sha1.c"],
},
},
cflags: [
"-Wno-sign-compare",
"-Wno-unused-parameter",
"-DPOSIX_MISTAKE",
"-include netbsd-compat.h",
],
local_include_dirs: [
"upstream-netbsd/android/include",
"upstream-netbsd/lib/libc/include",
],
name: "libc_netbsd",
}
// ========================================================
// libc_openbsd_ndk.a - upstream OpenBSD C library code
// that can be safely included in the libc_ndk.a (doesn't
// contain any troublesome global data or constructors).
// ========================================================
//
// These files are built with the openbsd-compat.h header file
// automatically included.
cc_library_static {
name: "libc_openbsd_ndk",
defaults: ["libc_defaults"],
srcs: [
"upstream-openbsd/lib/libc/gen/alarm.c",
"upstream-openbsd/lib/libc/gen/ctype_.c",
"upstream-openbsd/lib/libc/gen/daemon.c",
"upstream-openbsd/lib/libc/gen/err.c",
"upstream-openbsd/lib/libc/gen/errx.c",
"upstream-openbsd/lib/libc/gen/fnmatch.c",
"upstream-openbsd/lib/libc/gen/ftok.c",
"upstream-openbsd/lib/libc/gen/getprogname.c",
"upstream-openbsd/lib/libc/gen/setprogname.c",
"upstream-openbsd/lib/libc/gen/verr.c",
"upstream-openbsd/lib/libc/gen/verrx.c",
"upstream-openbsd/lib/libc/gen/vwarn.c",
"upstream-openbsd/lib/libc/gen/vwarnx.c",
"upstream-openbsd/lib/libc/gen/warn.c",
"upstream-openbsd/lib/libc/gen/warnx.c",
"upstream-openbsd/lib/libc/locale/btowc.c",
"upstream-openbsd/lib/libc/locale/mbrlen.c",
"upstream-openbsd/lib/libc/locale/mbstowcs.c",
"upstream-openbsd/lib/libc/locale/mbtowc.c",
"upstream-openbsd/lib/libc/locale/wcscoll.c",
"upstream-openbsd/lib/libc/locale/wcstombs.c",
"upstream-openbsd/lib/libc/locale/wcsxfrm.c",
"upstream-openbsd/lib/libc/locale/wctob.c",
"upstream-openbsd/lib/libc/locale/wctomb.c",
"upstream-openbsd/lib/libc/net/base64.c",
"upstream-openbsd/lib/libc/net/htonl.c",
"upstream-openbsd/lib/libc/net/htons.c",
"upstream-openbsd/lib/libc/net/inet_lnaof.c",
"upstream-openbsd/lib/libc/net/inet_makeaddr.c",
"upstream-openbsd/lib/libc/net/inet_netof.c",
"upstream-openbsd/lib/libc/net/inet_ntoa.c",
"upstream-openbsd/lib/libc/net/inet_ntop.c",
"upstream-openbsd/lib/libc/net/inet_pton.c",
"upstream-openbsd/lib/libc/net/ntohl.c",
"upstream-openbsd/lib/libc/net/ntohs.c",
"upstream-openbsd/lib/libc/net/res_random.c",
"upstream-openbsd/lib/libc/stdio/fgetln.c",
"upstream-openbsd/lib/libc/stdio/fgetwc.c",
"upstream-openbsd/lib/libc/stdio/fgetws.c",
"upstream-openbsd/lib/libc/stdio/flags.c",
"upstream-openbsd/lib/libc/stdio/fpurge.c",
"upstream-openbsd/lib/libc/stdio/fputwc.c",
"upstream-openbsd/lib/libc/stdio/fputws.c",
"upstream-openbsd/lib/libc/stdio/fvwrite.c",
"upstream-openbsd/lib/libc/stdio/fwide.c",
"upstream-openbsd/lib/libc/stdio/getdelim.c",
"upstream-openbsd/lib/libc/stdio/gets.c",
"upstream-openbsd/lib/libc/stdio/makebuf.c",
"upstream-openbsd/lib/libc/stdio/mktemp.c",
"upstream-openbsd/lib/libc/stdio/open_memstream.c",
"upstream-openbsd/lib/libc/stdio/open_wmemstream.c",
"upstream-openbsd/lib/libc/stdio/rget.c",
"upstream-openbsd/lib/libc/stdio/setvbuf.c",
"upstream-openbsd/lib/libc/stdio/ungetc.c",
"upstream-openbsd/lib/libc/stdio/ungetwc.c",
"upstream-openbsd/lib/libc/stdio/vasprintf.c",
"upstream-openbsd/lib/libc/stdio/vdprintf.c",
"upstream-openbsd/lib/libc/stdio/vsscanf.c",
"upstream-openbsd/lib/libc/stdio/vswprintf.c",
"upstream-openbsd/lib/libc/stdio/vswscanf.c",
"upstream-openbsd/lib/libc/stdio/wbuf.c",
"upstream-openbsd/lib/libc/stdio/wsetup.c",
"upstream-openbsd/lib/libc/stdlib/abs.c",
"upstream-openbsd/lib/libc/stdlib/div.c",
"upstream-openbsd/lib/libc/stdlib/getenv.c",
"upstream-openbsd/lib/libc/stdlib/getsubopt.c",
"upstream-openbsd/lib/libc/stdlib/insque.c",
"upstream-openbsd/lib/libc/stdlib/imaxabs.c",
"upstream-openbsd/lib/libc/stdlib/imaxdiv.c",
"upstream-openbsd/lib/libc/stdlib/labs.c",
"upstream-openbsd/lib/libc/stdlib/ldiv.c",
"upstream-openbsd/lib/libc/stdlib/llabs.c",
"upstream-openbsd/lib/libc/stdlib/lldiv.c",
"upstream-openbsd/lib/libc/stdlib/lsearch.c",
"upstream-openbsd/lib/libc/stdlib/recallocarray.c",
"upstream-openbsd/lib/libc/stdlib/remque.c",
"upstream-openbsd/lib/libc/stdlib/setenv.c",
"upstream-openbsd/lib/libc/stdlib/tfind.c",
"upstream-openbsd/lib/libc/stdlib/tsearch.c",
"upstream-openbsd/lib/libc/string/memccpy.c",
"upstream-openbsd/lib/libc/string/strcasecmp.c",
"upstream-openbsd/lib/libc/string/strcasestr.c",
"upstream-openbsd/lib/libc/string/strcoll.c",
"upstream-openbsd/lib/libc/string/strcspn.c",
"upstream-openbsd/lib/libc/string/strdup.c",
"upstream-openbsd/lib/libc/string/strndup.c",
"upstream-openbsd/lib/libc/string/strpbrk.c",
"upstream-openbsd/lib/libc/string/strsep.c",
"upstream-openbsd/lib/libc/string/strspn.c",
"upstream-openbsd/lib/libc/string/strtok.c",
"upstream-openbsd/lib/libc/string/strxfrm.c",
"upstream-openbsd/lib/libc/string/wcslcpy.c",
"upstream-openbsd/lib/libc/string/wcswidth.c",
// This file is originally from OpenBSD, and benefits from
// being compiled with openbsd-compat.h.
"bionic/fts.c",
],
cflags: [
"-Wno-sign-compare",
"-Wno-unused-parameter",
"-include openbsd-compat.h",
],
local_include_dirs: [
"private",
"stdio",
"upstream-openbsd/android/include",
"upstream-openbsd/lib/libc/include",
"upstream-openbsd/lib/libc/gdtoa/",
],
}
cc_library_static {
name: "libc_openbsd_large_stack",
defaults: ["libc_defaults"],
srcs: [
"stdio/vfprintf.cpp",
"stdio/vfwprintf.cpp",
"upstream-openbsd/lib/libc/string/memmem.c",
"upstream-openbsd/lib/libc/string/strstr.c",
],
cflags: [
"-include openbsd-compat.h",
"-Wno-sign-compare",
"-Wframe-larger-than=5000",
],
local_include_dirs: [
"private",
"upstream-openbsd/android/include/",
"upstream-openbsd/lib/libc/include/",
"upstream-openbsd/lib/libc/gdtoa/",
"upstream-openbsd/lib/libc/stdio/",
],
}
// ========================================================
// libc_openbsd.a - upstream OpenBSD C library code
// ========================================================
//
// These files are built with the openbsd-compat.h header file
// automatically included.
cc_library_static {
defaults: ["libc_defaults"],
srcs: [
// These two depend on getentropy, which isn't in libc_ndk.a.
"upstream-openbsd/lib/libc/crypt/arc4random.c",
"upstream-openbsd/lib/libc/crypt/arc4random_uniform.c",
],
// Each architecture has optimized versions of some routines,
// and only includes the portable C versions of ones it's missing.
arch: {
arm: {
srcs: [
"upstream-openbsd/lib/libc/string/memchr.c",
"upstream-openbsd/lib/libc/string/memrchr.c",
"upstream-openbsd/lib/libc/string/stpncpy.c",
"upstream-openbsd/lib/libc/string/strlcat.c",
"upstream-openbsd/lib/libc/string/strlcpy.c",
"upstream-openbsd/lib/libc/string/strncat.c",
"upstream-openbsd/lib/libc/string/strncmp.c",
"upstream-openbsd/lib/libc/string/strncpy.c",
],
},
arm64: {
srcs: [
"upstream-openbsd/lib/libc/string/strcat.c",
"upstream-openbsd/lib/libc/string/stpncpy.c",
"upstream-openbsd/lib/libc/string/strlcat.c",
"upstream-openbsd/lib/libc/string/strlcpy.c",
"upstream-openbsd/lib/libc/string/strncat.c",
"upstream-openbsd/lib/libc/string/strncpy.c",
],
},
riscv64: {
srcs: [
"upstream-openbsd/lib/libc/string/memrchr.c",
"upstream-openbsd/lib/libc/string/stpncpy.c",
"upstream-openbsd/lib/libc/string/strlcat.c",
"upstream-openbsd/lib/libc/string/strlcpy.c",
],
},
x86: {
srcs: [
// x86 has custom implementations of all of these.
],
},
x86_64: {
srcs: [
"upstream-openbsd/lib/libc/string/memchr.c",
"upstream-openbsd/lib/libc/string/memrchr.c",
"upstream-openbsd/lib/libc/string/strlcat.c",
"upstream-openbsd/lib/libc/string/strlcpy.c",
],
},
},
cflags: [
"-Wno-sign-compare",
"-Wno-unused-parameter",
"-include openbsd-compat.h",
],
local_include_dirs: [
"private",
"upstream-openbsd/android/include",
],
name: "libc_openbsd",
}
// ========================================================
// libc_gdtoa.a - upstream OpenBSD C library gdtoa code
// ========================================================
//
// These files are built with the openbsd-compat.h header file
// automatically included.
cc_library_static {
defaults: ["libc_defaults"],
srcs: [
"upstream-openbsd/android/gdtoa_support.cpp",
"upstream-openbsd/lib/libc/gdtoa/dmisc.c",
"upstream-openbsd/lib/libc/gdtoa/dtoa.c",
"upstream-openbsd/lib/libc/gdtoa/gdtoa.c",
"upstream-openbsd/lib/libc/gdtoa/gethex.c",
"upstream-openbsd/lib/libc/gdtoa/gmisc.c",
"upstream-openbsd/lib/libc/gdtoa/hd_init.c",
"upstream-openbsd/lib/libc/gdtoa/hdtoa.c",
"upstream-openbsd/lib/libc/gdtoa/hexnan.c",
"upstream-openbsd/lib/libc/gdtoa/ldtoa.c",
"upstream-openbsd/lib/libc/gdtoa/misc.c",
"upstream-openbsd/lib/libc/gdtoa/smisc.c",
"upstream-openbsd/lib/libc/gdtoa/strtod.c",
"upstream-openbsd/lib/libc/gdtoa/strtodg.c",
"upstream-openbsd/lib/libc/gdtoa/strtof.c",
"upstream-openbsd/lib/libc/gdtoa/strtord.c",
"upstream-openbsd/lib/libc/gdtoa/sum.c",
"upstream-openbsd/lib/libc/gdtoa/ulp.c",
],
multilib: {
lib64: {
srcs: ["upstream-openbsd/lib/libc/gdtoa/strtorQ.c"],
},
},
cflags: [
"-Wno-sign-compare",
"-include openbsd-compat.h",
],
local_include_dirs: [
"private",
"upstream-openbsd/android/include",
"upstream-openbsd/lib/libc/include",
],
name: "libc_gdtoa",
}
// ========================================================
// libc_fortify.a - container for our FORTIFY
// implementation details
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
srcs: ["bionic/fortify.cpp"],
name: "libc_fortify",
// Disable FORTIFY for the compilation of these, so we don't end up having
// FORTIFY silently call itself.
cflags: [
"-U_FORTIFY_SOURCE",
"-D__BIONIC_DECLARE_FORTIFY_HELPERS",
],
arch: {
arm: {
cflags: [
"-DRENAME___STRCAT_CHK",
"-DRENAME___STRCPY_CHK",
],
srcs: [
"arch-arm/generic/bionic/__memcpy_chk.S",
"arch-arm/cortex-a15/bionic/__strcat_chk.S",
"arch-arm/cortex-a15/bionic/__strcpy_chk.S",
"arch-arm/cortex-a7/bionic/__strcat_chk.S",
"arch-arm/cortex-a7/bionic/__strcpy_chk.S",
"arch-arm/cortex-a9/bionic/__strcat_chk.S",
"arch-arm/cortex-a9/bionic/__strcpy_chk.S",
"arch-arm/krait/bionic/__strcat_chk.S",
"arch-arm/krait/bionic/__strcpy_chk.S",
"arch-arm/cortex-a53/bionic/__strcat_chk.S",
"arch-arm/cortex-a53/bionic/__strcpy_chk.S",
"arch-arm/cortex-a55/bionic/__strcat_chk.S",
"arch-arm/cortex-a55/bionic/__strcpy_chk.S",
],
},
arm64: {
srcs: [
"arch-arm64/string/__memcpy_chk.S",
"arch-arm64/string/__memset_chk.S",
],
},
riscv64: {
srcs: [
"arch-riscv64/string/__memset_chk.S",
"arch-riscv64/string/__memcpy_chk.S",
],
},
},
}
// ========================================================
// libc_bionic.a - home-grown C library code
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
srcs: [
"bionic/android_set_abort_message.cpp",
"bionic/android_unsafe_frame_pointer_chase.cpp",
"bionic/atexit.cpp",
"bionic/bionic_elf_tls.cpp",
"bionic/__cxa_thread_atexit_impl.cpp",
"bionic/fork.cpp",
"bionic/pthread_atfork.cpp",
"bionic/pthread_attr.cpp",
"bionic/pthread_barrier.cpp",
"bionic/pthread_cond.cpp",
"bionic/pthread_create.cpp",
"bionic/pthread_detach.cpp",
"bionic/pthread_equal.cpp",
"bionic/pthread_exit.cpp",
"bionic/pthread_getcpuclockid.cpp",
"bionic/pthread_getschedparam.cpp",
"bionic/pthread_gettid_np.cpp",
"bionic/pthread_internal.cpp",
"bionic/pthread_join.cpp",
"bionic/pthread_key.cpp",
"bionic/pthread_kill.cpp",
"bionic/pthread_mutex.cpp",
"bionic/pthread_once.cpp",
"bionic/pthread_rwlock.cpp",
"bionic/pthread_sigqueue.cpp",
"bionic/pthread_self.cpp",
"bionic/pthread_setname_np.cpp",
"bionic/pthread_setschedparam.cpp",
"bionic/pthread_spinlock.cpp",
"bionic/setjmp_cookie.cpp",
"bionic/sysconf.cpp",
"bionic/sys_thread_properties.cpp",
"bionic/vdso.cpp",
],
arch: {
arm: {
asflags: libc_common_flags + ["-mno-restrict-it"],
srcs: [
"arch-arm/bionic/__aeabi_read_tp.S",
"arch-arm/bionic/__bionic_clone.S",
"arch-arm/bionic/__restore.S",
"arch-arm/bionic/_exit_with_stack_teardown.S",
"arch-arm/bionic/atomics_arm.c",
"arch-arm/bionic/bpabi.c",
"arch-arm/bionic/libcrt_compat.c",
"arch-arm/bionic/popcount_tab.c",
"arch-arm/bionic/setjmp.S",
"arch-arm/bionic/syscall.S",
"arch-arm/bionic/vfork.S",
"arch-arm/cortex-a7/bionic/memcpy.S",
"arch-arm/cortex-a7/bionic/memset.S",
"arch-arm/cortex-a9/bionic/memcpy.S",
"arch-arm/cortex-a9/bionic/memset.S",
"arch-arm/cortex-a9/bionic/stpcpy.S",
"arch-arm/cortex-a9/bionic/strcat.S",
"arch-arm/cortex-a9/bionic/strcpy.S",
"arch-arm/cortex-a9/bionic/strlen.S",
"arch-arm/cortex-a15/bionic/memcpy.S",
"arch-arm/cortex-a15/bionic/memmove.S",
"arch-arm/cortex-a15/bionic/memset.S",
"arch-arm/cortex-a15/bionic/stpcpy.S",
"arch-arm/cortex-a15/bionic/strcat.S",
"arch-arm/cortex-a15/bionic/strcmp.S",
"arch-arm/cortex-a15/bionic/strcpy.S",
"arch-arm/cortex-a15/bionic/strlen.S",
"arch-arm/cortex-a53/bionic/memcpy.S",
"arch-arm/cortex-a55/bionic/memcpy.S",
"arch-arm/generic/bionic/memcmp.S",
"arch-arm/generic/bionic/memmove.S",
"arch-arm/generic/bionic/memset.S",
"arch-arm/generic/bionic/stpcpy.c",
"arch-arm/generic/bionic/strcat.c",
"arch-arm/generic/bionic/strcmp.S",
"arch-arm/generic/bionic/strcpy.S",
"arch-arm/generic/bionic/strlen.c",
"arch-arm/krait/bionic/memcpy.S",
"arch-arm/krait/bionic/memset.S",
"arch-arm/kryo/bionic/memcpy.S",
"bionic/strchr.cpp",
"bionic/strchrnul.cpp",
"bionic/strnlen.cpp",
"bionic/strrchr.cpp",
],
},
arm64: {
srcs: [
"arch-arm64/bionic/__bionic_clone.S",
"arch-arm64/bionic/_exit_with_stack_teardown.S",
"arch-arm64/bionic/setjmp.S",
"arch-arm64/bionic/syscall.S",
"arch-arm64/bionic/vfork.S",
],
},
riscv64: {
srcs: [
"arch-riscv64/bionic/__bionic_clone.S",
"arch-riscv64/bionic/_exit_with_stack_teardown.S",
"arch-riscv64/bionic/setjmp.S",
"arch-riscv64/bionic/syscall.S",
"arch-riscv64/bionic/vfork.S",
"arch-riscv64/string/memchr_v.S",
"arch-riscv64/string/memcmp_v.S",
"arch-riscv64/string/memcpy_v.S",
"arch-riscv64/string/memmove_v.S",
"arch-riscv64/string/memset_v.S",
"arch-riscv64/string/stpcpy_v.S",
"arch-riscv64/string/strcat_v.S",
"arch-riscv64/string/strchr_v.S",
"arch-riscv64/string/strcmp_v.S",
"arch-riscv64/string/strcpy_v.S",
"arch-riscv64/string/strlen_v.S",
"arch-riscv64/string/strncat_v.S",
"arch-riscv64/string/strncmp_v.S",
"arch-riscv64/string/strncpy_v.S",
"arch-riscv64/string/strnlen_v.S",
"arch-riscv64/string/memchr.c",
"arch-riscv64/string/memcmp.c",
"arch-riscv64/string/memcpy.c",
"arch-riscv64/string/memmove.c",
"arch-riscv64/string/memset.c",
"arch-riscv64/string/stpcpy.c",
"arch-riscv64/string/strcat.c",
"arch-riscv64/string/strchr.c",
"arch-riscv64/string/strcmp.c",
"arch-riscv64/string/strcpy.c",
"arch-riscv64/string/strlen.c",
"arch-riscv64/string/strncat.c",
"arch-riscv64/string/strncmp.c",
"arch-riscv64/string/strncpy.c",
"arch-riscv64/string/strnlen.c",
"bionic/strchrnul.cpp",
"bionic/strrchr.cpp",
],
},
x86: {
srcs: [
"arch-x86/bionic/__bionic_clone.S",
"arch-x86/bionic/_exit_with_stack_teardown.S",
"arch-x86/bionic/libcrt_compat.c",
"arch-x86/bionic/setjmp.S",
"arch-x86/bionic/syscall.S",
"arch-x86/bionic/vfork.S",
"arch-x86/bionic/__x86.get_pc_thunk.S",
"arch-x86/generic/string/memcmp.S",
"arch-x86/generic/string/strcmp.S",
"arch-x86/generic/string/strncmp.S",
"arch-x86/generic/string/strcat.S",
"arch-x86/generic/string/strlcat.c",
"arch-x86/generic/string/strlcpy.c",
"arch-x86/generic/string/strncat.c",
"arch-x86/generic/string/wcscat.c",
"arch-x86/generic/string/wcscpy.c",
"arch-x86/generic/string/wmemcmp.c",
"arch-x86/string/sse2-memchr-atom.S",
"arch-x86/string/sse2-memmove-slm.S",
"arch-x86/string/sse2-memrchr-atom.S",
"arch-x86/string/sse2-memset-atom.S",
"arch-x86/string/sse2-memset-slm.S",
"arch-x86/string/sse2-stpcpy-slm.S",
"arch-x86/string/sse2-stpncpy-slm.S",
"arch-x86/string/sse2-strchr-atom.S",
"arch-x86/string/sse2-strcpy-slm.S",
"arch-x86/string/sse2-strlen-slm.S",
"arch-x86/string/sse2-strncpy-slm.S",
"arch-x86/string/sse2-strnlen-atom.S",
"arch-x86/string/sse2-strrchr-atom.S",
"arch-x86/string/sse2-wcschr-atom.S",
"arch-x86/string/sse2-wcsrchr-atom.S",
"arch-x86/string/sse2-wcslen-atom.S",
"arch-x86/string/sse2-wcscmp-atom.S",
"arch-x86/string/sse2-strlen-atom.S",
"arch-x86/string/ssse3-memcmp-atom.S",
"arch-x86/string/ssse3-memmove-atom.S",
"arch-x86/string/ssse3-strcat-atom.S",
"arch-x86/string/ssse3-strcmp-atom.S",
"arch-x86/string/ssse3-strcpy-atom.S",
"arch-x86/string/ssse3-strlcat-atom.S",
"arch-x86/string/ssse3-strlcpy-atom.S",
"arch-x86/string/ssse3-strncat-atom.S",
"arch-x86/string/ssse3-strncmp-atom.S",
"arch-x86/string/ssse3-strncpy-atom.S",
"arch-x86/string/ssse3-wcscat-atom.S",
"arch-x86/string/ssse3-wcscpy-atom.S",
"arch-x86/string/ssse3-wmemcmp-atom.S",
"arch-x86/string/sse4-memcmp-slm.S",
"arch-x86/string/sse4-wmemcmp-slm.S",
"bionic/strchrnul.cpp",
],
},
x86_64: {
srcs: [
"arch-x86_64/bionic/__bionic_clone.S",
"arch-x86_64/bionic/_exit_with_stack_teardown.S",
"arch-x86_64/bionic/__restore_rt.S",
"arch-x86_64/bionic/setjmp.S",
"arch-x86_64/bionic/syscall.S",
"arch-x86_64/bionic/vfork.S",
avx2 implementation for memset. This patch includes handwritten avx2 assembly for memset 64-bit. Uses non-temporal stores for very large sizes. Also includes dynamic dispatch for APIs having multiple implementations. Convincing benchmark improvements for sizes above 512 bytes, and although the slight regression for small sizes is unfortunate, it's probably small enough to be okay? Before: BM_string_memset/8/0 3.06 ns 3.04 ns 222703428 bytes_per_second=2.45261G/s BM_string_memset/16/0 3.50 ns 3.47 ns 202569932 bytes_per_second=4.29686G/s BM_string_memset/32/0 3.50 ns 3.48 ns 200064955 bytes_per_second=8.57386G/s BM_string_memset/64/0 3.49 ns 3.46 ns 201928186 bytes_per_second=17.2184G/s BM_string_memset/512/0 14.8 ns 14.7 ns 47776178 bytes_per_second=32.3887G/s BM_string_memset/1024/0 27.3 ns 27.1 ns 25884933 bytes_per_second=35.2515G/s BM_string_memset/8192/0 203 ns 201 ns 3476903 bytes_per_second=37.9311G/s BM_string_memset/16384/0 402 ns 399 ns 1750471 bytes_per_second=38.2725G/s BM_string_memset/32768/0 932 ns 925 ns 755750 bytes_per_second=33.0071G/s BM_string_memset/65536/0 2038 ns 2014 ns 347060 bytes_per_second=30.3057G/s BM_string_memset/131072/0 4012 ns 3980 ns 175186 bytes_per_second=30.6682G/s After: BM_string_memset/8/0 3.32 ns 3.23 ns 208939089 bytes_per_second=2.3051G/s BM_string_memset/16/0 4.07 ns 3.98 ns 173479615 bytes_per_second=3.74822G/s BM_string_memset/32/0 4.07 ns 3.95 ns 177208119 bytes_per_second=7.54344G/s BM_string_memset/64/0 4.09 ns 4.00 ns 174729144 bytes_per_second=14.8878G/s BM_string_memset/512/0 10.7 ns 10.4 ns 65922763 bytes_per_second=45.6611G/s BM_string_memset/1024/0 18.0 ns 17.6 ns 40489136 bytes_per_second=54.3166G/s BM_string_memset/8192/0 109 ns 106 ns 6577711 bytes_per_second=71.7667G/s BM_string_memset/16384/0 221 ns 210 ns 3343800 bytes_per_second=72.684G/s BM_string_memset/32768/0 655 ns 623 ns 1153501 bytes_per_second=48.9781G/s BM_string_memset/65536/0 1547 ns 1495 ns 461702 bytes_per_second=40.8154G/s BM_string_memset/131072/0 2991 ns 2924 ns 240189 bytes_per_second=41.7438G/s This patch drops the wmemset() code because we don't even have a microbenchmark for it, we have as many implementations checked in as we have non-test call sites (!), so at this point it seems like we've spent more time maintaining wmemset() than running it! Test: bionic/tests/run-on-host.sh 64 Signed-off-by: ahs <amrita.h.s@intel.com> Change-Id: Ie5047df5300638c1e4c69f8285d33d034f79c83b
2022-06-10 03:41:14 +02:00
"arch-x86_64/string/avx2-memset-kbl.S",
"arch-x86_64/string/sse2-memmove-slm.S",
"arch-x86_64/string/sse2-memset-slm.S",
"arch-x86_64/string/sse2-stpcpy-slm.S",
"arch-x86_64/string/sse2-stpncpy-slm.S",
"arch-x86_64/string/sse2-strcat-slm.S",
"arch-x86_64/string/sse2-strcpy-slm.S",
"arch-x86_64/string/sse2-strlen-slm.S",
"arch-x86_64/string/sse2-strncat-slm.S",
"arch-x86_64/string/sse2-strncpy-slm.S",
"arch-x86_64/string/sse4-memcmp-slm.S",
"arch-x86_64/string/ssse3-strcmp-slm.S",
"arch-x86_64/string/ssse3-strncmp-slm.S",
"bionic/strchr.cpp",
"bionic/strchrnul.cpp",
"bionic/strnlen.cpp",
"bionic/strrchr.cpp",
],
},
},
cppflags: ["-Wold-style-cast"],
include_dirs: ["bionic/libstdc++/include"],
name: "libc_bionic",
}
genrule {
name: "generated_android_ids",
out: ["generated_android_ids.h"],
srcs: [":android_filesystem_config_header"],
tools: ["fs_config_generator"],
cmd: "$(location fs_config_generator) aidarray $(in) > $(out)",
}
// ========================================================
// libc_bionic_ndk.a- The portions of libc_bionic that can
// be safely used in libc_ndk.a (no troublesome global data
// or constructors).
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
srcs: [
"bionic/NetdClientDispatch.cpp",
"bionic/__bionic_get_shell_path.cpp",
"bionic/__cmsg_nxthdr.cpp",
"bionic/__errno.cpp",
"bionic/__gnu_basename.cpp",
"bionic/__libc_current_sigrtmax.cpp",
"bionic/__libc_current_sigrtmin.cpp",
"bionic/abort.cpp",
"bionic/accept.cpp",
"bionic/access.cpp",
"bionic/arpa_inet.cpp",
"bionic/assert.cpp",
"bionic/atof.cpp",
"bionic/bionic_allocator.cpp",
"bionic/bionic_arc4random.cpp",
"bionic/bionic_futex.cpp",
"bionic/bionic_netlink.cpp",
"bionic/bionic_systrace.cpp",
"bionic/bionic_time_conversions.cpp",
"bionic/brk.cpp",
"bionic/c16rtomb.cpp",
"bionic/c32rtomb.cpp",
"bionic/chmod.cpp",
"bionic/chown.cpp",
"bionic/clearenv.cpp",
"bionic/clock.cpp",
"bionic/clock_getcpuclockid.cpp",
"bionic/clock_nanosleep.cpp",
"bionic/clone.cpp",
"bionic/ctype.cpp",
"bionic/dirent.cpp",
"bionic/dup.cpp",
"bionic/environ.cpp",
"bionic/error.cpp",
"bionic/eventfd.cpp",
"bionic/exec.cpp",
"bionic/execinfo.cpp",
"bionic/faccessat.cpp",
"bionic/fchmod.cpp",
"bionic/fchmodat.cpp",
"bionic/fcntl.cpp",
"bionic/fdsan.cpp",
"bionic/fdtrack.cpp",
"bionic/ffs.cpp",
"bionic/fgetxattr.cpp",
"bionic/flistxattr.cpp",
"bionic/fpclassify.cpp",
"bionic/fsetxattr.cpp",
"bionic/ftruncate.cpp",
"bionic/ftw.cpp",
"bionic/futimens.cpp",
"bionic/getcwd.cpp",
"bionic/getdomainname.cpp",
"bionic/getentropy.cpp",
"bionic/gethostname.cpp",
"bionic/getloadavg.cpp",
"bionic/getpagesize.cpp",
"bionic/getpgrp.cpp",
"bionic/getpid.cpp",
"bionic/getpriority.cpp",
"bionic/gettid.cpp",
"bionic/get_device_api_level.cpp",
"bionic/grp_pwd.cpp",
"bionic/grp_pwd_file.cpp",
"bionic/heap_zero_init.cpp",
"bionic/iconv.cpp",
"bionic/icu_wrappers.cpp",
"bionic/ifaddrs.cpp",
"bionic/inotify_init.cpp",
"bionic/ioctl.cpp",
"bionic/killpg.cpp",
"bionic/langinfo.cpp",
"bionic/lchown.cpp",
"bionic/lfs64_support.cpp",
"bionic/libc_init_common.cpp",
"bionic/libgen.cpp",
"bionic/link.cpp",
"bionic/locale.cpp",
"bionic/lockf.cpp",
"bionic/lstat.cpp",
"bionic/mblen.cpp",
"bionic/mbrtoc16.cpp",
"bionic/mbrtoc32.cpp",
"bionic/mempcpy.cpp",
"bionic/memset_explicit.cpp",
"bionic/mkdir.cpp",
"bionic/mkfifo.cpp",
"bionic/mknod.cpp",
"bionic/mntent.cpp",
"bionic/mremap.cpp",
"bionic/net_if.cpp",
"bionic/netdb.cpp",
"bionic/netinet_in.cpp",
"bionic/nl_types.cpp",
"bionic/open.cpp",
"bionic/pathconf.cpp",
"bionic/pause.cpp",
"bionic/pidfd.cpp",
"bionic/pipe.cpp",
"bionic/poll.cpp",
"bionic/posix_fadvise.cpp",
"bionic/posix_fallocate.cpp",
"bionic/posix_madvise.cpp",
"bionic/posix_timers.cpp",
"bionic/preadv_pwritev.cpp",
"bionic/ptrace.cpp",
"bionic/pty.cpp",
"bionic/raise.cpp",
"bionic/rand.cpp",
"bionic/readlink.cpp",
"bionic/realpath.cpp",
"bionic/reboot.cpp",
"bionic/recv.cpp",
"bionic/recvmsg.cpp",
"bionic/rename.cpp",
"bionic/rmdir.cpp",
"bionic/scandir.cpp",
"bionic/sched_getaffinity.cpp",
"bionic/sched_getcpu.cpp",
"bionic/semaphore.cpp",
"bionic/send.cpp",
"bionic/setegid.cpp",
"bionic/seteuid.cpp",
"bionic/setpgrp.cpp",
"bionic/sigaction.cpp",
"bionic/signal.cpp",
"bionic/sigprocmask.cpp",
"bionic/sleep.cpp",
"bionic/socketpair.cpp",
"bionic/spawn.cpp",
"bionic/stat.cpp",
"bionic/stdlib_l.cpp",
"bionic/strerror.cpp",
"bionic/string_l.cpp",
"bionic/strings_l.cpp",
"bionic/strsignal.cpp",
"bionic/strtol.cpp",
"bionic/strtold.cpp",
"bionic/swab.cpp",
"bionic/symlink.cpp",
"bionic/sync_file_range.cpp",
"bionic/sys_epoll.cpp",
"bionic/sys_msg.cpp",
"bionic/sys_sem.cpp",
"bionic/sys_shm.cpp",
"bionic/sys_signalfd.cpp",
"bionic/sys_statfs.cpp",
"bionic/sys_statvfs.cpp",
"bionic/sys_time.cpp",
"bionic/sysinfo.cpp",
"bionic/syslog.cpp",
"bionic/system.cpp",
"bionic/system_property_api.cpp",
"bionic/system_property_set.cpp",
"bionic/tdestroy.cpp",
"bionic/termios.cpp",
"bionic/thread_private.cpp",
"bionic/threads.cpp",
"bionic/time.cpp",
"bionic/time_l.cpp",
"bionic/tmpfile.cpp",
"bionic/umount.cpp",
"bionic/unlink.cpp",
"bionic/usleep.cpp",
"bionic/utmp.cpp",
"bionic/wait.cpp",
"bionic/wchar.cpp",
"bionic/wchar_l.cpp",
"bionic/wcstod.cpp",
"bionic/wctype.cpp",
"bionic/wcwidth.cpp",
"bionic/wmempcpy.cpp",
// This contains a weak stub implementation of __find_icu_symbol for wctype.cpp,
// which will be overridden by the actual one in libc.so.
"bionic/icu_static.cpp",
],
multilib: {
lib32: {
// LP32 cruft
srcs: ["bionic/mmap.cpp"],
},
},
whole_static_libs: [
"libsystemproperties",
],
cppflags: ["-Wold-style-cast"],
local_include_dirs: ["stdio"],
include_dirs: ["bionic/libstdc++/include"],
name: "libc_bionic_ndk",
generated_headers: ["generated_android_ids"],
}
// ========================================================
// libc_syscalls.a
// ========================================================
genrule {
name: "syscalls-arm",
out: ["syscalls-arm.S"],
srcs: ["SYSCALLS.TXT"],
tools: ["gensyscalls"],
cmd: "$(location gensyscalls) arm $(in) > $(out)",
}
genrule {
name: "syscalls-arm64",
out: ["syscalls-arm64.S"],
srcs: ["SYSCALLS.TXT"],
tools: ["gensyscalls"],
cmd: "$(location gensyscalls) arm64 $(in) > $(out)",
}
genrule {
name: "syscalls-riscv64",
out: ["syscalls-riscv64.S"],
srcs: ["SYSCALLS.TXT"],
tools: ["gensyscalls"],
cmd: "$(location gensyscalls) riscv64 $(in) > $(out)",
}
genrule {
name: "syscalls-x86",
out: ["syscalls-x86.S"],
srcs: ["SYSCALLS.TXT"],
tools: ["gensyscalls"],
cmd: "$(location gensyscalls) x86 $(in) > $(out)",
}
genrule {
name: "syscalls-x86_64",
out: ["syscalls-x86_64.S"],
srcs: ["SYSCALLS.TXT"],
tools: ["gensyscalls"],
cmd: "$(location gensyscalls) x86_64 $(in) > $(out)",
}
cc_library_static {
defaults: ["libc_defaults"],
srcs: ["bionic/__set_errno.cpp"],
arch: {
arm: {
srcs: [":syscalls-arm"],
},
arm64: {
srcs: [":syscalls-arm64"],
},
riscv64: {
srcs: [":syscalls-riscv64"],
},
x86: {
srcs: [":syscalls-x86"],
},
x86_64: {
srcs: [":syscalls-x86_64"],
},
},
name: "libc_syscalls",
}
// ========================================================
// libc_aeabi.a
// This is an LP32 ARM-only library that needs to be built with -fno-builtin
// to avoid infinite recursion. For the other architectures we just build an
// empty library to keep this makefile simple.
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
arch: {
arm: {
srcs: ["arch-arm/bionic/__aeabi.c"],
},
},
name: "libc_aeabi",
cflags: ["-fno-builtin"],
}
// ========================================================
// libc_common.a
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
name: "libc_common",
srcs: libc_common_src_files,
multilib: {
lib32: {
srcs: libc_common_src_files_32,
},
},
whole_static_libs: [
"libarm-optimized-routines-string",
"libasync_safe",
"libc_bionic",
"libc_bionic_ndk",
"libc_bootstrap",
"libc_dns",
"libc_fortify",
"libc_freebsd",
"libc_freebsd_large_stack",
"libc_freebsd_ldexp",
"libc_gdtoa",
"libc_netbsd",
"libc_openbsd",
"libc_openbsd_large_stack",
"libc_openbsd_ndk",
"libc_syscalls",
"libc_tzcode",
"libstdc++",
],
arch: {
arm: {
whole_static_libs: ["libc_aeabi"],
},
},
}
// ========================================================
// libc_static_dispatch.a
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
name: "libc_static_dispatch",
arch: {
avx2 implementation for memset. This patch includes handwritten avx2 assembly for memset 64-bit. Uses non-temporal stores for very large sizes. Also includes dynamic dispatch for APIs having multiple implementations. Convincing benchmark improvements for sizes above 512 bytes, and although the slight regression for small sizes is unfortunate, it's probably small enough to be okay? Before: BM_string_memset/8/0 3.06 ns 3.04 ns 222703428 bytes_per_second=2.45261G/s BM_string_memset/16/0 3.50 ns 3.47 ns 202569932 bytes_per_second=4.29686G/s BM_string_memset/32/0 3.50 ns 3.48 ns 200064955 bytes_per_second=8.57386G/s BM_string_memset/64/0 3.49 ns 3.46 ns 201928186 bytes_per_second=17.2184G/s BM_string_memset/512/0 14.8 ns 14.7 ns 47776178 bytes_per_second=32.3887G/s BM_string_memset/1024/0 27.3 ns 27.1 ns 25884933 bytes_per_second=35.2515G/s BM_string_memset/8192/0 203 ns 201 ns 3476903 bytes_per_second=37.9311G/s BM_string_memset/16384/0 402 ns 399 ns 1750471 bytes_per_second=38.2725G/s BM_string_memset/32768/0 932 ns 925 ns 755750 bytes_per_second=33.0071G/s BM_string_memset/65536/0 2038 ns 2014 ns 347060 bytes_per_second=30.3057G/s BM_string_memset/131072/0 4012 ns 3980 ns 175186 bytes_per_second=30.6682G/s After: BM_string_memset/8/0 3.32 ns 3.23 ns 208939089 bytes_per_second=2.3051G/s BM_string_memset/16/0 4.07 ns 3.98 ns 173479615 bytes_per_second=3.74822G/s BM_string_memset/32/0 4.07 ns 3.95 ns 177208119 bytes_per_second=7.54344G/s BM_string_memset/64/0 4.09 ns 4.00 ns 174729144 bytes_per_second=14.8878G/s BM_string_memset/512/0 10.7 ns 10.4 ns 65922763 bytes_per_second=45.6611G/s BM_string_memset/1024/0 18.0 ns 17.6 ns 40489136 bytes_per_second=54.3166G/s BM_string_memset/8192/0 109 ns 106 ns 6577711 bytes_per_second=71.7667G/s BM_string_memset/16384/0 221 ns 210 ns 3343800 bytes_per_second=72.684G/s BM_string_memset/32768/0 655 ns 623 ns 1153501 bytes_per_second=48.9781G/s BM_string_memset/65536/0 1547 ns 1495 ns 461702 bytes_per_second=40.8154G/s BM_string_memset/131072/0 2991 ns 2924 ns 240189 bytes_per_second=41.7438G/s This patch drops the wmemset() code because we don't even have a microbenchmark for it, we have as many implementations checked in as we have non-test call sites (!), so at this point it seems like we've spent more time maintaining wmemset() than running it! Test: bionic/tests/run-on-host.sh 64 Signed-off-by: ahs <amrita.h.s@intel.com> Change-Id: Ie5047df5300638c1e4c69f8285d33d034f79c83b
2022-06-10 03:41:14 +02:00
x86_64: {
srcs: ["arch-x86_64/static_function_dispatch.S"],
},
x86: {
srcs: ["arch-x86/static_function_dispatch.S"],
},
arm: {
srcs: ["arch-arm/static_function_dispatch.S"],
},
arm64: {
srcs: ["arch-arm64/static_function_dispatch.S"],
},
riscv64: {
srcs: ["arch-riscv64/static_function_dispatch.S"],
},
},
}
// ========================================================
// libc_dynamic_dispatch.a
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
name: "libc_dynamic_dispatch",
cflags: [
"-ffreestanding",
"-fno-stack-protector",
"-fno-jump-tables",
],
arch: {
avx2 implementation for memset. This patch includes handwritten avx2 assembly for memset 64-bit. Uses non-temporal stores for very large sizes. Also includes dynamic dispatch for APIs having multiple implementations. Convincing benchmark improvements for sizes above 512 bytes, and although the slight regression for small sizes is unfortunate, it's probably small enough to be okay? Before: BM_string_memset/8/0 3.06 ns 3.04 ns 222703428 bytes_per_second=2.45261G/s BM_string_memset/16/0 3.50 ns 3.47 ns 202569932 bytes_per_second=4.29686G/s BM_string_memset/32/0 3.50 ns 3.48 ns 200064955 bytes_per_second=8.57386G/s BM_string_memset/64/0 3.49 ns 3.46 ns 201928186 bytes_per_second=17.2184G/s BM_string_memset/512/0 14.8 ns 14.7 ns 47776178 bytes_per_second=32.3887G/s BM_string_memset/1024/0 27.3 ns 27.1 ns 25884933 bytes_per_second=35.2515G/s BM_string_memset/8192/0 203 ns 201 ns 3476903 bytes_per_second=37.9311G/s BM_string_memset/16384/0 402 ns 399 ns 1750471 bytes_per_second=38.2725G/s BM_string_memset/32768/0 932 ns 925 ns 755750 bytes_per_second=33.0071G/s BM_string_memset/65536/0 2038 ns 2014 ns 347060 bytes_per_second=30.3057G/s BM_string_memset/131072/0 4012 ns 3980 ns 175186 bytes_per_second=30.6682G/s After: BM_string_memset/8/0 3.32 ns 3.23 ns 208939089 bytes_per_second=2.3051G/s BM_string_memset/16/0 4.07 ns 3.98 ns 173479615 bytes_per_second=3.74822G/s BM_string_memset/32/0 4.07 ns 3.95 ns 177208119 bytes_per_second=7.54344G/s BM_string_memset/64/0 4.09 ns 4.00 ns 174729144 bytes_per_second=14.8878G/s BM_string_memset/512/0 10.7 ns 10.4 ns 65922763 bytes_per_second=45.6611G/s BM_string_memset/1024/0 18.0 ns 17.6 ns 40489136 bytes_per_second=54.3166G/s BM_string_memset/8192/0 109 ns 106 ns 6577711 bytes_per_second=71.7667G/s BM_string_memset/16384/0 221 ns 210 ns 3343800 bytes_per_second=72.684G/s BM_string_memset/32768/0 655 ns 623 ns 1153501 bytes_per_second=48.9781G/s BM_string_memset/65536/0 1547 ns 1495 ns 461702 bytes_per_second=40.8154G/s BM_string_memset/131072/0 2991 ns 2924 ns 240189 bytes_per_second=41.7438G/s This patch drops the wmemset() code because we don't even have a microbenchmark for it, we have as many implementations checked in as we have non-test call sites (!), so at this point it seems like we've spent more time maintaining wmemset() than running it! Test: bionic/tests/run-on-host.sh 64 Signed-off-by: ahs <amrita.h.s@intel.com> Change-Id: Ie5047df5300638c1e4c69f8285d33d034f79c83b
2022-06-10 03:41:14 +02:00
x86_64: {
srcs: ["arch-x86_64/dynamic_function_dispatch.cpp"],
},
x86: {
srcs: ["arch-x86/dynamic_function_dispatch.cpp"],
},
arm: {
srcs: ["arch-arm/dynamic_function_dispatch.cpp"],
},
arm64: {
srcs: ["arch-arm64/dynamic_function_dispatch.cpp"],
},
riscv64: {
srcs: ["arch-riscv64/dynamic_function_dispatch.cpp"],
},
},
}
// ========================================================
// libc_common_static.a For static binaries.
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
name: "libc_common_static",
whole_static_libs: [
"libc_common",
"libc_static_dispatch",
],
}
// ========================================================
// libc_common_shared.a For shared libraries.
// ========================================================
cc_library_static {
defaults: ["libc_defaults"],
name: "libc_common_shared",
whole_static_libs: [
"libc_common",
"libc_dynamic_dispatch",
],
}
// Versions of dl_iterate_phdr and similar APIs used to lookup unwinding information in a static
// executable.
cc_library_static {
name: "libc_unwind_static",
defaults: ["libc_defaults"],
cflags: ["-DLIBC_STATIC"],
srcs: ["bionic/dl_iterate_phdr_static.cpp"],
arch: {
// arm32-specific dl_unwind_find_exidx and __gnu_Unwind_Find_exidx APIs
arm: {
srcs: ["arch-arm/bionic/exidx_static.c"],
},
},
}
// ========================================================
// libc_nomalloc.a
// ========================================================
//
// This is a version of the static C library used by the dynamic linker that exclude malloc. It also
// excludes functions selected using ifunc's (e.g. for string.h). Link in either
// libc_static_dispatch or libc_dynamic_dispatch to provide those functions.
cc_library_static {
name: "libc_nomalloc",
defaults: ["libc_defaults"],
whole_static_libs: [
"libc_common",
"libc_init_static",
"libc_unwind_static",
],
}
filegroup {
name: "libc_sources_shared",
srcs: [
"arch-common/bionic/crtbegin_so.c",
"arch-common/bionic/crtbrand.S",
"bionic/gwp_asan_wrappers.cpp",
"bionic/heap_tagging.cpp",
"bionic/icu.cpp",
"bionic/malloc_common.cpp",
"bionic/malloc_common_dynamic.cpp",
2020-01-02 20:54:57 +01:00
"bionic/android_profiling_dynamic.cpp",
"bionic/malloc_heapprofd.cpp",
"bionic/malloc_limit.cpp",
"bionic/ndk_cruft.cpp",
"bionic/ndk_cruft_data.cpp",
"bionic/NetdClient.cpp",
"arch-common/bionic/crtend_so.S",
],
}
filegroup {
name: "libc_sources_static",
srcs: [
"bionic/gwp_asan_wrappers.cpp",
"bionic/heap_tagging.cpp",
"bionic/malloc_common.cpp",
"bionic/malloc_limit.cpp",
],
}
filegroup {
name: "libc_sources_shared_arm",
srcs: [
"arch-arm/bionic/exidx_dynamic.c",
"arch-arm/bionic/atexit_legacy.c",
],
}
// ========================================================
// libc.a + libc.so
// ========================================================
cc_defaults {
defaults: [
"libc_defaults",
"libc_native_allocator_defaults",
],
name: "libc_library_defaults",
product_variables: {
platform_sdk_version: {
asflags: ["-DPLATFORM_SDK_VERSION=%d"],
},
},
static: {
srcs: [":libc_sources_static"],
cflags: ["-DLIBC_STATIC"],
whole_static_libs: [
"gwp_asan",
"gwp_asan_crash_handler",
"libc_init_static",
"libc_common_static",
"libc_unwind_static",
],
},
shared: {
srcs: [":libc_sources_shared"],
whole_static_libs: [
"gwp_asan",
"gwp_asan_crash_handler",
"libc_init_dynamic",
"libc_common_shared",
"libunwind-exported",
],
},
required: [
"tzdata_prebuilt",
"tz_version_prebuilt", // Version metadata for tzdata to help debugging.
],
// Do not pack libc.so relocations; see http://b/20645321 for details.
pack_relocations: false,
// WARNING: The only libraries libc.so should depend on are libdl.so and ld-android.so!
// If you add other libraries, make sure to add -Wl,--exclude-libs=libgcc.a to the
// LOCAL_LDFLAGS for those libraries. This ensures that symbols that are pulled into
// those new libraries from libgcc.a are not declared external; if that were the case,
// then libc would not pull those symbols from libgcc.a as it should, instead relying
// on the external symbols from the dependent libraries. That would create a "cloaked"
// dependency on libgcc.a in libc though the libraries, which is not what you wanted!
shared_libs: [
"ld-android",
"libdl",
],
static_libs: [
"libdl_android",
],
nocrt: true,
arch: {
arm: {
// TODO: This is to work around b/24465209. Remove after root cause is fixed.
pack_relocations: false,
ldflags: [
"-Wl,--hash-style=both",
// Since we are preserving the debug_frame, do not compress
// in this case to make unwinds as fast as possible.
"-Wl,--compress-debug-sections=none",
],
version_script: ":libc.arm.map",
no_libcrt: true,
shared: {
srcs: [":libc_sources_shared_arm"],
// special for arm
cflags: ["-DCRT_LEGACY_WORKAROUND"],
// For backwards-compatibility, some arm32 builtins are exported from libc.so.
static_libs: ["libclang_rt.builtins-exported"],
},
// Arm 32 bit does not produce complete exidx unwind information
// so keep the .debug_frame which is relatively small and does
// include needed unwind information.
// See b/132992102 for details.
strip: {
keep_symbols_and_debug_frame: true,
},
},
arm64: {
version_script: ":libc.arm64.map",
// Leave the symbols in the shared library so that stack unwinders can produce
// meaningful name resolution.
strip: {
keep_symbols: true,
},
},
riscv64: {
version_script: ":libc.riscv64.map",
// Leave the symbols in the shared library so that stack unwinders can produce
// meaningful name resolution.
strip: {
keep_symbols: true,
},
},
x86: {
// TODO: This is to work around b/24465209. Remove after root cause is fixed.
pack_relocations: false,
ldflags: ["-Wl,--hash-style=both"],
version_script: ":libc.x86.map",
no_libcrt: true,
shared: {
// For backwards-compatibility, some x86 builtins are exported from libc.so.
static_libs: ["libclang_rt.builtins-exported"],
},
// Leave the symbols in the shared library so that stack unwinders can produce
// meaningful name resolution.
strip: {
keep_symbols: true,
},
},
x86_64: {
version_script: ":libc.x86_64.map",
// Leave the symbols in the shared library so that stack unwinders can produce
// meaningful name resolution.
strip: {
keep_symbols: true,
},
},
},
apex_available: [
"//apex_available:platform",
"com.android.runtime",
],
target: {
native_bridge: {
shared: {
installable: false,
},
},
},
}
cc_library {
name: "libc",
defaults: [
"libc_library_defaults",
],
stubs: {
symbol_file: "libc.map.txt",
versions: [
"29",
"R",
"current",
],
},
static_ndk_lib: true,
llndk: {
symbol_file: "libc.map.txt",
export_headers_as_system: true,
export_preprocessed_headers: ["include"],
export_llndk_headers: ["libc_llndk_headers"],
},
}
cc_library {
name: "libc_hwasan",
defaults: [
"libc_library_defaults",
],
sanitize: {
hwaddress: true,
},
enabled: false,
target: {
android_arm64: {
enabled: true,
},
},
stem: "libc",
relative_install_path: "hwasan",
// We don't really need the stubs, but this needs to stay to trigger the
// symlink logic in soong.
stubs: {
symbol_file: "libc.map.txt",
},
native_bridge_supported: false,
// It is never correct to depend on this directly. This is only
// needed for the runtime apex, and in base_system.mk.
visibility: ["//bionic/apex"],
}
genrule {
name: "libc.arm.map",
out: ["libc.arm.map.txt"],
srcs: ["libc.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) arm $(in) $(out)",
}
genrule {
name: "libc.arm64.map",
out: ["libc.arm64.map.txt"],
srcs: ["libc.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) arm64 $(in) $(out)",
}
genrule {
name: "libc.riscv64.map",
out: ["libc.riscv64.map.txt"],
srcs: ["libc.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
}
genrule {
name: "libc.x86.map",
out: ["libc.x86.map.txt"],
srcs: ["libc.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) x86 $(in) $(out)",
}
genrule {
name: "libc.x86_64.map",
out: ["libc.x86_64.map.txt"],
srcs: ["libc.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
}
// Headers that only other parts of the platform can include.
cc_library_headers {
name: "bionic_libc_platform_headers",
defaults: ["linux_bionic_supported"],
visibility: [
"//art:__subpackages__",
"//bionic:__subpackages__",
"//frameworks:__subpackages__",
"//device/generic/goldfish-opengl:__subpackages__",
"//external/gwp_asan:__subpackages__",
"//external/perfetto:__subpackages__",
"//external/scudo:__subpackages__",
"//system/core/debuggerd:__subpackages__",
"//system/core/init:__subpackages__",
"//system/core/libcutils:__subpackages__",
"//system/memory/libmemunreachable:__subpackages__",
"//system/unwinding/libunwindstack:__subpackages__",
"//tools/security/sanitizer-status:__subpackages__",
],
vendor_available: true,
product_available: true,
ramdisk_available: true,
vendor_ramdisk_available: true,
recovery_available: true,
native_bridge_supported: true,
export_include_dirs: [
"platform",
],
system_shared_libs: [],
stl: "none",
sdk_version: "current",
min_sdk_version: "29",
apex_available: [
"//apex_available:platform",
"//apex_available:anyapex",
],
}
cc_library_headers {
name: "libc_llndk_headers",
visibility: [
"//external/musl",
],
llndk: {
llndk_headers: true,
},
host_supported: true,
vendor_available: true,
product_available: true,
ramdisk_available: true,
vendor_ramdisk_available: true,
recovery_available: true,
native_bridge_supported: true,
apex_available: [
"//apex_available:platform",
"//apex_available:anyapex",
],
// used by most APEXes indirectly via libunwind_llvm
min_sdk_version: "apex_inherit",
no_libcrt: true,
stl: "none",
system_shared_libs: [],
// The build system generally requires that any dependencies of a target
// with an sdk_version must have a lower sdk_version. By setting sdk_version
// to 1 we let targets with an sdk_version that need to depend on the libc
// headers but cannot depend on libc itself due to circular dependencies
// (such as libunwind_llvm) depend on the headers. Setting sdk_version to 1
// is correct because the headers can support any sdk_version.
sdk_version: "1",
export_system_include_dirs: [
"kernel/uapi",
"kernel/android/scsi",
"kernel/android/uapi",
],
arch: {
arm: {
export_system_include_dirs: ["kernel/uapi/asm-arm"],
},
arm64: {
export_system_include_dirs: ["kernel/uapi/asm-arm64"],
},
riscv64: {
export_system_include_dirs: ["kernel/uapi/asm-riscv"],
},
x86: {
export_system_include_dirs: ["kernel/uapi/asm-x86"],
},
x86_64: {
export_system_include_dirs: ["kernel/uapi/asm-x86"],
},
},
}
cc_library_headers {
name: "libc_headers",
host_supported: true,
native_bridge_supported: true,
vendor_available: true,
product_available: true,
ramdisk_available: true,
vendor_ramdisk_available: true,
recovery_available: true,
sdk_version: "1",
apex_available: [
"//apex_available:platform",
"//apex_available:anyapex",
],
// used by most APEXes indirectly via libunwind_llvm
min_sdk_version: "apex_inherit",
visibility: [
"//bionic:__subpackages__", // visible to bionic
// ... and only to these places (b/152668052)
"//external/arm-optimized-routines",
"//external/gwp_asan",
"//external/jemalloc_new",
"//external/libunwind_llvm",
"//external/scudo",
"//system/core/property_service/libpropertyinfoparser",
"//system/extras/toolchain-extras",
],
stl: "none",
no_libcrt: true,
system_shared_libs: [],
target: {
android: {
export_system_include_dirs: ["include"],
header_libs: ["libc_llndk_headers"],
export_header_lib_headers: ["libc_llndk_headers"],
},
linux_bionic: {
export_system_include_dirs: ["include"],
header_libs: ["libc_llndk_headers"],
export_header_lib_headers: ["libc_llndk_headers"],
},
},
}
// ========================================================
// libstdc++.so and libstdc++.a.
// ========================================================
cc_library {
defaults: ["libc_defaults"],
include_dirs: ["bionic/libstdc++/include"],
srcs: [
"bionic/__cxa_guard.cpp",
"bionic/__cxa_pure_virtual.cpp",
"bionic/new.cpp",
],
name: "libstdc++",
static_ndk_lib: true,
static_libs: ["libasync_safe"],
apex_available: [
"//apex_available:platform",
],
static: {
system_shared_libs: [],
},
target: {
bionic: {
shared: {
system_shared_libs: ["libc"],
},
},
},
//TODO (dimitry): This is to work around b/24465209. Remove after root cause is fixed
arch: {
arm: {
// TODO: This is to work around b/24465209. Remove after root cause is fixed.
pack_relocations: false,
ldflags: ["-Wl,--hash-style=both"],
version_script: ":libstdc++.arm.map",
},
arm64: {
version_script: ":libstdc++.arm64.map",
},
riscv64: {
version_script: ":libstdc++.riscv64.map",
},
x86: {
pack_relocations: false,
ldflags: ["-Wl,--hash-style=both"],
version_script: ":libstdc++.x86.map",
},
x86_64: {
version_script: ":libstdc++.x86_64.map",
},
},
}
genrule {
name: "libstdc++.arm.map",
out: ["libstdc++.arm.map.txt"],
srcs: ["libstdc++.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) arm $(in) $(out)",
}
genrule {
name: "libstdc++.arm64.map",
out: ["libstdc++.arm64.map.txt"],
srcs: ["libstdc++.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) arm64 $(in) $(out)",
}
genrule {
name: "libstdc++.riscv64.map",
out: ["libstdc++.riscv64.map.txt"],
srcs: ["libstdc++.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) riscv64 $(in) $(out)",
}
genrule {
name: "libstdc++.x86.map",
out: ["libstdc++.x86.map.txt"],
srcs: ["libstdc++.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) x86 $(in) $(out)",
}
genrule {
name: "libstdc++.x86_64.map",
out: ["libstdc++.x86_64.map.txt"],
srcs: ["libstdc++.map.txt"],
tools: ["generate-version-script"],
cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
}
// ========================================================
// crt object files.
// ========================================================
cc_defaults {
name: "crt_and_memtag_defaults",
defaults: ["linux_bionic_supported"],
vendor_available: true,
product_available: true,
ramdisk_available: true,
vendor_ramdisk_available: true,
recovery_available: true,
native_bridge_supported: true,
apex_available: [
"//apex_available:platform",
"//apex_available:anyapex",
],
// Generate NDK variants of the CRT objects for every supported API level.
min_sdk_version: "16",
stl: "none",
crt: true,
cflags: [
"-Wno-gcc-compat",
"-Wall",
"-Werror",
],
sanitize: {
never: true,
},
}
cc_defaults {
name: "crt_defaults",
defaults: ["crt_and_memtag_defaults"],
system_shared_libs: [],
}
cc_defaults {
name: "crt_so_defaults",
defaults: ["crt_defaults"],
arch: {
x86: {
cflags: ["-fPIC"],
},
x86_64: {
cflags: ["-fPIC"],
},
},
stl: "none",
}
cc_object {
name: "crtbrand",
// crtbrand.c needs <stdint.h> and a #define for the platform SDK version.
local_include_dirs: [
"include",
"private", // crtbrand.S depends on private/bionic_asm_note.h
],
product_variables: {
platform_sdk_version: {
asflags: ["-DPLATFORM_SDK_VERSION=%d"],
},
},
srcs: ["arch-common/bionic/crtbrand.S"],
defaults: ["crt_so_defaults"],
// crtbrand is an intermediate artifact, not a final CRT object.
exclude_from_ndk_sysroot: true,
}
cc_object {
name: "crtbegin_so",
local_include_dirs: ["include"],
srcs: ["arch-common/bionic/crtbegin_so.c"],
defaults: ["crt_so_defaults"],
objs: [
"crtbrand",
],
}
cc_object {
name: "crtend_so",
local_include_dirs: [
"include",
"private", // crtend_so.S depends on private/bionic_asm_arm64.h
],
srcs: ["arch-common/bionic/crtend_so.S"],
defaults: ["crt_so_defaults"],
}
cc_object {
name: "crtbegin_static",
local_include_dirs: [
"include",
"bionic", // crtbegin.c includes bionic/libc_init_common.h
],
cflags: ["-DCRTBEGIN_STATIC"],
srcs: ["arch-common/bionic/crtbegin.c"],
objs: [
"crtbrand",
],
defaults: ["crt_defaults"],
// When using libc.a, we're using the latest library regardless of target API level.
min_sdk_version: "current",
}
cc_object {
name: "crtbegin_dynamic",
local_include_dirs: [
"include",
"bionic", // crtbegin.c includes bionic/libc_init_common.h
],
srcs: ["arch-common/bionic/crtbegin.c"],
objs: [
"crtbrand",
],
target: {
linux_bionic: {
generated_sources: ["host_bionic_linker_asm"],
objs: [
"linker_wrapper",
],
},
},
defaults: ["crt_defaults"],
}
cc_object {
// We rename crtend.o to crtend_android.o to avoid a
// name clash between gcc and bionic.
name: "crtend_android",
local_include_dirs: [
"include",
"private", // crtend.S depends on private/bionic_asm_arm64.h
],
srcs: ["arch-common/bionic/crtend.S"],
defaults: ["crt_defaults"],
}
2024-01-09 22:13:50 +01:00
cc_object {
name: "crt_pad_segment",
local_include_dirs: [
"include",
"private", // crt_pad_segment.S depends on private/bionic_asm_note.h
2024-01-09 22:13:50 +01:00
],
srcs: ["arch-common/bionic/crt_pad_segment.S"],
defaults: ["crt_defaults"],
}
cc_library_static {
name: "note_memtag_heap_async",
arch: {
arm64: {
srcs: ["arch-arm64/bionic/note_memtag_heap_async.S"],
},
},
sdk_version: "minimum",
defaults: ["crt_and_memtag_defaults"],
}
cc_library_static {
name: "note_memtag_heap_sync",
arch: {
arm64: {
srcs: ["arch-arm64/bionic/note_memtag_heap_sync.S"],
},
},
sdk_version: "minimum",
defaults: ["crt_and_memtag_defaults"],
}
// ========================================================
// libc dependencies for baremetal Rust projects.
// ========================================================
// This library contains the following unresolved symbols:
// __errno
// abort
// async_safe_fatal_va_list
cc_library_static {
name: "librust_baremetal",
header_libs: ["libc_headers"],
include_dirs: [
"bionic/libc/async_safe/include",
"bionic/libc/platform",
],
cflags: [
"-Wall",
"-Werror",
],
srcs: [
"bionic/fortify.cpp",
"bionic/strtol.cpp",
],
arch: {
arm64: {
srcs: [
"arch-arm64/string/__memcpy_chk.S",
],
},
riscv64: {
srcs: [
"arch-riscv64/string/__memcpy_chk.S",
],
},
},
whole_static_libs: [
"libarm-optimized-routines-mem",
"libc_netbsd",
],
system_shared_libs: [],
nocrt: true,
stl: "none",
visibility: [
"//packages/modules/Virtualization/vmbase",
],
}
// ========================================================
// NDK headers.
// ========================================================
versioned_ndk_headers {
name: "common_libc",
from: "include",
to: "",
license: "NOTICE",
}
ndk_headers {
name: "libc_uapi",
from: "kernel/uapi",
to: "",
srcs: [
"kernel/uapi/asm-generic/**/*.h",
"kernel/uapi/drm/**/*.h",
"kernel/uapi/linux/**/*.h",
"kernel/uapi/misc/**/*.h",
"kernel/uapi/mtd/**/*.h",
"kernel/uapi/rdma/**/*.h",
"kernel/uapi/scsi/**/*.h",
"kernel/uapi/sound/**/*.h",
"kernel/uapi/video/**/*.h",
"kernel/uapi/xen/**/*.h",
],
license: "NOTICE",
}
ndk_headers {
name: "libc_kernel_android_uapi_linux",
from: "kernel/android/uapi/linux",
to: "linux",
srcs: ["kernel/android/uapi/linux/**/*.h"],
license: "NOTICE",
}
ndk_headers {
name: "libc_kernel_android_scsi",
from: "kernel/android/scsi/scsi",
to: "scsi",
srcs: ["kernel/android/scsi/**/*.h"],
license: "NOTICE",
}
ndk_headers {
name: "libc_asm_arm",
from: "kernel/uapi/asm-arm",
to: "arm-linux-androideabi",
srcs: ["kernel/uapi/asm-arm/**/*.h"],
license: "NOTICE",
}
ndk_headers {
name: "libc_asm_arm64",
from: "kernel/uapi/asm-arm64",
to: "aarch64-linux-android",
srcs: ["kernel/uapi/asm-arm64/**/*.h"],
license: "NOTICE",
}
ndk_headers {
name: "libc_asm_riscv64",
from: "kernel/uapi/asm-riscv",
to: "riscv64-linux-android",
srcs: ["kernel/uapi/asm-riscv/**/*.h"],
license: "NOTICE",
}
ndk_headers {
name: "libc_asm_x86",
from: "kernel/uapi/asm-x86",
to: "i686-linux-android",
srcs: ["kernel/uapi/asm-x86/**/*.h"],
license: "NOTICE",
}
ndk_headers {
name: "libc_asm_x86_64",
from: "kernel/uapi/asm-x86",
to: "x86_64-linux-android",
srcs: ["kernel/uapi/asm-x86/**/*.h"],
license: "NOTICE",
}
ndk_library {
name: "libc",
symbol_file: "libc.map.txt",
first_version: "9",
export_header_libs: [
"common_libc",
"libc_uapi",
"libc_kernel_android_uapi_linux",
"libc_kernel_android_scsi",
"libc_asm_arm",
"libc_asm_arm64",
"libc_asm_riscv64",
"libc_asm_x86",
"libc_asm_x86_64",
],
}
ndk_library {
name: "libstdc++",
symbol_file: "libstdc++.map.txt",
first_version: "9",
}
// Export these headers for toolbox to process
filegroup {
name: "kernel_input_headers",
srcs: [
"kernel/uapi/linux/input.h",
"kernel/uapi/linux/input-event-codes.h",
],
}
// Generate a syscall name / number mapping. These objects are text files
// (thanks to the -dD -E flags) and not binary files. They will then be
// consumed by the genseccomp.py script and converted into C++ code.
cc_defaults {
name: "libseccomp_gen_syscall_nrs_defaults",
recovery_available: true,
srcs: ["seccomp/gen_syscall_nrs.cpp"],
cflags: [
"-dD",
"-E",
"-Wall",
"-Werror",
"-nostdinc",
],
}
cc_object {
name: "libseccomp_gen_syscall_nrs_arm",
defaults: ["libseccomp_gen_syscall_nrs_defaults"],
local_include_dirs: [
"kernel/uapi/asm-arm",
"kernel/uapi",
],
}
cc_object {
name: "libseccomp_gen_syscall_nrs_arm64",
defaults: ["libseccomp_gen_syscall_nrs_defaults"],
local_include_dirs: [
"kernel/uapi/asm-arm64",
"kernel/uapi",
],
}
cc_object {
name: "libseccomp_gen_syscall_nrs_riscv64",
defaults: ["libseccomp_gen_syscall_nrs_defaults"],
local_include_dirs: [
"kernel/uapi/asm-riscv",
"kernel/uapi",
],
}
cc_object {
name: "libseccomp_gen_syscall_nrs_x86",
defaults: ["libseccomp_gen_syscall_nrs_defaults"],
srcs: ["seccomp/gen_syscall_nrs_x86.cpp"],
exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
local_include_dirs: [
"kernel/uapi/asm-x86",
"kernel/uapi",
],
}
cc_object {
name: "libseccomp_gen_syscall_nrs_x86_64",
defaults: ["libseccomp_gen_syscall_nrs_defaults"],
srcs: ["seccomp/gen_syscall_nrs_x86_64.cpp"],
exclude_srcs: ["seccomp/gen_syscall_nrs.cpp"],
local_include_dirs: [
"kernel/uapi/asm-x86",
"kernel/uapi",
],
}
filegroup {
name: "all_kernel_uapi_headers",
srcs: ["kernel/uapi/**/*.h"],
}
cc_genrule {
name: "func_to_syscall_nrs",
recovery_available: true,
cmd: "$(location genfunctosyscallnrs) --out-dir=$(genDir) $(in)",
tools: ["genfunctosyscallnrs"],
srcs: [
"SYSCALLS.TXT",
],
arch: {
arm: {
srcs: [
":libseccomp_gen_syscall_nrs_arm",
":libseccomp_gen_syscall_nrs_arm64",
],
},
arm64: {
srcs: [
":libseccomp_gen_syscall_nrs_arm",
":libseccomp_gen_syscall_nrs_arm64",
],
},
riscv64: {
srcs: [":libseccomp_gen_syscall_nrs_riscv64"],
},
x86: {
srcs: [
":libseccomp_gen_syscall_nrs_x86",
":libseccomp_gen_syscall_nrs_x86_64",
],
},
x86_64: {
srcs: [
":libseccomp_gen_syscall_nrs_x86",
":libseccomp_gen_syscall_nrs_x86_64",
],
},
},
out: [
"func_to_syscall_nrs.h",
],
}
// SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT = SECCOMP_BLOCKLIST_APP.txt - setresgid*
genrule {
name: "generate_app_zygote_blocklist",
out: ["SECCOMP_BLOCKLIST_APP_ZYGOTE.TXT"],
srcs: ["SECCOMP_BLOCKLIST_APP.TXT"],
cmd: "grep -v '^int[ \t]*setresgid' $(in) > $(out)",
}
filegroup {
name: "seccomp_syscalls_sources_zygote",
srcs: [
"SYSCALLS.TXT",
"SECCOMP_ALLOWLIST_COMMON.TXT",
"SECCOMP_ALLOWLIST_APP.TXT",
"SECCOMP_BLOCKLIST_COMMON.TXT",
"SECCOMP_PRIORITY.TXT",
":generate_app_zygote_blocklist",
],
}
filegroup {
name: "seccomp_syscalls_sources_app",
srcs: [
"SYSCALLS.TXT",
"SECCOMP_ALLOWLIST_COMMON.TXT",
"SECCOMP_ALLOWLIST_APP.TXT",
"SECCOMP_BLOCKLIST_COMMON.TXT",
"SECCOMP_BLOCKLIST_APP.TXT",
"SECCOMP_PRIORITY.TXT",
],
}
filegroup {
name: "seccomp_syscalls_sources_system",
srcs: [
"SYSCALLS.TXT",
"SECCOMP_ALLOWLIST_COMMON.TXT",
"SECCOMP_ALLOWLIST_SYSTEM.TXT",
"SECCOMP_BLOCKLIST_COMMON.TXT",
"SECCOMP_PRIORITY.TXT",
],
}
cc_genrule {
name: "libseccomp_policy_app_zygote_sources_x86",
recovery_available: true,
cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
tools: ["genseccomp"],
srcs: [
":seccomp_syscalls_sources_zygote",
":libseccomp_gen_syscall_nrs_x86",
":libseccomp_gen_syscall_nrs_x86_64",
],
out: [
"x86_app_zygote_policy.cpp",
"x86_64_app_zygote_policy.cpp",
],
enabled: false,
arch: {
x86: {
enabled: true,
},
x86_64: {
enabled: true,
},
},
}
cc_genrule {
name: "libseccomp_policy_app_zygote_sources_arm",
recovery_available: true,
cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
tools: ["genseccomp"],
srcs: [
":seccomp_syscalls_sources_zygote",
":libseccomp_gen_syscall_nrs_arm",
":libseccomp_gen_syscall_nrs_arm64",
],
out: [
"arm_app_zygote_policy.cpp",
"arm64_app_zygote_policy.cpp",
],
enabled: false,
arch: {
arm: {
enabled: true,
},
arm64: {
enabled: true,
},
},
}
cc_genrule {
name: "libseccomp_policy_app_zygote_sources_riscv64",
recovery_available: true,
cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app_zygote $(in)",
tools: ["genseccomp"],
srcs: [
":seccomp_syscalls_sources_zygote",
":libseccomp_gen_syscall_nrs_riscv64",
],
out: [
"riscv64_app_zygote_policy.cpp",
],
enabled: false,
arch: {
riscv64: {
enabled: true,
},
},
}
cc_genrule {
name: "libseccomp_policy_app_sources_x86",
recovery_available: true,
cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
tools: ["genseccomp"],
srcs: [
":seccomp_syscalls_sources_app",
":libseccomp_gen_syscall_nrs_x86",
":libseccomp_gen_syscall_nrs_x86_64",
],
out: [
"x86_app_policy.cpp",
"x86_64_app_policy.cpp",
],
enabled: false,
arch: {
x86: {
enabled: true,
},
x86_64: {
enabled: true,
},
},
}
cc_genrule {
name: "libseccomp_policy_app_sources_arm",
recovery_available: true,
cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
tools: ["genseccomp"],
srcs: [
":seccomp_syscalls_sources_app",
":libseccomp_gen_syscall_nrs_arm",
":libseccomp_gen_syscall_nrs_arm64",
],
out: [
"arm_app_policy.cpp",
"arm64_app_policy.cpp",
],
enabled: false,
arch: {
arm: {
enabled: true,
},
arm64: {
enabled: true,
},
},
}
cc_genrule {
name: "libseccomp_policy_app_sources_riscv64",
recovery_available: true,
cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=app $(in)",
tools: ["genseccomp"],
srcs: [
":seccomp_syscalls_sources_app",
":libseccomp_gen_syscall_nrs_riscv64",
],
out: [
"riscv64_app_policy.cpp",
],
enabled: false,
arch: {
riscv64: {
enabled: true,
},
},
}
cc_genrule {
name: "libseccomp_policy_system_sources_x86",
recovery_available: true,
cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
tools: ["genseccomp"],
srcs: [
":seccomp_syscalls_sources_system",
":libseccomp_gen_syscall_nrs_x86",
":libseccomp_gen_syscall_nrs_x86_64",
],
out: [
"x86_system_policy.cpp",
"x86_64_system_policy.cpp",
],
enabled: false,
arch: {
x86: {
enabled: true,
},
x86_64: {
enabled: true,
},
},
}
cc_genrule {
name: "libseccomp_policy_system_sources_arm",
recovery_available: true,
cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
tools: ["genseccomp"],
srcs: [
":seccomp_syscalls_sources_system",
":libseccomp_gen_syscall_nrs_arm",
":libseccomp_gen_syscall_nrs_arm64",
],
out: [
"arm_system_policy.cpp",
"arm64_system_policy.cpp",
],
enabled: false,
arch: {
arm: {
enabled: true,
},
arm64: {
enabled: true,
},
},
}
cc_genrule {
name: "libseccomp_policy_system_sources_riscv64",
recovery_available: true,
cmd: "$(location genseccomp) --out-dir=$(genDir) --name-modifier=system $(in)",
tools: ["genseccomp"],
srcs: [
":seccomp_syscalls_sources_system",
":libseccomp_gen_syscall_nrs_riscv64",
],
out: [
"riscv64_system_policy.cpp",
],
enabled: false,
arch: {
riscv64: {
enabled: true,
},
},
}
cc_library {
name: "libseccomp_policy",
recovery_available: true,
generated_headers: ["func_to_syscall_nrs"],
arch: {
arm: {
generated_sources: [
"libseccomp_policy_app_sources_arm",
"libseccomp_policy_app_zygote_sources_arm",
"libseccomp_policy_system_sources_arm",
],
},
arm64: {
generated_sources: [
"libseccomp_policy_app_sources_arm",
"libseccomp_policy_app_zygote_sources_arm",
"libseccomp_policy_system_sources_arm",
],
},
riscv64: {
generated_sources: [
"libseccomp_policy_app_sources_riscv64",
"libseccomp_policy_app_zygote_sources_riscv64",
"libseccomp_policy_system_sources_riscv64",
],
},
x86: {
generated_sources: [
"libseccomp_policy_app_sources_x86",
"libseccomp_policy_app_zygote_sources_x86",
"libseccomp_policy_system_sources_x86",
],
},
x86_64: {
generated_sources: [
"libseccomp_policy_app_sources_x86",
"libseccomp_policy_app_zygote_sources_x86",
"libseccomp_policy_system_sources_x86",
],
},
},
srcs: [
"seccomp/seccomp_policy.cpp",
],
export_include_dirs: ["seccomp/include"],
cflags: [
"-Wall",
"-Werror",
],
shared: {
shared_libs: ["libbase"],
},
static: {
static_libs: ["libbase"],
},
}
cc_library_host_static {
name: "libfts",
srcs: [
"bionic/fts.c",
"upstream-openbsd/lib/libc/stdlib/recallocarray.c",
],
export_include_dirs: ["fts/include"],
local_include_dirs: [
"private",
"upstream-openbsd/android/include",
],
cflags: [
"-include openbsd-compat.h",
"-Wno-unused-parameter",
],
enabled: false,
target: {
musl: {
enabled: true,
},
},
stl: "none",
}
cc_library_host_static {
name: "libexecinfo",
visibility: ["//external/musl"],
srcs: ["bionic/execinfo.cpp"],
export_include_dirs: ["execinfo/include"],
local_include_dirs: ["private"],
enabled: false,
target: {
musl: {
enabled: true,
system_shared_libs: [],
header_libs: ["libc_musl_headers"],
},
},
stl: "none",
}
cc_library_host_static {
name: "libb64",
visibility: ["//external/musl"],
srcs: ["upstream-openbsd/lib/libc/net/base64.c"],
export_include_dirs: ["b64/include"],
local_include_dirs: [
"private",
"upstream-openbsd/android/include",
],
cflags: [
"-include openbsd-compat.h",
],
enabled: false,
target: {
musl: {
enabled: true,
system_shared_libs: [],
header_libs: ["libc_musl_headers"],
},
},
stl: "none",
}
// Export kernel uapi headers to be used in the musl sysroot.
// Also include the execinfo headers for the libexecinfo and the
// b64 headers for libb64 embedded in musl libc.
cc_genrule {
name: "libc_musl_sysroot_bionic_headers",
visibility: ["//external/musl"],
host_supported: true,
device_supported: false,
enabled: false,
target: {
musl: {
enabled: true,
},
},
srcs: [
"kernel/uapi/**/*.h",
"kernel/android/**/*.h",
"execinfo/include/**/*.h",
"b64/include/**/*.h",
"NOTICE",
":libc_musl_sysroot_bionic_arch_headers",
],
out: ["libc_musl_sysroot_bionic_headers.zip"],
tools: [
"soong_zip",
"merge_zips",
"zip2zip",
],
cmd: "BIONIC_LIBC_DIR=$$(dirname $(location NOTICE)) && " +
"$(location soong_zip) -o $(genDir)/sysroot.zip -symlinks=false" +
// NOTICE
" -j -f $(location NOTICE) " +
// headers
" -P include " +
" -C $${BIONIC_LIBC_DIR}/kernel/uapi " +
" -D $${BIONIC_LIBC_DIR}/kernel/uapi " +
" -C $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
" -D $${BIONIC_LIBC_DIR}/kernel/android/scsi " +
" -C $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
" -D $${BIONIC_LIBC_DIR}/kernel/android/uapi " +
" -C $${BIONIC_LIBC_DIR}/execinfo/include " +
" -D $${BIONIC_LIBC_DIR}/execinfo/include " +
" -C $${BIONIC_LIBC_DIR}/b64/include " +
" -D $${BIONIC_LIBC_DIR}/b64/include " +
" && " +
"$(location zip2zip) -i $(genDir)/sysroot.zip -o $(genDir)/sysroot-renamed.zip " +
" -x **/BUILD " +
" include/**/*:include/ " +
" NOTICE:NOTICE.bionic " +
" && " +
"$(location merge_zips) $(out) $(location :libc_musl_sysroot_bionic_arch_headers) $(genDir)/sysroot-renamed.zip",
}
// The architecture-specific bits have to be handled separately because the label varies based
// on architecture, which prevents using $(locations) to find them and requires using $(in)
// instead, which would mix in all the other files if this were part of the main libc_musl_sysroot
// genrule.
cc_genrule {
name: "libc_musl_sysroot_bionic_arch_headers",
visibility: ["//visibility:private"],
host_supported: true,
device_supported: false,
enabled: false,
target: {
musl: {
enabled: true,
},
},
arch: {
arm: {
srcs: ["kernel/uapi/asm-arm/**/*.h"],
},
arm64: {
srcs: ["kernel/uapi/asm-arm64/**/*.h"],
},
x86: {
srcs: ["kernel/uapi/asm-x86/**/*.h"],
},
x86_64: {
srcs: ["kernel/uapi/asm-x86/**/*.h"],
},
},
out: ["libc_musl_sysroot_bionic_arch_headers.zip"],
tools: ["soong_zip"],
cmd: "includes=($(in)) && $(location soong_zip) -o $(out) -P include/asm -j -D $$(dirname $${includes[0]})",
}
cc_genrule {
name: "bionic_sysroot_crt_objects",
visibility: ["//visibility:private"],
out: ["bionic_sysroot_crt_objects.zip"],
tools: ["soong_zip"],
srcs: [
":crtbegin_dynamic",
":crtbegin_so",
":crtbegin_static",
":crtend_android",
":crtend_so",
],
cmd: "$(location soong_zip) -o $(out) -j " +
"-f $(location :crtbegin_dynamic) " +
"-f $(location :crtbegin_so) " +
"-f $(location :crtbegin_static) " +
"-f $(location :crtend_android) " +
"-f $(location :crtend_so)",
dist: {
targets: ["bionic_sysroot_crt_objects"],
},
arch: {
arm: {
dist: {
suffix: "_arm",
},
},
arm64: {
dist: {
suffix: "_arm64",
},
},
riscv64: {
dist: {
suffix: "_riscv64",
},
},
x86: {
dist: {
suffix: "_x86",
},
},
x86_64: {
dist: {
suffix: "_x86_64",
},
},
},
}
// headers that will be placed on the include path when running versioner in bazel
// this module should be a no-op in soong
filegroup {
name: "versioner-dependencies",
srcs: ["versioner-dependencies/**/*"],
}