cuviper / autocfg

Automatic cfg for Rust compiler features
Apache License 2.0
95 stars 24 forks source link

Support RUSTC_WRAPPER #26

Closed cuviper closed 5 months ago

cuviper commented 4 years ago

In https://github.com/rust-num/num-complex/issues/83, they reported problems detecting features under cargo no-std-check, which I found to be using RUSTC_WRAPPER to rewrite arguments for a fake target. This seems like something that autocfg could reasonably support. When present and non-empty, we would just wrap commands as $RUSTC_WRAPPER $RUSTC <args...>.

An alternate environment name is CARGO_BUILD_RUSTC_WRAPPER, or it can be set in .cargo/config -- but we don't have any support to find or parse config files yet.

RalfJung commented 2 years ago

An alternate environment name is CARGO_BUILD_RUSTC_WRAPPER, or it can be set in .cargo/config -- but we don't have any support to find or parse config files yet.

With https://github.com/rust-lang/cargo/pull/9601, it should be enough to just check RUSTC_WRAPPER -- cargo will set it to whatever wrapper value it ended up computing based on the config files.

RalfJung commented 2 years ago

Turns out that by not supporting RUSTC_WRAPPER autocfg has accidentally worked around https://github.com/rust-lang/rust-analyzer/issues/12973.

RalfJung commented 5 months ago

The lack of support for RUSTC_WRAPPER is unfortunately preventing us from removing some hacks from the Miri driver: https://github.com/rust-lang/miri/pull/3411.

cuviper commented 5 months ago

Ok, I'll work on this -- shouldn't be too hard, I hope...

RalfJung commented 5 months ago

I think it should be fairly simple, yeah. Here's how anyhow does it.

RalfJung commented 5 months ago

Thanks a lot! Now I will have to check what this RUSTC_WORKSPACE_WRAPPER thing is, I never heard about this before...

cuviper commented 5 months ago

Now I will have to check what this RUSTC_WORKSPACE_WRAPPER thing is, I never heard about this before...

The summary in https://github.com/rust-lang/cargo/issues/8143 is pretty good. I don't know if anyone would really use that in a way that affects autocfg probes, but it's simple enough to support it anyway.

RalfJung commented 5 months ago

Oh, so this doesn't have anything to do with workspaces, it also works for single-crate projects that don't use workspaces. That 's a very confusing name. Thanks for the link!