Repository navigation
Conversation
weihanglo
approved these changes
Oct 9, 2026
| /// or an absolute path /.../sysroot/... | ||
| BuildRootRelative, | ||
| /// Relative to the workspace root (but not in the package root) | ||
| WorkspaceRootRelative, |
Member
There was a problem hiding this comment.
I feel this is not that uncommon of a usecase and could reduce rebuilds in some scenarios.
I'd say include_bytes! outside package root is an anti pattern, though it is indeed not uncommon. This does help if the entire workspace is relocated.
weihanglo
enabled auto-merge
October 9, 2026 18:17
opensource-fork-sync Bot
pushed a commit
to cla7aye15I4nd/opensource-rust-lang__cargo
that referenced
this pull request
Oct 10, 2026
…#17575) ### What does this PR try to resolve? This is a follow up on rust-lang#17573 to fix a bug that it introduced. The gist is that if there is a shared `target-dir` between 2 workspaces and both workspaces take a path dependency on an external crate that uses `include!` to a file in one of the workspaces, the relative workspace path is used in the fingerprint and leads to a stale build. This is admittedly a mega edge case, but the fix is pretty straight forward. :robot: LLM Disclosure: An LLM found this bug and I used it to help me create the test commit. ### How to test and review this PR? See the test case r? @weihanglo
rust-bors Bot
pushed a commit
to rust-lang/rust
that referenced
this pull request
Oct 14, 2026
Update cargo submodule 14 commits in 29c5daa1afc262323364e039bb70c83372cc702c..3960fa69bb617e3d93c4ddc087c1b32bf12ad907 2026-10-07 22:13:48 +0000 to 2026-10-12 19:29:05 +0000 - refactor: modernize some API usages for 1.99 (rust-lang/cargo#17584) - Removed some dead workspace tests (rust-lang/cargo#17582) - Bypass rustup proxy when RUSTUP_TOOLCHAIN is an absolute path (rust-lang/cargo#17562) - chore: Add an LLM disclosure to the PR template (rust-lang/cargo#17580) - Restrict workspace-relative dep-info to workspace packages (rust-lang/cargo#17575) - fix(layout): exclude a build-dir created as a parent from backups (rust-lang/cargo#17560) - Avoid absolute paths in fingerprints if they are relative to the workspace root (rust-lang/cargo#17573) - chore(deps): update msrv (3 versions) to v1.97 (rust-lang/cargo#17572) - fix(job): Allow explicit child process breakaway on Windows (rust-lang/cargo#17527) - fix(git): Add future-incompat warning in prep for removing auto-detection (rust-lang/cargo#17568) - fix(config): Don't process includes for `credentials.toml` files (rust-lang/cargo#17569) - doc(builtin-dep): Document the builtin package ID spec format (rust-lang/cargo#17564) - test(mock-std): Set stable crate versions to 0.0.0 (rust-lang/cargo#17565) - Fix: cargo installing from a directory source fails for binary packages with no dependencies. (rust-lang/cargo#17552) r? ghost
rust-bors Bot
pushed a commit
to rust-lang/rust
that referenced
this pull request
Oct 14, 2026
Update cargo submodule 14 commits in 29c5daa1afc262323364e039bb70c83372cc702c..3960fa69bb617e3d93c4ddc087c1b32bf12ad907 2026-10-07 22:13:48 +0000 to 2026-10-12 19:29:05 +0000 - refactor: modernize some API usages for 1.99 (rust-lang/cargo#17584) - Removed some dead workspace tests (rust-lang/cargo#17582) - Bypass rustup proxy when RUSTUP_TOOLCHAIN is an absolute path (rust-lang/cargo#17562) - chore: Add an LLM disclosure to the PR template (rust-lang/cargo#17580) - Restrict workspace-relative dep-info to workspace packages (rust-lang/cargo#17575) - fix(layout): exclude a build-dir created as a parent from backups (rust-lang/cargo#17560) - Avoid absolute paths in fingerprints if they are relative to the workspace root (rust-lang/cargo#17573) - chore(deps): update msrv (3 versions) to v1.97 (rust-lang/cargo#17572) - fix(job): Allow explicit child process breakaway on Windows (rust-lang/cargo#17527) - fix(git): Add future-incompat warning in prep for removing auto-detection (rust-lang/cargo#17568) - fix(config): Don't process includes for `credentials.toml` files (rust-lang/cargo#17569) - doc(builtin-dep): Document the builtin package ID spec format (rust-lang/cargo#17564) - test(mock-std): Set stable crate versions to 0.0.0 (rust-lang/cargo#17565) - Fix: cargo installing from a directory source fails for binary packages with no dependencies. (rust-lang/cargo#17552) r? ghost
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR try to resolve?
This was inspired by the discussion in #17571.
Currently we use relative paths in the Cargo dep-info file if its in
build-diror the package dir.Otherwise, we use absolute paths.
I felt that a relatively low hanging fruit to avoid absolute paths was to extend this to workspaces as well.
So that
include_str!("../../foo.txt")fromfoo/src/lib.rsin a workspace can avoid absolute paths.I feel this is not that uncommon of a usecase and could reduce rebuilds in some scenarios.
The change itself is quiet simple, add a new
DepInfoPathType::WorkspaceRootRelativeand serialize that with a new value2in our depinfo file.The remainder of the changes is plumbing
ws_rootthrough the fingerprint functions to get it totranslate_dep_infoHow to test and review this PR?
include_str!("../../foo.txt")and afoo.txtin the workspace rootcargo buildmvthe workspacecargo build(previously would rebuild, but now should avoid a rebuild)r? @weihanglo