Can't `wasm-pack build`: No available targets are compatible with triple "wasm32-unknown-unknown"
Closed this issue ยท 10 comments
I was trying to run README instructions and this is what I got. It seems to have something to do with clang (and I'm running Apple clang version 12.0.0 (clang-1200.0.32.2)
).
OS: MacOS 11.2.3
error: failed to run custom build command for `secp256k1-sys v0.4.0`
Caused by:
process didn't exit successfully: `/Users/gleb/Workspace/sapio/plugin-example/target/release/build/secp256k1-sys-5e6f5fc641c49029/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-apple-darwin")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_BUILD=1" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DECMULT_GEN_PREC_BITS=4" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-DENABLE_MODULE_RECOVERY=1" "-o" "/Users/gleb/Workspace/sapio/plugin-example/target/wasm32-unknown-unknown/release/build/secp256k1-sys-1758a304c2fd7414/out/depend/secp256k1/contrib/lax_der_parsing.o" "-c" "depend/secp256k1/contrib/lax_der_parsing.c"
cargo:warning=error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
cargo:warning=1 error generated.
exit code: 1
--- stderr
error occurred: Command "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_BUILD=1" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DECMULT_GEN_PREC_BITS=4" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-DENABLE_MODULE_RECOVERY=1" "-o" "/Users/gleb/Workspace/sapio/plugin-example/target/wasm32-unknown-unknown/release/build/secp256k1-sys-1758a304c2fd7414/out/depend/secp256k1/contrib/lax_der_parsing.o" "-c" "depend/secp256k1/contrib/lax_der_parsing.c" with args "clang" did not execute successfully (status code exit code: 1).
warning: build failed, waiting for other jobs to finish...
Building [=============================================> ] 60/74: serde
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
gleb@Glebs-MacBook-Pro plugin-example %
gleb@Glebs-MacBook-Pro plugin-example % wasm-pack buildclang
error: The subcommand 'buildclang' wasn't recognized
Did you mean 'build'?
If you believe you received this message in error, try re-running with 'wasm-pack -- buildclang'
Got the same issue on cloud ubuntu by default, but then upgrading to clang-12 from clang-6 helped there.
You should probably open this issue in rust-secp rather than here?
I should figure out the min version of clang required for wasm32-unknown-unknown.
Short of that, run llc --version
and does it say it supports wasm?
Sorry it seems I don't have llvm
installed and I can't install it atm. I will come back here in a bit, if I don't respond soon feel free to close.
fixed?
please gimme couple more days :)
Got a new issue after I installed llvm:
[INFO]: ๐ฏ Checking for the Wasm target...
[INFO]: ๐ Compiling to Wasm...
Compiling secp256k1-sys v0.4.0
Compiling schemars v0.8.2
Compiling bitcoin_hashes v0.9.4
Compiling sapio-secp256k1 v0.20.1
LLVM ERROR: malformed uleb128, extends past end
The following warnings were emitted during compilation:
warning: In file included from depend/secp256k1/src/secp256k1.c:10:
warning: In file included from depend/secp256k1/src/assumptions.h:12:
warning: In file included from depend/secp256k1/src/util.h:16:
warning: wasm-sysroot/stdio.h:4:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_INT_SIZE = sizeof(int);
warning: ^
warning: wasm-sysroot/stdio.h:5:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_INT_ALIGN = alignof(int);
warning: ^
warning: wasm-sysroot/stdio.h:7:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_UNSIGNED_INT_SIZE = sizeof(unsigned int);
warning: ^
warning: wasm-sysroot/stdio.h:8:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_UNSIGNED_INT_ALIGN = alignof(unsigned int);
warning: ^
warning: wasm-sysroot/stdio.h:10:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_SIZE_T_SIZE = sizeof(size_t);
warning: ^
warning: wasm-sysroot/stdio.h:11:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_SIZE_T_ALIGN = alignof(size_t);
warning: ^
warning: wasm-sysroot/stdio.h:13:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_UNSIGNED_CHAR_SIZE = sizeof(unsigned char);
warning: ^
warning: wasm-sysroot/stdio.h:14:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_UNSIGNED_CHAR_ALIGN = alignof(unsigned char);
warning: ^
warning: wasm-sysroot/stdio.h:16:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_PTR_SIZE = sizeof(void*);
warning: ^
warning: wasm-sysroot/stdio.h:17:28: warning: 'extern' variable has an initializer [-Wextern-initializer]
warning: extern const unsigned char WASM32_PTR_ALIGN = alignof(void*);
warning: ^
warning: In file included from depend/secp256k1/src/secp256k1.c:13:
warning: depend/secp256k1/src/field_impl.h:266:13: warning: unused function 'rustsecp256k1_v0_4_0_fe_inv_all_var' [-Wunused-function]
warning: static void rustsecp256k1_v0_4_0_fe_inv_all_var(rustsecp256k1_v0_4_0_fe *r, const rustsecp256k1_v0_4_0_fe *a, size_t len) {
warning: ^
warning: In file included from depend/secp256k1/src/secp256k1.c:15:
warning: depend/secp256k1/src/group_impl.h:191:13: warning: unused function 'rustsecp256k1_v0_4_0_ge_set_infinity' [-Wunused-function]
warning: static void rustsecp256k1_v0_4_0_ge_set_infinity(rustsecp256k1_v0_4_0_ge *r) {
warning: ^
warning: depend/secp256k1/src/group_impl.h:658:12: warning: unused function 'rustsecp256k1_v0_4_0_gej_has_quad_y_var' [-Wunused-function]
warning: static int rustsecp256k1_v0_4_0_gej_has_quad_y_var(const rustsecp256k1_v0_4_0_gej *a) {
warning: ^
warning: In file included from depend/secp256k1/src/secp256k1.c:16:
warning: In file included from depend/secp256k1/src/ecmult_impl.h:16:
warning: In file included from depend/secp256k1/src/ecmult.h:13:
warning: depend/secp256k1/src/scratch.h:24:38: warning: unused function 'rustsecp256k1_v0_4_0_scratch_create' [-Wunused-function]
warning: static rustsecp256k1_v0_4_0_scratch* rustsecp256k1_v0_4_0_scratch_create(const rustsecp256k1_v0_4_0_callback* error_callback, size_t max_size);
warning: ^
warning: depend/secp256k1/src/scratch.h:26:13: warning: unused function 'rustsecp256k1_v0_4_0_scratch_destroy' [-Wunused-function]
warning: static void rustsecp256k1_v0_4_0_scratch_destroy(const rustsecp256k1_v0_4_0_callback* error_callback, rustsecp256k1_v0_4_0_scratch* scratch);
warning: ^
warning: In file included from depend/secp256k1/src/secp256k1.c:16:
warning: depend/secp256k1/src/ecmult_impl.h:1035:12: warning: unused function 'rustsecp256k1_v0_4_0_ecmult_multi_var' [-Wunused-function]
warning: static int rustsecp256k1_v0_4_0_ecmult_multi_var(const rustsecp256k1_v0_4_0_callback* error_callback, const rustsecp256k1_v0_4_0_ecmult_context *ctx, rustsecp256k1_v0_4_0_scratch *scratch, rustsecp256k1_v0_4_0_gej *r, const rustsecp256k1_v0_4_0_scalar *inp_g_sc, rustsecp256k1_v0_4_0_ecmult_multi_callback cb, void *cbdata, size_t n) {
warning: ^
warning: depend/secp256k1/src/ecmult_impl.h:621:12: warning: unused function 'rustsecp256k1_v0_4_0_ecmult_strauss_batch_single' [-Wunused-function]
warning: static int rustsecp256k1_v0_4_0_ecmult_strauss_batch_single(const rustsecp256k1_v0_4_0_callback* error_callback, const rustsecp256k1_v0_4_0_ecmult_context *actx, rustsecp256k1_v0_4_0_scratch *scratch, rustsecp256k1_v0_4_0_gej *r, const rustsecp256k1_v0_4_0_scalar *inp_g_sc, rustsecp256k1_v0_4_0_ecmult_multi_callback cb, void *cbdata, size_t n) {
warning: ^
warning: depend/secp256k1/src/ecmult_impl.h:863:15: warning: unused function 'rustsecp256k1_v0_4_0_pippenger_scratch_size' [-Wunused-function]
warning: static size_t rustsecp256k1_v0_4_0_pippenger_scratch_size(size_t n_points, int bucket_window) {
warning: ^
warning: depend/secp256k1/src/ecmult_impl.h:944:12: warning: unused function 'rustsecp256k1_v0_4_0_ecmult_pippenger_batch_single' [-Wunused-function]
warning: static int rustsecp256k1_v0_4_0_ecmult_pippenger_batch_single(const rustsecp256k1_v0_4_0_callback* error_callback, const rustsecp256k1_v0_4_0_ecmult_context *actx, rustsecp256k1_v0_4_0_scratch *scratch, rustsecp256k1_v0_4_0_gej *r, const rustsecp256k1_v0_4_0_scalar *inp_g_sc, rustsecp256k1_v0_4_0_ecmult_multi_callback cb, void *cbdata, size_t n) {
warning: ^
warning: 19 warnings generated.
warning: warning: /Library/Developer/CommandLineTools/usr/bin/ranlib: archive library: /Users/gleb/Workspace/sapio/plugin-example/target/wasm32-unknown-unknown/release/build/secp256k1-sys-1758a304c2fd7414/out/libsecp256k1.a the table of contents is empty (no object file members in the library define global symbols)
error: could not compile `secp256k1-sys`.
To learn more, run the command again with --verbose.
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
gleb@Glebs-MacBook-Pro plugin-example % llc -version
LLVM (http://llvm.org/):
LLVM version 11.1.0
Optimized build.
Default target: x86_64-apple-darwin20.3.0
Host CPU: skylake
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_32 - AArch64 (little endian ILP32)
aarch64_be - AArch64 (big endian)
amdgcn - AMD GCN GPUs
arm - ARM
arm64 - ARM64 (little endian)
arm64_32 - ARM64 (little endian ILP32)
armeb - ARM (big endian)
avr - Atmel AVR Microcontroller
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
hexagon - Hexagon
lanai - Lanai
mips - MIPS (32-bit big endian)
mips64 - MIPS (64-bit big endian)
mips64el - MIPS (64-bit little endian)
mipsel - MIPS (32-bit little endian)
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc64 - PowerPC 64
ppc64le - PowerPC 64 LE
r600 - AMD GPUs HD2XXX-HD6XXX
riscv32 - 32-bit RISC-V
riscv64 - 64-bit RISC-V
sparc - Sparc
sparcel - Sparc LE
sparcv9 - Sparc V9
systemz - SystemZ
thumb - Thumb
thumbeb - Thumb (big endian)
wasm32 - WebAssembly 32-bit
wasm64 - WebAssembly 64-bit
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
I have the exact same issue on ubuntu
$ uname -a
Linux wepa 5.4.0-74-generic #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
$ llc --version
LLVM (http://llvm.org/):
LLVM version 10.0.0
Optimized build.
Default target: x86_64-pc-linux-gnu
Host CPU: skylake
Registered Targets:
aarch64 - AArch64 (little endian)
aarch64_32 - AArch64 (little endian ILP32)
aarch64_be - AArch64 (big endian)
amdgcn - AMD GCN GPUs
arm - ARM
arm64 - ARM64 (little endian)
arm64_32 - ARM64 (little endian ILP32)
armeb - ARM (big endian)
avr - Atmel AVR Microcontroller
bpf - BPF (host endian)
bpfeb - BPF (big endian)
bpfel - BPF (little endian)
hexagon - Hexagon
lanai - Lanai
mips - MIPS (32-bit big endian)
mips64 - MIPS (64-bit big endian)
mips64el - MIPS (64-bit little endian)
mipsel - MIPS (32-bit little endian)
msp430 - MSP430 [experimental]
nvptx - NVIDIA PTX 32-bit
nvptx64 - NVIDIA PTX 64-bit
ppc32 - PowerPC 32
ppc64 - PowerPC 64
ppc64le - PowerPC 64 LE
r600 - AMD GPUs HD2XXX-HD6XXX
riscv32 - 32-bit RISC-V
riscv64 - 64-bit RISC-V
sparc - Sparc
sparcel - Sparc LE
sparcv9 - Sparc V9
systemz - SystemZ
thumb - Thumb
thumbeb - Thumb (big endian)
wasm32 - WebAssembly 32-bit
wasm64 - WebAssembly 64-bit
x86 - 32-bit X86: Pentium-Pro and above
x86-64 - 64-bit X86: EM64T and AMD64
xcore - XCore
$ cd plugin-example && wasm-pack build && cd ..
[INFO]: Checking for the Wasm target...
[INFO]: Compiling to Wasm...
Compiling proc-macro2 v1.0.27
Compiling unicode-xid v0.2.2
Compiling syn v1.0.72
Compiling rand_core v0.4.2
Compiling autocfg v0.1.7
Compiling serde_derive v1.0.126
Compiling ryu v1.0.5
Compiling serde v1.0.126
Compiling serde_json v1.0.64
Compiling schemars v0.8.3
Compiling cc v1.0.68
Compiling itoa v0.4.7
Compiling dyn-clone v1.0.4
Compiling wasm-bindgen-shared v0.2.74
Compiling log v0.4.14
Compiling bech32 v0.7.3
Compiling cfg-if v1.0.0
Compiling lazy_static v1.4.0
Compiling bumpalo v3.7.0
Compiling wasm-bindgen v0.2.74
Compiling paste v1.0.5
Compiling rand_core v0.3.1
Compiling rand_os v0.1.3
Compiling rand_jitter v0.1.4
Compiling rand_pcg v0.1.2
Compiling rand_chacha v0.1.1
Compiling rand v0.6.5
Compiling rand_hc v0.1.0
Compiling rand_xorshift v0.1.1
Compiling rand_isaac v0.1.1
Compiling secp256k1-sys v0.4.0
error: failed to run custom build command for `secp256k1-sys v0.4.0`
Caused by:
process didn't exit successfully: `/home/rust/dev/sapio/plugin-example/target/release/build/secp256k1-sys-0d6bf46ad28c7a08/build-script-build` (exit code: 1)
--- stdout
TARGET = Some("wasm32-unknown-unknown")
OPT_LEVEL = Some("3")
HOST = Some("x86_64-unknown-linux-gnu")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
DEBUG = Some("false")
CC_wasm32-unknown-unknown = None
CC_wasm32_unknown_unknown = None
TARGET_CC = None
CC = None
CFLAGS_wasm32-unknown-unknown = None
CFLAGS_wasm32_unknown_unknown = None
TARGET_CFLAGS = None
CFLAGS = None
CRATE_CC_NO_DEFAULTS = None
running: "clang" "-O3" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-I" "depend/secp256k1/" "-I" "depend/secp256k1/include" "-I" "depend/secp256k1/src" "-I" "wasm-sysroot" "-Wall" "-Wextra" "-DSECP256K1_BUILD=1" "-DENABLE_MODULE_ECDH=1" "-DENABLE_MODULE_SCHNORRSIG=1" "-DENABLE_MODULE_EXTRAKEYS=1" "-DECMULT_GEN_PREC_BITS=4" "-DUSE_NUM_NONE=1" "-DUSE_FIELD_INV_BUILTIN=1" "-DUSE_SCALAR_INV_BUILTIN=1" "-DECMULT_WINDOW_SIZE=15" "-DUSE_EXTERNAL_DEFAULT_CALLBACKS=1" "-DENABLE_MODULE_RECOVERY=1" "-o" "/home/rust/dev/sapio/plugin-example/target/wasm32-unknown-unknown/release/build/secp256k1-sys-2f0c3ec84dce942a/out/depend/secp256k1/contrib/lax_der_parsing.o" "-c" "depend/secp256k1/contrib/lax_der_parsing.c"
--- stderr
error occurred: Failed to find tool. Is `clang` installed?
warning: build failed, waiting for other jobs to finish...
error: build failed
Error: Compiling your crate to WebAssembly failed
Caused by: failed to execute `cargo build`: exited with exit code: 101
full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
clang
was missing, I installed with sudo apt install clang
and now it compiles
$ uname -a Linux wepa 5.4.0-74-generic #83-Ubuntu SMP Sat May 8 02:35:39 UTC 2021 x86_64 x86_64 x86_64 GNU/Linux
error occurred: Failed to find tool. Is `clang` installed? warning: build failed, waiting for other jobs to finish... error: build failed Error: Compiling your crate to WebAssembly failed Caused by: failed to execute `cargo build`: exited with exit code: 101 full command: "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
@naumenkogs reopen if needed/