A Question to LLVM

Hi,
I want to use LLVM to compile a ARM-CortexM0 project on windows. But LLVM can’t output ELF file on windows. An assert was thrown from LLVM. What can I do now? Thanks!

Steven.Q

Hi Steven,

I want to use LLVM to compile a ARM-CortexM0 project on windows. But LLVM
can't output ELF file on windows. An assert was thrown from LLVM. What can
I do now? Thanks!

It sounds like you're using the wrong triple. Even on Windows you
should be able to output ELF if you compile with (say) "clang -target
arm-none-eabi".

Cheers.

Tim.

Or not using a triple at all. Windows on ARM support is coming along,
I bet it defaults to WoA and outputs COFF or whatever.

cheers,
--renato

Hi, all

Could you give an ARM example project that can be compiled to ELF file by LLVM ?

My command lines is as follows.

clang -c d:\aa.c -emit-llvm -o aa.bc
llc aa.bc -march=arm -filetype=obj -o aa.elf

the follow assert will be thrown
“ARM does not support Windows COFF format
Unreachable executed …\ARMMCTargetDesc.cpp 250!”

I am looking forward to your help.

Thanks!

Steven

Hi Steven,

As Tim said, try:

$ clang -target armv6m-none-eabi -c d:\aa.c -emit-llvm -o aa.bc

Otherwise, Clang will generate binaries to the target platform, you
your case, probably an x86_64 Windows. On its own, llc cannot
transform an IR that was emitted to x86_64 to an ARM IR, which are
reasonably different.

Once you have an ARMv6 IR, llc will create an ELF object even without
-march of -filetype parameters.

cheers,
--renato