1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 01:23:49 +01:00

makefiles/rust: Remove CARGO_CHANNEL special casing

Back when specific control of the Rust version used with RIOT was
needed, CARGO_CHANNEL was added to explicitly set the Rust version with
consideration for CI special cases.

Rust's mechansims of selecting a toolchain can be used instead now.
This commit is contained in:
chrysn 2024-01-31 12:06:23 +01:00
parent e98d3a5d3a
commit 6724884b93
8 changed files with 8 additions and 48 deletions

View File

@ -108,19 +108,17 @@ To install the necessary Rust components, it is easiest use [**rustup**, install
Using Rust on RIOT needs the latest stable version of Rust. Using Rust on RIOT needs the latest stable version of Rust.
Make sure you have the stable **toolchain** Make sure you have the core library for the CPU (**target**) of your choice available:
and the core library for the CPU (**target**) of your choice available:
``` ```
$ rustup toolchain add stable $ rustup target add thumbv7m-none-eabi
$ rustup target add thumbv7m-none-eabi --toolchain stable
``` ```
Substitute thumbv7m-none-eabi 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 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). (or just add it later whenever the Rust compiler complains about not finding the core library for a given target).
Using a beta or nightly will work just as well, Using the beta or nightly toolchains will work just as well
but you may need to set `CARGO_CHANNEL=nightly` on your shell or in your Makefiles. if they are selected through rustup's override mechanism.
While Rust comes with its own [cargo] dependency tracker for any Rust code, While Rust comes with its own [cargo] dependency tracker for any Rust code,

View File

@ -41,8 +41,6 @@ BASELIBS += $(APPLICATION_RUST_MODULE).module
FEATURES_REQUIRED += rust_target FEATURES_REQUIRED += rust_target
CARGO_CHANNEL ?= stable
# Currently unknown, something related to the LED_PORT definition that doesn't # Currently unknown, something related to the LED_PORT definition that doesn't
# pass C2Rust's transpilation # pass C2Rust's transpilation
BOARD_BLACKLIST := ek-lm4f120xl BOARD_BLACKLIST := ek-lm4f120xl

View File

@ -21,11 +21,6 @@ BASELIBS += $(APPLICATION_RUST_MODULE).module
FEATURES_REQUIRED += rust_target FEATURES_REQUIRED += rust_target
# All Rust components RIOT uses work on stable Rust. If any extra libraries
# were to require a more recent version, switch to `CARGO_CHANNEL =
# $(CARGO_CHANNEL_NIGHTLY)` to use whichever nightly version is available.
CARGO_CHANNEL ?= stable
# Currently unknown, something related to the LED_PORT definition that doesn't # Currently unknown, something related to the LED_PORT definition that doesn't
# pass C2Rust's transpilation # pass C2Rust's transpilation
BOARD_BLACKLIST := ek-lm4f120xl BOARD_BLACKLIST := ek-lm4f120xl

View File

@ -4,28 +4,6 @@
# binary is derived from this. # binary is derived from this.
CARGO_PROFILE ?= release CARGO_PROFILE ?= release
# Value for CARGO_CHANNEL when using nightly
#
# As different environments have different versions of nightly installed, but
# rustup / cargo does not take "the latest installed nightly" for a toolchain,
# a good value is determined dynamically. Typical values this takes are
# `nightly` (on regular installations) and `nightly-2022-03-08` (or whichever
# date it is currently pinned to) in riotbuild.
#
# Workaround-For: https://github.com/rust-lang/rustup/issues/3015
#
# This does not get evaluated unless actually used; if rustup is not installed,
# the default value will likely not be usable but at least set the user on the
# right track.
CARGO_CHANNEL_NIGHTLY = $(shell rustup toolchain list | sed 's/ .*//' |grep nightly | tail -n1 || echo nightly)
# The Rust version to use.
#
# Examples should set this to either `stable` or `$(CARGO_CHANNEL_NIGHTLY)`.
# The default is empty, which is suitable for applications that select their
# version through a `rust-toolchain.yaml` file.
CARGO_CHANNEL ?=
# Note that if we did not set this explicitly, CARGO_LIB would have to # Note that if we did not set this explicitly, CARGO_LIB would have to
# understand which value cargo uses in absence of CARGO_TARGET_DIR, which would # understand which value cargo uses in absence of CARGO_TARGET_DIR, which would
# be $(APPDIR)/target. # be $(APPDIR)/target.

View File

