xref: /aosp_15_r20/external/arm-optimized-routines/Android.bp (revision 412f47f9e737e10ed5cc46ec6a8d7fa2264f8a14)
1package {
2    default_applicable_licenses: ["external_arm-optimized-routines_license"],
3}
4
5// Added automatically by a large-scale-change
6// See: http://go/android-license-faq
7license {
8    name: "external_arm-optimized-routines_license",
9    visibility: [":__subpackages__"],
10    license_kinds: [
11        "SPDX-license-identifier-MIT",
12    ],
13    license_text: [
14        "LICENSE",
15    ],
16}
17
18cc_defaults {
19    name: "arm-optimized-routines-defaults",
20    host_supported: true,
21    cflags: [
22        "-Werror",
23        "-Wno-unused-parameter",
24        "-O2",
25        "-ffp-contract=fast",
26        "-fno-math-errno",
27
28        // bionic configuration.
29
30        // We're actually implementing bionic here, so we don't want <math.h>
31        // to try to be helpful by renaming long double routines.
32        "-D__BIONIC_LP32_USE_LONG_DOUBLE",
33        "-DFLT_EVAL_METHOD=0",
34
35        // arm-optimized-routines configuration.
36
37        // BSD libm doesn't set errno, and bionic was based on the BSDs.
38        // https://github.com/ARM-software/optimized-routines/issues/16#issuecomment-572009659
39        "-DWANT_ERRNO=0",
40        // TODO: we may want the vector code in future, but it's not ready yet.
41        "-DWANT_VMATH=0",
42        // Disable tests for routines that are not available.
43        "-DWANT_SIMD_TESTS=0",
44        "-DWANT_EXP10_TESTS=0",
45        // Enable MOPS.
46        "-DWANT_MOPS=1",
47    ],
48    local_include_dirs: ["math/include"],
49    arch: {
50        arm64: {
51            oryon: {
52                cflags: [
53                    "-Xclang -target-feature",
54                    "-Xclang +ldp-aligned-only",
55                ],
56            },
57        },
58    },
59}
60
61cc_defaults {
62    name: "libarm-optimized-routines-defaults",
63    defaults: ["arm-optimized-routines-defaults"],
64    ramdisk_available: true,
65    vendor_ramdisk_available: true,
66    recovery_available: true,
67    native_bridge_supported: true,
68    apex_available: [
69        "//apex_available:platform",
70        "com.android.runtime",
71    ],
72
73    stl: "none",
74    target: {
75        bionic: {
76            static: {
77                system_shared_libs: [],
78            },
79            header_libs: ["libc_headers"],
80        },
81    },
82}
83
84cc_library_static {
85    name: "libarm-optimized-routines-math",
86    defaults: ["libarm-optimized-routines-defaults"],
87    srcs: [
88        "math/cosf.c",
89        "math/exp.c",
90        "math/exp2.c",
91        "math/exp2f.c",
92        "math/exp2f_data.c",
93        "math/exp_data.c",
94        "math/expf.c",
95        "math/log.c",
96        "math/log2.c",
97        "math/log2_data.c",
98        "math/log2f.c",
99        "math/log2f_data.c",
100        "math/log_data.c",
101        "math/logf.c",
102        "math/logf_data.c",
103        "math/math_err.c",
104        "math/math_errf.c",
105        "math/pow.c",
106        "math/pow_log_data.c",
107        "math/powf.c",
108        "math/powf_log2_data.c",
109        "math/sincosf.c",
110        "math/sincosf_data.c",
111        "math/sinf.c",
112    ],
113
114    arch: {
115        arm64: {
116            cflags: [
117                "-DHAVE_FAST_FMA=1",
118            ],
119        },
120        riscv64: {
121            cflags: [
122                "-DHAVE_FAST_FMA=1",
123            ],
124        },
125    },
126
127    target: {
128        darwin: {
129            enabled: false,
130        },
131        linux_bionic: {
132            enabled: true,
133        },
134    },
135}
136
137cc_library_static {
138    name: "libarm-optimized-routines-string",
139    defaults: ["libarm-optimized-routines-defaults"],
140
141    arch: {
142        arm64: {
143            srcs: [
144                "string/aarch64/memchr-mte.S",
145                "string/aarch64/memchr-sve.S",
146                "string/aarch64/memchr.S",
147                "string/aarch64/memcmp-sve.S",
148                "string/aarch64/memcmp.S",
149                "string/aarch64/memcpy-advsimd.S",
150                "string/aarch64/memcpy-sve.S",
151                "string/aarch64/memcpy.S",
152                "string/aarch64/memmove-mops.S",
153                "string/aarch64/memrchr.S",
154                "string/aarch64/memset.S",
155                "string/aarch64/memset-mops.S",
156                "string/aarch64/stpcpy-sve.S",
157                "string/aarch64/stpcpy.S",
158                "string/aarch64/strchrnul-mte.S",
159                "string/aarch64/strchrnul-sve.S",
160                "string/aarch64/strchrnul.S",
161                "string/aarch64/strchr-mte.S",
162                "string/aarch64/strchr-sve.S",
163                "string/aarch64/strchr.S",
164                "string/aarch64/strcmp-sve.S",
165                "string/aarch64/strcmp.S",
166                "string/aarch64/strcpy-sve.S",
167                "string/aarch64/strcpy.S",
168                "string/aarch64/strlen-mte.S",
169                "string/aarch64/strlen-sve.S",
170                "string/aarch64/strlen.S",
171                "string/aarch64/strncmp-sve.S",
172                "string/aarch64/strncmp.S",
173                "string/aarch64/strnlen-sve.S",
174                "string/aarch64/strnlen.S",
175                "string/aarch64/strrchr-mte.S",
176                "string/aarch64/strrchr-sve.S",
177                "string/aarch64/strrchr.S",
178            ],
179            asflags: [
180                "-march=armv8-a+sve",
181            ],
182        },
183    },
184}
185
186// Memory intrinsics for bare-metal Rust binaries.
187cc_library_static {
188    name: "libarm-optimized-routines-mem",
189    nocrt: true,
190    system_shared_libs: [],
191    stl: "none",
192    sanitize: {
193        hwaddress: false,
194    },
195    arch: {
196        arm64: {
197            srcs: [
198                "string/aarch64/memchr.S",
199                "string/aarch64/memcmp.S",
200                "string/aarch64/memcpy.S",
201                "string/aarch64/memrchr.S",
202                "string/aarch64/memset.S",
203                "string/aarch64/stpcpy.S",
204                "string/aarch64/strchr.S",
205                "string/aarch64/strchrnul.S",
206                "string/aarch64/strcmp.S",
207                "string/aarch64/strcpy.S",
208                "string/aarch64/strlen.S",
209                "string/aarch64/strncmp.S",
210                "string/aarch64/strnlen.S",
211                "string/aarch64/strrchr.S",
212            ],
213            asflags: [
214                "-D__memchr_aarch64=memchr",
215                "-D__memcmp_aarch64=memcmp",
216                "-D__memcpy_aarch64=memcpy",
217                "-D__memmove_aarch64=memmove",
218                "-D__memrchr_aarch64=memrchr",
219                "-D__memset_aarch64=memset",
220                "-D__stpcpy_aarch64=stpcpy",
221                "-D__strchr_aarch64=strchr",
222                "-D__strchrnul_aarch64=strchrnul",
223                "-D__strcmp_aarch64=strcmp",
224                "-D__strcpy_aarch64=strcpy",
225                "-D__strlen_aarch64=strlen",
226                "-D__strncmp_aarch64=strncmp",
227                "-D__strnlen_aarch64=strnlen",
228                "-D__strrchr_aarch64=strrchr",
229            ],
230        },
231    },
232    visibility: ["//bionic/libc"],
233}
234
235// adb shell "/data/nativetest64/mathtest/mathtest /data/nativetest64/mathtest/test/testcases/directed/*"
236// adb shell "/data/nativetest/mathtest/mathtest /data/nativetest/mathtest/test/testcases/directed/*"
237cc_test {
238    name: "mathtest",
239    defaults: ["arm-optimized-routines-defaults"],
240    gtest: false,
241    cflags: ["-Wno-missing-braces"],
242    srcs: ["math/test/mathtest.c"],
243    data: ["math/test/testcases/directed/*.tst"],
244    target: {
245        darwin: {
246            enabled: false,
247        },
248        linux_bionic: {
249            enabled: true,
250        },
251    },
252}
253
254cc_test {
255    name: "ulp",
256    defaults: ["arm-optimized-routines-defaults"],
257    gtest: false,
258
259    // https://github.com/ARM-software/optimized-routines/issues/53
260    local_include_dirs: ["math/"],
261
262    srcs: ["math/test/ulp.c"],
263    data: ["math/test/runulp.sh"],
264}
265
266sh_test {
267    name: "arm-optimized-routines-tests",
268    src: "run-arm-optimized-routines-tests-on-android.sh",
269    filename: "run-arm-optimized-routines-tests-on-android.sh",
270    test_suites: ["general-tests"],
271    host_supported: true,
272    device_supported: false,
273    require_root: true,
274    target_required: [
275        "mathtest",
276        "ulp",
277    ],
278}
279