This patch allows users to cross-compile and cross-execute LLVM test-suite on an Android device for testing and benchmark purposes.
Usage:
- Obtain llvm-test-suite and Android NDK for your host machine. The test-suite also supports SPEC CPU2006 benchmark. (SPEC CPU2017 requires too much system memory and is not suitable for an actual android device.)
- Get the build template inside cmake/caches/target-arm64-android-template.sh and create your own build script build.sh. Put build.sh inside the build directory you desire.
- Run sh build.sh to setup the build. Then do ninja to build.
- Run ninja push_android to push the tests onto an Android device, whose serial number is specified inside build.sh.
- Run llvm-lit -j1 -o result.json ./build to cross-execute.
Notes
- I manually exclude several tests and benchmarks for Android build by checking against TEST_SUITE_REMOTE_CLIENT STREQUAL "adb" in corresponding CMakeLists.txt files. All of them are excluded due to build failures. A list of excluded tests and benchmarks with concise build failure messages:
- test-suite/External/SPEC/CINT2006/CMakeLists.txt:
- Exclude cpu2006_subdir(400.perlbench)
- incomplete definition of type 'struct __sFILE'
- Many other errors
- Exclude cpu2006_subdir(464.h264ref)
- sys/timeb.h not found <- this header file is deprecated and no longer exists inside Android NDK.
- Exclude cpu2006_subdir(483.xalancbmk)
- undefined reference to `xercesc_2_5::XMLPlatformUtils::openFile(unsigned short const*, xercesc_2_5::MemoryManager*)'
- Many other errors
- Exclude cpu2006_subdir(400.perlbench)
- test-suite/External/SPEC/CINT2006/462.libquantum/CMakeLists.txt
- Use diff -w instead of diff --strip-trailing-cr
- --strip-trailing-cr is not supported in Android's diff
- Use diff -w instead of diff --strip-trailing-cr
- test-suite/External/SPEC/CFP2006/CMakeLists.txt
- Exclude cpu2006_subdir(446.dealII)
- error: no template named 'pair' in namespace 'std'
- Exclude cpu2006_subdir(446.dealII)
- test-suite/Multisource/Applications/CMakeLists.txt
- Exclude add_subdirectory(JM)
- Exclude add_subdirectory(hexxagon)
- Exclude out add_subdirectory(SPASS)
- sys/timeb.h not found
- Exclude add_subdirectory(ClamAV)
- undefined reference to `endprotoent'
- Exclude add_subdirectory(siod)
- undefined reference to `getpwent'
- Exclude add_subdirectory(Burg)
- error: conflicting types for 'atoi'
- Exclude add_subdirectory(spiff)
- parse.c:85: undefined reference to `index'
- test-suite/Multisource/Benchmarks/MiBench/CMakeLists.txt
- Exclude add_subdirectory(network-patricia)
- undefined reference to `bcopy'
- Exclude add_subdirectory(office-ispell)
- fatal error: 'sgtty.h' file not found
- Exclude add_subdirectory(network-patricia)
- test-suite/Multisource/Benchmarks/Prolangs-C/CMakeLists.txt
- Exclude add_subdirectory(bison)
- conflicts.c:266: undefined reference to `bcopy'
- Exclude add_subdirectory(bison)
- test-suite/Multisource/Benchmarks/DOE-ProxyApps-C++/CMakeLists.txt
- Exclude add_subdirectory(CLAMR)
- fatal error: 'sys/sysctl.h' file not found
- Exclude add_subdirectory(CLAMR)
- test-suite/Multisource/Benchmarks/CMakeLists.txt
- Exclude add_subdirectory(7zip)
- 7zip/CPP/7zip/UI/Console/UserInputUtils.cpp:81:25: error: use of undeclared identifier 'getpass'
- Many other errors
- Exclude add_subdirectory(7zip)
- test-suite/SingleSource/UnitTests/
- Exclude 2005-05-11-Popcount-ffs-fls.c
- 110: undefined reference to `ffsl'
- Exclude 2005-05-11-Popcount-ffs-fls.c
- test-suite/Microbenchmarks
- Exclude the whole folder because of unsupported test-format when cross-exec
- An issue on the llvm-lit side
- Exclude the whole folder because of unsupported test-format when cross-exec
- test-suite/MultiSource/Benchmarks/Prolangs-C/CMakeLists.txt
- Exclude add_subdirectory(unix-small)
- can't create /tmp/rmJKvjCz.
- Exclude add_subdirectory(unix-small)
- test-suite/MultiSource/Applications/CMakeLists.txt
- Exclude out add_subdirectory(obsequi)
- Unable to find library -lsupc++
- Exclude out add_subdirectory(obsequi)
- test-suite/External/SPEC/CINT2006/CMakeLists.txt:
- Initially, I just want to use the test-suite to benchmark a compiler feature. Therefore, I only care about the benchmarks in the test-suite.
The patch works locally for me. If you have any suggestions / comments / encounter bugs when targeting Android, please let me know.
Got a link to a bug? CMAKE_SYSTEM_NAME should be Android for Android.