Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

sp-core full_crypto is no_std incompatible #12793

Closed
2 tasks done
Slesarew opened this issue Nov 28, 2022 · 4 comments
Closed
2 tasks done

sp-core full_crypto is no_std incompatible #12793

Slesarew opened this issue Nov 28, 2022 · 4 comments
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.

Comments

@Slesarew
Copy link

Is there an existing issue?

  • I have searched the existing issues

Experiencing problems? Have you tried our Stack Exchange first?

  • This is not a support question.

Description of bug

When building for no_std targets, sp-core dependency fails due to issue with libsecp256k1

$cargo build --target=thumbv7m-none-eabi

<truncated>

error[E0463]: can't find crate for `std`
  --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/subtle-2.4.1/src/lib.rs:88:1
   |
88 | extern crate std;
   | ^^^^^^^^^^^^^^^^^ can't find crate
   |
   = note: the `thumbv7m-none-eabi` target may not support the standard library
   = help: consider building the standard library from source with `cargo build -Zbuild-std`


See more details and proposed fix paritytech/libsecp256k1#146

Steps to reproduce

  1. Install appropriate targets
  2. $cargo generate --git https://github.com/rust-embedded/cortex-m-quickstart
  3. give test project a name, cd
  4. add to Cargo.toml sp-core = {version = "7.0.0", default-features = false, features = ["full_crypto"]} dependency
  5. $cargo build --target=thumbv7m-none-eabi
@github-actions github-actions bot added the J2-unconfirmed Issue might be valid, but it’s not yet known. label Nov 28, 2022
@bkchr
Copy link
Member

bkchr commented Nov 30, 2022

There was recently an issue around no_std incompatibility. Which was solved? #12225

Maybe the problem is the target architecture.

@Slesarew
Copy link
Author

Looks similar, but this time it's ECDSA, different crypto and different crate. Issue you refer to is about ed25519-zebra crate, while this is libsecp256k1 crate, and it still persists even in 7.0.0

With a tweak proposed above it builds nicely, should be a simple fix since the lib is also owned by Parity.

@bkchr
Copy link
Member

bkchr commented Nov 30, 2022

Ahh the problem is that libsecp256k1 is pulled in build-dependencies.

The solution to your problem is to add:

[workspace]
resolver = "2"

in your workspace Cargo.toml.

@Slesarew
Copy link
Author

It does work indeed, did not notice that generate script still uses 2018 rust version. Setting rust edition to 2021 seems even better here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
J2-unconfirmed Issue might be valid, but it’s not yet known.
Projects
None yet
Development

No branches or pull requests

2 participants