Coder Social home page Coder Social logo

cargo-wasix's People

Contributors

alexcrichton avatar arshia001 avatar chenks12138 avatar dependabot-preview[bot] avatar dierbei avatar dynamite-bud avatar fedeparma74 avatar fitzgen avatar ibaryshnikov avatar john-sharratt avatar kubkon avatar maekawatoshiki avatar markmccaskey avatar piotrsikora avatar syrusakbary avatar theduke avatar thomasdezeeuw avatar tschneidereit avatar xxshady avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cargo-wasix's Issues

Generate Pre-Built Binaries

Generate pre-built cargo-wasix binaries for releases, and provide them through a Github release.

The building should be done in a CI task.

GLIBC_2.36 not found

Running cargo wasix build produces the following output:

$ cargo wasix build
/home/ben/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.36' not found (required by /home/ben/.rustup/toolchains/wasix/lib/librustc_driver-239bacfa42cce6c3.so)
error: Could not execute rustc

Caused by:
    failed to execute "rustc" "+wasix" "--print" "sysroot"
        status: exit status: 1

My currently installed version of glibc is 2.35.

Will wasix support glibc version 2.35 or will people need to update their glibc version to run wasix?

Fix Testsuite

The tests (cargo test) are currently broken.

Need to fix them and make the CI pass again.

`cargo wasix test`: Error while importing "wasix_32v1"."sock_accept_v2"

Hi, I am trying to run cargo wasix test for my project with this Cargo.toml, but I got this error. I cannot find any clue to fix it. Any ideas? Thanks!

[dependencies]
tokio = { version = "=1.24.2", features = ["full"] }

[patch.crates-io]
socket2 = { git = "https://github.com/wasix-org/socket2.git", branch = "v0.4.7" }
libc = { git = "https://github.com/wasix-org/libc.git" }
tokio = { git = "https://github.com/wasix-org/tokio.git", branch = "wasix-1.24.2" }

Errors

info: Post-processing WebAssembly files
     Running `/Users/al/.cargo/target/wasm32-wasmer-wasi/debug/deps/showbiz_wasm-fcdd37f471140938.wasm`
warning: Found more than 1 WASI version in this module (`wasi_snapshot_preview1`, `wasix_32v1`). If this is intentional, pass `--allow-multiple-wasi-versions` to suppress this warning.
error: failed to run `/Users/al/.cargo/target/wasm32-wasmer-wasi/debug/deps/showbiz_wasm-fcdd37f471140938.wasm`
│   1: failed to instantiate WASI module
│   2: Instantiation failed
╰─▶ 3: Error while importing "wasix_32v1"."sock_accept_v2": unknown import. Expected Function(FunctionType { params: [I32, I32, I32, I32], results: [I32] })

Web Hello world example

Hi I'm a bit compile hello world and then load it in the browser with the following. Are you able to do an example with this to point people in the right direction

Thanks

<!DOCTYPE html>
<html>

<head>
    <meta charset='utf-8'>
    <meta http-equiv='X-UA-Compatible' content='IE=edge'>
    <title>Page Title</title>
    <meta name='viewport' content='width=device-width, initial-scale=1'>
    <!-- <link rel='stylesheet' type='text/css' media='screen' href='main.css'> -->
    <script lang="ts">
        const importObject = {
            module: {},
            env: {
                memory: new WebAssembly.Memory({ initial: 256 }),
            }
        };
        const response = fetch('/wasmix-play.wasm').then((response) =>
            response.arrayBuffer()
        ).then((bytes) =>  WebAssembly.instantiate(bytes, importObject)
        ).then((instance) => {
            console.log(instance.exports);
        });
    </script>
