Skip to content

cargo publish panics when running on a procedural macros crate which uses the build-std unstable feature #9828

@GabrielMajeri

Description

@GabrielMajeri

Problem
I was trying to publish a new version of the uefi-macros crate, and I encountered the following panic upon running cargo publish --target x86_64-unknown-uefi:

thread 'main' panicked at 'no entry found for key', src/tools/cargo/src/cargo/core/compiler/context/compilation_files.rs:340:9
stack backtrace:
   0: rust_begin_unwind
             at /rustc/af140757b4cb1a60d107c690720311ba8e06e7de/library/std/src/panicking.rs:517:5
   1: core::panicking::panic_fmt
             at /rustc/af140757b4cb1a60d107c690720311ba8e06e7de/library/core/src/panicking.rs:93:14
   2: core::option::expect_failed
             at /rustc/af140757b4cb1a60d107c690720311ba8e06e7de/library/core/src/option.rs:1618:5
   3: cargo::core::compiler::context::compilation_files::CompilationFiles::outputs
   4: cargo::core::compiler::context::Context::compile
   5: cargo::ops::cargo_compile::compile_ws
   6: cargo::ops::cargo_package::package_one
   7: cargo::ops::registry::publish
   8: cargo::commands::publish::exec
   9: cargo::cli::main
  10: cargo::main

The project is using the build-std unstable feature, and it seems to be the cause for this issue. If I comment out the build-std line in the cargo config file, I'm successfully able to publish the crate.

Additionally, I had no issue with publishing a new version of the uefi-rs crate, which is a regular library (not proc-macro).

Steps

  1. Check out the code from rust-osdev/uefi-rs@8832fbc
  2. Move into the uefi-macros subdirectory and run cargo publish --target x86_64-unknown-uefi
  3. Observe the cargo panic

Possible Solution(s)

The panic message is the same as the one in this issue, so the solution might be similar.

Notes

Output of rustc --version:

rustc 1.56.0-nightly (af140757b 2021-08-22)

Output of cargo --version:

cargo 1.56.0-nightly (e96bdb0c3 2021-08-17)

Contents of the project's .cargo/config:

[unstable]
build-std = ["core", "compiler_builtins", "alloc"]

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: bug

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions