Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error: package ID specification panic_unwind did not match any packages with -Zbuild-std #14935

Closed
Wyvern opened this issue Dec 15, 2024 · 10 comments · Fixed by #14938
Closed
Assignees
Labels
regression-from-stable-to-nightly Regression in nightly that previously worked in stable. S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. Z-build-std Nightly: build-std

Comments

@Wyvern
Copy link

Wyvern commented Dec 15, 2024

Update to latest rust nightly: cargo 1.85.0-nightly (769f622e1 2024-12-14) got error: package ID specification panic_unwind did not match any packages when build with -Zbuild-std option.

It happened only on today's update, all builds before have no problems.

What does it mean? And how to fix it...

@weihanglo
Copy link
Member

weihanglo commented Dec 15, 2024

Could you share a minimal reproducible example, with the complete error mesaage? Like the content of your .cargo/config.toml, crates and features specified in -Zbuild-std and -Zbuild-std-feature, env var like RUSTFLAGS, and the target platform you're building.

It might be related to #14899, which automatically determine building core or std, if -Zbuild-std has no crate specified.

@weihanglo weihanglo added Z-build-std Nightly: build-std S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. labels Dec 15, 2024
@Wyvern
Copy link
Author

Wyvern commented Dec 15, 2024

Could you share a minimal reproducible example, with the complete error mesaage?

This is the complete error mesaage, the only output content before actually start building.

Like the content of your .cargo/config.toml, crates and features specified in -Zbuild-std and -Zbuild-std-feature

-Zbuild-std=std,proc_macro,panic_abort -Zbuild-std-features=panic_immediate_abort"

@Wyvern
Copy link
Author

Wyvern commented Dec 15, 2024

It might be related to #14899, which automatically determine building core or std, if -Zbuild-std has no crate specified.

I try to remove -Zbuild-std-features=panic_immediate_abort and build succeeded. NOT sure it related to #14899.

@weihanglo weihanglo added the regression-from-stable-to-nightly Regression in nightly that previously worked in stable. label Dec 15, 2024
@weihanglo weihanglo self-assigned this Dec 15, 2024
weihanglo added a commit to weihanglo/cargo that referenced this issue Dec 15, 2024
@weihanglo
Copy link
Member

This failed because since 125e873
std_resolve only includes sysroot as primary package.
When any custom Cargo feature is provied through -Zbuild-std-feature,
the default feature set panic-unwind wouldn't be gone, so
no panic_unwind crate presents in std_resolve.

When then calling std_resolve.query with the default set of
crates from std_crates, which automatically includes
panic_unwind when std presents, it'll result in spec not found
because panic_unwind was not in std_resolve anyway.

weihanglo added a commit to weihanglo/cargo that referenced this issue Dec 17, 2024
This failed because since 125e873
[`std_resolve`][1] only includes `sysroot` as primary package.
When any custom Cargo feature is provied through `-Zbuild-std-feature`,
the default feature set `panic-unwind` wouldn't be gone, so
no `panic_unwind` crate presents in `std_resolve`.

When then calling [`std_resolve.query`][2] with the default set of
crates from [`std_crates`][3], which automatically includes
`panic_unwind` when `std` presents, it'll result in spec not found
because `panic_unwind` was not in `std_resolve` anyway.

[1]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L96
[2]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L158
[3]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L156

See rust-lang#14935
weihanglo added a commit to weihanglo/cargo that referenced this issue Dec 17, 2024
This failed because since 125e873
[`std_resolve`][1] only includes `sysroot` as primary package.
When any custom Cargo feature is provided via `-Zbuild-std-feature`,
the default feature set `panic-unwind` would be gone, so no
`panic_unwind` crate presents in `std_resolve`.

When then calling [`std_resolve.query`][2] with the default set of
crates from [`std_crates`][3], which automatically includes
`panic_unwind` when `std` presents, it'll result in spec not found
because `panic_unwind` was not in `std_resolve` anyway.

[1]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L96
[2]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L158
[3]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L156

See rust-lang#14935
@Wyvern
Copy link
Author

Wyvern commented Dec 17, 2024

So -Zbuild-std-feature=panic-unwind,other-features... will be necessary from now on?

@weihanglo
Copy link
Member

I would recommend using an older nightly toolchain for now, if it is urgent. rustup toolchain install nightly-2024-12-13 should work.

@Manishearth
Copy link
Member

A simple reproduction for this is cargo +nightly rustc -Z build-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort on an empty cargo new --lib foo crate.

I was able to cargo bisect-rustc it down to rust-lang/rust#134278

@weihanglo can that commit be reverted?

@weihanglo
Copy link
Member

weihanglo commented Dec 17, 2024

@Manishearth
I have a patch pending for review #14938.
Prefer getting it merged and do a submodule update.

A revert of #14899 or rust-lang/rust#134278 isn't better IMO. Some target platforms used to compile std successfully and now are rejected to build just because they have metadata.std: false in their target-spec jsons.

@Manishearth
Copy link
Member

Ah, that works, I didn't realize there was a PR.

@epage
Copy link
Contributor

epage commented Dec 17, 2024

In reviewing #14938, I am concerned about the state of the implementation of build-std. It feels like we've accumulated a mountain of patches on top of each other without a clear goal of where its going and out of expediency for each problem that is run into. I feel like build-std doesn't just need a clear picture of what it is and where its going to be stabilized, but to clean up the implementation so its possible to understand what is being reviewed.

CC @davidtwco

weihanglo added a commit to weihanglo/cargo that referenced this issue Dec 17, 2024
This failed because since 125e873
[`std_resolve`][1] only includes `sysroot` as primary package.
When any custom Cargo feature is provided via `-Zbuild-std-feature`,
the default feature set `panic-unwind` would be gone, so no
`panic_unwind` crate presents in `std_resolve`.

When then calling [`std_resolve.query`][2] with the default set of
crates from [`std_crates`][3], which automatically includes
`panic_unwind` when `std` presents, it'll result in spec not found
because `panic_unwind` was not in `std_resolve` anyway.

[1]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L96
[2]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L158
[3]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L156

See rust-lang#14935
weihanglo added a commit to weihanglo/cargo that referenced this issue Dec 18, 2024
This failed because since 125e873
[`std_resolve`][1] only includes `sysroot` as primary package.
When any custom Cargo feature is provided via `-Zbuild-std-feature`,
the default feature set `panic-unwind` would be gone, so no
`panic_unwind` crate presents in `std_resolve`.

When then calling [`std_resolve.query`][2] with the default set of
crates from [`std_crates`][3], which automatically includes
`panic_unwind` when `std` presents, it'll result in spec not found
because `panic_unwind` was not in `std_resolve` anyway.

[1]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L96
[2]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L158
[3]: https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L156

See rust-lang#14935
github-merge-queue bot pushed a commit that referenced this issue Dec 18, 2024
### What does this PR try to resolve?

Blocked on <#14943> (or can just
merge this one).

Fixes #14935

#14935 failed because since 125e873
[`std_resolve`][1] only includes `sysroot` as primary package.
When any custom Cargo feature is provided via `-Zbuild-std-feature`,
the default feature set `panic-unwind` would be gone, so no
`panic_unwind` crate presents in `std_resolve`.

When then calling [`std_resolve.query`][2] with the default set of
crates from [`std_crates`][3], which automatically includes
`panic_unwind` when `std` presents, it'll result in spec not found
because `panic_unwind` was not in `std_resolve` anyway.

[1]:
https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L96
[2]:
https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L158
[3]:
https://github.com/rust-lang/cargo/blob/addcc8ca715bc7fe20df66afd6efbf3c77ef43f8/src/cargo/core/compiler/standard_lib.rs#L156

### How should we test and review this PR?

This patch is kinda a revert of 125e873
in terms of the behavior.

With this, now `std_resolve` is always resolved to the same set of
packages that Cargo will use to generate the unit graph, (technically
the same set of crates + `sysroot`), by sharing the same set of primary
packages via `std_crates` functions.

Note that when multiple `--target`s provided, if std is specified or
there
is one might support std, Cargo will always resolve std dep graph.

To test it manually, run

```
RUSTFLAGS="-C panic=abort" cargo +nightly-2024-12-15 b -Zbuild-std=std,panic_abort -Zbuild-std-features=panic_immediate_abort
```

change to this PR's cargo with the same nightly rustc, it would succeed.

I am a bit reluctant to add an new end-2end build-std test, but I still
did it.
A bit scared when mock-std gets out-of-sync of features in std in
rust-lang/rust.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
regression-from-stable-to-nightly Regression in nightly that previously worked in stable. S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. Z-build-std Nightly: build-std
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants