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

forced-target does not work with target dependencies within same package #12108

Open
ehuss opened this issue May 8, 2023 · 1 comment
Open
Labels
A-features2 Area: issues specifically related to the v2 feature resolver C-bug Category: bug S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. Z-per-package-target Nightly: per-package-target

Comments

@ehuss
Copy link
Contributor

ehuss commented May 8, 2023

Problem

forced-target will fail when used with target dependencies defined in the same package that match that target.

thread 'main' panicked at 'activated_features for invalid package: features did not find PackageId { name: "regex", version: "1.8.1", source: "registry `crates-io`" } NormalOrDev', src/cargo/core/resolver/features.rs:321:14

Steps

Try to build a project with the following manifest:

cargo-features = ["per-package-target"]
[package]
name = "foo"
version = "0.1.0"
edition = "2021"
forced-target = "wasm32-unknown-unknown"

[target.'cfg(target_family="wasm")'.dependencies]
regex = "1"

This requires resolver=2.

Possible Solution(s)

There are several issues here:

  • Missing RustcTargetData information (which is being fixed in Support registry dependencies for bindeps #12062).
  • The FeatureResolver doesn't know about per-package targets.
  • Feature resolution for per-package targets is up in the air at the moment.

Notes

No response

Version

cargo 1.71.0-nightly (569b648b5 2023-05-05)
release: 1.71.0-nightly
commit-hash: 569b648b5831ae8a515e90c80843a5287c3304ef
commit-date: 2023-05-05
host: aarch64-apple-darwin
libgit2: 1.6.3 (sys:0.17.0 vendored)
libcurl: 7.87.0 (sys:0.4.61+curl-8.0.1 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1t  7 Feb 2023
os: Mac OS 13.3.1 [64-bit]
@ehuss ehuss added C-bug Category: bug S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. A-features2 Area: issues specifically related to the v2 feature resolver Z-per-package-target Nightly: per-package-target labels May 8, 2023
@fee1-dead
Copy link
Member

I've been thinking about this while reading the feature resolver code. I think the best way to support forced-target and default-target is to add those fields to the Summary type. I don't what that would entail, for the index side, but I think it would reduce the amount of changes needed for feature resolver to support these fields.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-features2 Area: issues specifically related to the v2 feature resolver C-bug Category: bug S-needs-mentor Status: Issue or feature is accepted, but needs a team member to commit to helping and reviewing. Z-per-package-target Nightly: per-package-target
Projects
None yet
Development

No branches or pull requests

2 participants