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

Compiling your crate to WebAssembly failed #49

Open
pacu opened this issue Oct 29, 2024 · 4 comments
Open

Compiling your crate to WebAssembly failed #49

pacu opened this issue Oct 29, 2024 · 4 comments
Assignees

Comments

@pacu
Copy link

pacu commented Oct 29, 2024

Hi! I'm trying to build WebZ.js from source using the README.md instructions and I'm not being able to.

I have all the pre-requisites installed.
wasm32-unknown-unknown is installed and up-to-date and the nightly build specified by the toolchain file also is.

Mac: M1 Max 32 GB
OS: Mac OS 14.7 (23H124)

just build-wallet
cd crates/webz-wallet && wasm-pack build -t web --release --scope webzjs --out-dir ../../packages/webz-wallet --no-default-features --features="wasm wasm-parallel " -Z build-std="panic_abort,std"
[INFO]: 🎯  Checking for the Wasm target...
[INFO]: 🌀  Compiling to Wasm...
    Updating crates.io index
   Compiling secp256k1-sys v0.8.1
   Compiling maybe-rayon v0.1.1
   Compiling bellman v0.14.0
   Compiling thread_local v1.1.8
   Compiling hash32 v0.2.1
   Compiling smallvec v1.13.2
   Compiling wagyu-zcash-parameters-4 v0.2.0
   Compiling stable_deref_trait v1.2.0
   Compiling wagyu-zcash-parameters-5 v0.2.0
   Compiling wagyu-zcash-parameters-3 v0.2.0
   Compiling halo2_proofs v0.3.0
   Compiling wagyu-zcash-parameters-2 v0.2.0
   Compiling wagyu-zcash-parameters-1 v0.2.0
   Compiling wagyu-zcash-parameters-6 v0.2.0
   Compiling tracing-subscriber v0.3.18
   Compiling wagyu-zcash-parameters v0.2.0
   Compiling heapless v0.7.17
   Compiling async-std v1.13.0
   Compiling futures v0.3.30
   Compiling unicode-normalization v0.1.23
   Compiling httparse v1.9.4
   Compiling pbkdf2 v0.12.2
   Compiling wasm-streams v0.4.0
   Compiling uuid v1.10.0
   Compiling cobs v0.2.3
   Compiling sapling-crypto v0.3.0
   Compiling tokio_with_wasm v0.7.1
   Compiling bip0039 v0.12.0
   Compiling postcard v1.0.10
   Compiling indexed_db_futures v0.5.0
   Compiling tracing-web v0.1.3
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.8.1`

Caused by:
  process didn't exit successfully: `[REDACTED]/WebZjs/target/release/build/secp256k1-sys-2ec8c9dd4060fdcd/build-script-build` (exit status: 1)
  --- stdout
  OUT_DIR = Some([REDACTED]/WebZjs/target/wasm32-unknown-unknown/release/build/secp256k1-sys-ff7bc03772ba7720/out)
  TARGET = Some(wasm32-unknown-unknown)
  OPT_LEVEL = Some(3)
  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(false)
  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([REDACTED]/WebZjs/target/wasm32-unknown-unknown/release/build/secp256k1-sys-ff7bc03772ba7720/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
  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" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "-fno-exceptions" "--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" "-DECMULT_GEN_PREC_BITS=4" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-o" "[REDACTED]/WebZjs/target/wasm32-unknown-unknown/release/build/secp256k1-sys-ff7bc03772ba7720/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: Compiling your crate to WebAssembly failed
Caused by: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: cd "[REDACTED]/WebZjs/crates/webz-wallet" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown" "--no-default-features" "--features=wasm wasm-parallel " "-Z" "build-std=panic_abort,std"
error: Recipe `build-wallet` failed on line 10 with exit code 1
error: Recipe `build` failed on line 5 with exit code 1
@willemolding
Copy link
Contributor

willemolding commented Nov 8, 2024

Thanks for posting.

I think this error might be related to having an older versions of clang and llvm installed that don't support building for wasm. What is the output of running

clang --version

and

llvm-gcc --version

on your machine?

You might be able to update them through xcode-tools or some other way depending on how you have things set up.

We will definitely update the pre-requisites in the readme once we figure out what it is exactly.

@pacu
Copy link
Author

pacu commented Nov 12, 2024

Oh! I should have checked this before upgrading the OS :/

@pacu
Copy link
Author

pacu commented Nov 12, 2024

@willemolding

clang --version
Apple clang version 16.0.0 (clang-1600.0.26.4)
Target: arm64-apple-darwin24.1.0
Thread model: posix

and same for

llvm-gcc --version
Apple clang version 16.0.0 (clang-1600.0.26.4)
Target: arm64-apple-darwin24.1.0
Thread model: posix

@ec2
Copy link
Member

ec2 commented Dec 4, 2024

@pacu Can you try updating your clang version? This is mine:

clang --version
Homebrew clang version 18.1.8
Target: arm64-apple-darwin24.1.0
Thread model: posix

llvm-gcc --version
Apple clang version 15.0.0 (clang-1500.3.9.4)
Target: arm64-apple-darwin24.1.0
Thread model: posix

@ec2 ec2 self-assigned this Dec 4, 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

3 participants