Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

LLVM & Clang can't compile for a supported arch

Under 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't do this

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

I'm missing something here ? Why I can't compile for ARM ?

like image 987
user1849534 Avatar asked Dec 19 '12 01:12

user1849534


2 Answers

-march is LLVM's internal tools command line option and is not connected with clang at all. If you need to compile for other target you need to specify the target triplet. This can be done in several ways (I do not remember offhand, whether they work with 3.1, but they definitely work with 3.2):

  • Make a link from clang to your-target-triple-clang, e.g. to arm-none-linux-gnueabi-clang and compile everything via it
  • Provide -target option, e.g. clang -target arm-none-linux-gnueabi
like image 105
Anton Korobeynikov Avatar answered Sep 23 '22 23:09

Anton Korobeynikov


You're confusing your flags. clang's -march= wants a processor family. You probably meant to use clang -arch arm instead.

like image 39
Lily Ballard Avatar answered Sep 24 '22 23:09

Lily Ballard