@ -55,15 +55,15 @@ $(CARGO_LIB): $(RIOTBUILD_CONFIG_HEADER_C) $(BUILDDEPS) $(CARGO_COMPILE_COMMANDS
$(Q)# If distribution installed cargos ever grow the capacity to build RIOT, this absence of `rustup` might be OK. But that'd need them to both have cross tools around and cross core libs, none of which is currently the case. $(Q)# If distribution installed cargos ever grow the capacity to build RIOT, this absence of `rustup` might be OK. But that'd need them to both have cross tools around and cross core libs, none of which is currently the case.
$(Q)# Ad grepping for "std": We're not *actually* checking for std but more for core -- but rust-stc-$TARGET is the name of any standard libraries that'd be available for that target. $(Q)# Ad grepping for "std": We're not *actually* checking for std but more for core -- but rust-stc-$TARGET is the name of any standard libraries that'd be available for that target.
$(Q)[ x"$(findstring build-std,$(CARGO_OPTIONS))" != x"" ] || \ $(Q)[ x"$(findstring build-std,$(CARGO_OPTIONS))" != x"" ] || \
(rustup component list $(patsubst %,--toolchain %,$(CARGO_CHANNEL)) --installed | grep 'rust-std-$(RUST_TARGET)$$' -q) || \ (rustup component list --installed | grep 'rust-std-$(RUST_TARGET)$$' -q) || \
($(COLOR_ECHO) \ ($(COLOR_ECHO) \
'$(COLOR_RED)Error: No Rust libraries are installed for the board'"'"'s CPU.$(COLOR_RESET) Run\n $(COLOR_GREEN)$$$(COLOR_RESET) rustup target add $(RUST_TARGET) $(patsubst %,--toolchain %,$(CARGO_CHANNEL))\nor set `CARGO_OPTIONS=-Zbuild-std=core`.'; \ '$(COLOR_RED)Error: No Rust libraries are installed for the board'"'"'s CPU.$(COLOR_RESET) Run\n $(COLOR_GREEN)$$$(COLOR_RESET) rustup target add $(RUST_TARGET)\nor set `CARGO_OPTIONS=-Zbuild-std=core`.'; \
exit 1) exit 1)
$(Q)# finally call out to cargo. mind the "+" to pass down make's jobserver. $(Q)# finally call out to cargo. mind the "+" to pass down make's jobserver.
$(Q)+ CC= CFLAGS= CPPFLAGS= CXXFLAGS= \ $(Q)+ CC= CFLAGS= CPPFLAGS= CXXFLAGS= \
RIOT_COMPILE_COMMANDS_JSON="$(CARGO_COMPILE_COMMANDS)" \ RIOT_COMPILE_COMMANDS_JSON="$(CARGO_COMPILE_COMMANDS)" \
RIOT_USEMODULE="$(USEMODULE)" \ RIOT_USEMODULE="$(USEMODULE)" \
cargo $(patsubst +,,+${CARGO_CHANNEL}) \ cargo \
build \ build \
--target $(RUST_TARGET) \ --target $(RUST_TARGET) \
--profile $(CARGO_PROFILE) \ --profile $(CARGO_PROFILE) \

View File

@ -90,7 +90,6 @@ info-build:
@echo -e 'CXXEXFLAGS:$(patsubst %, \n\t%, $(CXXEXFLAGS))' @echo -e 'CXXEXFLAGS:$(patsubst %, \n\t%, $(CXXEXFLAGS))'
@echo '' @echo ''
@echo 'RUST_TARGET: $(RUST_TARGET)' @echo 'RUST_TARGET: $(RUST_TARGET)'
@echo 'CARGO_CHANNEL: $(CARGO_CHANNEL)'
@echo 'CARGO_PROFILE: $(CARGO_PROFILE)' @echo 'CARGO_PROFILE: $(CARGO_PROFILE)'
@echo 'CARGO_OPTIONS: $(CARGO_OPTIONS)' @echo 'CARGO_OPTIONS: $(CARGO_OPTIONS)'
@echo '' @echo ''
@ -250,5 +249,5 @@ info-programmers-supported:
@echo $(sort $(PROGRAMMERS_SUPPORTED)) @echo $(sort $(PROGRAMMERS_SUPPORTED))
info-rust: info-rust:
cargo $(patsubst +,,+${CARGO_CHANNEL}) version cargo version
c2rust --version c2rust --version

View File

@ -5,10 +5,6 @@ USEMODULE += shell_democommands
FEATURES_REQUIRED += rust_target FEATURES_REQUIRED += rust_target
# Testing on stable to ensure that no nightly features are needed when Rust is
# pulled in through modules.
CARGO_CHANNEL = stable
# Currently unknown, something related to the LED_PORT definition that doesn't # Currently unknown, something related to the LED_PORT definition that doesn't
# pass C2Rust's transpilation # pass C2Rust's transpilation
BOARD_BLACKLIST := ek-lm4f120xl BOARD_BLACKLIST := ek-lm4f120xl

View File

@ -5,10 +5,6 @@ BASELIBS += $(APPLICATION_RUST_MODULE).module
FEATURES_REQUIRED += rust_target FEATURES_REQUIRED += rust_target
# Testing on stable to ensure that no nightly features are needed for basic
# Rust usage.
CARGO_CHANNEL = stable
# Currently unknown, something related to the LED_PORT definition that doesn't # Currently unknown, something related to the LED_PORT definition that doesn't
# pass C2Rust's transpilation # pass C2Rust's transpilation
BOARD_BLACKLIST := ek-lm4f120xl BOARD_BLACKLIST := ek-lm4f120xl