Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compiling to WASM #67

Open
godronus opened this issue Apr 8, 2024 · 7 comments
Open

Compiling to WASM #67

godronus opened this issue Apr 8, 2024 · 7 comments

Comments

@godronus
Copy link

godronus commented Apr 8, 2024

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
Copy link
Contributor

MasatoDev commented Apr 16, 2024

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
Copy link
Member

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
Copy link
Member

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

@MasatoDev
Copy link
Contributor

MasatoDev commented Apr 17, 2024

@Arshia001

Thank you for your reply.🙇‍♂️

my versions log
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
Copy link
Member

@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
Copy link
Contributor

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

@marvelken
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants