Skip to content

Cargo panics when building a proc-macro crate with build-std present in any parent .cargo/config.toml #8975

@rjb3977

Description

@rjb3977

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

  1. Clone this minimal repo.
  2. Run cargo build, or RUST_BACKTRACE=full cargo build if you so desire.

Possible Solution(s)

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugS-triageStatus: This issue is waiting on initial triage.Z-build-stdNightly: build-std

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions