Valida Rust Compiler Toolchain

Here are instructions for compiling and running a subset of Rust programs, starting with release 0.3.0-alpha of the Valida compiler toolchain.

First make sure you have a proper version of rustc in your system PATH. A convenient way to do this is using rustup. If you have rustup installed, then you can set a proper version of rustc this way:

rustup install nightly-2024-07-29
rustup default nightly-2024-07-29

To build the Rust examples, you can use the following script, which assumes it is run from the root directly of the extracted release bundle. Just replace fib-write in line 2 with the name of the example:

#!/usr/bin/env bash
EXAMPLE=fib-write
rustc --emit=llvm-ir -Cpanic="abort" -C opt-level=3  -C target-cpu=generic ./examples/$EXAMPLE.rs
./llc -march=delendum -filetype=obj $EXAMPLE.ll
./ld.lld --script=./valida.ld $EXAMPLE.o -L . -lstdio -o $EXAMPLE

To make this process a little easier, this script is included in the release bundle as ./build-rust.sh.

You can add your own Rust programs and possibly build them this way, subject to the following limitations.

Rust to Valida limitations

  • Exception handling is not yet supported

  • Multi-file compilation is not yet supported

  • The Rust standard library is not yet supported

  • The Rust compiler toolchain (rustc, cargo, etc) is not yet supported

  • Due to the lack of thorough testing so far, it is safe to assume that there are other limitations not documented here.

Next steps on Rust to Valida support involve getting the Rust compiler toolchain to work with Valida. Once Valida is integrated into the Rust compiler toolchain, pieces like multi-file compilation and the Rust standard library should begin to fall into place.

Last updated