From 118d0f849bfa6fd763b70965fafd7e33cacfd687 Mon Sep 17 00:00:00 2001 From: Marko Bencun Date: Mon, 13 May 2024 09:29:17 +0200 Subject: [PATCH] Dockerfile: bump Rust toolchain to 1.78 This reduces the fw binary size by 4176 bytes as compared to the v9.18.0 release. Also bump LLVM 18 - it is unrelated but I did it anyway as the Rust release notes also mentioned that they moved to LLVM 18. The workflow.rs change is due to this deprecation warning: ``` warning: creating a shared reference to mutable static is discouraged --> bitbox02-rust-c/src/workflow.rs:103:11 | 103 | match &CONFIRM_STATE { | ^^^^^^^^^^^^^^ shared reference to mutable static | = note: for more information, see issue #114447 = note: this will be a hard error in the 2024 edition = note: this shared reference has lifetime `'static`, but if the static ever gets mutated, or a mutable reference is created, then any further use of this shared reference is Undefined Behavior = note: `#[warn(static_mut_refs)]` on by default help: use `addr_of!` instead to create a raw pointer | 103 | match addr_of!(CONFIRM_STATE) { ``` --- .ci/run-container-ci | 2 +- Dockerfile | 10 +++++----- src/rust/bitbox02-rust-c/src/workflow.rs | 4 ++-- .../src/hww/api/ethereum/sign_typed_msg.rs | 5 ++++- src/rust/rust-toolchain | 2 +- 5 files changed, 13 insertions(+), 10 deletions(-) diff --git a/.ci/run-container-ci b/.ci/run-container-ci index a35332861..996013669 100755 --- a/.ci/run-container-ci +++ b/.ci/run-container-ci @@ -25,7 +25,7 @@ set -e set -x -CONTAINER=shiftcrypto/firmware_v2:37 +CONTAINER=shiftcrypto/firmware_v2:38 if [ "$1" == "pull" ] ; then docker pull "$CONTAINER" diff --git a/Dockerfile b/Dockerfile index 5ce3b9676..09ee291e3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -20,8 +20,8 @@ ENV DEBIAN_FRONTEND noninteractive RUN apt-get update && apt-get upgrade -y && apt-get install -y wget nano rsync curl gnupg2 jq unzip bzip2 # for clang-*-15, see https://apt.llvm.org/ -RUN echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" >> /etc/apt/sources.list && \ - echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-15 main" >> /etc/apt/sources.list && \ +RUN echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \ + echo "deb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main" >> /etc/apt/sources.list && \ wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - # Install gcc8-arm-none-eabi @@ -37,7 +37,7 @@ RUN mkdir ~/Downloads &&\ # Tools for building RUN apt-get update && apt-get install -y \ build-essential \ - llvm-15 \ + llvm-18 \ gcc-10 \ binutils \ valgrind \ @@ -68,8 +68,8 @@ RUN update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-10 100 RUN apt-get update && apt-get install -y \ python3 \ python3-pip \ - clang-format-15 \ - clang-tidy-15 + clang-format-18 \ + clang-tidy-18 RUN python3 -m pip install --upgrade pip diff --git a/src/rust/bitbox02-rust-c/src/workflow.rs b/src/rust/bitbox02-rust-c/src/workflow.rs index 2bde948df..1a3591934 100644 --- a/src/rust/bitbox02-rust-c/src/workflow.rs +++ b/src/rust/bitbox02-rust-c/src/workflow.rs @@ -100,8 +100,8 @@ pub unsafe extern "C" fn rust_workflow_unlock_poll(result_out: &mut bool) -> boo /// Returns true if there was a result. #[no_mangle] pub unsafe extern "C" fn rust_workflow_confirm_poll(result_out: &mut bool) -> bool { - match &CONFIRM_STATE { - TaskState::ResultAvailable(result) => { + match CONFIRM_STATE { + TaskState::ResultAvailable(ref result) => { CONFIRM_TITLE = None; CONFIRM_BODY = None; CONFIRM_PARAMS = None; diff --git a/src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs b/src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs index f182723d6..7f732ce9c 100644 --- a/src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs +++ b/src/rust/bitbox02-rust/src/hww/api/ethereum/sign_typed_msg.rs @@ -423,7 +423,10 @@ async fn hash_struct( child_formatted_path.push("".into()); for (index, member) in typ.members.iter().enumerate() { *child_path.last_mut().unwrap() = index as u32; - *child_formatted_path.last_mut().unwrap() = member.name.clone(); + child_formatted_path + .last_mut() + .unwrap() + .clone_from(&member.name); let member_type = member.r#type.as_ref().ok_or(Error::InvalidInput)?; encode_member( &mut hasher, diff --git a/src/rust/rust-toolchain b/src/rust/rust-toolchain index 32a6ce3c7..54227249d 100644 --- a/src/rust/rust-toolchain +++ b/src/rust/rust-toolchain @@ -1 +1 @@ -1.76.0 +1.78.0