[cfe-dev] Cross compiling with clang

Renato Golin renato.golin at linaro.org
Tue May 12 02:19:04 PDT 2015

On 12 May 2015 at 09:55, Guilherme <guibufolo+llvm at gmail.com> wrote:
> But what I could not find is a list, link or reference to where get a
> version of clang for windows which is able to cross-compile to ARM.

Hi Guilherme,

Clang+LLVM is a native cross-compiler. If the appropriate back-end is
bundled, it will produce that target's assembly or, if integrated
assembler is supported, object files. But it will not generate
executables, since we don't distribute (yet) a cross-linker, nor all
targets' libraries. You'll need to source that elsewhere.

> D:\Playground\xcompile-arm>c:\llvm\bin\clang.exe -target
> armv7-unknown-none-elf main.c
> clang.exe: warning: unknown platform, assuming -mfloat-abi=soft
> clang.exe: warning: unknown platform, assuming -mfloat-abi=soft

It seems that your binary doesn't have the ARM back-end compiled with
it. I believe we should be a lot better in specifying this, as this
error message is very misleading.

It also seems that the PowerPC back-end was not compiled with your
binary, so you'll need to either find someone that has compiled a
Windows binary that can cross-compile to PPC, or do it yourself.

By default, a standard build of LLVM builds *all* back-ends, so if you
just follow the website's "getting started" guide, you'll get all you
need in the compiler side.

But you'll still need a PPC linker, and probably some PPC static
libraries for bare-metal.

> For the sys part of the triple, if i'm doing bare metal development, should
> i use None? What exactly does the sys part change when compiling code?

In ARM, "none-eabi" specifies bare-metal, I don't know in PPC. Triples
have a lot of target specific idiosyncrasies, and that's older than
LLVM, so we're just following the legacy. :)


More information about the cfe-dev mailing list