1// https://ci.android.com/builds/latest/branches/aosp-build-tools/targets/linux/view/soong_build.html 2 3cc_defaults { 4 name: "llvmlibc_defaults", 5 defaults: [ 6 // b/379681564: Bionic's dependencies all must support linux-bionic, 7 // which is not an enabled target by default. 8 "linux_bionic_supported", 9 ], 10 cppflags: [ 11 // Necessary to build. 12 "-DLIBC_NAMESPACE=llvmlibc", 13 ], 14 arch: { 15 // TODO: https://github.com/llvm/llvm-project/issues/93738 16 // llvm-libc does not (yet) support --target=armv7a-linux -mthumb 17 // Build in ARM mode, but perhaps revisit this in the future. 18 arm: { 19 instruction_set: "arm", 20 }, 21 }, 22} 23 24cc_library_static { 25 name: "llvmlibc", 26 defaults: ["llvmlibc_defaults"], 27 visibility: [ 28 "//bionic/libc", 29 ], 30 include_dirs: [ 31 "external/llvm-libc", 32 ], 33 srcs: [ 34 "src/stdlib/bsearch.cpp", 35 "src/string/memrchr.cpp", 36 "src/string/strlcat.cpp", 37 "src/string/strlcpy.cpp", 38 ], 39 cppflags: [ 40 // Necessary for non-namespaced exports. 41 "-DLIBC_COPT_PUBLIC_PACKAGING", 42 // TODO: remove when https://github.com/llvm/llvm-project/pull/116686 is 43 // integrated. 44 "-DLLVM_LIBC_FUNCTION_ATTR=__attribute__((visibility(\"default\")))", 45 ], 46 // No C++ runtime. 47 stl: "none", 48 // No crt_begin and crt_end. 49 nocrt: true, 50 // Needs to be unset from the default value in order to avoid creating a 51 // cyclic dependency between llvm-libc and bionic's libc. 52 system_shared_libs: [], 53 54 // Bionic's libc's dependencies must have these set, or the build will fail 55 // due to missing a "ramdisk", "vendor_ramdisk", and "recovery" variants. 56 native_bridge_supported: true, 57 ramdisk_available: true, 58 recovery_available: true, 59 vendor_ramdisk_available: true, 60 61 // Bionic's dependencies must also set this. 62 apex_available: ["com.android.runtime"], 63 64 // When llvm-libc includes <stdlib.h>, use bionic's headers for these. 65 header_libs: ["libc_headers"], 66 67 // TODO(b/378117947): push these into non-arch-specific `srcs` as llvm-libc 68 // functions are rolled out. 69 arch: { 70 arm64: { 71 // These have optimized baseline and vectorized impls from 72 // arm-optimized-routines, and aren't yet heavily optimized by 73 // llvm-libc. 74 exclude_srcs: [ 75 "src/string/memrchr.cpp", 76 ], 77 }, 78 x86_64: { 79 srcs: [ 80 "src/string/memchr.cpp", 81 "src/string/strchr.cpp", 82 "src/string/strchrnul.cpp", 83 "src/string/strnlen.cpp", 84 "src/string/strrchr.cpp", 85 ], 86 }, 87 }, 88} 89 90cc_test_library { 91 name: "llvmlibc_test_harness", 92 defaults: ["llvmlibc_defaults"], 93 srcs: [ 94 "test/UnitTest/LibcTest.cpp", 95 "test/UnitTest/TestLogger.cpp", 96 "test/UnitTest/LibcTestMain.cpp", 97 ], 98} 99 100cc_defaults { 101 name: "llvmlibc_test_defaults", 102 defaults: ["llvmlibc_defaults"], 103 static_libs: [ 104 "llvmlibc", 105 "llvmlibc_test_harness", 106 ], 107 // Do not try to link against gtest. llvm-libc has its own pseudo-gtest 108 // framework. 109 gtest: false, 110 // Needed to avoid the diagnostic: 111 // WARNING: Please add {test name} to either suite: 112 // ['device-tests', 'general-tests'] for this TEST_MAPPING file to work 113 // with TreeHugger. 114 test_suites: ["device-tests"], 115} 116 117cc_test { 118 // TODO: rename test to simply llvmlibc_tests. Needs to go through a post 119 // submit cycle before can be renamed for presubmit. 120 name: "llvmlibc_stdlib_bsearch_test", 121 defaults: ["llvmlibc_test_defaults"], 122 srcs: [ 123 "test/src/stdlib/bsearch_test.cpp", 124 "test/src/string/memrchr_test.cpp", 125 "test/src/string/strlcat_test.cpp", 126 "test/src/string/strlcpy_test.cpp", 127 ], 128 arch: { 129 arm64: { 130 // Match exclusions in ':llvmlibc' for arm64. 131 exclude_srcs: [ 132 "test/src/string/memrchr_test.cpp", 133 ], 134 }, 135 x86_64: { 136 // TODO(b/378117947): push these into non-arch-specific `srcs` as 137 // llvm-libc functions are rolled out. 138 srcs: [ 139 "test/src/string/memchr_test.cpp", 140 "test/src/string/strchr_test.cpp", 141 "test/src/string/strchrnul_test.cpp", 142 "test/src/string/strnlen_test.cpp", 143 "test/src/string/strrchr_test.cpp", 144 ], 145 }, 146 }, 147} 148