</head>
<body>
</body>
</html>```

`cargo wasix run` fails

Cargo wasix run fails with this error:

error: no such command: `+wasix`

        Cargo does not handle `+toolchain` directives.
        Did you mean to invoke `cargo` through `rustup` instead?

[Minor nit] toolchain install missing download detials

Attempting to install the toolchain on a very slow (KB/s) hangs on Extracting... but I believe that message is printed too early, while the download is progressing still:

// Download and extract sysroot.
eprintln!(
"Downloading sysroot from url '{}'...",
&sysroot_asset.browser_download_url
);
let res = client
.get(&sysroot_asset.browser_download_url)
.send()?
.error_for_status()?;
eprintln!("Extracting...");

Some minimal progress bar would be great, but at least ensuring that it is clear what is blocking the install step-wise would be a very nice fix to have.

Request for changing the name of WASIX

Hey all, first off: congratulations on putting this system interface and tooling around it together! I know how much work goes into something like this, even if you can reuse so much existing code.

Unfortunately there is a sizable problem with the name you chose, which I have no doubt is a simple oversight: since early in 2022, WASIX has been in use for an open source project by SingleStore Labs, originally developed for their port of cpython to WASI. At one point it was also used by the official cpython distribution.

Given that this project is very much in the same space as your system interface, this name collision would be bound to cause a great deal of confusion once you announce more widely.

I'm glad I stumbled upon this before a big announcement could be made, since I know @syrusakbary's very strong stance against using names already taken by other projects in a related space (see e.g. here, here, and here), and hence that he'd certainly agree that continued use of this name would be the wrong thing to do.

(Note: I would have filed this on the wasix-libc repo, but it has issues disabled.)

`cargo wasix` cannot find the rustc executable

When building / running for the first time on Windows, the downloaded toolchain cannot be found.

$ cargo wasix build --release
Finding latest release... (https://api.github.com/repos/wasix-org/rust/releases/latest)...
Toolchain path C:\Users\twitc\AppData\Roaming\cargo-wasix\toolchains\x86_64-pc-windows-msvc_v2023-05-26.1 already exists - deleting existing files!
Downloading sysroot from url 'https://github.com/wasix-org/rust/releases/download/v2023-05-26.1/wasix-libc.tar.gz'...
Extracting...
Downloading Rust toolchain from url 'https://github.com/wasix-org/rust/releases/download/v2023-05-26.1/rust-toolchain-x86_64-pc-windows-msvc.tar.gz'...
Extracting...
Downloaded toolchain x86_64-pc-windows-msvc to C:\Users\twitc\AppData\Roaming\cargo-wasix\toolchains\x86_64-pc-windows-msvc_v2023-05-26.1\rust
Activating rustup toolchain wasix at C:\Users\twitc\AppData\Roaming\cargo-wasix\toolchains\x86_64-pc-windows-msvc_v2023-05-26.1\rust...
error: Invalid toolchain directory: rustc executable not found at C:\Users\twitc\AppData\Roaming\cargo-wasix\toolchains\x86_64-pc-windows-msvc_v2023-05-26.1\rust\bin/rustc

The binary is present, so it seems like wasix may be looking for exactly rustc instead of rustc.exe?

`cargo install cargo-wasix` does not install `wasix` toolchain

Installation instructions on https://wasix.org/docs/language-guide/rust/installation are not helpful, as they do not provide link how to troubleshoot if installation does not work:

$ cargo install cargo-wasix
    Updating crates.io index
     Ignored package `cargo-wasix v0.1.23` is already installed, use --force to override
$ cargo wasix --version
cargo-wasix 0.1.23
$ rustup toolchain list | grep wasix 
$ rustup toolchain list | grep wasix | wc
      0       0       0
$ rustup toolchain install wasix
error: invalid toolchain name: 'wasix'     

I am using Archlinux. Probably adding link on https://wasix.org/docs/language-guide/rust/installation to more detailed explanation or troubleshooting would be helpful.

Fix CI Tests

The CI is currently red due to one failing test.

Probably just some STDOUT/ERR that changed in upstream cargo.

Need to investigate.

Wrong wasmer install URL

The link https://wasmer.io/install.sh does not exist now, and I think curl https://get.wasmer.io -sSfL | sh is a correct way for installation.

# cargo wasix run
error: failed to find `wasmer` in $PATH, you'll want to install `wasmer` before running this command
you can also install through a shell:

        curl https://wasmer.io/install.sh -sSf | bash

cargo wasix build fails: could not execute rustc

On a fresh install of Debian 11 with the latest rustup 1.26.0 following this plan:

mkdir app && cd app
cargo init
cargo install cargo-wasix
cargo wasix build

The toolchain reports that it's linked & available, but I get a ton of errors related to libc not found. Then a final "could not execute rustc"

dev@localhost:~/app$ cargo wasix build
Finding latest release... (https://api.github.com/repos/wasix-org/rust/releases/latest)...
Downloading sysroot from url 'https://github.com/wasix-org/rust/releases/download/v2023-07-21.1/wasix-libc.tar.gz'...
Extracting...
Downloading Rust toolchain from url 'https://github.com/wasix-org/rust/releases/download/v2023-07-21.1/rust-toolchain-x86_64-unknown-linux-gnu.tar.gz'...
Extracting...
Downloaded toolchain x86_64-unknown-linux-gnu to /home/dev/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-07-21.1/rust
Activating rustup toolchain wasix at /home/dev/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-07-21.1/rust...
Running rustup toolchain link wasix /home/dev/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-07-21.1/rust:
rustup toolchain wasix was linked and is now available!
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/dev/.rustup/toolchains/wasix/bin/rustc)
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/dev/.rustup/toolchains/wasix/lib/librustc_driver-239bacfa42cce6c3.so)
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/dev/.rustup/toolchains/wasix/lib/librustc_driver-239bacfa42cce6c3.so)
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /home/dev/.rustup/toolchains/wasix/lib/librustc_driver-239bacfa42cce6c3.so)
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.30' not found (required by /home/dev/.rustup/toolchains/wasix/lib/librustc_driver-239bacfa42cce6c3.so)
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libstdc++.so.6: version `GLIBCXX_3.4.29' not found (required by /home/dev/.rustup/toolchains/wasix/lib/librustc_driver-239bacfa42cce6c3.so)
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libstdc++.so.6: version `CXXABI_1.3.13' not found (required by /home/dev/.rustup/toolchains/wasix/lib/librustc_driver-239bacfa42cce6c3.so)
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.33' not found (required by /home/dev/.rustup/toolchains/wasix/lib/libstd-9047e6e40084bd20.so)
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.32' not found (required by /home/dev/.rustup/toolchains/wasix/lib/libstd-9047e6e40084bd20.so)
/home/dev/.rustup/toolchains/wasix/bin/rustc: /lib/x86_64-linux-gnu/libc.so.6: version `GLIBC_2.34' not found (required by /home/dev/.rustup/toolchains/wasix/lib/libstd-9047e6e40084bd20.so)
error: Could not execute rustc

