Building Cross Compiler

I am using the following CMake command to (hopefully) build a cross compiler.

cmake -DLLVM_TARGET_ARCH=ARM -DLLVM_TARGETS_TO_BUILD=ARM -DLLVM_DEFAULT_TARGET_TRIPLE=armv7a-none-eabi -DCMAKE_CROSSCOMPILING=True …\llvm

In the CMake output I see

– Target triple: i686-pc-win32
– Native target architecture is ARM

Which confused me. I spent two days (5 minutes here and there) trying to get the triple right before I gave up. I compiled the VS2013 solution that was generated and then ran clang --version and got the following output

PS D:\llvm\build> clang --version
clang version 3.7.0 (trunk 226193)
Target: armv7a-none–eabi
Thread model: posix

It seems that the CMake script outputs the wrong triple, but clang outputs the correct triple (with an extra ‘-’). Am I missing something or is this a bug in the build script?

It seems that the CMake script outputs the wrong triple, but clang outputs
the correct triple (with an extra '-'). Am I missing something or is this a
bug in the build script?

I think I've encountered things like this from before; what CMake
(always) calls the "target triple" is what autotools would call the
host triple, as I recall. Quite a few places in LLVM's build system
has terminology inherited from autotools, so it can get a bit
confusing.

-DCMAKE_CROSSCOMPILING=True

You probably don't want this either. That's almost certainly an option
for when you'd be *using* your cross-compiler.

Cheers.

Tim.

By default ,Clang is full-Target compiler ,it’s size 30MB+, default target like i686-pc-win32.
and Your can use:
clang --target=armv7a-none-eabi
or
clang -target armv7a-none-eabi
Android NDK .ToolChain clang default target is x86.

I have done that with the --target flag, but I am attempting to use the clang I am compiling to build compiler-rt. I can’t figure out how to get compiler-rt’s build system to attempt to compile for anything except i386, so I am going to try to build an ARM cross compiler to see if that will build compiler-rt for ARM.