-
Notifications
You must be signed in to change notification settings - Fork 2.6k
perf(package): Always reuse the workspace's target-dir #15783
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
Conversation
…verify When running `cargo package` the verify the build cache (target-dir/build-dir) will not be used and all dependencies will be recompiled. This is inconsistent as setting target dir (via `CARGO_TARGET_DIR` for example) will cause `cargo package` to reuse the build cache. This commit changes the default behavior to always use the build cache, matching the behavior of having target-dir set.
Linking to the Cargo meeting discussion about this PR. It appears no consensus was made as many members were out that week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'm fine with making this change. I don't recall any reasoning for keeping it separate, but I suspect if it was intentional that the intent was to avoid bad fingerprinting from properly validating the package. However, I'm comfortable now with proper fingerprinting from catching anything that needs to be rebuilt.
@epage or @weihanglo Do you have any other context on this? Otherwise I think we should merge.
Build scripts and proc macros can mess with things. However, if the packaged packages (which is what we care about verifying) are getting a unique package id (which it should) it should then have a unique fingerprint, avoiding those problems. Unless people are digging around outside of whats fingerprinted. I assume the current-dir is the package root and I'm assuming that is in the packaging directory, so that interferes with mucking around. I don't think we officially expose target-dir but people try to approximate it through what |
We discussed this in today's meeting. There were no objections and we can always revert this later. |
What does this PR try to resolve?
While preparing to stabilize
build-dir
, it was discovered thatcargo package
will sometimes use the build cache for dependency crates ifCARGO_TARGET_DIR
is explicitly set.If target-dir is not set, the build will be preformed in an "inner target dir" at
target/package/{name}-{version}/target
and rebuild everything.This PR changes the default behavior to always use the build cache,
matching the behavior of having
target-dir
set.How to test and review this PR?
Added a dedicated test to verify the previous behavior (cargo recompiled non-workspace crates) in the first commit.
Then updated it to verify the new behavior.
Related links/notes
target_dir
to Workspace and fix #2848 #2912cargo package
(and hencecargo publish
) verify step is slow from doing a full build #14941