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

ecdsa and associated features not working in wasm #1819

Closed
Kofituo opened this issue Oct 8, 2024 · 2 comments
Closed

ecdsa and associated features not working in wasm #1819

Kofituo opened this issue Oct 8, 2024 · 2 comments

Comments

@Kofituo
Copy link

Kofituo commented Oct 8, 2024

Hello,
When I add subxt-signer to my Cargo.toml and build with wasm-pack test --chrome --headless, I get this error

kofiotuo@Kofis-MacBook-Pro-2 Frontend % wasm-pack test --chrome --headless
[INFO]: 🎯  Checking for the Wasm target...
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
    Blocking waiting for file lock on package cache
   Compiling libp2p-request-response v0.27.0
   Compiling libp2p-gossipsub v0.47.0
   Compiling secp256k1-sys v0.9.2
   Compiling libp2p-identify v0.45.0
   Compiling libp2p-relay v0.18.0
   Compiling libp2p-kad v0.46.2
   Compiling libp2p-dcutr v0.12.0
   Compiling libp2p-connection-limits v0.4.0
   Compiling libp2p-ping v0.45.0
   Compiling libp2p-allow-block-list v0.4.0
   Compiling libp2p-autonat v0.13.0
   Compiling libp2p-rendezvous v0.15.0
   Compiling libp2p v0.54.1
The following warnings were emitted during compilation:

warning: [email protected]: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: [email protected]: 1 error generated.
warning: [email protected]: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
warning: [email protected]: 1 error generated.

error: failed to run custom build command for `secp256k1-sys v0.9.2`

Caused by:
  process didn't exit successfully: `/Users/kofiotuo/IdeaProjects/Frontend/target/debug/build/secp256k1-sys-b670370f0286fbad/build-script-build` (exit status: 1)
  --- stdout
  OUT_DIR = Some(/Users/kofiotuo/IdeaProjects/Frontend/target/wasm32-unknown-unknown/debug/build/secp256k1-sys-d1305604f429b824/out)
  TARGET = Some(wasm32-unknown-unknown)
  OPT_LEVEL = Some(0)
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CC_wasm32-unknown-unknown
  CC_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CC_wasm32_unknown_unknown
  CC_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CC
  TARGET_CC = None
  cargo:rerun-if-env-changed=CC
  CC = None
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  RUSTC_WRAPPER = None
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  cargo:rerun-if-env-changed=WASI_SYSROOT
  WASI_SYSROOT = None
  DEBUG = Some(true)
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  OUT_DIR = Some(/Users/kofiotuo/IdeaProjects/Frontend/target/wasm32-unknown-unknown/debug/build/secp256k1-sys-d1305604f429b824/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  cargo:rerun-if-env-changed=WASI_SYSROOT
  WASI_SYSROOT = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  OUT_DIR = Some(/Users/kofiotuo/IdeaProjects/Frontend/target/wasm32-unknown-unknown/debug/build/secp256k1-sys-d1305604f429b824/out)
  cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
  cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  cargo:rerun-if-env-changed=WASI_SYSROOT
  WASI_SYSROOT = None
  HOST = Some(aarch64-apple-darwin)
  cargo:rerun-if-env-changed=CFLAGS_wasm32-unknown-unknown
  CFLAGS_wasm32-unknown-unknown = None
  cargo:rerun-if-env-changed=CFLAGS_wasm32_unknown_unknown
  CFLAGS_wasm32_unknown_unknown = None
  cargo:rerun-if-env-changed=TARGET_CFLAGS
  TARGET_CFLAGS = None
  cargo:rerun-if-env-changed=CFLAGS
  CFLAGS = None
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.

  --- stderr


  error occurred: Command "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-fPIC" "-fno-exceptions" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm/wasm-sysroot" "-I" "wasm/wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_API=" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DENABLE_MODULE_ELLSWIFT=1" "-Dprintf(...)=" "-DECMULT_GEN_PREC_BITS=4" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-DENABLE_MODULE_RECOVERY=1" "-o" "/Users/kofiotuo/IdeaProjects/Frontend/target/wasm32-unknown-unknown/debug/build/secp256k1-sys-d1305604f429b824/out/3fec8a5f3c4f77fb-wasm.o" "-c" "wasm/wasm.c" with args clang did not execute successfully (status code exit status: 1).


warning: build failed, waiting for other jobs to finish...
Error: Compilation of your program failed
Caused by: Compilation of your program failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: cd "/Users/kofiotuo/IdeaProjects/Frontend" && "cargo" "build" "--tests" "--target" "wasm32-unknown-unknown"
k

This is how it's added

subxt-signer = { version = "0.37.0", default-features = false, features = ["unstable-eth", "subxt"] }
@Kofituo Kofituo changed the title ecdsa and associated features not working in warm ecdsa and associated features not working in wasm Oct 8, 2024
@jsdw
Copy link
Collaborator

jsdw commented Nov 13, 2024

I bumped into this the other day, and the reason is that the clang version installed on MacOS by default doesn't know about a wasm32-unknown-unknown target when compiling the crypto code there.

The fix for me was to run:

brew install llvm
echo 'export PATH="/opt/homebrew/opt/llvm/bin:$PATH"' >> ~/.zshrc

Then restart your terminal and try again!

@Kofituo
Copy link
Author

Kofituo commented Nov 13, 2024

Thanks. It works now

@Kofituo Kofituo closed this as completed Nov 13, 2024
@Kofituo Kofituo reopened this Nov 13, 2024
@Kofituo Kofituo closed this as completed Nov 13, 2024
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