22

Has someone infos how to build a llvm+clang toolchain using binutils and newlib and how to use it?

  • host: Linux, AMD64
  • target: cortex-m3, stm32
  • c-lib: newlib
  • assembler: gnu as
tuxfool
  • 15
  • 4

2 Answers2

8

I created a firmware framework - PolyMCU https://github.com/labapart/polymcu - that is based on CMake that support GCC and LLVM. Because it is based on CMake you can build your firmware on Linux/Windows/MacOS. It also uses Newlib - it looks all your requirements are there!

I also wrote a blog where I compared GCC and LLVM build size on ARM Cortex-M: http://labapart.com/blogs/3-the-importance-of-the-toolchain-version-in-embedded-space Interesting results, Clang generated code is not much bigger than GCC on Cortex-M...

OlivierM
  • 214
  • 3
  • 3
2

Unfortunately, right now clang does not support flexible cross-compilation settings. So, most probably you will need to invoke necessary tools with all necessary arguments.

Start with building llvm + clang using --target=thumbv7-eabi configure argument (note that you will need llvm + clang as of yesterday for this). You might want to specify --enable-targets=arm as well. This will instruct clang to generate code for thumb by default. After this you can invoke clang -mcpu=cortex-m3 to generate the code for you.

You will have to provide all necessary include / library paths by hands via -I / -L, etc.

If you're happy with some C++ hacking, you can write necessary "HostInfo", so it will invoke the right tools and provide right paths automagically.

James
  • 22,556
  • 11
  • 75
  • 125
Anton Korobeynikov
  • 8,100
  • 21
  • 27