LLVM & Clang cannot compile for a supported arc

On Ubuntu 64 bit I got

llc --version LLVM (http://llvm.org/): LLVM version 3.1 Optimized build with assertions. Built Oct 15 2012 (18:15:59). Default target: x86_64-pc-linux-gnu Host CPU: btver1 Registered Targets: arm - ARM mips - Mips mips64 - Mips64 [experimental] mips64el - Mips64el [experimental] mipsel - Mipsel thumb - Thumb x86 - 32-bit X86: Pentium-Pro and above x86-64 - 64-bit X86: EM64T and AMD64 

I can not do it

 clang -march=arm -x c++ /tmp/cpp.cpp error: unknown target CPU 'arm' 

Am I missing something? Why can't I compile ARM?

+6
source share
6 answers

As this comment says, this option is not yet supported on Linux.

+1
source

links llvm linker for a host that is only one of the targets, it does not bind to each target in the list. it will definitely compile for any purpose. Basically, clang goes from C / C ++ to bytecode, then llc takes the bytecode and builds for a specific purpose (new experimental option to take the bytecode directly to the object file), then you need to get a cross assembler and a crosslinking agent to take its final mile (I use gnu binutils). Unfortunately, I found that clang to bytecode is not completely general (I hoped and expected it to be so), it will actually change the target independent output based on the target. The example below, using the host triple instead of using -march, allowed my examples to build correctly on other hosts.

 ARMGNU?=arm-none-eabi LOPS = -Wall -m32 -emit-llvm -ccc-host-triple $(ARMGNU) OOPS = -std-compile-opts LLCOPS = -march=thumb -mtriple=$(ARMGNU) clang $(LOPS) -c blinker03.c -o blinker03.clang.bc opt $(OOPS) blinker03.clang.bc -o blinker03.clang.thumb.opt.bc llc $(LLCOPS) blinker03.clang.thumb.opt.bc -o blinker03.clang.thumb.opt.s $(ARMGNU)-as blinker03.clang.thumb.opt.s -o blinker03.clang.thumb.opt.o $(ARMGNU)-ld -o blinker03.clang.thumb.opt.elf -T memmap vectors.o blinker03.clang.thumb.opt.o 

I don’t have, but will soon be experimenting using llc directly to the object (in fact, I tried this on a simple test, but did not use it on anything else or did not place it anywhere).

see examples at http://github.com/dwelch67 There are several raspberrypi in mbed, maybe there are some, thumbulator. Most of the examples are gnu based, but for some of them I also included llvm / clang commands in the Makefile.

+5
source

To get a list of clang compiler options using

clang -cc1 -help

To specify a target, use -triple

clang -cc1 -triple "arm-vendor-os" filename

where "vendor" and "os" should be replaced with the actual name of the vendor and os. It can also be replaced with unknown . triple is a string in the form ARCHITECTURE-VENDOR-OS or ARCHITECTRUE-VENDOR-OS-ENVIRONMENT , for example: x86_64-apple-darwin10

+4
source

-march is a command line option of the LLVM internal tools and is not related to clang at all. If you need to compile another target, you need to specify the target triplet. This can be done in several ways (I don’t remember how they work with 3.1, but they definitely work with 3.2):

  • Make a link from clang to your-target-triple-clang, for example. in arm-none-linux-gnueabi-clang and compile everything through it
  • Provide the -target option, for example. clang -target arm-none-linux-gnueabi
+4
source

You mix your flags. clang -march= wants a processor family. You probably used clang -arch arm instead.

+1
source

"- arch arm" is equivalent to "-arch armv4t" in clang. I believe that a common "hand" of the target is not allowed with "-march =", which should require something more precise, such as "armv6", "thumbv7", "armv4t", ...

Try to select a specific subarchive.

0
source

All Articles