Skip to content

Commit

Permalink
Dockerfile: bump Rust toolchain to 1.78
Browse files Browse the repository at this point in the history
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 <rust-lang/rust#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) {
```
  • Loading branch information
benma committed May 13, 2024
1 parent 13c527d commit 118d0f8
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .ci/run-container-ci
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 \
Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions src/rust/bitbox02-rust-c/src/workflow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/rust/rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.76.0
1.78.0

0 comments on commit 118d0f8

Please sign in to comment.