4 ms·
Since Rust can compile to JS and WebAssembly, and Rust's compiler is written in Rust... could you compile Rust in a browser?
by smt88 5y ago
Since Rust can compile to JS and WebAssembly, and Rust's compiler is written in Rust... could you compile Rust in a browser?
- timClicks 5y agoI have been waiting for this to emerge for a few years, but I assume that it must be very difficult because it hasn't happened yet.
- smt88 5y agoIt's probably difficult and also seems mostly useless, right?
- qw3rty01 5y agoThe hardest part would probably be getting LLVM (written in C++) to compile to webassembly, since that's what rust uses as a compiler backend.
- azakai 5y agoIt takes some work (mostly due to LLVM building code to run later in its build system as it goes), but it's very feasible. LLVM has been ported to Wasm (and before that to JS) many times, for example: https://github.com/jprendes/emception https://github.com/jprendes/emception (2021) https://github.com/tbfleming/cib https://github.com/tbfleming/cib (2017) https://github.com/kripken/llvm.js https://github.com/kripken/llvm.js (2012) I agree it would be great to see this repl running 100% in the browser!
- qw3rty01 5y agoTurns out there's been some work, and the rust part has actually been the main issue: https://github.com/rust-lang/miri/issues/722 https://github.com/rust-lang/miri/issues/722