I am one of the maintainers of cargo-quickinstall and one challenges we face is to sandbox the compilation process since build.rs and proc-macro can essen do whatever they want, going even as far as trying to access GHA tokens or mess with the workflow itself.
Thus, I think we shall have a sandboxing mechanism in rust for build.rs and proc-macro.
What I propose is a new environment variable RUSTC_BUILD_OVERRIDES_RUNNER.
When this environment variable is present, instead of running build.rs or proc- macro directly, rustc will instead runs the command specified by the env and then pass the path to build.rs and its args to it like this:
$RUSTC_BUILD_OVERRIDES_RUNNER build-rs /path/to/build.rs /path/to/build.rs/crate args-for-build.rs...
For proc-macro, this is a bit harder since it is loaded as a dynlib, so the natural thing to do is to pass rustc or a shim binary that loads the proc-macro crate and then communicates with the rustc using stdin and stdout:
$RUSTC_BUILD_OVERRIDES_RUNNER proc-macro /path/to/shim/or/rustc /path/to/proc-macro/dynlib args...
For proc-macro, it is certainly better to have them compiled down to wasm and run them in an interpreter, but this seems to take longer than expected and have an additional problem:
In order to update transitive dependencies of the proc-macro crates, you would have to wait for upstreamto re-compile and publish another release, which seems to be cumbersome for me.
It also added additional overhead as many proc-macro crates depend on proc-macro2 and syn.
I think in order for this to work, we would have to figure out how to link proc-macro crates with their dependencies dynamically so that they can be upgraded at will by the users while reducing the size of the prov-macro crates on crates.io and users' computers.
But repr(interoper) is simply not there yet and judging by the RFC, it would likely takes years to finish and that would block compiling proc-macro to wasm for a long time, and there's demands to sandbox them today.
So I propose this simple mechanism for both build.rs and proc-macro right now and if proc-macro to wasm is supprted to future, we can simply retire RUSTC_BUILD_OVERRIDES_RUNNER support for proc-macro that is compiled to wasm.