-
Notifications
You must be signed in to change notification settings - Fork 39
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
WebAssembly/WASI support #211
Comments
Hey, we haven't explicitly supported wasm yet, can you try the following:
For bare wasm I think we would have to define a separate package which exposes JS bindings with wasm-bindgen |
hey thank you for a quick response! I'm not sure if I'm doing this right, but the compilation fails with these flags:
|
you want to pass -j1 to solar |
@DaniPopes alright, but, the build still fails because of jemalloc:
also I wouldn't recommend wasm-pack, it's kind of abandoned. Just having a regular .wasm file that's loadable is more than enough imo |
Can you try again, pushed a fix 20ea26c |
it compiled but is now throwing a similar error as
I'm testing it with |
huh ok, I'll have a deeper look tomorrow to see if I can make it work |
Here are my findings.
|
happy to confirm that both I think it's safe to close the issue, since there's not really a need to support all possible wasm targets (I don't need support for threads in my usecase) also if that's helpful, Huge thanks for putting your time and effort into investigating this |
It's probably worth documenting usage with WebAssembly in the readme I think. This is how you use it with wasip1 (in Node.js): import { WASI } from 'node:wasi'
import { readFile } from 'node:fs/promises'
const wasi = new WASI({
version: 'preview1',
args: ['-j1','-V']
})
const wasm = await WebAssembly.compile(
await readFile(new URL('./solar.wasm', import.meta.url)),
)
const instance = await WebAssembly.instantiate(wasm, wasi.getImportObject())
wasi.start(instance) with wasm32-unknown-unknown it throws "Unreachable" when trying to call Reproduction with Deno/Node.js: import fs from 'node:fs/promises';
const wasmBuffer = await fs.readFile('./solar.wasm');
const wasmModule = await WebAssembly.instantiate(wasmBuffer);
console.log(wasmModule.instance.exports.main(2, 3)) emscripten target's not really importable as a module, it runs only in CLI mode (for example if you try to import solar.js, it will print a help message) |
Including WASM targets in the releases would also be great |
Just published this: https://github.com/deno-web3/solar a JS SDK that uses WASI ( |
Describe the feature
Hey, I'm trying to find a Solidity compiler that compiles to WASM (other than solc-js but with a simpler API) so it is easy to write bindings for it.
I was trying to compile Solar to WASM/WASI and hit these errors with different targets:
wasm32-wasip2
wasm32-wasip1-threads
wasm32-unknown-unknown
compiles successfully, but throws "RuntimeError: unreachable" when trying to import itrun via
deno test.js
wasm32-unknown-emscripten
fails because jemalloc doesn't support emscriptenAdditional context
No response
The text was updated successfully, but these errors were encountered: