Skip to content

Conversation

@weihanglo
Copy link
Member

What does this PR try to resolve?

#16493 regressed because we looked up the manifest dependency name by matching SourceId, which fails when [patch] changes the source.

This fix ensures the synthetic RunCustomBuild-RunCustomBuild edges carry the manifest dep name, so CARGO_DEP_* environment variable uses the correct prefix even with patched sources and renamed dependencies.

How to test and review this PR?

Run repro in #16493.

Fixes #16493

This regressed because we looked up the manifest dependency name
by matching SourceId, which fails when `[patch]` changes the source.

https://github.com/rust-lang/cargo/blob/dc03f44ec82c9d4947997b36165d0e2502623506/src/cargo/core/compiler/custom_build.rs?plain=1#L473-L475
This fix ensures the synthetic RunCustomBuild-RunCustomBuild edges carry
the manifest dep name, so `CARGO_DEP_*` environment variable uses the
correct prefix even with patched sources and renamed dependencies.
@rustbot rustbot added A-build-scripts Area: build.rs scripts S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 10, 2026
@rustbot
Copy link
Collaborator

rustbot commented Jan 10, 2026

r? @epage

rustbot has assigned @epage.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

@weihanglo weihanglo changed the title test(build-script): regression test #16493 fix: preserve dep_name for build script metadata Jan 10, 2026
@epage epage added this pull request to the merge queue Jan 10, 2026
@epage
Copy link
Contributor

epage commented Jan 10, 2026

Does this mean we can remove the std == std check?

Merged via the queue into rust-lang:master with commit 6d1bd93 Jan 10, 2026
29 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 10, 2026
@ranger-ross
Copy link
Member

@weihanglo thanks a ton for fixing this!

I had a feeling dep.dep_name was probably a better route but wasn't quite sure how modify the unit graph so it is populated for build scripts. I think this should be a more robust solution than trying to find the original manifest dependency.

@weihanglo
Copy link
Member Author

@epage
Posted #16496. Can remove the std == std line if we want to revert back to the old build-std behavior.

rust-bors bot added a commit to rust-lang/rust that referenced this pull request Jan 11, 2026
Update cargo submodule

5 commits in 8c133afcd5e0d69932fe11f5907683723f8d361d..6d1bd93c47f059ec1344cb31e68a2fb284cbc6b1
2026-01-09 03:50:15 +0000 to 2026-01-10 12:53:59 +0000
- fix: preserve `dep_name` for build script metadata  (rust-lang/cargo#16494)
- refactor(toml): clarify `to_dependency` for config patch (rust-lang/cargo#16492)
- Add `--id` flag to `cargo report timings` and `cargo report rebuilds` (rust-lang/cargo#16490)
- Display lockfile path in very verbose mode when blocking (rust-lang/cargo#16491)
- fix(info): resolve underscore vs hyphen mismatch in schema lookup (rust-lang/cargo#16455)

---

An extra submodule update right after <#150739> due to a relatively impactful nightly regression <rust-lang/cargo#16493>
rust-bors bot added a commit to rust-lang/rust that referenced this pull request Jan 11, 2026
Update cargo submodule

5 commits in 8c133afcd5e0d69932fe11f5907683723f8d361d..6d1bd93c47f059ec1344cb31e68a2fb284cbc6b1
2026-01-09 03:50:15 +0000 to 2026-01-10 12:53:59 +0000
- fix: preserve `dep_name` for build script metadata  (rust-lang/cargo#16494)
- refactor(toml): clarify `to_dependency` for config patch (rust-lang/cargo#16492)
- Add `--id` flag to `cargo report timings` and `cargo report rebuilds` (rust-lang/cargo#16490)
- Display lockfile path in very verbose mode when blocking (rust-lang/cargo#16491)
- fix(info): resolve underscore vs hyphen mismatch in schema lookup (rust-lang/cargo#16455)

---

An extra submodule update right after <#150739> due to a relatively impactful nightly regression <rust-lang/cargo#16493>
@rustbot rustbot added this to the 1.94.0 milestone Jan 11, 2026
github-actions bot pushed a commit to rust-lang/rustc-dev-guide that referenced this pull request Jan 12, 2026
Update cargo submodule

5 commits in 8c133afcd5e0d69932fe11f5907683723f8d361d..6d1bd93c47f059ec1344cb31e68a2fb284cbc6b1
2026-01-09 03:50:15 +0000 to 2026-01-10 12:53:59 +0000
- fix: preserve `dep_name` for build script metadata  (rust-lang/cargo#16494)
- refactor(toml): clarify `to_dependency` for config patch (rust-lang/cargo#16492)
- Add `--id` flag to `cargo report timings` and `cargo report rebuilds` (rust-lang/cargo#16490)
- Display lockfile path in very verbose mode when blocking (rust-lang/cargo#16491)
- fix(info): resolve underscore vs hyphen mismatch in schema lookup (rust-lang/cargo#16455)

---

An extra submodule update right after <rust-lang/rust#150739> due to a relatively impactful nightly regression <rust-lang/cargo#16493>
github-actions bot pushed a commit to rust-lang/miri that referenced this pull request Jan 12, 2026
Update cargo submodule

5 commits in 8c133afcd5e0d69932fe11f5907683723f8d361d..6d1bd93c47f059ec1344cb31e68a2fb284cbc6b1
2026-01-09 03:50:15 +0000 to 2026-01-10 12:53:59 +0000
- fix: preserve `dep_name` for build script metadata  (rust-lang/cargo#16494)
- refactor(toml): clarify `to_dependency` for config patch (rust-lang/cargo#16492)
- Add `--id` flag to `cargo report timings` and `cargo report rebuilds` (rust-lang/cargo#16490)
- Display lockfile path in very verbose mode when blocking (rust-lang/cargo#16491)
- fix(info): resolve underscore vs hyphen mismatch in schema lookup (rust-lang/cargo#16455)

---

An extra submodule update right after <rust-lang/rust#150739> due to a relatively impactful nightly regression <rust-lang/cargo#16493>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-build-scripts Area: build.rs scripts

Projects

None yet

Development

Successfully merging this pull request may close these issues.

custom_build.rs regression: Dependency not found in dependencies

4 participants