// https://ci.android.com/builds/latest/branches/aosp-build-tools/targets/linux/view/soong_build.html cc_defaults { name: "llvmlibc_defaults", defaults: [ // b/379681564: Bionic's dependencies all must support linux-bionic, // which is not an enabled target by default. "linux_bionic_supported", ], cppflags: [ // Necessary to build. "-DLIBC_NAMESPACE=llvmlibc", ], arch: { // TODO: https://github.com/llvm/llvm-project/issues/93738 // llvm-libc does not (yet) support --target=armv7a-linux -mthumb // Build in ARM mode, but perhaps revisit this in the future. arm: { instruction_set: "arm", }, }, } cc_library_static { name: "llvmlibc", defaults: ["llvmlibc_defaults"], visibility: [ "//bionic/libc", ], include_dirs: [ "external/llvm-libc", ], srcs: [ "src/stdlib/bsearch.cpp", "src/string/memrchr.cpp", "src/string/strlcat.cpp", "src/string/strlcpy.cpp", ], cppflags: [ // Necessary for non-namespaced exports. "-DLIBC_COPT_PUBLIC_PACKAGING", // TODO: remove when https://github.com/llvm/llvm-project/pull/116686 is // integrated. "-DLLVM_LIBC_FUNCTION_ATTR=__attribute__((visibility(\"default\")))", ], // No C++ runtime. stl: "none", // No crt_begin and crt_end. nocrt: true, // Needs to be unset from the default value in order to avoid creating a // cyclic dependency between llvm-libc and bionic's libc. system_shared_libs: [], // Bionic's libc's dependencies must have these set, or the build will fail // due to missing a "ramdisk", "vendor_ramdisk", and "recovery" variants. native_bridge_supported: true, ramdisk_available: true, recovery_available: true, vendor_ramdisk_available: true, // Bionic's dependencies must also set this. apex_available: ["com.android.runtime"], // When llvm-libc includes , use bionic's headers for these. header_libs: ["libc_headers"], // TODO(b/378117947): push these into non-arch-specific `srcs` as llvm-libc // functions are rolled out. arch: { arm64: { // These have optimized baseline and vectorized impls from // arm-optimized-routines, and aren't yet heavily optimized by // llvm-libc. exclude_srcs: [ "src/string/memrchr.cpp", ], }, x86_64: { srcs: [ "src/string/memchr.cpp", "src/string/strchr.cpp", "src/string/strchrnul.cpp", "src/string/strnlen.cpp", "src/string/strrchr.cpp", ], }, }, } cc_test_library { name: "llvmlibc_test_harness", defaults: ["llvmlibc_defaults"], srcs: [ "test/UnitTest/LibcTest.cpp", "test/UnitTest/TestLogger.cpp", "test/UnitTest/LibcTestMain.cpp", ], } cc_defaults { name: "llvmlibc_test_defaults", defaults: ["llvmlibc_defaults"], static_libs: [ "llvmlibc", "llvmlibc_test_harness", ], // Do not try to link against gtest. llvm-libc has its own pseudo-gtest // framework. gtest: false, // Needed to avoid the diagnostic: // WARNING: Please add {test name} to either suite: // ['device-tests', 'general-tests'] for this TEST_MAPPING file to work // with TreeHugger. test_suites: ["device-tests"], } cc_test { // TODO: rename test to simply llvmlibc_tests. Needs to go through a post // submit cycle before can be renamed for presubmit. name: "llvmlibc_stdlib_bsearch_test", defaults: ["llvmlibc_test_defaults"], srcs: [ "test/src/stdlib/bsearch_test.cpp", "test/src/string/memrchr_test.cpp", "test/src/string/strlcat_test.cpp", "test/src/string/strlcpy_test.cpp", ], arch: { arm64: { // Match exclusions in ':llvmlibc' for arm64. exclude_srcs: [ "test/src/string/memrchr_test.cpp", ], }, x86_64: { // TODO(b/378117947): push these into non-arch-specific `srcs` as // llvm-libc functions are rolled out. srcs: [ "test/src/string/memchr_test.cpp", "test/src/string/strchr_test.cpp", "test/src/string/strchrnul_test.cpp", "test/src/string/strnlen_test.cpp", "test/src/string/strrchr_test.cpp", ], }, }, }