A fork of the Rust programming language with AVR support
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Jake Goulding 8405b30a34
Document to use stage2
2 years ago
.azure-pipelines azure: Uninstall previous rustc from builders if any 2 years ago
src [AVR] Fix debug printing of function pointers 2 years ago
.dockerignore Add Gitlab CI config and Dockerfile 2 years ago
.gitattributes ignore images line ending on older git versions 2 years ago
.gitignore Ignore .vscode even if it is a symlink 2 years ago
.gitlab-ci.yml Add Gitlab CI config and Dockerfile 2 years ago
.gitmodules [AVR][No Upstream] Use forked LLVM with non-upstreamed fixes 2 years ago
.mailmap Rollup merge of #61591 - christianpoveda:patch-1, r=jonas-schievink 2 years ago
.travis.yml [AVR][No Upstream] Add AVR-Rust specific travis-ci manifest 2 years ago
.travis_rust.yml [AVR][No Upstream] Move aside travis.yml 2 years ago
CODE_OF_CONDUCT.md Make extern ref HTTPS 2 years ago
CONTRIBUTING.md Rollup merge of #59234 - stepnivlk:add-no_merge_policy, r=oli-obk 2 years ago
COPYRIGHT Rebase to the llvm-project monorepo 2 years ago
Cargo.lock Update compiler_builtins 2 years ago
Cargo.toml Make libstd depend on the hashbrown crate 2 years ago
Dockerfile Add Gitlab CI config and Dockerfile 2 years ago
Jenkinsfile [AVR][No Upstream] Add Jenkinsfile 2 years ago
LICENSE-APACHE Update license, add license boilerplate to most files. Remainder will follow. 8 years ago
LICENSE-MIT LICENSE-MIT: Remove inaccurate (misattributed) copyright notice 4 years ago
README.md Document to use stage2 2 years ago
RELEASES.md Fix spelling in release notes 2 years ago
RUST_README.md [AVR][No Upstream] Move aside Rust README 2 years ago
appveyor.yml Update all s3 URLs used on CI with subdomains 2 years ago
config.toml.example [AVR] Add AVR platform support 2 years ago
configure rustbuild: Rewrite the configure script in Python 4 years ago
rustfmt.toml Add rustfmt toml 2 years ago
triagebot.toml Allow claiming issues with triagebot 2 years ago
x.py Remove licenses 2 years ago


Rust with AVR support


This project adds support for the AVR microcontroller to Rust.

It uses the AVR-LLVM backend.


While the stock libcore may be compiled, certain code patterns may still exercise code in LLVM that is broken or that produces miscompiled code. Looking for existing issues or submitting a new issue is appreciated!

Building and installation

This will compile Rust with AVR support. This will not create a fully-fledged cross-compiler, however, as it does not compile any libraries such as libcore or liblibc. To do this, the --target=avr-unknown-unknown flag must be passed to configure, which is not fully supported yet due to bugs.

First make sure you've installed all dependencies for building, as specified in the main Rust repository here. Then use the following commands:

Notes for macOS

The conventional install directory for macOS is /usr/local/avr-rust rather than the Linux default /opt/avr-rust, so before the steps below, you must:

  1. Edit build/config.toml to set prefix = '/usr/local/avr-rust'.
  2. Ensure /usr/local/avr-rust exists and has the correct permissions: sudo mkdir /usr/local/avr-rust && sudo chown $USER:admin /usr/local/avr-rust

Finally, realpath isn't included by default on macOS but is included in GNU Coreutils, so you can either brew install coreutils so the rustup toolchain... step works properly, or just use the explicit path (rustup toolchain link avr-toolchain /usr/local/avr-rust).

# Grab the avr-rust sources
git clone https://github.com/avr-rust/rust.git --recursive

# Create a directory to place built files in
mkdir build && cd build

# Generate Makefile using settings suitable for an experimental compiler
../rust/configure \
  --enable-debug \
  --disable-docs \
  --enable-llvm-assertions \
  --enable-debug-assertions \
  --enable-optimize \
  --enable-llvm-release-debuginfo \
  --experimental-targets=AVR \

# Build the compiler, optionally install it to /opt/avr-rust
make install

# Register the toolchain with rustup
rustup toolchain link avr-toolchain $(realpath $(find . -name 'stage2'))

# Optionally enable the avr toolchain globally
rustup default avr-toolchain


With Xargo (recommended)

Take a look at the example blink program.

Vanilla rustc

AVR support is enabled by passing the --target avr-unknown-unknown flag to rustc.

Note that the Rust libcore library (essentially required for every Rust program), must be manually compiled for it to be used, as it will not be built for AVR during compiler compilation (yet). Work is currently being done in order to allow libcore to be automatically compiled for AVR.