4 ms·
The Pre-RFC that came out of this situation is pretty interesting: https://internals.rust-lang.org/t/pre-rfc-sandboxed-deterministic-reproducible-efficient-wasm
by phamilton 3y ago
The Pre-RFC that came out of this situation is pretty interesting: https://internals.rust-lang.org/t/pre-rfc-sandboxed-deterministic-reproducible-efficient-wasm-compilation-of-proc-macros/19359 https://internals.rust-lang.org/t/pre-rfc-sandboxed-determin...
Some points I hadn't considered:
- Current compile times aren't too bad, but compile times are a factor in how macros are developed. Making that less of an issue will likely make the macro ecosystem richer and more ambitious.
- Precompiled binaries can be compiled with optimizations, which anecdotally overcome the potential perf hit from running in WASM
- Nondeterminism in macros (especially randomness) has bit a lot of people and a more controlled execution environment is very beneficial
- Sandboxing doesn't have to be WASM, it's just the most capable, currently available option.
- Comments on the pre-RFC are exploring solving this in rustup/cargo instead of crates.io and that is also promising.
In general, I appreciate how this is creating awareness and driving exploration of solutions. In particular I really like the notion that there is currently implicit pressure on macro authors to make them somewhat quick to compile and releasing that pressure will enable innovation.
- mid-kid 3y agoPlease don't ship wasm binaries in cargo please don't ship wasm binaries in cargo please don't ship wasm binaries in cargo please don't ship wasm binaries in cargo please don-
- MrJohz 3y agoWhy not? WASM with optimisations will mostly run faster than binaries without optimisations, which is the current strategy. Plus you won't need the compile step that's necessary at the moment. Distributing arbitrary binaries right now is bad because it's not clear what those binaries contain, but the WASM environment is completely sandboxed, so it wouldn't be possible for them to read files they weren't meant to or phone home with telemetry. The Cargo project already does some amount of automatic building e.g. of docs pages - this could be extended to proc macro crates to ensure that the uploaded binaries must be built from the uploaded source files. Alternatively, making sure that reproducible binaries are standard would help a lot from a trust perspective. This isn't suitable for every situation, but as a tool to reduce the compile times of some of the bigger and slower macro crates, it sounds like a great option to have.