maidsafe / safe_network

Autonomi combines the spare capacity of everyday devices to form a new, autonomous, data and communications layer of the Internet
http://autonomi.com
84 stars 51 forks source link

Generating WASM for the browser #2366

Open cobite opened 3 weeks ago

cobite commented 3 weeks ago

I'm creating a browser extension and would like to use wasm for the client api.

I'm following along with the instructions on: https://github.com/maidsafe/safe_network/tree/main/autonomi

I got the latest maidsafe repo code, then I cd into the autonomi folder.

Then I do:

cargo build

After that I cd back to the root and run:

SAFE_PEERS=/ip4/157.245.40.245/udp/57224/quic-v1/p2p/12D3KooWGB1aq5dbWT8oY5hQwmT63JZSgtLDMRWhnNuoM7fvpdGf wasm-pack test --release --firefox autonomi --features=data,files --test wasm -- put

The error I get:

[INFO]: 🎯  Checking for the Wasm target...
error: none of the selected packages contains these features: files, did you mean: fs, full?
Error: Compilation of your program failed
Caused by: Compilation of your program failed
Caused by: failed to execute `cargo build`: exited with exit status: 101
  full command: cd "autonomi" && "cargo" "build" "--tests" "--release" "--target" "wasm32-unknown-unknown" "--features=data,files" "--test" "wasm"
cobite commented 1 week ago

I changed --features=data,files to --features=data

Now I seem to get further in the build process, but I now get the following:

The following warnings were emitted during compilation:


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

error: failed to run custom build command for `blst v0.3.13`

Caused by:
  process didn't exit successfully: `/safe_network/target/release/build/blst-829a41e45397a7fd/build-script-build` (exit status: 1)

    error occurred: Command "clang" "-O2" "-ffunction-sections" "-fdata-sections" "-fPIC" "-fno-exceptions" "-g" "-fno-omit-frame-pointer" "--target=wasm32-unknown-unknown" "-Wall" "-Wextra" "-ffreestanding" "-D__BLST_NO_ASM__" "-D__BLST_PORTABLE__" "-DSCRATCH_LIMIT=(45 * 1024)" "-o" "/safe_network/target/wasm32-unknown-unknown/release/build/blst-a76cd73b679018c0/out/76cbfa861e1aafe5-server.o" "-c" "/.cargo/registry/src/index.crates.io-6f17d22bba15001f/blst-0.3.13/blst/src/server.c" with args clang did not execute successfully (status code exit status: 1).