[PATCH] D64427: LLVM Test-Suite: Support Cross-Compilation and Cross-execution targeting arm64-linux-android

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 12:37:22 PDT 2019


pcc added a comment.

FWIW, I did something similar: https://github.com/pcc/llvm-test-suite/tree/android
but never got time to clean it up and send it for review.

Here are a few differences between your changes and mine:

- I statically linked libc++ (avoids needing to mess around with LD_LIBRARY_PATH and pushing libc++_shared.so).
- I fixed all of the tests that fail to compile/link on Android instead of disabling them. That should probably be easy to send out as a separate review, so I'll try to do that soon.
- I wrote cmake cache files for Android instead of using a shell script.



================
Comment at: cmake/caches/target-arm64-android-template.sh:6
+# REQUIRED: path to the test-suite source file
+TEST_SUITE_LOCATION="/data/local/tmp/devspace/test-suite"
+# REQUIRED: path to android ndk that contains necessary header files and libraries
----------------
danalbert wrote:
> ziangwan wrote:
> > fhahn wrote:
> > > This setting and the ones below seems very system/setup specific, and related to general test-suite setup, not android related.
> > Exactly, there is a requirement on host system setup for llvm-test-suite to correctly execute:
> > > Special Requirement for build directory: Due to the current state of the build system, the tests are generated using the absolute path on the host machine. For example, if you build the test-suite at /aa/bb/cc on the host machine, all the build files should also be stored at /aa/bb/cc on the target android device for the tests to correctly execute. Therefore, we need to create a build directory, whose absolute path is also a writable location on the target Android device, on the host machine. For example, if you want the tests to run on /data/local/tmp/build on the Android device, you should build the test-suite inside /data/local/tmp/build as well. You specifically cannot use arbitrary path on the host machine since Android's SeLinux prevents creating directories at sysroot.
> Probably worth a comment referencing whatever doc you're quoting.
I addressed this in my implementation by basically search-and-replacing any commands sent to the device to change host-side paths into device-side paths (which is basically `/data/local/tmp/llvm-test-suite/staging` plus the source-relative path).


================
Comment at: cmake/caches/target-arm64-android-template.sh:32
+-D BIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD \
+-L $ANDROID_NDK_LOCATION/toolchains/llvm/prebuilt/$HOST_SYSTEM/lib/gcc/aarch64-linux-android/4.9.x/"
+
----------------
danalbert wrote:
> This is needed because the compiler being used isn't the NDK toolchain, right? It's just the bare compiler without the sysroot and all that? If so, you *might* be able to use `-gcc-toolchain $ANDROID_NDK_LOCATION/toolchains/llvm/prebuilt/$HOST_SYSTEM` instead of specifying the internal location of libgcc. (If not, fixing the driver to make that work would probably be good)
What I usually do is: `-B${ANDROID_NDK_PATH}/toolchains/llvm/prebuilt/linux-x86_64`.

Would it be worth considering moving libgcc.a into the sysroot in a future release of the NDK? Then I believe only `--sysroot` should be required.


Repository:
  rT test-suite

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64427/new/

https://reviews.llvm.org/D64427





More information about the llvm-commits mailing list