Join GitHub today
RFC First cut support for sandboxing procmacros with wasm #7297
This is a first cut experiment at building proc-macros with wasm in order to sandbox them.
It adds a new
In Cargo.toml, you can set
When the compilation actually happens, it's treated as a cross-build to wasm32-unknown-unknown.
Lightly tested on
Assuming this basic approach is sound, I'm thinking that the
dtolnay left a comment •
In the medium term, I would like for crates.io to distribute proc macros as precompiled wasm binaries -- which immediately eliminates all complaints about proc macros taking long to compile.
Is the implementation here forward compatible with a world where
If you assume features are additive then you could just set them all for prebuilt. Or if some are rare and bloaty then prebuilt could exclude them and you'd need to build locally if you want them.
IOW the prebuilt would have associated features and resolution would work out whether it's usable.
Of course it breaks if features are used wrongly.
Thanks for getting started on this @jsgf! I think this has the rough shape of what will be necessary, but I think that we'll probably want to pursue the rustc changes first since they're likely the much more meaty ones for now.
Some updates we'll need on the Cargo side eventually are:
I suspect we'll have some sort of different
In terms of overall feature design I personally feel that precompiled wasm files distributed on crates.io is one of the biggest wins here and is one we'd want to flesh out before stabilizing everything. That doesn't necessarily needed to happen right here on this PR, but would likely be accompanied in the eventual RFC to flesh all this out.
For example I do have concerns about what @dtolnay was mentioning with features but I also have concerns about transitive dependencies. For example the precompiled wasm file might use
@alexcrichton I'm thinking that
Maybe, but is some logic being applied to Kind in this diff - for example, the build script for a Kind::HostSandbox target will be Host. I'm not how that would look if it were just strings.
Now that this seems to have minimal correct functionality, I've moved into rustc. I'll put up a WIP RFC PR once I've made some headway. I expect it require further changes here.