Skip to content

#1488 CI/packaging for rust2 builds - #1554

Merged
caomengxuan666 merged 7 commits into
mainfrom
build/rust2-ci-packaging
Nov 10, 2026
Merged

caomengxuan666 merged 7 commits into
mainfrom
build/rust2-ci-packaging

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs #1488. Makes the Rust-carrying build a first-class citizen of the CI/packaging pipeline (#1550, #1553 follow-up).

Audit findings (evidence first)

CI changes

  1. Pinned toolchain on every leg (RUST2_TOOLCHAIN=1.99.1, matching the windows-2025 image) replacing the arm64-only rustup step; both MSVC targets installed on all four legs, cached via actions/cache (toolchain slot + cargo registry; per-tree rust2-target dirs deliberately not cached - fresh checkout mtimes force a cargo rebuild anyway).
  2. -DWINUXCMD_ENABLE_RUST2=ON explicit on all three configure invocations (main/PGO train/PGO rebuild): a cargo-less runner now fails at configure instead of silently shrinking the applet set.
  3. RUST2_STATUS log line + marker file (rust2-build-status.txt) per leg, uploaded with the packages; fails loudly if the per-triple winuxcmd_ffi.lib is missing (build(rust2): build the ffi staticlib for the C++ target arch (Refs #1552) #1553 moved it under the triple directory).
  4. New rust2-surface-check job (gates release): PE machine types (0x8664/0xAA64), cross-arch marker comparison (rust2 ON, same commands/toolchain/rustc), GNU exit-code contract on the x64 exe (true=0, false=1, true --version=0, false --version=1 - coreutils true.c sole-argument rule, probed against the multicall dispatcher), and the packaging stray-file guard.
  5. Docs: "Rust toolchain requirements" in README/README-zh build sections, CONTRIBUTING prerequisites, AGENTS.md How-to-build.

Known limit

The arm64 binary cannot be executed on the x64 runner (no ARM64 emulation on x64 Windows), so behavioral parity for the arm64 slice is enforced by markers + gate coverage (rust2/gate), not by running it. A native probe on a windows-11-arm runner can close that later without changing the contract.

…log the WINUXCMD_ENABLE_RUST2 surface (Refs #1488)

A build with Rust is the first-class product (#1550: WINUXCMD_ENABLE_RUST2
defaults ON when cargo is found; replaced commands - true;false - are
dropped when it is OFF, never dual-tracked). Harden the CI accordingly:

- replace the arm64-only rustup target step with a pinned-toolchain setup
  (RUST2_TOOLCHAIN=1.99.1, matching the windows-2025 image) that installs
  BOTH msvc targets on EVERY leg: the arch skew run 42581933801 hit
  (LNK2001 winuxcmd_abi_version/run/free_buf on arm64, pre-#1553) must
  stay impossible by construction, and the aarch64 std library is not in
  the image's default installation.
- pass -DWINUXCMD_ENABLE_RUST2=ON explicitly on all three configure
  invocations (main, PGO train, PGO rebuild) so a cargo-less runner fails
  at configure time instead of silently shrinking the applet set.
- cache ~/.cargo registry/git (workspace has zero external crates; the
  per-tree rust2-target dirs are deliberately not cached - fresh checkout
  mtimes force a cargo rebuild anyway).
- new 'Record rust2 build surface' step: one RUST2_STATUS log line
  (ON/arch/triple/toolchain/rustc) per leg and a rust2-build-status.txt
  marker uploaded with the packages for the cross-arch consistency check
  that follows; fails the leg loudly if the per-triple winuxcmd_ffi.lib
  is missing (#1553 moved it under the triple directory).
…ckaging guard) (Refs #1488)

New rust2-surface-check job (needs build-windows, runs on every CI run,
gates release) enforcing the one-product invariant: the x64 and arm64
legs must carry the SAME rust2 command library. The arm64 exe cannot be
executed on the x64 runner (no ARM64 emulation on x64 Windows), so parity
is enforced on four layers:

1. PE machine type of both shipped winuxcmd.exe images (0x8664 / 0xAA64).
2. Per-leg rust2-build-status.txt markers compared: rust2=ON on both,
   same command set, same pinned toolchain and rustc version.
3. The x64 exe dispatches the replaced commands with the GNU exit-code
   contract: true=0, false=1, true --version=0, false --version=1
   (coreutils true.c sole-argument rule; false keeps EXIT_STATUS 1 -
   the same rule the rust2 gate pins in rust2/gate/cases). Local probe
   against the multicall dispatcher confirms the rc set.
4. Packaging guard: no stray rust2/toolchain files (winuxcmd_ffi,
   rlib/rmeta/pdb) in either archive - the staticlib is folded into
   winuxcmd.exe by the link run, so there is nothing to distribute.

release now needs the check, so a tag cannot publish an arch-skewed
applet set. Native arm64 behavioral probing (windows-11-arm runner) can
replace layer 3's arch asymmetry later without changing the contract.
…y (Refs #1488)

Document what a builder needs now that true/false live in Rust (#1550):
rustup + both MSVC targets (aarch64-pc-windows-msvc is required for
cross arm64 builds - cargo --target per the C++ target arch, #1553),
the WINUXCMD_ENABLE_RUST2 switch semantics (auto-ON with cargo, OFF
without, explicit ON without cargo = configure error), and the honest
degradation story: no C++ fallback, replaced commands simply absent
from a rust-less applet set (never dual-tracked).

Sections: README.md 'Building from source' (+prereq line),
README-zh.md, CONTRIBUTING.md prerequisites, AGENTS.md How to build.
The version pin installs under its own rustup slot
(1.99.1-x86_64-pc-windows-msvc), separate from the image's stable alias,
so each leg would otherwise download the full toolchain every run. Cache
the slot (aarch64 std included after the first target add) so only the
first leg pays for it.
The surface-check job parses markers as key=value; the bare rustc line
parsed as a keyless entry and the cross-arch rustc comparison degraded
to null==null. Emit rustc=<version> so the comparison is real.
'cargo rustc --version' is not a version query - cargo rustc is the
build subcommand and rejects --version (exit != 0, null stdout), which
killed the marker step under ErrorActionPreference=Stop on every leg
that reached it (reproduced locally under pwsh). Use the rustc shim
(%USERPROFILE%\.cargo\bin\rustc.exe --version), which reports the
pinned default toolchain.
download-artifact@v8 extracts pattern-matched artifacts flat into the
download path (verified in run 42813275974: both downloads log 'to:
...pkgs', PE checks passed but the shared rust2-build-status.txt was
not found under a -x64\ path and would have been overwritten by the
arm64 download). Name the marker per arch (rust2-build-status-x64.txt /
-arm64.txt) so the layout cannot collide, list the pkgs tree in the
check log for debuggability.
@caomengxuan666
caomengxuan666 merged commit 8a5f271 into main Nov 10, 2026
13 of 14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant