Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newest rust versions seem incompatible with ledger #157

Open
SWvheerden opened this issue Jan 9, 2025 · 3 comments
Open

Newest rust versions seem incompatible with ledger #157

SWvheerden opened this issue Jan 9, 2025 · 3 comments

Comments

@SWvheerden
Copy link

It seems like the newest rust versions don't compile with what I suspect is -Zbuild-std
Any attempt to build our ledger application with the ledger-app-builder version higher than 3.43.0 leads to the following rust error

error[E0432]: unresolved imports `super::key::Key`, `super::key::LazyKey`, `super::key::get`, `super::key::set`build.rs), ledger_device_sdk(build.rs)                                                                                                                                                                                                                                                                          
 --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/sys/thread_local/os.rs:1:18
  |
1 | use super::key::{Key, LazyKey, get, set};
  |                  ^^^  ^^^^^^^  ^^^  ^^^ no `set` in `sys::thread_local::key`
  |                  |    |        |
  |                  |    |        no `get` in `sys::thread_local::key`
  |                  |    no `LazyKey` in `sys::thread_local::key`
  |                  no `Key` in `sys::thread_local::key`
  |
@SWvheerden
Copy link
Author

The full error looks as follows:

   Compiling minotari_ledger_wallet v1.9.2-pre.0 (/app/applications/minotari_ledger_wallet/wallet)
error[E0432]: unresolved imports `super::key::Key`, `super::key::LazyKey`, `super::key::get`, `super::key::set`build.rs), ledger_device_sdk(build.rs)                                                                                                                                                                                                                                                                          
 --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/sys/thread_local/os.rs:1:18
  |
1 | use super::key::{Key, LazyKey, get, set};
  |                  ^^^  ^^^^^^^  ^^^  ^^^ no `set` in `sys::thread_local::key`
  |                  |    |        |
  |                  |    |        no `get` in `sys::thread_local::key`
  |                  |    no `LazyKey` in `sys::thread_local::key`
  |                  no `Key` in `sys::thread_local::key`
  |
note: module `crate::collections::hash::set` exists but is inaccessible
 --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/collections/hash/mod.rs:4:1
  |
4 | pub mod set;
  | ^^^^^^^^^^^^ not accessible


error[E0432]: unresolved imports `crate::sys::thread_local::key::LazyKey`, `crate::sys::thread_local::key::set`ld.rs), ledger_device_sdk(build.rs)                                                                                                                                                                                                                                                                             
 --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/sys/thread_local/guard/key.rs:6:37
  |
6 | use crate::sys::thread_local::key::{LazyKey, set};
  |                                     ^^^^^^^  ^^^ no `set` in `sys::thread_local::key`
  |                                     |
  |                                     no `LazyKey` in `sys::thread_local::key`
  |
note: module `crate::collections::hash::set` exists but is inaccessible
 --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/collections/hash/mod.rs:4:1
  |
4 | pub mod set;
  | ^^^^^^^^^^^^ not accessible


error[E0425]: cannot find function `fill_bytes` in module `sys`ecure_sdk_sys(build.rs)                                                                                                                                                                                                                                                                                                                                         
  --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/random.rs:67:14
   |
67 |         sys::fill_bytes(bytes)
   |              ^^^^^^^^^^ not found in `sys`


error[E0277]: the trait bound `System: core::alloc::GlobalAlloc` is not satisfiedd.rs)                                                                                                                                                                                                                                                                                                                                         
  --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/sys/alloc/mod.rs:59:42
   |
59 |         let new_ptr = GlobalAlloc::alloc(alloc, new_layout);
   |                       ------------------ ^^^^^ the trait `core::alloc::GlobalAlloc` is not implemented for `System`
   |                       |
   |                       required by a bound introduced by this call


error[E0277]: the trait bound `System: core::alloc::GlobalAlloc` is not satisfied
  --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/sys/alloc/mod.rs:63:34
   |
63 |             GlobalAlloc::dealloc(alloc, ptr, old_layout);
   |             -------------------- ^^^^^ the trait `core::alloc::GlobalAlloc` is not implemented for `System`
   |             |
   |             required by a bound introduced by this call


error[E0425]: cannot find function `fill_bytes` in this scope_secure_sdk_sys(build.rs)                                                                                                                                                                                                                                                                                                                                         
  --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/sys/random/mod.rs:94:5
   |
94 |     fill_bytes(&mut buf);
   |     ^^^^^^^^^^ not found in this scope


error[E0277]: the trait bound `System: core::alloc::GlobalAlloc` is not satisfiedd.rs)                                                                                                                                                                                                                                                                                                                                         
   --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/alloc.rs:142:47
    |
142 |                     GlobalAlloc::alloc_zeroed(self, layout)
    |                     ------------------------- ^^^^ the trait `core::alloc::GlobalAlloc` is not implemented for `System`
    |                     |
    |                     required by a bound introduced by this call


    Building error[E0277]: the trait bound `System: core::alloc::GlobalAlloc` is not satisfied
   --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/alloc.rs:144:40
    |
144 |                     GlobalAlloc::alloc(self, layout)
    |                     ------------------ ^^^^ the trait `core::alloc::GlobalAlloc` is not implemented for `System`
    |                     |
    |                     required by a bound introduced by this call

[==================>      ] 145/186: std, ledger_secure_sdk_sys(build.rs)                                                                                                                                                                                                                                                                                                                                         
error[E0277]: the trait bound `System: core::alloc::GlobalAlloc` is not satisfiedd.rs)                                                                                                                                                                                                                                                                                                                                         
   --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/alloc.rs:178:52
    |
