Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust: test on stable #17805

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions doc/doxygen/src/using-rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,31 +84,26 @@ Toolchain {#toolchain}

To install the necessary Rust components, it is easiest use [**rustup**, installed as described on its website].

Using most of Rust on RIOT requires a nightly version of Rust,
because some transpiled expressions for RIOT make use of unstable features,
and because the RIOT wrappers use some unstable idioms.
Using Rust on RIOT needs the latest stable or nightly version of Rust,
depending on the precise example used.
(Several modules, such as CoAP, SAUL or the shell, need features not yet available on stable yet;
the minimal test is performed on stable, and examples are configured to use stable as it becomes available).

@note
Building on stable is supported for some examples and platforms starting with Rust 1.59
(e.g., the rust-hello-world on any ARM Cortex, but not yet on native).
Try it out by adding `CARGO_CHANNEL=stable` to the project's Makefile;
where it doesn't work, rustc will complain that "`#![feature]` may not be used on the stable release channel".

@note
A stable version of Rust is not currently provided with the Docker images;
consequently, builds on stable are not tested as regularly as builds on nightly.

Make sure you have both the nightly **toolchain**
Make sure you have both the nightly and stable **toolchains**
and the core library for the CPU (**target**) of your choice available:

```
$ rustup toolchain add nightly
$ rustup toolchain add stable
$ rustup target add thumbv7m-none-eabi --toolchain nightly
$ rustup target add thumbv7m-none-eabi --toolchain stable
```

(Substitute thumbv7m-none-eavi with the value of `RUST_TARGET`
Substitute thumbv7m-none-eabi with the value of `RUST_TARGET`
in the output of `make info-build` of an application that has your current board selected,
or just add it later whenever the Rust compiler complains about not finding the core library for a given target).
Installing only nightly will work just as well,
but you may need to remove the `CARGO_CHANNEL = stable` lines from tests or examples.


While Rust comes with its own [cargo] dependency tracker for any Rust code,
Expand Down
6 changes: 6 additions & 0 deletions tests/rust_minimal/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ resolver = "2"
[lib]
crate-type = ["staticlib"]

[profile.release]
# Setting the panic mode has little effect on the built code (as Rust on RIOT
# supports no unwinding), but setting it allows builds on native without using
# the nightly-only lang_items feature.
panic = "abort"

[dependencies]
# `default-features = false` can be removed with 0.8, and enables building on stable during the 0.7 series
riot-wrappers = { version = "0.7", features = [ "set_panic_handler" ], default-features = false }
5 changes: 5 additions & 0 deletions tests/rust_minimal/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ BASELIBS += $(APPLICATION_RUST_MODULE).module

FEATURES_REQUIRED += rust_target

# This example can, on all platforms, be built with a stable version of Rust.
# For most advanced features (eg. when using CoAP, SAUL or the shell with
# Rust), this needs to be set to "nightly" for the time being.
CARGO_CHANNEL = stable

# Currently unknown, something related to the LED_PORT definition that doesn't
# pass C2Rust's transpilation
BOARD_BLACKLIST := ek-lm4f120xl
Expand Down