This adds cross-compilation support for the cmake+lit-based way to build and run the test-suite, by letting users specify a cmake toolchain file if they want to cross-compile.
The advantage of doing so over other ways to enable cross-compiling is:
- It is in line with the recommended cmake way to cross-compile a project: using a toolchain file.
- Fewer command line options need to be given to lnt runtest test-suite.
Regression tests and documentation still needs to be written for this, but I first wanted to get feedback on this approach before spending more time on it.
FWIW, an actual lnt runtest test-suite invoke command that I use to cross-compile and cross-test the test-suite on for an aarch64-target is:
lnt runtest test-suite \ --test-suite ~/dev/llvm.org/test-suite -j40 \ --cppflags="-O3" \ --run-under=$HOME/dev/aarch64-emu/aarch64-qemu.sh \ --use-lit ~/dev/llvm.org/build/bin/llvm-lit \ --cross-compiling-toolchain-file=$HOME/dev/llvm.org/clang_aarch64_linux.cmake
With the content of clang_aarch64_linux.cmake being:
set(CMAKE_SYSTEM_NAME Linux ) set(triple aarch64-linux-gnu ) set(CMAKE_C_COMPILER /home/kribey01/dev/llvm.org/build/bin/clang ) set(CMAKE_C_COMPILER_TARGET ${triple} ) set(CMAKE_CXX_COMPILER /home/kribey01/dev/llvm.org/build/bin/clang++ ) set(CMAKE_CXX_COMPILER_TARGET ${triple} ) set(CMAKE_SYSROOT /home/kribey01/dev/aarch64-emu/sysroot-glibc-linaro-2.23-2016.11-aarch64-linux-gnu ) set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN /home/kribey01/dev/aarch64-emu/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu) set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN /home/kribey01/dev/aarch64-emu/gcc-linaro-6.2.1-2016.11-x86_64_aarch64-linux-gnu)
I intend to put the above details in the documentation, if we decide this is the right approach to take.
What do you think?
This probably should pick up opts.cmake, not the cmake which happens to be on the path.