How close are we to having rustc.wasm?

I’ve had a thought of a build system + package manager that only ever executes wasm, and I feel like rust is the perfect language both to create this build system as well as be one of the primary languages using it (although ideally it could support any language).

Basic idea:

  • very similar to Nix package manager, except gets around the complexity of multiple build systems / build targets. Also I’d use jsonnet for the config language personally, where inputs to build steps are passed as only files in NAR archives and json blobs into stdin.
  • only runs wasm – i.e. compilers are wasm and output “binaries” are wasm. Obviously there might be intermediate object files/etc that are not wasm – but they also don’t get executed.
  • deterministic inputs/outputs could allow for truly distributed builds. You know the exact hash of your inputs, and you could have “trusted signatures” to simply download the intermediate outputs. Think a web-level build system with multiple actors. Possibly even do something blockchain-esque and have multiple sources build things and compare to mark as “trusted”… you could go crazy here.

Anyway, none of this is possible if we don’t have the “stage0” rustc.wasm compiler – in other words we need rust to build rust into a wasm target. We also need a wasm engine capable of at least file+network I/O, which I’m not sure is quite there yet.

Anyway, wondering how close these goals are to reality to determine when I should get started :smiley:

3 Likes

What’s the benefit of the compiler itself being wasm instead of a regular executable?

play.rust-lang.org could be cached inside a service worker and be made available offline, for example.

3 Likes

It removes any importance of what OS is compiling your code. All “builders” just need to be able to run the wasm executables, which include compilers, tool-chains, shell scripts – and there are never any “cross compilation” issues ever again.

All “builders” can build any part of a compile chain (compiler, intermediate or products) the product of which runs anywhere – regardless of what platform those builders run on (Linux, Mac, super computer, redoxOS, etc – or what target they are targeting

2 Likes

Sounds like “write once, run anywhere”, aka Java.

4 Likes

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.