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 to wasm with crypto-primitives feature is not possible on macOS #231

Open
Bargsteen opened this issue Mar 8, 2023 · 0 comments
Labels
[Type] Bug Something isn't working

Comments

@Bargsteen
Copy link
Contributor

Bug Description
It is currently not possible to compile to the wasm32-unknown-unknown target on macOS when the crypto-primitives feature is enabled.

The issue is that the library we use for some of the cryptographic primitives, secp256k1, doesn't support this target on macOS.
They are aware of the issue, but it sounds like a fix is not coming along soon. Actually, it sounds like it shouldn't work for wasm32-unknown-unknown on any platform, but it works on Linux (at least the parts we use in concordium-std).

We might consider replacing it with a pure rust library if we can find a suitable one.

Steps to Reproduce

  1. Use concordium-std in a project (fx a smart contract ;))
  2. Enable the crypto-primitives feature.
  3. Compile to wasm32-unknown-unknown (fx by running cargo concordium build)

Expected Result
Compiles successfully.

Actual Result
Compilation fails with:

The following warnings were emitted during compilation:

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

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

Caused by:
  process didn't exit successfully: `/Users/kasper/Projects/concordium-rust-smart-contracts/examples/cis2-wccd/target/concordium/release/build/secp256k1-sys-67ff0bf93ddea026/build-script-build` (exit status: 1)
  --- stdout
  TARGET = Some("wasm32-unknown-unknown")
  OPT_LEVEL = Some("s")
  HOST = Some("x86_64-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=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:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  DEBUG = Some("false")
  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=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:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
  CRATE_CC_NO_DEFAULTS = None
  running: "clang" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm/wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_API=" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DECMULT_WINDOW_SIZE=4" "-DECMULT_GEN_PREC_BITS=2" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-o" "/Users/kasper/Projects/concordium-rust-smart-contracts/examples/cis2-wccd/target/concordium/wasm32-unknown-unknown/release/build/secp256k1-sys-f5ac37fe988cf4c9/out/wasm/wasm.o" "-c" "wasm/wasm.c"
  cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
  cargo:warning=1 error generated.
  exit status: 1

  --- stderr


  error occurred: Command "clang" "-Os" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm/wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_API=" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DECMULT_WINDOW_SIZE=4" "-DECMULT_GEN_PREC_BITS=2" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-o" "/Users/kasper/Projects/concordium-rust-smart-contracts/examples/cis2-wccd/target/concordium/wasm32-unknown-unknown/release/build/secp256k1-sys-f5ac37fe988cf4c9/out/wasm/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: Could not build smart contract.

Caused by:
    Compilation failed.

Versions

  • Software Version: 6.0.1
  • OS: macOS
@Bargsteen Bargsteen added the [Type] Bug Something isn't working label Mar 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Type] Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant