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

Fix freshness checks for build scripts on renamed dirs #8497

Merged
merged 1 commit into from
Jul 17, 2020

Conversation

alexcrichton
Copy link
Member

This commit fixes an issue in Cargo where when an entire project
directory is renamed (preserving the target directory) then path
dependencies with build scripts would have their build scripts rereun
when building again. The problem with this was that when a build script
doesn't print rerun-if-changed Cargo's conservative fingerprint listed
an absolute path in it, which was intended to be a relative path.

The fix here is to use a relative path in the fingerprint to ensure that
it's not the reason a rebuild happens when directories are renamed.

This commit fixes an issue in Cargo where when an entire project
directory is renamed (preserving the target directory) then path
dependencies with build scripts would have their build scripts rereun
when building again. The problem with this was that when a build script
doesn't print `rerun-if-changed` Cargo's conservative fingerprint listed
an absolute path in it, which was intended to be a relative path.

The fix here is to use a relative path in the fingerprint to ensure that
it's not the reason a rebuild happens when directories are renamed.
@rust-highfive
Copy link

r? @ehuss

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 17, 2020
pkg.package_id().source_id(),
self.config,
);
let mut src = PathSource::new(pkg.root(), pkg.package_id().source_id(), self.config);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there's one more case of this going wrong. vendor also passes the manifest path. I think a cursory looks suggests that's the last case though.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah I think .parent() is called there so the directory is passed in (I tried to audit all sources of PathSource::new to make sure the directory, not the manifest, was passed in)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah yes, I missed that -- seems like it should be calling Package::root() rather than manually getting the parent though. But indeed not an issue.

@ehuss
Copy link
Contributor

ehuss commented Jul 17, 2020

👍
Any idea why the macos job was cancelled?
@bors r+

@bors
Copy link
Contributor

bors commented Jul 17, 2020

📌 Commit 64a4682 has been approved by ehuss

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jul 17, 2020
@bors
Copy link
Contributor

bors commented Jul 17, 2020

⌛ Testing commit 64a4682 with merge 03f084c...

@alexcrichton
Copy link
Member Author

❓ infrastructure ❓

@bors
Copy link
Contributor

bors commented Jul 17, 2020

☀️ Test successful - checks-actions
Approved by: ehuss
Pushing 03f084c to master...

@bors bors merged commit 03f084c into rust-lang:master Jul 17, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 23, 2020
Update cargo

21 commits in 43cf77395cad5b79887b20b7cf19d418bbd703a9..aa6872140ab0fa10f641ab0b981d5330d419e927
2020-07-13 17:35:42 +0000 to 2020-07-23 13:46:27 +0000
- Update features set in CI. (rust-lang/cargo#8530)
- Stabilize -Z crate-versions (rust-lang/cargo#8509)
- Fix typo in docs (rust-lang/cargo#8529)
- Remove unused CompileMode::all_modes (rust-lang/cargo#8526)
- Mask out system core.autocrlf settings before resetting git repos (rust-lang/cargo#8523)
- Flag git zlib errors as spurious errors (rust-lang/cargo#8520)
- Fix the help display for the target-triple option (rust-lang/cargo#8515)
- Check workspace member existence as dir. (rust-lang/cargo#8511)
- Bump to 0.48.0, update changelog (rust-lang/cargo#8508)
- Apply workspace.exclude to workspace.default-members. (rust-lang/cargo#8485)
- Fix nightly tests for intra-doc links. (rust-lang/cargo#8528)
- doc: Replace "regenerate" with "revoke" for API tokens (rust-lang/cargo#8510)
- Add back Manifest::targets_mut (rust-lang/cargo#8494)
- Build host dependencies with opt-level 0 by default (rust-lang/cargo#8500)
- Fix freshness checks for build scripts on renamed dirs (rust-lang/cargo#8497)
- Add a `-Zbuild-std-features` flag (rust-lang/cargo#8490)
- clippy cleanups (rust-lang/cargo#8495)
- Fix self-publish script. (rust-lang/cargo#8492)
- Ensure `unstable.build-std` works like `-Zbuild-std` (rust-lang/cargo#8491)
- Make `cargo metadata` output deterministic (rust-lang/cargo#8489)
- Switch to github actions (rust-lang/cargo#8467)
@alexcrichton alexcrichton deleted the fix-rebuild-on-rename branch July 29, 2020 17:48
@ehuss ehuss added this to the 1.47.0 milestone Feb 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants