Skip to content

Commit

Permalink
Define a MSRV, use that toolchain by default.
Browse files Browse the repository at this point in the history
This PR defines a Minimum Supported Rust Version. It specifies that toolchain in `rust-toolchain`, so `rustup` will use that toolchain by default. The `test-stable` make action is removed, as it is now redundant.

We still need the nightly toolchain for Miri. Instead of specifying the nightly toolchain version via the command line, I created a new `nightly/rust-toolchain.toml` file that specifies the toolchain. The benefit is this makes `rustup` automatically install the nightly toolchain *including Miri*. This should stop the toil we currently have where every time the Rust toolchain is updated, everyone using `make test` has to manually install new toolchains and Miri. The downside is it's kinda ugly.

I set the MSRV to 1.70 so this doesn't conflict with #498.

I will send another PR that adds `rust-version.workspace = true` to all the `Cargo.toml` files in this repository; I didn't want to clutter this PR with those changes.
  • Loading branch information
jrvanwhy committed Aug 24, 2023
1 parent 571e1c2 commit 0ae3974
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/Cargo.lock
/nightly/target
/target
6 changes: 6 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,14 @@ edition = "2021"
license = "Apache-2.0 OR MIT"
name = "libtock"
repository = "https://www.github.com/tock/libtock-rs"
rust-version.workspace = true
version = "0.1.0"

[workspace.package]
# This must be kept in sync with rust-toolchain.toml; please see that file for
# more information.
rust-version = "1.70"

[dependencies]
libtock_adc = { path = "apis/adc"}
libtock_air_quality = { path = "apis/air_quality" }
Expand Down
24 changes: 6 additions & 18 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,7 @@ endif

.PHONY: setup
setup: setup-qemu
rustup install stable
cargo +stable install elf2tab
cargo miri setup
rustup target add --toolchain stable thumbv7em-none-eabi
cargo install elf2tab

# Sets up QEMU in the tock/ directory. We use Tock's QEMU which may contain
# patches to better support boards that Tock supports.
Expand Down Expand Up @@ -108,28 +105,19 @@ EXCLUDE_STD := --exclude libtock_unittest --exclude print_sizes \
--exclude runner --exclude syscalls_tests \
--exclude libtock_build_scripts

# Currently, all of our crates should build with a stable toolchain. This
# verifies our crates don't depend on unstable features by using cargo check. We
# specify a different target directory so this doesn't flush the cargo cache of
# the primary toolchain.
.PHONY: test-stable
test-stable:
cargo +stable check --target-dir=target/stable --workspace \
$(EXCLUDE_RUNTIME)
LIBTOCK_PLATFORM=nrf52 cargo +stable check $(EXCLUDE_STD) \
--target=thumbv7em-none-eabi --target-dir=target/stable --workspace

.PHONY: test
test: examples test-stable
test: examples
cargo test $(EXCLUDE_RUNTIME) --workspace
LIBTOCK_PLATFORM=nrf52 cargo fmt --all -- --check
cargo clippy --all-targets $(EXCLUDE_RUNTIME) --workspace
LIBTOCK_PLATFORM=nrf52 cargo clippy $(EXCLUDE_STD) \
--target=thumbv7em-none-eabi --workspace
LIBTOCK_PLATFORM=hifive1 cargo clippy $(EXCLUDE_STD) \
--target=riscv32imac-unknown-none-elf --workspace
MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check" \
cargo miri test $(EXCLUDE_MIRI) --workspace
cd nightly && \
MIRIFLAGS="-Zmiri-strict-provenance -Zmiri-symbolic-alignment-check" \
cargo miri test $(EXCLUDE_MIRI) --manifest-path=../Cargo.toml \
--target-dir=target --workspace
echo '[ SUCCESS ] libtock-rs tests pass'

# Helper functions to define make targets to build for specific (flash, ram,
Expand Down
4 changes: 4 additions & 0 deletions nightly/rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# This is the nightly Rust toolchain used by `make test`.
[toolchain]
channel = "nightly-2023-08-22"
components = ["miri"]
9 changes: 0 additions & 9 deletions rust-toolchain

This file was deleted.

13 changes: 13 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[toolchain]
# This is libtock-rs' Minimum Supported Rust Version (MSRV).
#
# Update policy: Update this if doing so allows you to use a Rust feature that
# you'd like to use. When you do so, update this to the first Rust version that
# includes that feature. Whenever this value is updated, the rust-version field
# in Cargo.toml must be updated as well.
channel = "1.70"
components = ["clippy", "rustfmt"]
targets = ["thumbv6m-none-eabi",
"thumbv7em-none-eabi",
"riscv32imac-unknown-none-elf",
"riscv32imc-unknown-none-elf"]

0 comments on commit 0ae3974

Please sign in to comment.