Caused by:
    failed to execute "rustc" "+wasix" "--print" "sysroot"
        status: exit status: 1

Rustup doesn't work on NixOS when downloading `wasix`

The first reason is that rustc will already point to the system installed Rust:

~/.rustup/toolchains ❯ command -v rustc
/etc/profiles/per-user/odd/bin/rustc
~/.rustup/toolchains ❯ rustc +wasix --print sysroot
error: couldn't read +wasix: No such file or directory (os error 2)

The second reason is that the downloaded files such as rustc and rustdoc needs to be patched with patchelf, otherwise they won't run due to assuming paths for dependencies:

toolchains/wasix/bin ❯ pwd
/home/odd/.rustup/toolchains/wasix/bin
toolchains/wasix/bin ❯ ls
rustc  rustdoc
toolchains/wasix/bin ❯ ./rustc
bash: ./rustc: cannot execute: required file not found

Nix stores these dependencies in /nix/store, which is why they need patching.

Cannot publish to wasmer

Hello, I have been trying to publish to wasmer.io following the wasix guide.

I have added the wasm32-wasmer-wasi target but am under the understanding I can publish wasix binaries to wasmer as well?

When I build my project with cargo wasix buid --release I get a binary in ./target/wasm32-wasmer-wasi/release/foo.wasm.

My wasmer.toml contains the following:

[[module]]
name = 'foo'
source = './target/wasm32-wasmer-wasi/release/foo.wasm'
abi = 'wasi'

However when I try to wasmer publish I get the following error:

error: WASM file "/home/***/target/wasm32-wasmer-wasi/release/foo.wasm" detected as invalid because InterfaceViolated { errors: ["Missing import \"wasix_32v1\" \"thread_exit\"", "Missing import \"wasix_32v1\" \"futex_wait\"", "Missing import \"wasix_32v1\" \"thread_signal\"", "Missing import \"wasix_32v1\" \"futex_wake_all\"", "Missing import \"wasix_32v1\" \"futex_wake\"", "Missing import \"wasix_32v1\" \"getcwd\"", "Missing import \"wasix_32v1\" \"callback_signal\""] }

However I can

$ wasmer run /home/***/target/wasm32-wasmer-wasi/release/foo.wasm
Hello, world!

So the binary is definitely located at that path. Is there another target I need in order to publish to wasmer.io? Is it required to use the wasi target? Or are wasix binaries also allowed?

wasix build not working on macos aarch64 after install

Hi,

I just installed cargo-wasix with cargo install cargo-wasix but after writing a simple fibonacci application I cant seem to get it building or running with wasix.

