Compiling V8 (d8 shell) to WASM

I've been trying to compile V8 to WASM, including a patch that provides binary I/O capabilities.

So far I've been using the free Google Gemini on the Web to try to get the correct formula. 61 attempts so far. Build V8 d8 Shell to WASM (WASI Target) · Workflow runs · guest271314/v8 · GitHub.

I got the patch working without the WASM target. Build V8 d8 Shell (Optimized Split Files) · Workflow runs · guest271314/v8 · GitHub.

I'm wondering if using the Rust crate will make things simpler?

No, adding an extra language won't fix what is broken if your not fully replacing the break.

I don't think V8 has been compiled to WASM. Hasn't been done, so breaking stuff to figure it out. Thanks.

I'm not sure there's a world where V8 could be supported by WASM in any way that would be useful or desirable. Even if WASM does support JIT (and I'm relatively sure it doesn't? at least directly - you could play some games with swapping out modules), V8 won't have a JIT target for it, so at best you're getting a pure interpreter, running in an interpreter. The thing would be so painfully slow you'd be waiting 5 minutes just to import the typical node project's dependencies!

But I honestly doubt you would even want to get to that; even without JIT, you're still essentially porting a huge project that's very sensitive to platform differences to a completely new and very different and restricted platform. Getting it building is the least of your issues. This sounds to me like at least in the thousands of dollars, minimum, in AI tokens, assuming it's on the easier side. Pretty expensive for a "I just want to see if I can do it!" project.

No JIT. Ahead-of-Time compilation is the goal. E.g., js2wasm GitHub - loopdive/js2: JavaScript (ECMAScript) ahead-of-time compiler · GitHub. There's StarlingMonkey GitHub - bytecodealliance/StarlingMonkey: The StarlingMonkey JS runtime · GitHub, which the Bytecode Alliance folks have been working on, and they use for ComponentizeJS, jco, etc.; but there's some bloat in there Compile JavaScript to WASM with no networking involved - just reading STDIN and writing to STDOUT · Issue #314 · bytecodealliance/StarlingMonkey · GitHub. Seeing how far I can go with V8.

I'm basically working on doing this GitHub - guest271314/quickjs-ng-wasi-wasm: Embed JavaScript into QuickJS NG, compile to WASM with WASI-SDK · GitHub that I do with QuickJS with V8.

Some relatively similar work going on over here GitHub - littledivy/v8x: Engine agnostic JavaScript · GitHub. See js2/examples/v8x-js2wasm-spike at main · loopdive/js2 · GitHub.

Last evening I got to thinking about going from V8 bytecode to WASM.

Yeah, I get that if you're not specifically working in this domain you might think stuff is not possible, or wasn't designed to do this or that, thus the work...

I'm not spending one single, solitary dime on "artificial intelligence".

Who said anything about node (Node.js)?

Check out loopdive's js2wasm. The maintainer is very interested in Node.js and NPM "compatibility", and has achieved that - in WASM world - to an appreciable degree.

The goal would be that any NPM package can be compiled to .wasm, starting with simpler cases like acorn. Note CommonJS is already partially implemented and on the roadmap.

You've listed a bunch of AOT compilers for JavaScript code and a few much more simple than V8 JS runtimes being explicitly developed for or ported to WASM.

The former has absolutely no connection whatsoever to getting a JS runtime ported to WASM, so it's kind of bewildering to list them, and the latter is exactly the amount of work I said it would be of actually porting the code but without dragging in all the additional complexity of V8.

If you had some experience you wouldn't be mixing those up, and you wouldn't be confused by my pointing out a port is a tremendous amount of work.

If you're using free models then, yeah, I'm not at all surprised you're not even able to get a build setup. I said it would cost thousands for you to get it working, remember?

It would be far simpler to just write a new JS interpreter specifically for WASM, I don't know why you're trying to drag V8 into this. I certainly don't know why you're asking about the Rust V8 crate, of which the relevant part is just a wrapper around the existing V8 build such that it can ship a binary blob.

So, the TLDR is: No, and also what you're trying to do is both way overshooting your ability, and AI isn't a magic bullet that will get you there. Aim lower, you might even learn something.

Interesting answer. Why? Because it hasn't been done, yet. Naw, can't aim lower. Not how I get down. Thanks for your opinion though.