I am new to CLANG/LLVM and wish to use it to cross compile an application for an arm target. I was able to get this to work for a small test application, but only after I pointed clang at the gcc toolchain source I was formerly using by providing --sysroot and -I arguments - otherwise, I was getting undefined header file errors.
It seems a bit odd that given CLANG is intended to be a gcc replacement, I still need to provide a gcc toolchain for it to work. Am I doing this right?
It is likely that you are doing it right, although you might be able
to use the --gcc-toolchain option to point clang at your gcc
toolchain. This should prevent you having to add -I arguments although
my experience has been that you often need --sysroot as well. Without
-gcc-toolchain clang will follow some heuristics to find a
cross-compilation toolchain that may or may not work depending on
where you have gcc installed.
There is some information available on
https://llvm.org/docs/HowToCrossCompileBuiltinsOnArm.html that you
might find helpful.
Hope this is of some use
You don't need to provide a gcc toolchain. You need to provide a linker,
potentially an assembler and a target environment though. The target
environment can be a snapshot of the real system, i.e. just a copy of
/lib and /usr.