❯ cargo wasix run
error: couldn't read +wasix: No such file or directory (os error 2)

error: aborting due to previous error

error: Could not execute rustc

Caused by:
    failed to execute "rustc" "+wasix" "--print" "sysroot"
        status: exit status: 1

This is happening on macOS Ventura 13.5.1 on an M1 Max

Automatic Dependency Screening and Patching

Problem Statement

Currently many common crates are not compatible with WASIX and require forks to work properly.

This results in a very suboptimal user experience.

cargo wasix should check for the presence of such dependencies in Cargo.lock, and either apply automatic fixes or inform the user.

This should apply to cargo wasix {check,build,run}.

Implementation

cargo wasix {check,build,run} should:

  • make sure the Cargo.lock has been generated
  • Check the Cargo.lock for well-known incompatible crates
  • In case a fork exists:
    automatically extend the [patch.crates-io] section with the appropriate patches
  • In case no fork exists:
    Fail the build with a concrete error, like crate XXX is not compatible with WASIX yet

Care must be taken to pick branches that match the semver constraints for the patches, otherwise the patch will just be silently ignored.

List of crates

Example

A good example is the WASIX Axum example found here: http://wasix.org/docs/language-guide/rust/tutorials/wasix-axum

It requires the below Cargo.toml to work properly:

[package]
name = "wasix-axum"
version = "0.1.0"
edition = "2021"
 
[dependencies]
axum = { version = "=0.6.9", features = ["tokio"] } # ← Updated Line
tokio = { version = "=1.24.2", default-features = false, features = ["full"] } # ← Updated Line
parking_lot = { version = "=0.12.1", features = ["nightly"] } # ← Added Line
 
[patch.crates-io]
socket2 = { git = "https://github.com/wasix-org/socket2.git", branch = "v0.4.7" } # ← Added Line
libc = { git = "https://github.com/wasix-org/libc.git" } # ← Added Line
tokio = { git = "https://github.com/wasix-org/tokio.git", branch = "wasix-1.24.2" }

Absence of pre-built toolchain for Intel MacOS

Unable to use on Intel based Mac.

