-
Notifications
You must be signed in to change notification settings - Fork 296
Closed
Description
I've been reading a ton of issues and trying to understand the state of WASM support in this library, but I'm now totally unsure because my problem seems to be unrelated to everything else and all the issues I read were from some time ago, so I decided to open this one.
It has this very simple reproducible example with two files:
# Cargo.toml
[package]
name = "foo"
version = "0.1.0"
edition = "2024"
[dependencies]
secp256k1 = "0.31.1"
getrandom = { version = "0.3", features = ["wasm_js"] }
// src/main.rs
fn main() {
println!("hello world");
}
Then try to build it (the getrandom part is apparently necessary):
RUSTFLAGS='--cfg getrandom_backend="wasm_js"' cargo build --target wasm32-unknown-unknown
It fails with this:
Compiling secp256k1-sys v0.11.0
warning: [email protected]: In file included from depend/secp256k1/src/secp256k1.c:39:
warning: [email protected]: depend/secp256k1/src/hsort_impl.h:30:5: error: call to undeclared library function 'memmove' with type 'void *(void *, const void *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
warning: [email protected]: 30 | memmove(a, b, len);
warning: [email protected]: | ^
warning: [email protected]: depend/secp256k1/src/hsort_impl.h:30:5: note: include the header <string.h> or explicitly provide a declaration for 'memmove'
warning: [email protected]: 1 error generated.
warning: [email protected]: In file included from depend/secp256k1/src/secp256k1.c:39:
warning: [email protected]: depend/secp256k1/src/hsort_impl.h:30:5: error: call to undeclared library function 'memmove' with type 'void *(void *, const void *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
warning: [email protected]: 30 | memmove(a, b, len);
warning: [email protected]: | ^
warning: [email protected]: depend/secp256k1/src/hsort_impl.h:30:5: note: include the header <string.h> or explicitly provide a declaration for 'memmove'
warning: [email protected]: 1 error generated.
error: failed to run custom build command for `secp256k1-sys v0.11.0`
Caused by:
process didn't exit successfully: `/tmp/foo/target/debug/build/secp256k1-sys-83d023945924158e/build-script-build` (exit status: 1)
--- stdout
OUT_DIR = Some(/tmp/foo/target/wasm32-unknown-unknown/debug/build/secp256k1-sys-2d0c6ddc3f632ec7/out)
OPT_LEVEL = Some(0)
TARGET = Some(wasm32-unknown-unknown)
HOST = Some(x86_64-unknown-linux-gnu)
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
DEBUG = Some(true)
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = 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_ENCODED_RUSTFLAGS = Some(--cfggetrandom_backend="wasm_js")
OUT_DIR = Some(/tmp/foo/target/wasm32-unknown-unknown/debug/build/secp256k1-sys-2d0c6ddc3f632ec7/out)
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
TARGET = Some(wasm32-unknown-unknown)
HOST = Some(x86_64-unknown-linux-gnu)
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = 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
OUT_DIR = Some(/tmp/foo/target/wasm32-unknown-unknown/debug/build/secp256k1-sys-2d0c6ddc3f632ec7/out)
cargo:rerun-if-env-changed=CC_ENABLE_DEBUG_OUTPUT
cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS
CRATE_CC_NO_DEFAULTS = None
TARGET = Some(wasm32-unknown-unknown)
HOST = Some(x86_64-unknown-linux-gnu)
cargo:rerun-if-env-changed=CFLAGS
CFLAGS = None
cargo:rerun-if-env-changed=TARGET_CFLAGS
TARGET_CFLAGS = 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:warning=In file included from depend/secp256k1/src/secp256k1.c:39:
cargo:warning=depend/secp256k1/src/hsort_impl.h:30:5: error: call to undeclared library function 'memmove' with type 'void *(void *, const void *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
cargo:warning= 30 | memmove(a, b, len);
cargo:warning= | ^
cargo:warning=depend/secp256k1/src/hsort_impl.h:30:5: note: include the header <string.h> or explicitly provide a declaration for 'memmove'
cargo:warning=1 error generated.
cargo:warning=In file included from depend/secp256k1/src/secp256k1.c:39:
cargo:warning=depend/secp256k1/src/hsort_impl.h:30:5: error: call to undeclared library function 'memmove' with type 'void *(void *, const void *, unsigned long)'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
cargo:warning= 30 | memmove(a, b, len);
cargo:warning= | ^
cargo:warning=depend/secp256k1/src/hsort_impl.h:30:5: note: include the header <string.h> or explicitly provide a declaration for 'memmove'
cargo:warning=1 error generated.
--- stderr
error occurred in cc-rs: command did not execute successfully (status code exit status: 1): LC_ALL="C" "clang" "-O0" "-ffunction-sections" "-fdata-sections" "-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" "-Wno-unused-function" "-Wno-unused-parameter" "-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" "-o" "/tmp/foo/target/wasm32-unknown-unknown/debug/build/secp256k1-sys-2d0c6ddc3f632ec7/out/fce6141bfa9bf74c-secp256k1.o" "-c" "depend/secp256k1/src/secp256k1.c"
My tooling is all basically new, but if it matters I can give more detail. I don't know if this memmove
stuff is relevant or if I'm doing something totally wrong here and some files are missing. Anyway, thank you for your help!
Metadata
Metadata
Assignees
Labels
No labels