wasmerio / winterjs

Winter is coming... ❄️
https://winterjs.org/
MIT License
3.04k stars 53 forks source link

Compiling to WASM #67

Closed godronus closed 2 weeks ago

godronus commented 7 months ago

Having managed to get winterjs building on Linux, @Arshia001 thanks again.. I am now trying to build it to wasm. My understanding is that I should be able to follow your build.sh script to get this done. i.e. cargo +wasix build --target wasm32-wasmer-wasi -r so long as I have the required tooling installed.

error: failed to run custom build command for `mozjs_sys v0.68.2 (https://github.com/wasmerio/mozjs.git?branch=fix-obj-file-lists#f6cbd122)`

Caused by:
  process didn't exit successfully: `/home/doco/dev/winterjs/target/release/build/mozjs_sys-e8860a2e484c9cf9/build-script-build` (exit status: 101)
  --- stdout
  cargo:outdir=/home/doco/dev/winterjs/target/wasm32-wasmer-wasi/release/build/mozjs_sys-f724c30fa6d4af20/out/build

  --- stderr
  gmake: *** No targets specified and no makefile found.  Stop.
  thread 'main' panicked at /home/doco/.cargo/git/checkouts/mozjs-e1c76167ba7c548f/f6cbd12/mozjs-sys/build.rs:251:38:
  Please provide WASI_SYSROOT for WASI targets: NotPresent
  note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Any help here would be appreciated... :)

MasatoDev commented 7 months ago

I also tried it, but I encountered the following error:

error[E0658]: use of unstable library feature 'wasi_ext'
  --> /home/myname/.cargo/git/checkouts/tokio-2eb71367495b4da5/833de72/tokio/src/fs/open_options.rs:19:5
   |
19 | use std::os::wasi::fs::OpenOptionsExt;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
   |
   = note: see issue #71213 <https://github.com/rust-lang/rust/issues/71213> for more information
   = help: add `#![feature(wasi_ext)]` to the crate attributes to enable

I put #![feature(wasi_ext)] at the top of the file main.rs, but it didn't work.

Arshia001 commented 7 months ago

Hey @godronus!

To fix this issue, you need a build of the wasix-libc, available here: https://github.com/wasix-org/wasix-libc

You'd need to clone that repo, run build32.sh, and feed the resulting sysroot into the WinterJS build process using WASI_SYSROOT=path/to/sysroot, which is what the error message is complaining about. Make sure you have the latest version of the WASIX toolchain as well, since WinterJS does not compile with older versions.

Arshia001 commented 7 months ago

@MasatoDev which version of the WASIX toolchain do you have? That looks like an error message from an outdated compiler to me.

MasatoDev commented 7 months ago

@Arshia001

Thank you for your reply.🙇‍♂️

my versions log ```bash ubuntu :~/winterjs$ cargo wasix --version cargo-wasix 0.1.23 ubuntu :~/winterjs$ rustup show Default host: x86_64-unknown-linux-gnu rustup home: /home/ubuntu/.rustup installed toolchains -------------------- stable-x86_64-unknown-linux-gnu nightly-x86_64-unknown-linux-gnu (default) 1.76-x86_64-unknown-linux-gnu wasix active toolchain ---------------- nightly-x86_64-unknown-linux-gnu (default) rustc 1.79.0-nightly (ccfcd950b 2024-04-15) ubuntu :~/winterjs$ rustup -V rustup 1.27.0 (bbb9276d2 2024-03-08) info: This is the version for the rustup toolchain manager, not the rustc compiler. info: The currently active `rustc` version is `rustc 1.79.0-nightly (ccfcd950b 2024-04-15)` ubuntu :~/winterjs$ cargo -V cargo 1.79.0-nightly (48eca1b16 2024-04-12) ubuntu :~/winterjs$ rustc -V rustc 1.79.0-nightly (ccfcd950b 2024-04-15) ```

I've already tried with cargo 1.76.

Arshia001 commented 7 months ago

@MasatoDev Try running:

cargo wasix download-toolchain

and retry your build, see if the output changes? Unfortunately, it's not easy to view the WASIX toolchain version, so I don't know if you have the latest version or not. The downloader should find version v2023-11-01.1 and install it for use.

MasatoDev commented 7 months ago

@Arshia001 thank you! I've already installedx86_64-unknown-linux-gnu_v2023-11-01.1 but it's not working with same error.

marvelken commented 6 months ago

@godronus, how did you manage to build winter.js on linux? Please your immediate reply would be deeply appreciated.