cargo wasix build --release
Finding latest release... (https://api.github.com/repos/wasix-org/rust/releases/latest)...
Could not download pre-built toolchain: Release v2023-05-26.1 does not have a prebuilt toolchain for host x86_64-apple-darwin
error: Download of pre-built toolchain failed

`cargo-wasix` assumes presence of `rustup`

$ cargo wasix build
error: failed to create process "rustup" "toolchain" "list" "--verbose"

Caused by:
    No such file or directory (os error 2)

This is annoying for NixOS users since we typically don't use rustup for managing the Rust toolchain but Nix instead. What should happen instead is that cargo-wasix should try to build, and if it fails to build display a helpful message instead of checking if the toolchain is available beforehand. Message can be something like this:

Toolchain not found, make sure to install it

Issue with downloading pre-built toolchain on Macos when running `cargo wasix` commands

Info

Platform/OS: Apple Silicon, Macos Sonoma 14.0

Steps

  1. installed cargo-wasix: cargo install cargo-wasix
  2. make new test project: cargo new --bin wasix-test
  3. try to build the project: cargo wasix build

Notes

Hello!
I was looking to try out the cargo-wasix cli since WASIX is exactly what I have been waiting for, but it looks like whenever i go to build/test/run using cargo wasix build or cargo wasix run, i get this error:

❯ cargo wasix build
Finding latest release... (https://api.github.com/repos/wasix-org/rust/releases/latest)...
Could not download pre-built toolchain: Could not download release info

Caused by:
    HTTP status client error (401 Unauthorized) for url (https://api.github.com/repos/wasix-org/rust/releases/latest)
error: Download of pre-built toolchain failed

Caused by:
    Could not download release info

Caused by:
    HTTP status client error (401 Unauthorized) for url (https://api.github.com/repos/wasix-org/rust/releases/latest)

I tried manually linking the toolchain as well, but that wasn't working out so well.
What can I do to work around this issue or help solve it? Thank you for any help in advance.

cargo wasix test error: Compilation error: Code for function is too large

While my code successfully compiles under ordinary targets (package: citadel_pqcrypto), running cargo wasix test --package citadel_pqcrypto fails with: error: Unable to compile "/Users/nologik/avarok/Citadel-Protocol/target/wasm32-wasmer-wasi/debug/deps/primary-0e896da8cb2e0eac.wasm" ╰─▶ 1: Compilation error: Code for function is too large

I thought that maybe running wasmer run --enable-all /Users/nologik/avarok/Citadel-Protocol/target/wasm32-wasmer-wasi/debug/deps/primary-0e896da8cb2e0eac.wasm would solve the problem by enabling larger memory, however, it did not (I get the same error as above). How can I work around this?

WASIX toolchain issue on Windows

Hi,
I installed WASIX on windows. Now when I try to execute the cargo wasix build, I am getting toolchain not found error. I can understand if WASIX has no windows gnu toolchain. Here I have no idea why it is looking for "x86_64-pc-windows-gnu" even tough I use "x86_64-pc-windows-msvc".

image

Release v2023-07-21.1 does not have a prebuilt toolchain for host x86_64-pc-windows-msvc

Hello! I am using Windows 11 and am facing this problem.

> cargo wasix check
Finding latest release... (https://api.github.com/repos/wasix-org/rust/releases/latest)...
Could not download pre-built toolchain: Release v2023-07-21.1 does not have a prebuilt toolchain for host x86_64-pc-windows-msvc
error: Download of pre-built toolchain failed

Caused by:
    Release v2023-07-21.1 does not have a prebuilt toolchain for host x86_64-pc-windows-msvc

cargo-wasix does not work when the toolchain is installed in a deleted directory

If the toolchain is installed and the directory where it's installed is later removed, cargo-wasix fails to detect the missing toolchain and fails instead.

Steps to reproduce:

  1. Remove or rename the toolchain directory: mv /home/arshia/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-07-21.1/rust /home/arshia/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-07-21.1/rust-backup
  2. Run rustup toolchain list. The wasix toolchain will still be listed.
  3. Run rustup default wasix. Rustup will complain that the toolchain is not installed.
  4. Run cargo wasix build. It will fail to detect the missing toolchain and report an error instead:
$ cargo wasix build
error: toolchain 'wasix' is not installed
error: Could not execute rustc

Caused by:
    failed to execute "rustc" "+wasix" "--print" "sysroot"
        status: exit status: 1

Expected behaviour:
cargo-wasix should detect the missing/invalid toolchain and download it again.

Wasix-Axum WASM application thread panics at runtime after load stress test

Upon load testing the application the application thread panics as below:

picasso@picasso:~/Desktop/src/projects/wasm/wasix-rust-examples/wasix-axum$ wasmer run target/wasm32-wasmer-wasi/debug/wasix-axum.wasm --net --enable-threads --env PORT=8080
Listening on http://127.0.0.1:8080
thread 'main' panicked at /home/picasso/.cargo/registry/src/index.crates.io-6f17d22bba15001f/parking_lot_core-0.9.8/src/thread_parker/wasm_atomic.rs:51:13:
assertion failed: r == 0 || r == 1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
error: RuntimeError: unreachable
    at __rust_start_panic (<module>[9542]:0x9c5e94)
    at rust_panic (<module>[1904]:0x6daaa8)
    at std::panicking::rust_panic_with_hook::hfdfcaa6e69ebc719 (<module>[391]:0x3f5bdb)
    at std::panicking::begin_panic_handler::{{closure}}::h3f7789fd24ed3f08 (<module>[3741]:0x826189)
    at std::sys_common::backtrace::__rust_end_short_backtrace::hbe7fbe04baf16200 (<module>[9479]:0x9c4caf)
    at rust_begin_unwind (<module>[5666]:0x8ef2a4)
    at core::panicking::panic_fmt::h07835762205d9da6 (<module>[7816]:0x97fdc9)
    at core::panicking::panic::h18678cb124bcc731 (<module>[6962]:0x94ea04)
    at <parking_lot_core::thread_parker::imp::ThreadParker as parking_lot_core::thread_parker::ThreadParkerT>::park::h239fcb653d5e8208 (<module>[1990]:0x6eff0d)
    at parking_lot_core::parking_lot::park::{{closure}}::h747f8f4c6ffb9884 (<module>[117]:0x25927a)
    at parking_lot_core::parking_lot::park::h0c82da8664c01e84 (<module>[1006]:0x5b82c7)
    at parking_lot::condvar::Condvar::wait_until_internal::h14feacfd5e810820 (<module>[815]:0x54f5bd)
    at parking_lot::condvar::Condvar::wait::h46b42241deee20ee (<module>[4998]:0x8b404b)
    at tokio::loom::std::parking_lot::Condvar::wait::h5886f82229a2d832 (<module>[4795]:0x8a0e07)
    at tokio::park::thread::Inner::park::h13d6871b9cf36ff9 (<module>[329]:0x3b1764)
    at <tokio::park::thread::CachedParkThread as tokio::park::Park>::park::{{closure}}::h074b229273ffab5b (<module>[7480]:0x971b6c)
    at tokio::park::thread::CachedParkThread::with_current::{{closure}}::he9760f52961154e1 (<module>[7116]:0x95a3f0)
    at std::thread::local::LocalKey<T>::try_with::hd1d2223d0d96b4d4 (<module>[1764]:0x6b8615)
    at tokio::park::thread::CachedParkThread::with_current::hd43a4cfda3f350a4 (<module>[5388]:0x8d7a29)
    at <tokio::park::thread::CachedParkThread as tokio::park::Park>::park::h69abcd569cf15580 (<module>[3223]:0x7e1ca7)
    at tokio::park::thread::CachedParkThread::block_on::h66d5e8981ec1b1db (<module>[697]:0x508d16)
    at tokio::runtime::enter::Enter::block_on::h9c87833c42353e15 (<module>[5418]:0x8da492)
    at tokio::runtime::thread_pool::ThreadPool::block_on::h165f604ff938f099 (<module>[3650]:0x819f00)
    at tokio::runtime::Runtime::block_on::h23f1bdae2f89888e (<module>[2530]:0x76305f)
    at wasix_axum::main::h17aa3b46cb99d6f2 (<module>[2144]:0x713075)
    at core::ops::function::FnOnce::call_once::ha9b2c8eb2ddd4496 (<module>[7844]:0x981660)
    at std::sys_common::backtrace::__rust_begin_short_backtrace::h311b36d1bc0c7f41 (<module>[7926]:0x987e9a)
    at std::rt::lang_start::{{closure}}::h55a3403b35cc2a28 (<module>[5827]:0x8ff999)
    at std::rt::lang_start_internal::h9f91ddae2fba41c4 (<module>[5810]:0x8fe1ba)
    at std::rt::lang_start::h3abfa2c193587021 (<module>[4130]:0x85942e)
    at __main_void (<module>[8977]:0x9b985a)
    at _start (<module>[8636]:0x9b41d6)
╰─▶ 1: RuntimeError: unreachable
           at __rust_start_panic (<module>[9542]:0x9c5e94)
           at rust_panic (<module>[1904]:0x6daaa8)
           at std::panicking::rust_panic_with_hook::hfdfcaa6e69ebc719 (<module>[391]:0x3f5bdb)
           at std::panicking::begin_panic_handler::{{closure}}::h3f7789fd24ed3f08 (<module>[3741]:0x826189)
           at std::sys_common::backtrace::__rust_end_short_backtrace::hbe7fbe04baf16200 (<module>[9479]:0x9c4caf)
           at rust_begin_unwind (<module>[5666]:0x8ef2a4)
           at core::panicking::panic_fmt::h07835762205d9da6 (<module>[7816]:0x97fdc9)
           at core::panicking::panic::h18678cb124bcc731 (<module>[6962]:0x94ea04)
           at <parking_lot_core::thread_parker::imp::ThreadParker as parking_lot_core::thread_parker::ThreadParkerT>::park::h239fcb653d5e8208 (<module>[1990]:0x6eff0d)
           at parking_lot_core::parking_lot::park::{{closure}}::h747f8f4c6ffb9884 (<module>[117]:0x25927a)
           at parking_lot_core::parking_lot::park::h0c82da8664c01e84 (<module>[1006]:0x5b82c7)
           at parking_lot::condvar::Condvar::wait_until_internal::h14feacfd5e810820 (<module>[815]:0x54f5bd)
           at parking_lot::condvar::Condvar::wait::h46b42241deee20ee (<module>[4998]:0x8b404b)
           at tokio::loom::std::parking_lot::Condvar::wait::h5886f82229a2d832 (<module>[4795]:0x8a0e07)
           at tokio::park::thread::Inner::park::h13d6871b9cf36ff9 (<module>[329]:0x3b1764)
           at <tokio::park::thread::CachedParkThread as tokio::park::Park>::park::{{closure}}::h074b229273ffab5b (<module>[7480]:0x971b6c)
           at tokio::park::thread::CachedParkThread::with_current::{{closure}}::he9760f52961154e1 (<module>[7116]:0x95a3f0)
           at std::thread::local::LocalKey<T>::try_with::hd1d2223d0d96b4d4 (<module>[1764]:0x6b8615)
           at tokio::park::thread::CachedParkThread::with_current::hd43a4cfda3f350a4 (<module>[5388]:0x8d7a29)
           at <tokio::park::thread::CachedParkThread as tokio::park::Park>::park::h69abcd569cf15580 (<module>[3223]:0x7e1ca7)
           at tokio::park::thread::CachedParkThread::block_on::h66d5e8981ec1b1db (<module>[697]:0x508d16)
           at tokio::runtime::enter::Enter::block_on::h9c87833c42353e15 (<module>[5418]:0x8da492)
           at tokio::runtime::thread_pool::ThreadPool::block_on::h165f604ff938f099 (<module>[3650]:0x819f00)
           at tokio::runtime::Runtime::block_on::h23f1bdae2f89888e (<module>[2530]:0x76305f)
           at wasix_axum::main::h17aa3b46cb99d6f2 (<module>[2144]:0x713075)
           at core::ops::function::FnOnce::call_once::ha9b2c8eb2ddd4496 (<module>[7844]:0x981660)
           at std::sys_common::backtrace::__rust_begin_short_backtrace::h311b36d1bc0c7f41 (<module>[7926]:0x987e9a)
           at std::rt::lang_start::{{closure}}::h55a3403b35cc2a28 (<module>[5827]:0x8ff999)
           at std::rt::lang_start_internal::h9f91ddae2fba41c4 (<module>[5810]:0x8fe1ba)
           at std::rt::lang_start::h3abfa2c193587021 (<module>[4130]:0x85942e)
           at __main_void (<module>[8977]:0x9b985a)
           at _start (<module>[8636]:0x9b41d6)

The first 1,000 requests load test past well but after changing the requests to 10,000 it failed after almost 2,800 requests as shown below:
1,000 requests

$ bombardier -c 2 -n 1000 http://localhost:8080
Bombarding http://localhost:8080 with 1000 request(s) using 2 connection(s)
 1000 / 1000 [=====================================================================================================================================================================] 100.00% 43/s 22s
Done!
Statistics        Avg      Stdev        Max
  Reqs/sec        44.36      30.88     117.87
  Latency       45.05ms     1.44ms    51.13ms
  HTTP codes:
    1xx - 0, 2xx - 1000, 3xx - 0, 4xx - 0, 5xx - 0
    others - 0
  Throughput:     8.83KB/s

10,000 requests

$ bombardier -c 4 -n 10000 http://localhost:8080
Bombarding http://localhost:8080 with 10000 request(s) using 4 connection(s)
10000 / 10000 [==================================================================================================================================================================] 100.00% 316/s 31s
Done!
Statistics        Avg      Stdev        Max
 Reqs/sec       320.87    2950.83   45532.62
 Latency       12.61ms     9.93ms    52.27ms
 HTTP codes:
   1xx - 0, 2xx - 2801, 3xx - 0, 4xx - 0, 5xx - 0
   others - 7199
 Errors:
   dial tcp 127.0.0.1:8080: connect: connection refused - 7199
 Throughput:    17.69KB/s

Development environment:

  • Rust compiler: rustc 1.73.0 (cc66ad468 2023-10-03)
  • cargo-wasix: v0.1.23
  • Wasmer: 4.2.3
  • OS: Ubuntu 22.04.3 LTS x86_64

'cargo' is not installed for the toolchain 'wasix'

Outcome

cargo wasix build fails with error 'cargo' is not installed for the toolchain 'wasix'.

Expected Result

Should build successfully.

Replication Steps

# Dockerfile

FROM rust:1.70-bookworm

WORKDIR /src

RUN cargo init
RUN cargo install cargo-wasix
RUN cargo wasix build
$ docker build -t cargo-wasix-test:latest .
[+] Building 73.1s (8/8) FINISHED
 => [internal] load build definition from Dockerfile                                                                                                                                                                        0.0s
 => => transferring dockerfile: 143B                                                                                                                                                                                        0.0s
 => [internal] load .dockerignore                                                                                                                                                                                           0.0s
 => => transferring context: 2B                                                                                                                                                                                             0.0s
 => [internal] load metadata for docker.io/library/rust:1.70-bookworm                                                                                                                                                       1.5s
 => CACHED [1/5] FROM docker.io/library/rust:1.70-bookworm@sha256:79ca6896ecfe3787599bba6fd9dcd98b28f2742396df96a5b33f737ca7749730                                                                                          0.0s
 => [2/5] WORKDIR /src                                                                                                                                                                                                      0.0s
 => [3/5] RUN cargo init                                                                                                                                                                                                    1.0s
 => [4/5] RUN cargo install cargo-wasix                                                                                                                                                                                    26.7s
 => ERROR [5/5] RUN cargo wasix build                                                                                                                                                                                      43.8s
------
 > [5/5] RUN cargo wasix build:
#0 0.494 Finding latest release... (https://api.github.com/repos/wasix-org/rust/releases/latest)...
#0 0.844 Downloading sysroot from url 'https://github.com/wasix-org/rust/releases/download/v2023-05-26.1/wasix-libc.tar.gz'...
#0 1.417 Extracting...
#0 1.555 Downloading Rust toolchain from url 'https://github.com/wasix-org/rust/releases/download/v2023-05-26.1/rust-toolchain-x86_64-unknown-linux-gnu.tar.gz'...
#0 2.118 Extracting...
#0 40.61 Downloaded toolchain x86_64-unknown-linux-gnu to /root/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-05-26.1/rust
#0 40.61 Activating rustup toolchain wasix at /root/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-05-26.1/rust...
#0 40.62 Running rustup toolchain link wasix /root/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-05-26.1/rust:
#0 40.62 rustup toolchain wasix was linked and is now available!
#0 40.72 error: 'cargo' is not installed for the toolchain 'wasix'
#0 40.72 note: this is a custom toolchain, which cannot use `rustup component add`
#0 40.72 help: if you built this toolchain from source, and used `rustup toolchain link`, then you may be able to build the component with `x.py`
------
Dockerfile:7
--------------------
   5 |     RUN cargo init
   6 |     RUN cargo install cargo-wasix
   7 | >>> RUN cargo wasix build
   8 |
--------------------
ERROR: failed to solve: process "/bin/sh -c cargo wasix build" did not complete successfully: exit code: 1

cargo-wasix as the successor to cargo-wasi

cargo-wasi is being archived, so users need a replacement.

cargo-wasix could be what we should use and recommend instead. But it currently requires/install the wasix-libc as well as an old Rust toolchain. This may not be desirable, and is an issue for packaging.

Would it be reasonable to only download the wasix components when actually compiling to wasix? And maybe provide a cargo wasi command for people who need a maintained version of cargo wasi?

Improve Decompression Speed

Decompression of the toolchain after downloading is really slow.

Might have to:

  • use better library for decompression
  • fall back to OS native decompression utility
  • reduce the compression level when building the artifact

[Minor nit] toolchain install missing download detials

Attempting to install the toolchain on a very slow (KB/s) hangs on Extracting... but I believe that message is printed too early, while the download is progressing still:

// Download and extract sysroot.
eprintln!(
"Downloading sysroot from url '{}'...",
&sysroot_asset.browser_download_url
);
let res = client
.get(&sysroot_asset.browser_download_url)
.send()?
.error_for_status()?;
eprintln!("Extracting...");

Some minimal progress bar would be great, but at least ensuring that it is clear what is blocking the install step-wise would be a very nice fix to have.


# Run in a rust crate:
cargo wasix build

Finding latest release... (https://api.github.com/repos/wasix-org/rust/releases/latest)...
Toolchain path ~/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-11-01.1 already exists - deleting existing files!
Downloading sysroot from url 'https://github.com/wasix-org/rust/releases/download/v2023-11-01.1/wasix-libc.tar.gz'...
Extracting...
Downloading Rust toolchain from url 'https://github.com/wasix-org/rust/releases/download/v2023-11-01.1/rust-toolchain-x86_64-unknown-linux-gnu.tar.gz'...
Extracting...

# hangs for ~1 minute or more here

Downloaded toolchain x86_64-unknown-linux-gnu to /home/nuke/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-11-01.1/rust
Activating rustup toolchain wasix at /home/nuke/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-11-01.1/rust...
Running rustup toolchain link wasix /home/nuke/.local/share/cargo-wasix/toolchains/x86_64-unknown-linux-gnu_v2023-11-01.1/rust:
rustup toolchain wasix was linked and is now available!

Allow Updating the Toolchain

Currently, the wasix toolchain is not updated.

The only way to update is to manually delete the rustup wasix toolchain directory.

Need to add a command to make that possible.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.