rust-lang / wg-cargo-std-aware

Repo for working on "std aware cargo"
133 stars 8 forks source link

metaprogramming and bootstrapping #42

Open Ericson2314 opened 4 years ago

Ericson2314 commented 4 years ago

I think build.rs and procedural macros should be able to take advantage of std-aware cargo too. This is needed to get rid of the sysroot as a concept entirely. This is also needed to boostrap a working rust from a plain compiler without any libraries. This type of boostrapping is very advantageous of distros.

gmorenz commented 1 month ago

I was poking around at trying to get a proc-macro to compile, dynamically link to, and call a inline-proc-macro (i.e. what this crate used to do). This is difficult right now because proc-macro (the crate) is statically linked and has important thread locals, but if I compile it by hand I can compile it to a dylib and share those with my inline-proc-macro, at which point things work.

This is absurdly niche and wouldn't even be stable behavior even if it worked, but it's sort of a use case that would be enabled by letting me say something like cargo build --build-std-host=proc-macro -Z target-applies-to-host -Z host-config --config host.rustflags="--crate-type=dylib -C prefer-dynamic".

I'm honestly not sure if this is an argument for or against this feature.