-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Description
Problem
If you have a .cargo/config.toml
file with build-std = ['std']
(and valid target
), and you try to build a crate with proc-macro = true
, Cargo panics. This is only really a problem if that .cargo/config.toml
exists in some parent directory of the crate.
Steps
- Clone this minimal repo.
- Run
cargo build
, orRUST_BACKTRACE=full cargo build
if you so desire.
Possible Solution(s)
- Display an error message saying that
build-std
is not allowed forproc-macro
crates. - Fix
build-std
forproc-macro
crates. - Ignore
build-std
forproc-macro
crates. - Implement something like AIlow to unset
.cargo/config
settings through a newreset
config key #8687.
Notes
Output of cargo version
: cargo 1.50.0-nightly (d274fcf86 2020-12-07)
Backtrace: hastebin
My actual use case
I have a crate that targets wasm32-unknown-unknown
, and I'd like to have a small child crate so I can use procedural macros. Since I'm using atomics in the wasm32
crate, I need build-std
. In this case, I will still most likely need something like #8687, so that I can reset the rustflags
array. I'll probably just end up figuring out how to pull the proc-macro
crate up a level to get around this whole issue, but I figure a panic is still undesirable and at the very least can be turned into a helpful error message.