178 |                 let raw_ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), old_layout, new_size);
    |                               -------------------- ^^^^ the trait `core::alloc::GlobalAlloc` is not implemented for `System`
    |                               |
    |                               required by a bound introduced by this call


error[E0277]: the trait bound `System: core::alloc::GlobalAlloc` is not satisfied
   --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/alloc.rs:220:43
    |
220 |             unsafe { GlobalAlloc::dealloc(self, ptr.as_ptr(), layout) }
    |                      -------------------- ^^^^ the trait `core::alloc::GlobalAlloc` is not implemented for `System`
    |                      |
    |                      required by a bound introduced by this call


error[E0277]: the trait bound `System: core::alloc::GlobalAlloc` is not satisfiedd.rs)                                                                                                                                                                                                                                                                                                                                         
   --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/alloc.rs:270:52
    |
270 |                 let raw_ptr = GlobalAlloc::realloc(self, ptr.as_ptr(), old_layout, new_size);
    |                               -------------------- ^^^^ the trait `core::alloc::GlobalAlloc` is not implemented for `System`
    |                               |
    |                               required by a bound introduced by this call


error[E0599]: no method named `alloc` found for struct `System` in the current scopes)                                                                                                                                                                                                                                                                                                                                         
   --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/alloc.rs:401:20
    |
132 | pub struct System;
    | ----------------- method `alloc` not found for this struct
...
401 |             System.alloc(layout)
    |                    ^^^^^
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `alloc`, perhaps you need to implement it:
            candidate #1: `core::alloc::GlobalAlloc`
help: there is a method `allocate` with a similar name
    |
401 |             System.allocate(layout)
    |                    ~~~~~~~~


error[E0599]: no method named `dealloc` found for struct `System` in the current scope                                                                                                                                                                                                                                                                                                                                         
   --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/alloc.rs:409:25
    |
132 | pub struct System;
    | ----------------- method `dealloc` not found for this struct
...
409 |         unsafe { System.dealloc(ptr, Layout::from_size_align_unchecked(size, align)) }
    |                         ^^^^^^^
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `dealloc`, perhaps you need to implement it:
            candidate #1: `core::alloc::GlobalAlloc`
help: there is a method `deallocate` with a similar name
    |
409 |         unsafe { System.deallocate(ptr, Layout::from_size_align_unchecked(size, align)) }
    |                         ~~~~~~~~~~


error[E0599]: no method named `realloc` found for struct `System` in the current scope                                                                                                                                                                                                                                                                                                                                         
   --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/alloc.rs:423:20
    |
132 | pub struct System;
    | ----------------- method `realloc` not found for this struct
...
423 |             System.realloc(ptr, old_layout, new_size)
    |                    ^^^^^^^ method not found in `System`
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `realloc`, perhaps you need to implement it:
            candidate #1: `core::alloc::GlobalAlloc`


error[E0599]: no method named `alloc_zeroed` found for struct `System` in the current scope
   --> /opt/rustup/toolchains/nightly-2024-11-22-aarch64-unknown-linux-musl/lib/rustlib/src/rust/library/std/src/alloc.rs:433:20
    |
132 | pub struct System;
    | ----------------- method `alloc_zeroed` not found for this struct
...
433 |             System.alloc_zeroed(layout)
    |                    ^^^^^^^^^^^^
    |
    = help: items from traits can only be used if the trait is implemented and in scope
    = note: the following trait defines an item `alloc_zeroed`, perhaps you need to implement it:
            candidate #1: `core::alloc::GlobalAlloc`
help: there is a method `allocate_zeroed` with a similar name
    |
433 |             System.allocate_zeroed(layout)
    |                    ~~~~~~~~~~~~~~~

    Building 
Some errors have detailed explanations: E0277, E0425, E0432, E0599.e_sdk_sys(build.rs)                                                                                                                                                                                                                                                                                                                                         

For more information about an error, try `rustc --explain E0277`.ure_sdk_sys(build.rs)                                                                                                                                                                                                                                                                                                                                         

error: could not compile `std` (lib) due to 15 previous errors
warning: build failed, waiting for other jobs to finish...
thread 'main' panicked at /opt/.cargo/registry/src/index.crates.io-6f17d22bba15001f/cargo-ledger-1.5.1/src/main.rs:274:41:
called `Option::unwrap()` on a `None` value
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

@tdejoigny-ledger
Copy link
Contributor

@SWvheerden what is your application ?
As you can see here most of the apps compile correctly
https://github.com/LedgerHQ/ledger-device-rust-sdk/actions/runs/12674487413

@SWvheerden
Copy link
Author

this is project we are trying to compile: https://github.com/tari-project/tari/tree/development/applications/minotari_ledger_wallet/wallet

I had to lock the build image to 3.43.0 and ledger_secure_sdk_sys to 1.5.3 to keep it compiling and working.

Updating ledger_secure_sdk_sys to 1.6.x breaks on a rust version problem, which I suspect is why the build image has rust updated. But the updated rust wont build at all, I suspect its to do with this: -Zbuild-std as I see issues on building this on nightly 2024 versions. But we don't directly call this. Our build command is simply:

docker run --rm -it \
  -v ".:/app" \
  -w /app/applications/minotari_ledger_wallet/wallet \
  ghcr.io/ledgerhq/ledger-app-builder/ledger-app-builder \
  cargo ledger build {TARGET}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants