[build] Fix build failure on non-English Windows#499
Merged
Conversation
On a non-English Windows (e.g. French), running build.bat panicked in the nanvix_binaries build script with 'certutil output not UTF-8'. certutil_sha256() in src/backends/nanvix/binaries/build.rs read certutil's stdout via String::from_utf8(...).expect(...). On localized Windows, certutil emits its header/footer lines (e.g. 'Hachage SHA256 de ...', '... s'est terminee correctement.') in the console's OEM code page (CP850), not UTF-8. Bytes such as 0xA0, 0x92 and 0xE9 are invalid UTF-8, so the strict conversion panicked even though the SHA256 hash line itself is pure ASCII. Use String::from_utf8_lossy so the localized header/footer no longer aborts the build, and locate the hash by scanning for the 64-character hex line instead of relying on a fixed line index. This keeps hash extraction locale-independent and robust to certutil output variations. Fixes microsoft#498 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Running build.bat without --with-microvm still downloaded the NanVix release assets and verified them with certutil. This was the trigger for the locale crash in issue microsoft#498, and it forced network + hashing work on every build even when the micro-VM backend was not requested. Root cause: nanvix_binaries is an unconditional workspace member, so a plain `cargo build` (which builds all default members) compiled it and ran its build script. The script gated only on the target OS, never on whether the micro-VM backend was actually being built. The --with-microvm flag merely added `--features microvm` (gating the nanvix_runner link and the SDK copy step) and never reached the download path. Gate the expensive work behind a new `microvm` feature on the crate: - nanvix_binaries: add a `microvm = []` feature. build.rs now early-returns when CARGO_FEATURE_MICROVM is unset, emitting only NANVIX_BIN_DIR (still required because lib.rs references it via env!) and the rerun directive. No download, no certutil, no snapshot generation. - wxc / lxc: their `microvm` features now enable `nanvix_binaries/microvm` (instead of just pulling the optional dep), so the download path runs exactly when --with-microvm / --features microvm is requested. build.bat needs no change: it already passes --features microvm, which now turns on the crate's gate. The crate is still compiled on a default build (cheap lib + early-returning build script); only the network/hashing work is skipped. Verified: - `cargo build -p nanvix_binaries` (no feature): compiles, no download/certutil. - `cargo build -p wxc --features microvm`: build script runs full path (binaries verified, snapshots checked), confirming CARGO_FEATURE_MICROVM propagates via nanvix_binaries/microvm. - `cargo tree`: nanvix_binaries absent by default, present with the feature. - cargo fmt --check and cargo clippy -- -D warnings clean on touched crates. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Fixes a Windows locale-dependent build-script panic and prevents the NanVix binary download/certutil checksum step from running unless the MicroVM backend is actually being built.
Changes:
- Made
nanvix_binaries’certutilSHA256 parsing resilient to non-UTF-8 localized output by using lossy decoding and scanning for the 64-hex digest line. - Added a
microvmfeature tonanvix_binariesand gated the build script’s expensive download/verification work behindCARGO_FEATURE_MICROVM. - Updated
wxcandlxcfeature wiring to enablenanvix_binaries’ newmicrovmfeature when building with--features microvm.
Show a summary per file
| File | Description |
|---|---|
| src/core/wxc/Cargo.toml | Adjusts the microvm feature to propagate nanvix_binaries’ new microvm feature. |
| src/core/lxc/Cargo.toml | Same as wxc: ensures MicroVM builds propagate the dependency feature. |
| src/backends/nanvix/binaries/Cargo.toml | Introduces a microvm feature to gate expensive build-script work. |
| src/backends/nanvix/binaries/build.rs | Adds feature gating to skip downloads by default and makes certutil output parsing locale-robust. |
Copilot's findings
- Files reviewed: 4/4 changed files
- Comments generated: 3
Apply the three suggestions from the PR microsoft#499 review: - nanvix_binaries/build.rs: emit `cargo:rerun-if-env-changed=CARGO_FEATURE_MICROVM` so toggling the `microvm` feature between builds re-runs the script instead of reusing stale output (NANVIX_BIN_DIR and whether the download/verify path runs). - wxc / lxc Cargo.toml: enable the optional `nanvix_binaries` dependency explicitly via `dep:nanvix_binaries` alongside `nanvix_binaries/microvm`, matching the `dep:`-prefixed style used by the other optional-dep features (wslc, hyperlight). No behavioral change: `nanvix_binaries/microvm` already pulled in the optional dep, and Cargo already re-runs build scripts on feature-set changes; these make the wiring explicit and guard against stale build-script output. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Member
|
/azp run |
|
Azure Pipelines successfully started running 1 pipeline(s). |
MGudgin
approved these changes
Jun 5, 2026
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.
📖 Description
On a non-English Windows (reported on French), running
build.batpanickedin the
nanvix_binariesbuild script withcertutil output not UTF-8, evenwithout the
--with-microvmflag. This PR fixes both the immediate crash andthe underlying reason the NanVix download ran at all on a default build.
Two changes:
Locale-robust checksum parsing (
src/backends/nanvix/binaries/build.rs).certutil_sha256()readcertutil's stdout viaString::from_utf8(...).expect(...). On localized Windows,certutilemitsits header/footer lines (e.g. "Hachage SHA256 de …", "… s'est terminée
correctement.") in the console's OEM code page (CP850), not UTF-8 — bytes
like
0xA0,0x92,0xE9are invalid UTF-8 and the strict conversionpanicked. Switched to
String::from_utf8_lossy(the SHA256 line is pureASCII and survives lossy conversion) and made hash extraction
locale-independent by scanning for the 64-char hex line instead of relying
on a fixed line index.
Gate the NanVix download behind the
microvmfeature.nanvix_binariesis an unconditional workspace member, so a plain
cargo buildcompiled itand ran its build script — which gated only on the target OS, never on
whether the micro-VM backend was requested.
--with-microvmonly added--features microvm(gating thenanvix_runnerlink and the SDK copy step)and never reached the download path. The crate now has a
microvmfeature;its
build.rsearly-returns (emitting onlyNANVIX_BIN_DIR, still requiredby
lib.rs'senv!) whenCARGO_FEATURE_MICROVMis unset — no download, nocertutil, no snapshot generation.wxcandlxcenablenanvix_binaries/microvmthrough their ownmicrovmfeatures, so thedownload path runs exactly when
--with-microvmis requested.build.batneeds no change.
Net effect: a default
build.baton any locale no longer triggers the NanVixdownload/
certutilstep; the crate still compiles (cheap lib + early-returningbuild script), only the network/hashing work is skipped.
🔗 References
Closes #498
🔍 Validation
cargo build -p nanvix_binaries(no feature): compiles, performs nodownload/
certutil.cargo build -p wxc --features microvm: build script runs its full path(binaries verified, snapshots checked), confirming
CARGO_FEATURE_MICROVMpropagates via
nanvix_binaries/microvm.cargo tree:nanvix_binariesabsent on a default build, present with--features microvm.sequence from the issue; the new parser extracts the correct hash instead of
panicking.
cargo fmt --all -- --checkandcargo clippy -- -D warningsclean on thetouched crates.
✅ Checklist
📋 Issue Type
Microsoft Reviewers: Open in CodeFlow