I would like to cross-compile C-family languages (C, C++, Objective-C, and Objective-C++) to the Raspberry Pi using Clang and LLVM on a build computer of a different architecture. How may I do this?
Just completed my article, Cross compilation for Raspberry from Sierra, about exactly this thing. Under Mac OS Sierra though. But for clang it matters a little.
In this article I have shared experience (which costed me some days of suffering). Hope it will be useful. In short, all you have to do is to specify rootfs and target triple:
path/to/clang --target=arm-linux-gnueabihf --sysroot=/some/path/arm-linux-gnueabihf/sysroot my-happy-program.c -fuse-ld=lld
-fuse-ld=lld option, because otherwise clang will try to lookup legacy binutils.
There also seems to be this post over at SO, which might be helpful (haven't fully read thru it yet).