5

I'd like to cross-compile Clang for run on ARM devices and compile for ARM mcu (Cortex M3) or ATmega AVR mcus. Is Clang able to do it?

UPDATE: i've found llvm-avr backend for LLVM 3.5: https://github.com/sushihangover/llvm-avr

Is anyone except me interested?

4ntoine
  • 19,816
  • 21
  • 96
  • 220
  • Yes, [it can](http://clang.llvm.org/docs/CrossCompilation.html). – Jonathon Reinhart Jun 11 '14 at 05:53
  • What is command-line to compile "hello world" for AVR? – 4ntoine Jun 11 '14 at 05:59
  • should i compile clang with some specific arguments to add ARM/AVR support? – 4ntoine Jun 11 '14 at 06:33
  • thanks for explanation. i agree to have 2 versions of clang compiled for arm and for avr separately. the question is how to compile it (for avr especially)? – 4ntoine Jun 11 '14 at 18:41
  • 1
    [If only](http://llvm.org/docs/HowToCrossCompileLLVM.html) there were [some kind](http://clang.llvm.org/get_started.html) of [documentation](http://llvm.org/docs/HowToBuildOnARM.html) about [that](http://clang.llvm.org/docs/CrossCompilation.html)... – Notlikethat Jun 11 '14 at 18:47
  • if only someone could read its about cross-compiling on ARM but not for bare metal ARM. What about avr (arch = x86, arm, thumb, mips)? – 4ntoine Jun 11 '14 at 18:58
  • This is a very complex issue. See: [crosstool-ng](http://crosstool-ng.org/) for scripts to build `gcc` cross compilers. You need to build multiple compilers to make one of the two compilers you want. Are you versed in making a compiler already? If not, get a pre-packaged one. If you can make a *host=build=target* compiler, then tell us specifics of your issue. – artless noise Jun 11 '14 at 20:45
  • Read [crosstool-ng's how a toolchain is constructed](http://crosstool-ng.org/hg/crosstool-ng/file/99029fac116b/docs/9%20-%20How%20is%20a%20toolchain%20constructed.txt) for instance. This is for a simple cross compiler (13 steps). It is more complex for the type of compilers you are asking for. The process for llvm/clang is very similar and equally arcane. The main difference between *arm-linux* and *arm-none* (bare metal) is the 'C' library; which is part of building a compiler. – artless noise Jun 11 '14 at 20:51
  • See also: [How to compile Clang for an AVR](http://stackoverflow.com/questions/19006000/how-to-compile-clang-to-use-as-compiler-for-avr). – artless noise Jun 11 '14 at 21:06

1 Answers1

5

For those interested, there is a currently active fork over here: https://github.com/dylanmckay/avr-llvm

RandomInsano
  • 1,204
  • 2
  • 16
  • 36