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