Commit b546338
committed
fix(bindeps): do not propagate artifact dependency to proc macro or build deps
As reproduced in the 2 fixed test cases of this commit, cargo panicked
when
- a package `foo` has an artifact dependency `artifact` with a specified
target TARGET_ARTIFACT different from host TARGET_HOST,
- `artifact` depends on proc macro `macro`,
- `macro` conditionally depends on `arch` on TARGET_HOST,
with the follwing message
```
did not find features for (PackageId { name: "arch", version: "0.0.1", source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/arch" }, ArtifactDep(CompileTarget { name: "x86_64-apple-darwin" })) within activated_features:
[
(
PackageId {
name: "foo",
version: "0.0.1",
source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo",
},
NormalOrDev,
),
(
PackageId {
name: "macro",
version: "0.0.1",
source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/macro",
},
ArtifactDep(
CompileTarget {
name: "x86_64-apple-darwin",
},
),
),
(
PackageId {
name: "artifact",
version: "0.0.1",
source: "/Users/lencerf/Developer/cargo/target/tmp/cit/t0/foo/artifact",
},
ArtifactDep(
CompileTarget {
name: "x86_64-apple-darwin",
},
),
),
]
```
From the above message, it is clear that proc macro `macro` was wrongly
associated with `FeaturesFor::ArtifactDep` instead of
`FeaturesFor::HostDep`. Package `arch` was later ignored because cargo
thought `macro` should be built for TARGET_ARTIFACT
(x86_64-apple-darwin), while `arch` was conditionally needed on
TARGET_HOST (aarch64-apple-darwin).
Similar analyses apply to the other test case.
This commit fixes 2 paths:
- when resolving features, if we encounter build dependencies or proc
macros, always associate them with `FeaturesFor::HostDep`.
- when deriving UnitFor for dependencies, stop propagating
artifact_target_for_features if the the dependency is a build
dependency or a proc macro.
Signed-off-by: Changyuan Lyu <changyuan.lv@gmail.com>1 parent 7225a8e commit b546338
File tree
3 files changed
+12
-8
lines changed- src/cargo/core
- resolver
- tests/testsuite
3 files changed
+12
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1177 | 1177 | | |
1178 | 1178 | | |
1179 | 1179 | | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
1180 | 1186 | | |
1181 | 1187 | | |
1182 | 1188 | | |
1183 | 1189 | | |
1184 | 1190 | | |
1185 | | - | |
| 1191 | + | |
1186 | 1192 | | |
1187 | 1193 | | |
1188 | 1194 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
906 | 906 | | |
907 | 907 | | |
908 | 908 | | |
909 | | - | |
910 | | - | |
911 | | - | |
912 | | - | |
913 | | - | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
914 | 914 | | |
915 | 915 | | |
916 | 916 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3395 | 3395 | | |
3396 | 3396 | | |
3397 | 3397 | | |
3398 | | - | |
3399 | 3398 | | |
3400 | 3399 | | |
3401 | 3400 | | |
| |||
3490 | 3489 | | |
3491 | 3490 | | |
3492 | 3491 | | |
3493 | | - | |
3494 | 3492 | | |
3495 | 3493 | | |
3496 | 3494 | | |
| |||
0 commit comments