concordium-rust-smart-contracts
concordium-rust-smart-contracts copied to clipboard
Compiling to wasm with `crypto-primitives` feature is not possible on macOS
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
- Use
concordium-std
in a project (fx a smart contract ;)) - Enable the
crypto-primitives
feature. - Compile to
wasm32-unknown-unknown
(fx by runningcargo 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