Nios II clang port is finally “working”. It depends on the altera gcc tool chain to generate object code.

  • Clone llvm core and clang
$ git clone https://github.com/ivanllopard/nios2-llvm.git
$ export LLVM_SOURCE=`pwd`/nios2-llvm
$ cd nios2-llvm/tools
$ git clone https://github.com/ivanllopard/nios2-clang.git
  • Build llvm and clang inside a new build directory.
$ mkdir build
$ cd build
$ $LLVM_SOURCE/configure --enable-optimized --target=nios2 --enable-targets=nios2
$ make -j2 && sudo make install

You will get the nios2-clang compiler installed at the default prefix path. Currently, the front-end uses nios2-elf-as and nios2-elf-ld from the altera toolchain. You can either compile the entire toolchain from its sources or download a compiled version which comes with the Nios II Embedded Design Suite Legacy Tools Similar to nios2-elf-gcc, nios2-clang depends on nios2 system includes installed at H-i686-pc-linux-gnu/nios2-elf/include.

The compiler is still at its “hack” state, it has not been tested on a real board yet. Please feel free to test it and submit patches !