• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/memchr.cpp",
36        "src/string/memrchr.cpp",
37        "src/string/strchr.cpp",
38        "src/string/strchrnul.cpp",
39        "src/string/strlcat.cpp",
40        "src/string/strlcpy.cpp",
41        "src/string/strnlen.cpp",
42        "src/string/strrchr.cpp",
43    ],
44    cppflags: [
45        // Necessary for non-namespaced exports.
46        "-DLIBC_COPT_PUBLIC_PACKAGING",
47        // TODO: remove when https://github.com/llvm/llvm-project/pull/116686 is
48        // integrated.
49        "-DLLVM_LIBC_FUNCTION_ATTR=__attribute__((visibility(\"default\")))",
50    ],
51    // No C++ runtime.
52    stl: "none",
53    // No crt_begin and crt_end.
54    nocrt: true,
55    // Needs to be unset from the default value in order to avoid creating a
56    // cyclic dependency between llvm-libc and bionic's libc.
57    system_shared_libs: [],
58
59    // Bionic's libc's dependencies must have these set, or the build will fail
60    // due to missing a "ramdisk", "vendor_ramdisk", and "recovery" variants.
61    native_bridge_supported: true,
62    ramdisk_available: true,
63    recovery_available: true,
64    vendor_ramdisk_available: true,
65
66    // Bionic's dependencies must also set this.
67    apex_available: ["com.android.runtime"],
68
69    // When llvm-libc includes <stdlib.h>, use bionic's headers for these.
70    header_libs: ["libc_headers"],
71
72    // TODO(b/378117947): push these into non-arch-specific `srcs` as llvm-libc
73    // functions are rolled out.
74    arch: {
75        arm64: {
76            // These have optimized baseline and vectorized impls from
77            // arm-optimized-routines, and aren't yet heavily optimized by
78            // llvm-libc.
79            exclude_srcs: [
80                "src/string/memchr.cpp",
81                "src/string/memrchr.cpp",
82                "src/string/strchr.cpp",
83                "src/string/strchrnul.cpp",
84                "src/string/strnlen.cpp",
85                "src/string/strrchr.cpp",
86            ],
87        },
88        riscv64: {
89            // These have hand-vectorized impls in Bionic, and aren't yet
90            // heavily optimized by llvm-libc.
91            exclude_srcs: [
92                "src/string/memchr.cpp",
93                "src/string/strchr.cpp",
94                "src/string/strnlen.cpp",
95            ],
96        },
97    },
98}
99
100cc_test_library {
101    name: "llvmlibc_test_harness",
102    defaults: ["llvmlibc_defaults"],
103    srcs: [
104        "test/UnitTest/LibcTest.cpp",
105        "test/UnitTest/TestLogger.cpp",
106        "test/UnitTest/LibcTestMain.cpp",
107    ],
108}
109
110cc_defaults {
111    name: "llvmlibc_test_defaults",
112    defaults: ["llvmlibc_defaults"],
113    static_libs: [
114        "llvmlibc",
115        "llvmlibc_test_harness",
116    ],
117    // Do not try to link against gtest. llvm-libc has its own pseudo-gtest
118    // framework.
119    gtest: false,
120    // Needed to avoid the diagnostic:
121    // WARNING: Please add {test name} to either suite:
122    // ['device-tests', 'general-tests'] for this TEST_MAPPING file to work
123    // with TreeHugger.
124    test_suites: ["device-tests"],
125}
126
127cc_test {
128    name: "llvmlibc_tests",
129    defaults: ["llvmlibc_test_defaults"],
130    srcs: [
131        "test/src/stdlib/bsearch_test.cpp",
132        "test/src/string/memchr_test.cpp",
133        "test/src/string/memrchr_test.cpp",
134        "test/src/string/strchr_test.cpp",
135        "test/src/string/strchrnul_test.cpp",
136        "test/src/string/strlcat_test.cpp",
137        "test/src/string/strlcpy_test.cpp",
138        "test/src/string/strnlen_test.cpp",
139        "test/src/string/strrchr_test.cpp",
140    ],
141    arch: {
142        arm64: {
143            // Match exclusions in ':llvmlibc' for arm64.
144            exclude_srcs: [
145                "test/src/string/memchr_test.cpp",
146                "test/src/string/memrchr_test.cpp",
147                "test/src/string/strchr_test.cpp",
148                "test/src/string/strchrnul_test.cpp",
149                "test/src/string/strnlen_test.cpp",
150                "test/src/string/strrchr_test.cpp",
151            ],
152        },
153        riscv64: {
154            // Match exclusions in ':llvmlibc' for riscv64.
155            exclude_srcs: [
156                "test/src/string/memchr_test.cpp",
157                "test/src/string/strchr_test.cpp",
158                "test/src/string/strnlen_test.cpp",
159            ],
160        },
161    },
162}
163