Repository navigation
perf(ts): check std once per toolchain as a Nix sysroot - #237
Conversation
Quest-Claim: 87e6d34c667dfd46
The flake checks std for wasm32 with -Zbuild-std once per toolchain, with the profile translation reads its MIR at, and the dev shell and ts package pass it as RUST2_TS_SYSROOT, which the wrapper gives the target's crates as --sysroot. Without it, each target directory checks std with -Zbuild-std as before, from the same profile, now in ts/src/profile.toml. A nightly step runs the fixtures that way. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…apper elsewhere Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
kixelated
left a comment
There was a problem hiding this comment.
Automated review by review (OpenAI)
Reviewed commit: 4232079
No actionable new bugs found in the reviewed paths. A checked-std sysroot preserves the required MIR profile rather than relying on optimized prebuilt std; sharing profile.toml and retaining the source-build fallback are proportionate choices. Resolving the sysroot before Cargo changes directories fixes the relative-path issue, and target-only injection keeps host build scripts and proc macros on their normal sysroot.
The acknowledged warm-cache limitation remains: changing only std-specific profile settings does not invalidate dependent crates through Cargo's fingerprint, so a clean target directory can still be required after E0460. Coverage for relative paths, invalid sysroots and switching modes in a warm target directory would help protect these boundaries.
Verification: independent static inspection of the Nix derivation, CLI/wrapper, shared profile and fallback CI step. No Nix builds, fixture tests, census comparisons or performance measurements run; the reported equivalence and timings were not independently reproduced.
(Written by OpenAI)
# Conflicts: # quest/m2/ts-std-build.md
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 59 minutes. View limit details
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d77d3835c5
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if args.windows(2).any(|w| w[0] == "--target" && w[1] == cli::TARGET) | ||
| && let Some(sysroot) = cli::sysroot()? | ||
| { | ||
| args.extend(["--sysroot".into(), sysroot]); |
There was a problem hiding this comment.
Include the selected sysroot in Cargo's cache identity
When the sysroot changes without a toolchain or shared-rustflags change, Cargo can reuse dependencies checked against the previous std because this flag is added inside the wrapper, after Cargo computes its fingerprints. For example, changing only profile.dev.package.core.rustflags in profile.toml rebuilds the Nix sysroot but leaves cached target dependencies intact. Check::run cleans only the configured package, so its subsequent compilation fails with E0460 against those dependencies until the target directory is manually cleaned. Include the resolved sysroot in Cargo-visible fingerprint inputs or isolate target artifacts by sysroot identity so updating the dev shell does not break an existing translation directory.
Useful? React with 👍 / 👎.
* quest: plan follow-ups of #237 and #241 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> * quest: fold #247's follow-ups into ts-dyn and ts-drop-order Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> --------- Co-authored-by: Luke Curley <432854+kixelated@users.noreply.github.com> Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Completes and deletes quest/m2/ts-std-build.md, rewritten to the plan decided here.
Problem
rust2-ts checks std from source with
-Zbuild-stdin every cold target directory, because translation needs std's un-inlined MIR. The prebuilt std doesn't work: its optimized MIR changes snapshots and the census, and it refusesLocalKey's methods (measured in this PR's first attempt). On every cold run, CI pays for a std check in each of the fixture suite's 3 target directories.Approach
flake.nixaddsrust2-ts-std, a derivation that checks std once per toolchain. It runs-Zbuild-stdoffline from the crates rust-src vendors, with the same profile translation uses, and keeps thelib*.rmetafiles as a sysroot (72 MB). Its 23 rmeta files are byte-identical to the ones-Zbuild-stdwrites into a target directory, and the-C metadatahashes are the same.tspackage setRUST2_TS_SYSROOTto it. The CLI resolves that path to an absolute one and passes it on. The wrapper gives it to rustc as--sysroot, only for crates built for wasm32; build scripts and proc macros keep the host std.-Zbuild-std, rather than refusing, so the translator keeps working without the flake. ARUST2_TS_SYSROOTthat holds no std for wasm32 is refused, naming the path.ts/src/profile.toml, one--configper line. The CLI embeds it and the derivation passes it to cargo, so the two can't drift. The crate listcore,alloc,std,panic_abortappears in bothcli.rsandflake.nix, with a comment at each.RUST2_TS_SYSROOT=(empty), so the fallback stays held to the same snapshots.Proof
tsconfig.json,caller.ts). All snapshot and differential tests pass in both modes.just ts census(moq-net, model, kio) is byte-identical to main.just ts moqgives identical.tsfiles; the source maps differ only in source paths, because my moq checkout was a symlink.Measurements
CPU-s is user plus sys time. These were measured on a 32-core host with a load average around 30 from other jobs, so absolute numbers are inflated, but each pair below ran back to back.
-Zbuild-stdCI starts every cargo target directory cold, so a Check run saves the cold difference, about 250 to 350 CPU-s on this host. The derivation is rebuilt only when the nightly or
profile.tomlchanges, on runners that keep/nix/store. The nightly fallback step adds one fixture-suite run per night.Impact
RUST2_TS_SYSROOT, which thetspackage and the dev shell set. Unset, or set to empty, the translator checks std with-Zbuild-stdas before. No other API change, so noMIGRATE.mdentry.rust2-ts-std. The firstnix developafter a nightly bump builds it, about 1 CPU-minute.Alternatives
langand changes snapshots and the census.target.<triple>.rustflags: that would put it in cargo's fingerprint, but aRUSTFLAGSenvironment variable silently overrides it. The wrapper flag can't be overridden that way.Follow-ups
profile.toml, with the same nightly, leaves cached dependencies built against the old std. rustc then fails loudly with E0460 until the directory is cleaned. Any toolchain bump or change to the shared flags rebuilds everything already.Review
Codex gpt-6.1-sol, medium effort,
quest reviewround 2 on head 4232079: no findings.RUST2_TS_SYSROOTwas resolved from the package directory cargo runs the wrapper in. Fixed: the CLI now resolves it to an absolute path and passes that to cargo.Checks:
just checkandjust testpassed on a1ac238.just ts checkandjust ts testpassed on 4232079, which changes onlyts/src/cli.rs.Merge of main at
d77d3835c517f93e11bc4888db60b2b8cf4abb86: the only conflict was this PR deleting its finished quest file while #249 updated that file's links; resolved by deleting it. Nothing else changed since the reviewed head42320797, so this merge is a recorded skip, too trivial to review.(written by Claude Opus 5.5)
🤖 Generated with Claude Code