Skip to content

Commit

Permalink
optee_rust_examples_ext: Fix Rust toolchain conflicts
Browse files Browse the repository at this point in the history
Buildroot provides its own Rust toolchain for various Linux user-space
components. However, that toolchain doesn't support nightly version of
Rust complier which we need for OP-TEE Rust examples for the time being.

Due to two separate Rust toolchains being used for different buildroot
components, there are conflicts [1] [2] observed leading to CI errors.
In order to fix them enable OP-TEE specific Rust toolchain specifically
to build OP-TEE Rust examples rather than enabling it for the entire
buildroot build.

Fixes: [1] OP-TEE#727
Fixes: [2] OP-TEE#728
Signed-off-by: Sumit Garg <[email protected]>
  • Loading branch information
b49020 committed Feb 8, 2024
1 parent 7dd5580 commit e202ddf
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions br-ext/package/optee_rust_examples_ext/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,10 @@ config BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_CROSS_COMPILE_TA
the target platforms. Hence this options provides path to GCC linker
in order to link TA part of the Rust examples. For example:
aarch64-linux-gnu- or path/to/aarch64-linux-gnu-

config BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_TC_PATH
string "OP-TEE Rust toolchain installation path"
default ""
help
The path to OP-TEE Rust toolchain installation directory
endif
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,15 @@ OPTEE_RUST_EXAMPLES_EXT_SITE_METHOD = local
OPTEE_RUST_EXAMPLES_EXT_INSTALL_STAGING = YES
OPTEE_RUST_EXAMPLES_EXT_DEPENDENCIES = optee_client_ext
OPTEE_RUST_EXAMPLES_EXT_SDK = $(BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_SDK)
OPTEE_RUST_EXAMPLES_EXT_TC_PATH = $(subst $\",,$(BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_TC_PATH))

EXAMPLE = $(wildcard examples/*)

define OPTEE_RUST_EXAMPLES_EXT_BUILD_CMDS
echo Building OP-TEE rust examples && \
export RUSTUP_HOME=$(OPTEE_RUST_EXAMPLES_EXT_TC_PATH)/.rustup && \
export CARGO_HOME=$(OPTEE_RUST_EXAMPLES_EXT_TC_PATH)/.cargo && \
source $(OPTEE_RUST_EXAMPLES_EXT_TC_PATH)/.cargo/env && \
TARGET_HOST=$(BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_TARGET_HOST) \
TARGET_TA=$(BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_TARGET_TA) \
CROSS_COMPILE_HOST=$(BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_CROSS_COMPILE_HOST) \
Expand Down
3 changes: 2 additions & 1 deletion common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_TARGET_HOST ?= "$(AARCH$(COMPILE_NS_USER)_RU
BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_TARGET_TA ?= "$(AARCH$(COMPILE_S_USER)_RUST_TARGET)"
BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_SDK ?= $(OPTEE_OS_TA_DEV_KIT_DIR)
BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_SITE ?= $(OPTEE_RUST_PATH)
BR2_PACKAGE_OPTEE_RUST_EXAMPLES_EXT_TC_PATH ?= $(RUST_TOOLCHAIN_PATH)
endif
endif
# The OPTEE_OS package builds nothing, it just installs files into the
Expand Down Expand Up @@ -349,7 +350,7 @@ buildroot: optee-os
$(DEFCONFIG_FTPM) \
--br-defconfig out-br/extra.conf \
--make-cmd $(MAKE))
@source $(RUST_TOOLCHAIN_PATH)/.cargo/env && $(MAKE) $(br-make-flags) -C ../out-br all
@$(MAKE) $(br-make-flags) -C ../out-br all

.PHONY: buildroot-clean
buildroot-clean:
Expand Down
2 changes: 1 addition & 1 deletion qemu_v8.mk
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ QEMU_VIRTFS_AUTOMOUNT = y
endif

# Option to enable Rust examples
RUST_ENABLE ?= n
RUST_ENABLE ?= y

include common.mk

Expand Down
3 changes: 2 additions & 1 deletion toolchain.mk
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ define dl-rust-toolchain
source "$(1)/.cargo/env" && \
rustup target install aarch64-unknown-linux-gnu && \
rustup target install arm-unknown-linux-gnueabihf && \
rustup default nightly-2023-12-18; \
rustup default nightly-2023-12-18 && \
cargo --version >/dev/null;
fi
endef

Expand Down

0 comments on commit e202ddf

Please sign in to comment.