paritytech / libsecp256k1

Pure Rust Implementation of secp256k1.
Apache License 2.0
175 stars 84 forks source link

no-std support broken #68

Closed birchmd closed 2 years ago

birchmd commented 3 years ago

I think that https://github.com/paritytech/libsecp256k1/commit/3aa638bdee7fff9c11ce5f22d8cd19fa163861ac made a change which causes std to be pulled in even if default-features = false.

To reproduce:

First, create a no-std project with #[panic_handler] and #[alloc_error_handler] functions. Include as a dependency

libsecp256k1 = { git = "https://github.com/paritytech/libsecp256k1", rev="df8aaf1ba395e989546da001374a08145cdce0ca", default-features = false }

and make use of it. This compiles fine.

Now try with the dependency using the next commit:

libsecp256k1 = { git = "https://github.com/paritytech/libsecp256k1", rev="3aa638bdee7fff9c11ce5f22d8cd19fa163861ac", default-features = false }

and compile again. The following errors appear

error[E0152]: found duplicate lang item `panic_impl`
  --> src/lib.rs:49:5
   |
49 |     pub unsafe fn on_panic(_info: &::core::panic::PanicInfo) -> ! {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the lang item is first defined in crate `std` (which `libsecp256k1` depends on)
   = note: first definition in `std` loaded from /home/birchmd/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-c154c491353fefeb.rlib
   = note: second definition in the local crate (`aurora_engine`)

error[E0152]: found duplicate lang item `oom`
  --> src/lib.rs:56:5
   |
56 |     pub unsafe fn on_alloc_error(_: core::alloc::Layout) -> ! {
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: the lang item is first defined in crate `std` (which `libsecp256k1` depends on)
   = note: first definition in `std` loaded from /home/birchmd/.rustup/toolchains/nightly-2021-03-25-x86_64-unknown-linux-gnu/lib/rustlib/wasm32-unknown-unknown/lib/libstd-c154c491353fefeb.rlib
   = note: second definition in the local crate (`aurora_engine`)

error: aborting due to 2 previous errors

Note the error says that libsecp256k1 depends on std even though default-features = false.