Using LLVM instead of GCC

(chris hulbert) #1

Loving toying around with my just-arrived HiFive1, just a random question.
Is it reasonable to want to use LLVM instead of GCC to compile code? I see that has invested a lot of effort into giving LLVM a RISCV backend so it might be simple enough?
It’s simply a matter of compiling a binary and then uploading it to the HiFive’s flash at the correct memory offset?
My reasoning is that i’d like to experiment with some more interesting modern languages than C/C++, such as eg Rust etc.
Just asking because i dont want to bite off more than i can chew as a reasonably competent but not miracle-working developer.
Cheers :slight_smile:

(Bruce Hoult) #2

It’s a reasonable thing, although gcc works perfectly well.

The official llvm repository has had pretty good support for 32 bit RISC-V for most of this year. 64 bit support has only started to be upstreamed recently, but that doesn’t concern the HiFive1.

Clang/LLVM for RISC-V uses the gcc headers and gnu linker.

It should work no problem, but it’s not extensively tested and our build scripts assume everyone uses gcc :slight_smile:

And, yes, the main thing is to use a linker script that puts the code (at least something) at 0x2040000 in the flash, and runs a reasonable assembly language init entry point that sets up oscillators and so forth. Definitely easiest to just use our one for that.

(chris hulbert) #3

Thanks a lot, i might still give it a try. I’d really love to see if i can get something nontrivial running on it written in Swift or Rust.