Skip to content

Latest commit

 

History

History
55 lines (48 loc) · 1.74 KB

README.md

File metadata and controls

55 lines (48 loc) · 1.74 KB

Rust app for Linux or RISC-V targets

Pre-requisites

  1. Compile the C SDK

  2. Some libraries are required to build the app:

    • libc.a to build the app for a RISC-V target
    • libcrypto.a to run tests on a Linux target

    These libraries can be retrieved from Docker images thanks to the script:

    ./lib/create-lib.sh

    They are also generated as artifacts by the GitHub CI.

  3. Build the Rust Docker image

    docker build -t rust -f rust.Dockerfile .
    docker run --rm -ti  -v $(pwd):/usr/src/vanadium -w /usr/src/vanadium/app/rust rust:latest

Building

For RISC-V target

cargo build --release

For Linux aarch64 (Mac M1/M2) target

cargo build --release --target aarch64-unknown-linux-gnu

For Linux x86_64 target

cargo build --release --target x86_64-unknown-linux-gnu

Testing (Linux only)

Tests are ran on native thanks to libspeculos.so.

--test-threads=1 is required because libspeculos.so isn't thread safe.

For Linux aarch64 target

docker run --rm -ti  -v $(pwd):/usr/src/vanadium -w /usr/src/vanadium rust:latest
cd app/rust
cargo test --target aarch64-unknown-linux-gnu -- --test-threads=1

For Linux x86_64 target

docker run --rm -ti  -v $(pwd):/usr/src/vanadium -w /usr/src/vanadium rust:latest
cd app/rust
cargo test --target x86_64-unknown-linux-gnu -- --test-threads=1

Notes

  • Find which functions take the most of space with cargo install bloat && cargo bloat --release -n 10