Open dtbuchholz opened 1 week ago
@dtbuchholz The dtb/wasm-support
branch doesn't exist any longer under https://github.com/textileio/basin. I'm attempting to reproduce in order to poke around at the dependency tree.
@raulk sorry for the delay here—we had an offsite last week and weren't really connected to the internet much! also, I'm not sure what happened to the old wasm setup, so I've just recreated it. you can find it here: dtb/wasm-support
. I'm using the wasm-pack
boilerplate with a single Basin SDK import:
use wasm_bindgen::prelude::*;
use adm_sdk::network::Network;
#[wasm_bindgen]
extern "C" {
fn alert(s: &str);
}
#[wasm_bindgen]
pub fn initialize_network() {
Network::Testnet.init();
alert("initialized network");
}
now, it looks like the first time your run wasm-pack
, it complains about blst
(i.e., without the dependency errors mentioned above): warning: blst@0.3.11: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"'
then, all subsequent build attempts will complain about the aforementioned positioned-io
etc. dependencies.
here are the logs:
The following warnings were emitted during compilation: warning: blst@0.3.11: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"' warning: blst@0.3.11: 1 error generated. error: failed to run custom build command for `blst v0.3.11` Caused by: process didn't exit successfully: `/Users/dtb/textile/basin/target/release/build/blst-b200d02c0b326ff6/build-script-build` (exit status: 1) --- stdout cargo:rerun-if-env-changed=BLST_TEST_NO_STD Using blst source directory /Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.11/blst cargo:rerun-if-changed=/Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.11/blst/src TARGET = Some("wasm32-unknown-unknown") 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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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 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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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=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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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=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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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=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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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. --- stderr error occurred: Command "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-ffreestanding" "-D__BLST_NO_ASM__" "-DSCRATCH_LIMIT=(45 * 1024)" "-o" "/Users/dtb/textile/basin/target/wasm32-unknown-unknown/release/build/blst-d7105b903104e7e9/out/23f7fac37c814c3c-server.o" "-c" "/Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.11/blst/src/server.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 "/Users/dtb/textile/basin/wasm" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
error[E0433]: failed to resolve: use of undeclared type `SeekFrom` --> /Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/positioned-io-0.3.3/src/raf.rs:78:29 | 78 | let pos = file.seek(SeekFrom::Current(0))?; | ^^^^^^^^ use of undeclared type `SeekFrom` | help: consider importing this enum | 7 + use io::SeekFrom; | error[E0433]: failed to resolve: use of undeclared type `SeekFrom` --> /Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/positioned-io-0.3.3/src/raf.rs:94:30 | 94 | match self.file.seek(SeekFrom::Start(self.pos)) { | ^^^^^^^^ use of undeclared type `SeekFrom` | help: consider importing this enum | 7 + use io::SeekFrom; | error[E0599]: no method named `seek` found for struct `File` in the current scope --> /Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/positioned-io-0.3.3/src/raf.rs:78:24 | 78 | let pos = file.seek(SeekFrom::Current(0))?; | ^^^^ method not found in `File` | ::: /Users/dtb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/io/mod.rs:1919:8 | 1919 | fn seek(&mut self, pos: SeekFrom) -> Result; | ---- the method is available for `File` here | = help: items from traits can only be used if the trait is in scope help: trait `Seek` which provides `seek` is implemented but not in scope; perhaps you want to import it | 1 + use std::io::Seek; | error[E0599]: no method named `seek` found for struct `File` in the current scope --> /Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/positioned-io-0.3.3/src/raf.rs:94:25 | 94 | match self.file.seek(SeekFrom::Start(self.pos)) { | ^^^^ method not found in `File` | ::: /Users/dtb/.rustup/toolchains/stable-aarch64-apple-darwin/lib/rustlib/src/rust/library/std/src/io/mod.rs:1919:8 | 1919 | fn seek(&mut self, pos: SeekFrom) -> Result ; | ---- the method is available for `File` here | = help: items from traits can only be used if the trait is in scope help: trait `Seek` which provides `seek` is implemented but not in scope; perhaps you want to import it | 1 + use std::io::Seek; | error[E0277]: the trait bound `&RandomAccessFile: WriteAt` is not satisfied --> /Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/positioned-io-0.3.3/src/raf.rs:141:27 | 141 | WriteAt::write_at(&mut &*self, pos, buf) | ----------------- ^^^^^^^^^^^ the trait `WriteAt` is not implemented for `&RandomAccessFile` | | | required by a bound introduced by this call | help: consider removing the leading `&`-reference | 141 - WriteAt::write_at(&mut &*self, pos, buf) 141 + WriteAt::write_at(&*self, pos, buf) | error[E0277]: the trait bound `&RandomAccessFile: WriteAt` is not satisfied --> /Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/positioned-io-0.3.3/src/raf.rs:145:24 | 145 | WriteAt::flush(&mut &*self) | -------------- ^^^^^^^^^^^ the trait `WriteAt` is not implemented for `&RandomAccessFile` | | | required by a bound introduced by this call | help: consider removing the leading `&`-reference | 145 - WriteAt::flush(&mut &*self) 145 + WriteAt::flush(&*self) | Some errors have detailed explanations: E0277, E0433, E0599. For more information about an error, try `rustc --explain E0277`. error: could not compile `positioned-io` (lib) due to 6 previous errors warning: build failed, waiting for other jobs to finish... The following warnings were emitted during compilation: warning: blst@0.3.11: error: unable to create target: 'No available targets are compatible with triple "wasm32-unknown-unknown"' warning: blst@0.3.11: 1 error generated. error: failed to run custom build command for `blst v0.3.11` Caused by: process didn't exit successfully: `/Users/dtb/textile/basin/target/release/build/blst-b200d02c0b326ff6/build-script-build` (exit status: 1) --- stdout cargo:rerun-if-env-changed=BLST_TEST_NO_STD Using blst source directory /Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.11/blst cargo:rerun-if-changed=/Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.11/blst/src TARGET = Some("wasm32-unknown-unknown") 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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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 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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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=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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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=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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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=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 cargo:rerun-if-env-changed=CRATE_CC_NO_DEFAULTS CRATE_CC_NO_DEFAULTS = 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. --- stderr error occurred: Command "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-ffreestanding" "-D__BLST_NO_ASM__" "-DSCRATCH_LIMIT=(45 * 1024)" "-o" "/Users/dtb/textile/basin/target/wasm32-unknown-unknown/release/build/blst-d7105b903104e7e9/out/23f7fac37c814c3c-server.o" "-c" "/Users/dtb/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.11/blst/src/server.c" with args clang did not execute successfully (status code exit status: 1). 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 "/Users/dtb/textile/basin/wasm" && "cargo" "build" "--lib" "--release" "--target" "wasm32-unknown-unknown"
re: your question in the PR—i may have linked to a private repo before. here's the public builtin-actors
repo, and here's the forked ipc
repo that uses it. but, the dependency graph for cargo tree -i builtin-actors
doesn't log anything in the basin
repo, actually.
basin
does, however, use fendermint actors and IPC actor ABIs and IPC APIs from the ipc
repo. I'm not sure if that's relevant, though, but figured i'd mention it.
Issue type
Feature Request
Have you reproduced the bug with the latest dev version?
Yes
Version
0.1.0
Custom code
Yes
OS platform and distribution
Mac OS Sonoma 14.3
Describe the issue
Summary
When using
fvm_shared
and compiling to awasm32
, non-default features are pulled in due to thecrypto
feature flag. This flag pulls in thefilecoin-proofs-api
, which leads to problems on a wasm build.You can see additional conversations here and here.
Details
You'll see the error (below) complaining about the
positioned-io
andfs2
libraries. If you tease out patches for awasm32
build, you'll then run into an issue withsha2_asm
, which does not support wasm. That is, it's a cascading transitive dependency problem that stems from the merkletree library, which gets pulled in via thefilecoin-proofs-api
. You can run thecargo tree
command in the Basin repo for more details.Repro steps
fvm_shared
in theadm_sdk
crate:git clone https://github.com/textileio/basin
dtb/wasm-support
branch, which tries to do a simple enum export from theadm_sdk
wasm-pack build --target nodejs wasm
Relevant log output