Add TRYBUILD_NO_CFG to opt out of cfg injection and share parent target dir#329
Closed
TarunvirBains wants to merge 1 commit into
Closed
Add TRYBUILD_NO_CFG to opt out of cfg injection and share parent target dir#329TarunvirBains wants to merge 1 commit into
TarunvirBains wants to merge 1 commit into
Conversation
When TRYBUILD_NO_CFG is set, omit the --cfg trybuild rustflag and don't override CARGO_TARGET_DIR. The spawned cargo's incremental cache hits the parent workspace's existing artifacts, which substantially shortens cold-cache builds for crates with heavy dependency trees. Default behavior unchanged when the variable is unset.
fefbdcf to
62e3aa8
Compare
Author
|
Closing in favor of a different design direction. The shared-target-dir approach in this PR works for cache reuse but introduces build-lock contention between the parent workspace and trybuild's spawned cargo. A cleaner approach is to keep trybuild's target dir isolated and seed it from the parent's artifacts (reflink / hardlink / copy fallback), preserving trybuild's isolation invariant while still getting the cache reuse. Will follow up with a new PR. Issue #328 stays open as the problem statement. |
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.
Adds an opt-in
TRYBUILD_NO_CFGenv var. When set:rustflags::tomlomits--cfg trybuildfrom the rustflags passed to spawned cargo.cargo::cargo_target_dirreturns noCARGO_TARGET_DIRoverride, so the parent's value (or absence) flows through.Both halves are needed together. The cfg perturbs the rustc fingerprint, and the target-dir override means cargo never gets the chance to compare fingerprints anyway — either alone leaves the spawned cargo recompiling from cold.
When unset, behavior is unchanged. Filed as #328.
Verified end-to-end with a smoke harness:
Baseline: spawned cargo writes artifacts under
target/tests/trybuild/{debug,x86_64-...}. WithTRYBUILD_NO_CFG=1, those subdirs are absent and the spawned cargo's incremental output lands undertarget/debug/instead.Trybuild's existing tests pass (26/26) with no test changes — they're normalization fixtures that don't spawn cargo. I considered adding a unit test that asserts
rustflags::toml()returns different values based on the env var, but env-mutation tests are racy without serialization; let me know if you'd prefer it added and which approach you'd want.Related: #305 (narrow rustflags carve-out for
-C instrument-coverage), #106 / #283 (same friction from different angles).