Crosscompiling with Clang is cumbersome
Hello,
there are several drawbacks when compiling with clang using a secondary toolchain like gcc. There is an issue with having a separate Toolchain path, the clang/llvm path contains the compiler and several tools, while atleast the linker (via gcc) should be from the secondary path.
A naive toolchain fail will result in AR missing, see the attached project (a link to a crosscompiler is attached below). See the toolchain file that is necessary to set all the variables and whether they should be picked from primary or secondary toolchain. Also the llvm tools should be searched with and without the ${_CMAKE_TOOLCHAIN_PREFIX}.
For Cmake 3.9 the new COMPILER_RANLIB and COMPILER_AR variables have a similar issue and I attached a patch. LTO still does not work in this configuration.
There are alot of issues (see adding all those include paths, and clangs option "--gcc-toolchain" being pretty much useless), but IMHO CMake should atleast deal with finding the correct programs.
crosscompile_clang.tar.xz ARM Crosscompiler findclangbinutils.patch