Skip to content

bindep std errors when no_std bindep has a dependency which uses std in a build.rs #11772

@devsnek

Description

@devsnek

Problem

When a project contains a bindep, and that bindep is no_std, and that bindep has a dependency on a package which has a build.rs, sometimes this causes the entire build to freak out and fail:

$ cargo build
   Compiling phf_shared v0.11.1
error[E0463]: can't find crate for `std`
  |
  = note: the `x86_64-unknown-none` target may not support the standard library
  = note: `std` is required by `phf_shared` because it does not declare `#![no_std]`
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error[E0463]: can't find crate for `std`
 --> /home/snek/.cargo/registry/src/github.com-1ecc6299db9ec823/phf_shared-0.11.1/src/lib.rs:9:1
  |
9 | extern crate std as core;
  | ^^^^^^^^^^^^^^^^^^^^^^^^^ can't find crate
  |
  = note: the `x86_64-unknown-none` target may not support the standard library
  = help: consider building the standard library from source with `cargo build -Zbuild-std`

error: cannot find macro `write` in this scope
   --> /home/snek/.cargo/registry/src/github.com-1ecc6299db9ec823/phf_shared-0.11.1/src/lib.rs:368:5
    |
368 |     write!(f, "{:?}", array)
    |     ^^^^^
    |
    = help: consider importing this macro:
            core::write
[...]

I don't know which things cause this and which don't (I've run into several at this point), but my repro repo, which depends on the crate pci-ids, fails consistently: https://github.com/devsnek/bindep-repro

If I cd into the bindep directory and run cargo build, it compiles just fine. This only happens when compiling the project which has the bindep as a dependency.

Steps

  1. Create a project
  2. Create a bindep in that project
  3. Add a dependency to that bindep
  4. If you are (un)lucky, it will fail to build.

Possible Solution(s)

No response

Notes

No response

Version

cargo 1.69.0-nightly (9d5b32f50 2023-02-22)
release: 1.69.0-nightly
commit-hash: 9d5b32f503fc099c4064298465add14d4bce11e6
commit-date: 2023-02-22
host: x86_64-unknown-linux-gnu
libgit2: 1.5.0 (sys:0.16.0 vendored)
libcurl: 7.86.0-DEV (sys:0.4.59+curl-7.86.0 vendored ssl:OpenSSL/1.1.1q)
os: Arch Linux Rolling Release [64-bit]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bugZ-bindepsNightly: binary artifact dependencies

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions