Skip to content

Build: pin the Rust toolchain and enforce Cargo.lock in CI and scripts/test.ps1 #2214

In review

Description

@itsonewi

The build inputs are not pinned, so a green run cannot be reproduced later and CI can validate a dependency set that is not in the repository.

What is missing

  • No rust-toolchain.toml at the repository root (the root listing has Cargo.toml, Cargo.lock, README.md, ... but no toolchain file and no .cargo/config.toml).
  • No rust-version in Cargo.toml ([workspace.package] has version, edition and license, lines 5-8) or in crates/xcl/Cargo.toml, tests/testtitle/Cargo.toml, tests/testgamedll/Cargo.toml.
  • .github/workflows/ci.yml installs whatever stable is that day:
    • line 38: rustup toolchain install stable --profile minimal
    • line 39: rustup default stable
      It prints rustc --version (line 40) but nothing compares it with a committed value.
  • scripts/test.ps1 runs Cargo without --locked:
    • line 11: cargo build --workspace
    • line 16: cargo test --workspace -- --test-threads=4 @args

Cargo.lock is committed (15 KB), so the intent is clearly to build a fixed dependency set. Without --locked, a build after a Cargo.toml change (a dependency added or a version bumped) updates the lock in the working tree; CI passes, but the lock in the PR may still be the old one. A fresh clone then builds a different graph, and a later --locked build fails. cargo build --locked would fail immediately on a stale lock instead of silently rewriting it.

The same applies to contributors: scripts/test.ps1 is the documented local command (HANDOFF.md), and it does not tell Cargo to reject a lock update.

Why it matters

  • A PR checks / CI result is tied to a moving compiler. A new stable release can change lints, codegen, or a dependency's MSRV between the PR run and the merge, with no record of the version that was tested.
  • Two contributors following CONTRIBUTING can build different dependency graphs from the same commit.
  • There is no MSRV, so an older toolchain fails with a compiler error instead of Cargo's "requires rustc X" message, and nothing tells a packager which compiler is supported.
  • HANDOFF.md names Rust 1.96 x86_64-pc-windows-msvc; CI: lint, licence, cache and dependency-update checks #265 measured 1.97.1. The repository does not encode either.

Suggested fix

  1. Add rust-toolchain.toml with the version the last green run used:
    [toolchain]
    channel = "<version>"
    profile = "minimal"
    components = ["rustfmt", "clippy"]   # if wanted
    
  2. Add rust-version = "<version>" to [workspace.package] and inherit it in the three crates (rust-version.workspace = true).
  3. Use cargo build --locked --workspace and cargo test --locked --workspace ... in scripts/test.ps1, and the same flags in any other Cargo invocation in CI.
  4. Keep a non-blocking scheduled job (or one continue-on-error leg) on stable so a future compiler break is seen early, while the required check stays on the pinned version.
  5. Optionally print rustc --version and cargo --version in the workflow summary, and note the pinned version in CONTRIBUTING.

Related

Scope

Read through the GitHub API at 568e7db; nothing was cloned, built or run, so the --locked behaviour above is from Cargo's documented behaviour, not from a failing run in this repository.

Activity

  1. WASDeKeys commented on Nov 25, 2026

    @WASDeKeys

    I'd like to take this one, unless someone is already on it. I searched open PRs for rust-toolchain, --locked and rust-version and found none.

    Plan for a first, small PR:

    1. rust-toolchain.toml at the root
    2. rust-version in [workspace.package], inherited by crates/xcl, tests/testtitle and tests/testgamedll
    3. --locked in scripts/test.ps1 and in the Cargo calls in .github/workflows/ci.yml

    The scheduled non-blocking job on stable, and the version printout in the workflow summary, I would leave for a second PR if you want them.

    Question: which version should be pinned? HANDOFF.md names 1.96 and #265 measured 1.97.1. The latest green CI run on main used [version from the Actions log, or delete this sentence]. I build locally with 1.100.0. @itsonewi

    I will check the --locked claim on a scratch branch (stale Cargo.lock fails with --locked, is rewritten without it) and post the result in the PR. I am on Windows with NVIDIA, so I can run scripts/test.ps1 but cannot run CI itself.

    AI use: Claude helps run tests and draft description/comments; I code and check all outputs and compilations myself.

  2. luckyteagirl commented on Nov 25, 2026

    @luckyteagirl
    Contributor

    @WASDeKeys Please take #2214; your comment arrived while I was validating the same change, so I will not open a duplicate PR. These independent Windows results may help choose the versions and describe the test limits.

    On current main 568e7db7729c8fa6c8f0f4b32d798faaf11462bb, I made an uncommitted local scratch edit with rust-toolchain.toml set to 1.100.0 (minimal profile), rust-version = "1.99.0" inherited by the three workspace packages, and --locked in both calls in scripts/test.ps1. The CI workflow edit was present locally but was not run on Actions. cargo metadata --locked --no-deps showed Rust version 1.99.0 for all three packages, and Cargo.lock remained unchanged.

    Hardware: Windows 11 build 26200, Ryzen 9 5980HX, RX 6800M driver 30.0.13002.13003, DXC/DXIL 1.9.2609.5. The installed local stable alias is Rust 1.99.0; the explicit pinned toolchain is Rust 1.100.0.

    • Rust 1.99.0: cargo +stable build --locked --workspace -j 2 passed in a separate target directory.
    • Rust 1.100.0, no matching adapter (XCL_ADAPTER=XCL-NO-SUCH-ADAPTER): the edited scripts/test.ps1 passed. Across 21 targets: 1,154 passed, 0 failed, 46 ignored, with 294 explicit SKIPPED lines. This exercises the locked script and the no-GPU fallback on this PC; it is not a GitHub Actions runner.
    • Rust 1.100.0, XCL_ADAPTER=6800M: the edited script built the workspace, then stopped at the library test target: 937 passed, 161 failed, 26 ignored. A separate cargo test --locked --workspace --no-fail-fast -- --test-threads=4 reached all 21 targets: 993 passed, 161 failed, 46 ignored, with six explicit skips. The broad RX 6800M failure cluster includes D3D12 device suspension (0x887A0005) and was observed before this config-only edit; these counts are not a green GPU run.

    No scratch branch was pushed and no PR was opened. The result supports 1.99.0 as a tested minimum on this machine and 1.100.0 as a buildable pinned toolchain. It does not establish that older Rust versions fail, nor that the GitHub CI environment passes.

    AI use: OpenAI Codex (GPT-6; exact variant not exposed) made the local scratch edit, ran and checked these commands, and drafted this report.

  3. itsonewi commented on Nov 25, 2026

    @itsonewi
    Author

    On the version: there is no declared MSRV in the tree, and the three numbers are different things:

    • HANDOFF.md:8 says the project is developed on Rust 1.96 (the maintainer's machine, not a policy).
    • CI: lint, licence, cache and dependency-update checks #265 measured 1.97.1 on main 9ab7d76 for its cache/warning numbers.
    • CI installs floating stable and prints rustc --version in the "Rust (stable, MSVC)" step; the last green main run is the only version CI has actually tested.

    I would pin the oldest version the tree builds with, not the newest:

    1. Try 1.96.0 first, because HANDOFF names it. On a scratch branch: rustup toolchain install 1.96.0, cargo +1.96.0 build --workspace --locked, then cargo +1.96.0 test --workspace if time allows. If a dependency now needs newer, go to 1.97.1 and then to the lowest that passes; say in the PR which crate set the floor. Cargo.lock is format 4 (Cargo 1.78+), so that is not the constraint, and edition = "2021" only needs 1.56 - the dependencies decide.
    2. Set rust-version to the version you pinned, and add rust-version.workspace = true to each member (crates/xcl, tests/testtitle, tests/testgamedll); [workspace.package] is not inherited automatically. rust-version is a minimum check, not a selector, so do not set 1.100 just because you build with it locally.
    3. In CI, rust-toolchain.toml overrides rustup default stable, so the rustc --version line will print the pin. That is fine; keep the scheduled stable job (or a RUSTUP_TOOLCHAIN=stable step) for future-stable breakage, as you planned. Note that rustup will auto-install the pinned toolchain on first use, so the "install stable" step no longer describes what runs.
    4. --locked does what you expect: if a manifest is newer than the lock, cargo build --locked fails and without --locked Cargo rewrites Cargo.lock. For scripts/test.ps1, that means a contributor who adds a dependency must update the lock before the script passes; worth one line in CONTRIBUTING if it is not obvious.

    If you would rather not test 1.96, pin the stable version printed by the last green main CI run; it is the only one with evidence behind it today. A comment in rust-toolchain.toml with the date makes the next bump easier.

  4. WASDeKeys commented on Nov 25, 2026

    @WASDeKeys

    @itsonewi
    Thank you for your detailed feedback. I've revised the
    approach based on your instructions:

    1. Rust Version Pinning:
      • Will test 1.96.0 first as mentioned in HANDOFF.md
      • Will verify with: rustup toolchain install 1.96.0
      • Then: cargo +1.96.0 build --workspace --locked
      • If needed, will escalate to 1.97.1 and find the lowest working
        version
      • Will document which crate set the minimum version requirement
    2. Configuration Changes:
      • Will set rust-version to the pinned version in
        [workspace.package]
      • Will add rust-version.workspace = true to each member crate
      • This ensures proper minimum version checking without forcing a
        specific version
    3. CI Workflow:
      • rust-toolchain.toml will override the CI's stable installation
      • The rustc --version line will show the pinned version
      • Will keep the scheduled stable job for future compatibility
        checks
      • Will note that rustup will auto-install the pinned toolchain
    4. Locked Builds:
      • --locked will enforce reproducible builds
      • Contributors will need to update Cargo.lock when adding
        dependencies
      • Will document this requirement in CONTRIBUTING.md if not already
        clear
    5. Documentation:
      • Will add a comment in rust-toolchain.toml with the date
      • This will make future version bumps easier to track

    I'll proceed with these changes and verify the build with the pinned
    version.

    Claude AI was used to solely draft this reply.

  5. WASDeKeys commented on Nov 25, 2026

    @WASDeKeys

    @itsonewi
    Thanks for the independent Windows
    ▎ results — this is exactly the kind of
    ▎ cross-check #2214 needs, and I
    ▎ appreciate you not opening a
    ▎ duplicate PR.
    ▎
    ▎ A few things from my side on the
    ▎ pin-rust-toolchain branch:
    ▎ - It pins rust-toolchain.toml to
    ▎ 1.100.0 (minimal profile), sets
    ▎ workspace rust-version = "1.100.0",
    ▎ and uses --locked in both calls in
    ▎ scripts/test.ps1, matching the
    ▎ approach you validated locally. The
    ▎ CI workflow edit mirrors yours
    ▎ (rust-toolchain.toml selects the
    ▎ compiler; cache key includes
    ▎ rust-toolchain.toml).
    ▎ - Your numbers line up with what I'd
    ▎ expect: 1.99.0 builds cleanly as a
    ▎ tested minimum, 1.100.0 builds as the
    ▎ pinned toolchain, and the RX 6800M
    ▎ GPU failure cluster you saw is
    ▎ pre-existing and unrelated to this
    ▎ config-only change (device removal
    ▎ 0x887A0005, not a toolchain/compile
    ▎ issue).
    ▎ - What's still outstanding: a real
    ▎ GitHub Actions CI run (the workflow
    ▎ edit exists locally but hasn't run on
    ▎ Actions), and a green full-GPU test
    ▎ run on supported hardware. Your
    ▎ results are from a local machine, not
    ▎ Actions, so they support the
    ▎ direction but don't establish
    ▎ CI-passing.
    ▎
    ▎ One heads-up before this becomes a
    ▎ PR: I noticed a couple of things on
    ▎ the branch worth cleaning up first so
    ▎ the diff stays config-only and
    ▎ within the size/scope rules:
    ▎ - each crate manifest now has
    ▎ rust-rust-version.workspace = true,
    ▎ which looks like a typo/dead line (no
    ▎ such Cargo key), and
    ▎ version.workspace = true was dropped
    ▎ — Cargo.lock shows all three packages
    ▎ falling from 0.1.0 to 0.0.0;
    ▎ - the
    ▎ crates/xcl/src/hle/d3d12x/vram.rs
    ▎ test change (VRAM lock reorder + < 8
    ▎ GB VRAM skip) is unrelated to
    ▎ toolchain pinning.
    ▎
    ▎ I'd fold those out before opening the
    ▎ PR. Happy to hand off or stack
    ▎ however works for you — I won't push
    ▎ or open a PR unless you'd like me to.


    Heads-up on the branch (what I saw in
    git diff main..HEAD)

    1. rust-rust-version.workspace = true
      appears in all three crate manifests
      (crates/xcl, tests/testtitle,
      tests/testgamedll). That isn't a
      real Cargo manifest key — it looks
      like an accidental duplication/typo.
      Cargo may accept it with a warning
      or ignore it, but it's dead weight
      and should be removed. (WASDeKeys's
      scratch edit only added rust-version
      = "1.99.0" inherited via the
      workspace — no per-crate
      rust-version lines at all.)
    2. Version drift in Cargo.lock:
      testgame-mw, xcl, and xcl-testtitle
      all moved 0.1.0 → 0.0.0. This
      follows from removing
      version.workspace = true from each
      crate — they no longer inherit the
      workspace version. The workspace
      Cargo.toml still says version =
      "0.1.0", so this drift is almost
      certainly unintended and should be
      reverted (restore version.workspace
      = true).
    3. crates/xcl/src/hle/d3d12x/vram.rs:
      this test change has nothing to do
      with pinning the toolchain. Per the
      project's one-change-per-PR rule, it
      belongs in its own PR, not here.
    4. CI workflow wasn't run on Actions
      (per WASDeKeys), so the "CI green"
      requirement isn't satisfied yet —
      that's a next step, not something to
      claim.

    I will be making a new PR after i push these changes to my commit, i will be referencing #2214, thank you for the help @itsonewi

    Sonnet 5.5 was used to draft this reply while I myself made the changes and ran tests

  6. itsonewi commented on Nov 25, 2026

    @itsonewi
    Author

    Good, 1.96 first is the right order. Three notes:

    • Do not put components = ["rustfmt", "clippy"] in rust-toolchain.toml. The tree is not rustfmt-clean and AGENTS.md tells contributors never to run cargo fmt on it, so shipping rustfmt invites exactly the drive-by reformat the rules forbid. profile = "minimal" is enough for CI.
    • If 1.96.0 fails, the error names the package that raised the floor ("package X requires rustc Y"). Quote that line in the PR: it is the evidence for whatever version you settle on.
    • Leave the CI rustc --version step alone. With the pin it prints the pinned version, which is the record that the run used it; the scheduled stable leg stays the early-warning job for a future compiler break.
  7. WASDeKeys commented on Nov 25, 2026

    @WASDeKeys

    @itsonewi

    thanks for the review, three points:

    1. rustfmt/clippy components — Confirmed, rust-toolchain.toml uses profile = "minimal" only, no components array. No rustfmt or clippy shipped, matching the AGENTS.md rule against drive-by reformatting.
    2. Minimum version evidence — Noted. We've validated 1.99.0 builds and 1.100.0 as the pinned toolchain, but haven't tested below 1.100.0 yet. If we try 1.96.0 and it fails, we'll quote the "package X requires rustc Y" line as evidence for whatever version we settle on.
    3. CI rustc --version step — Confirmed, the CI workflow diff keeps rustc --version (it now prints the pinned version from rust-toolchain.toml); we're not touching that step.

    The cleanup is in on the pin-rust-toolchain branch: removed the bogus rust-rust-version.workspace = true lines, restored version.workspace = true, reverted the unrelated vram.rs test change, and Cargo.lock is back to 0.1.0 on all three packages. cargo build --workspace passes with --locked.

    still outstanding before the PR: a full test-suite run to report real counts, and the regression smoke blocks (main vs PR head) since this touches scripts/test.ps1 and CI. I'll add those once the suite is green.

    also, i assume i will have to run smoke tests before i make the PR @itsonewi ?

  8. itsonewi commented on Nov 25, 2026

    @itsonewi
    Author

    Short answer: no smoke blocks for this one. CONTRIBUTING item 3 requires the regression run only for a PR that changes the runtime (crates/xcl/src outside tests). Your diff is rust-toolchain.toml, the three Cargo.tomls, scripts/test.ps1 and .github/workflows/ci.yml - nothing in crates/xcl/src - so pr_check.py will not ask for the two xcl-smoke blocks. Two things that still apply:

    • Item 2 does: the whole suite on a GPU with the real counts (passed / failed / ignored / SKIPPED). Since the PR makes test.ps1 pass --locked, run it through the edited script at least once, so the counts come from the command the PR changes rather than from a bare cargo test.
    • If you end up touching crates/xcl/src for anything (even a test), the smoke requirement comes back. Keep it out of this PR.

    On the version: pinning 1.100.0 with rust-version = "1.99.0" is coherent (a minimum is not a selector), but the body should say why, because HANDOFF.md names 1.96 - a reader will see three numbers and no explanation. And "we validated 1.99.0 builds" is @luckyteagirl measurement on an RX 6800M, not yours; attribute it or drop the claim, since Tested has to be a run you made.

  9. WASDeKeys commented on Nov 25, 2026

    @WASDeKeys

    @itsonewi
    So when i make the PR without smoke blocks in its description, I just tag a maintainer so that the PR doesnt get flagged as failing the checks?

  10. itsonewi commented on Nov 25, 2026

    @itsonewi
    Author

    Correction to what I said above: the smoke pair is required for this PR. I answered from the CONTRIBUTING wording instead of checking pr_check.py, and the checker is wider than ".rs files under crates/xcl/src". It has two predicates:

    def runtime(path):
        return path.startswith("crates/xcl/src/") and "/tests" not in path and not path.endswith("tests.rs")
    
    RUNTIME_BUILD = ("crates/xcl/build.rs", "crates/xcl/Cargo.toml", "Cargo.toml", "Cargo.lock")
    
    def builds_runtime(path):
        return path.startswith("crates/xcl/data/") or path in RUNTIME_BUILD

    check() then asks for the regression run if any changed path matches either. Your branch touches Cargo.toml (root, +1) and Cargo.lock (+3/-3), and both are in RUNTIME_BUILD, so the section is required: one clean main block and one on the PR head, same title and same seconds. That is deliberate - the workspace manifest and the lock file pick xcl.exes dependencies and release profile, so the binary changes even when no source file moves. Sorry for the wrong first answer.

    The tagging part still holds: the decision comes from the diff, never from a mention, so nobody needs to be tagged and tagging does not make the check pass.

    Second thing I noticed while comparing the branch - it also changes AGENTS.md, CONTRIBUTING.md and README.md. For a toolchain pin those read as scope creep, and CONTRIBUTING.md +9/-1 is a policy change that a maintainer makes, not a side effect of a pin. I would drop all three from this PR (a one-line version note in the body covers it), and if the CONTRIBUTING line is really needed, ask a maintainer for it separately - otherwise the PR competes with its own purpose.

  11. added a commit that references this issue on Nov 25, 2026
    500578c
  12. WASDeKeys commented on Nov 25, 2026

    @WASDeKeys

    @itsonewi I have added a fix to this issue : #2295 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions