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

WASM support broken due to incompatible dependencies #472

Closed
jozanza opened this issue Oct 1, 2024 · 5 comments · Fixed by #483
Closed

WASM support broken due to incompatible dependencies #472

jozanza opened this issue Oct 1, 2024 · 5 comments · Fixed by #483

Comments

@jozanza
Copy link

jozanza commented Oct 1, 2024

Following instructions at https://jolt.a16zcrypto.com/usage/wasm_support.html, I was unable to compile my project to wasm.

Steps to reproduce

  1. Make a new project (jolt new foo --wasm)
  2. Ensure fib(n: 32) -> u128 in guest/src/lib.rs has #[jolt::provable(wasm)]
  3. Build the project jolt build-wasm

Expected result
I expect a wasm bin to be compiled and output to target/wasm32-unknown-unknown/release as well as an index.html and a pkg dir with some wasm-pack stuff.

Actual result
index.html is created, but wasm compilation fails as it encounters some nix modules within the tracing-profile dependency:

error[E0433]: failed to resolve: could not find `sys` in `nix`
 --> ~/.cargo/git/checkouts/tracing-profile-ea11638690e1685c/6d986ca/src/data/span_metadata.rs:4:10
  |
4 | use nix::sys::time::TimeSpec;
  |          ^^^ could not find `sys` in `nix`

error[E0433]: failed to resolve: could not find `sys` in `nix`
 --> ~/.cargo/git/checkouts/tracing-profile-ea11638690e1685c/6d986ca/src/layers/csv.rs:1:10
  |
1 | use nix::sys::time::TimeValLike;
  |          ^^^ could not find `sys` in `nix`

error[E0432]: unresolved import `nix::time`
 --> ~/.cargo/git/checkouts/tracing-profile-ea11638690e1685c/6d986ca/src/layers/csv.rs:2:10
  |
2 | use nix::time::{clock_gettime, ClockId};
  |          ^^^^ could not find `time` in `nix`

cargo tree -i tracing profile reveals the tree:

cargo tree -i tracing-profile              
tracing-profile v0.8.0 (https://gitlab.com/IrreducibleOSS/tracing-profile.git?branch=main#6d986ca1)
└── binius_utils v0.1.0 (https://gitlab.com/UlvetannaOSS/binius#a0a71393)
    └── binius_field v0.1.0 (https://gitlab.com/UlvetannaOSS/binius#a0a71393)
        └── jolt-core v0.1.0 (https://github.com/a16z/jolt#e08998e8)
            └── jolt-sdk v0.1.0 (https://github.com/a16z/jolt#e08998e8)
                ├── guest v0.1.0 (~/foo/guest)
                │   └── foo v0.1.0 (~/foo)
                └── foo v0.1.0 (~/foo)
@moodlezoup
Copy link
Collaborator

Hmm does #462 fix the issue?

@myceliaspy
Copy link
Contributor

hey! I'm getting this same issue, which is unrelated to my pr. that one was introduced to fix an issue originally mentioned here #448. I think the problem with this one is that, since nix uses sys related functions, it's definitely not no_std – which I think is a wasm requirements – so it can't be compiled. not sure what the fix can be, as I tried writing my own no_std compatible equivalents and it made me want to die. Will look forward to the progress here.

@jozanza
Copy link
Author

jozanza commented Oct 7, 2024

@myceliaspy no_std isn't required for wasm. Typically, the solution is just making sure code paths that use native-only crates/modules don't get imported. Just based on cursory observations, it looks like nix::sys is really just being used for some profiling that most likely wouldn't make sense in a wasm env anyways or at least wouldn't be critical to generate proofs, etc.

@moodlezoup
Copy link
Collaborator

hmm I guess we could just slap a #[cfg(not(target_arch = "wasm32"))] on all the Binius stuff... we'll need an upstream fix eventually though if we want to support Binius+wasm

@sagar-a16z
Copy link
Contributor

filed https://gitlab.com/IrreducibleOSS/binius/-/issues/5 to track the upstream fix and #483 to unblock wasm for now

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

Successfully merging a pull request may close this issue.

4 participants