xref: /aosp_15_r20/external/cronet/third_party/libc++/src/test/configs/llvm-libc++-android-ndk.cfg.in (revision 6777b5387eb2ff775bb5750e3f5d96f37fb7352b)
1# This testing configuration handles running the test suite against LLVM's
2# libc++ using adb and a libc++_shared.so library on Android.
3
4lit_config.load_config(config, '@CMAKE_CURRENT_BINARY_DIR@/cmake-bridge.cfg')
5
6import re
7import site
8
9site.addsitedir(os.path.join('@LIBCXX_SOURCE_DIR@', 'utils'))
10
11import libcxx.test.android
12import libcxx.test.config
13import libcxx.test.params
14
15config.substitutions.append(('%{flags}',
16    '--sysroot @CMAKE_SYSROOT@' if '@CMAKE_SYSROOT@' else ''
17))
18
19compile_flags = '-nostdinc++ -I %{include-dir} -I %{target-include-dir} -I %{libcxx-dir}/test/support'
20if re.match(r'i686-linux-android(21|22|23)$', config.target_triple):
21    # 32-bit x86 Android has a bug where the stack is sometimes misaligned.
22    # The problem appears limited to versions before Android N (API 24) and only
23    # __attribute__((constructor)) functions. Compile with -mstackrealign to
24    # work around the bug.
25    # TODO: Consider automatically doing something like this in Clang itself (LIBCXX-ANDROID-FIXME)
26    # See https://github.com/android/ndk/issues/693.
27    compile_flags += ' -mstackrealign'
28config.substitutions.append(('%{compile_flags}', compile_flags))
29
30# The NDK library is called "libc++_shared.so". Use LD_LIBRARY_PATH to find
31# libc++_shared.so because older Bionic dynamic loaders don't support rpath
32# lookup.
33config.substitutions.append(('%{link_flags}',
34    '-nostdlib++ -L %{lib-dir} -lc++_shared'
35))
36config.substitutions.append(('%{exec}',
37    '%{executor}' +
38    ' --job-limit-socket ' + libcxx.test.android.adb_job_limit_socket() +
39    ' --prepend-path-env LD_LIBRARY_PATH /data/local/tmp/libc++ --execdir %T -- '
40))
41
42libcxx.test.config.configure(
43    libcxx.test.params.DEFAULT_PARAMETERS,
44    libcxx.test.features.DEFAULT_FEATURES,
45    config,
46    lit_config
47)
48