When we left off, we were blinking the LED. Let’s take a brief detour and document how to get a working Rust compiler. This is mostly a way for me to document what I’ve been doing so I can find it again!
We are going to start by getting a local version of LLVM that supports
targeting AVR. After cloning the repository, we will need
to set up for a build. Note that the upstream
branch sometimes lags compared to
avr-support, so you will probably
want to merge the two branches to get any updates.
1 2 3 4 5
We will then configure LLVM. This particular configuration I have
here is based off the current Rust build and is specific to OS X (see
CXX_FLAGS). If you are using a different platform,
you’ll need to poke at the Rust build process to see the appropriate
Last updated: 2016-11-06
1 2 3 4 5 6 7 8 9 10 11 12 13
Then it’s just a matter of building and installing. Since it created
Makefiles for me, I passed an extra make flag to build in
parallel. The LLVM build is pretty fast this way!
Then we need to build Rust with this custom LLVM. After cloning the repository, set up the structure:
1 2 3 4
AVR-LLVM is based on a very new version of LLVM, so we need to use the in-progress Rust build system called “rustbuild”. Using in-development build systems with in-development compilers, what could go wrong?
Note that it’s very important to use an absolute path to your LLVM directory.
1 2 3 4 5 6 7
Then we build!
4 or more hours later, you will have a fully-built
compiler. However, you can usually get up-and-running earlier by using
the stage 1 compiler, located in
debug/build/*/stage1. This will be
available pretty quickly, before the entire build is complete.
We then add this build as a rustup toolchain and use it as the override compiler in a directory:
Note that this will only produce a cross-compiler; none of the libraries that make things actually work. That’s still coming!