Skip to content

[build] Fix build failure on non-English Windows#499

Merged
ppenna merged 3 commits into
microsoft:mainfrom
nanvix:user/ppenna/bugfix-build
Jun 5, 2026
Merged

[build] Fix build failure on non-English Windows#499
ppenna merged 3 commits into
microsoft:mainfrom
nanvix:user/ppenna/bugfix-build

Conversation

@ppenna
Copy link
Copy Markdown
Contributor

@ppenna ppenna commented Jun 5, 2026

📖 Description

On a non-English Windows (reported on French), running build.bat panicked
in the nanvix_binaries build script with certutil output not UTF-8, even
without the --with-microvm flag. This PR fixes both the immediate crash and
the underlying reason the NanVix download ran at all on a default build.

Two changes:

  1. Locale-robust checksum parsing (src/backends/nanvix/binaries/build.rs).
    certutil_sha256() 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 terminée
    correctement."
    ) in the console's OEM code page (CP850), not UTF-8 — bytes
    like 0xA0, 0x92, 0xE9 are invalid UTF-8 and the strict conversion
    panicked. Switched to String::from_utf8_lossy (the SHA256 line is pure
    ASCII 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.

  2. Gate the NanVix download behind the microvm feature. nanvix_binaries
    is an unconditional workspace member, so a plain cargo build compiled it
    and ran its build script — which gated only on the target OS, never on
    whether the micro-VM backend was requested. --with-microvm only added
    --features microvm (gating the nanvix_runner link and the SDK copy step)
    and never reached the download path. The crate now has a microvm feature;
    its build.rs early-returns (emitting only NANVIX_BIN_DIR, still required
    by lib.rs's env!) when CARGO_FEATURE_MICROVM is unset — no download, no
    certutil, no snapshot generation. wxc and lxc enable
    nanvix_binaries/microvm through their own microvm features, so the
    download path runs exactly when --with-microvm is requested. build.bat
    needs no change.

Net effect: a default build.bat on any locale no longer triggers the NanVix
download/certutil step; the crate still compiles (cheap lib + early-returning
build script), only the network/hashing work is skipped.

🔗 References

Closes #498

🔍 Validation

  • cargo build -p nanvix_binaries (no feature): compiles, performs no
    download/certutil.
  • cargo build -p wxc --features microvm: build script runs its full path
    (binaries verified, snapshots checked), confirming CARGO_FEATURE_MICROVM
    propagates via nanvix_binaries/microvm.
  • cargo tree: nanvix_binaries absent on a default build, present with
    --features microvm.
  • Reproduced the original parse failure against the exact non-UTF-8 byte
    sequence from the issue; the new parser extracts the correct hash instead of
    panicking.
  • cargo fmt --all -- --check and cargo clippy -- -D warnings clean on the
    touched crates.

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

ppenna and others added 2 commits June 5, 2026 07:05
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>
Copilot AI review requested due to automatic review settings June 5, 2026 14:17
@ppenna ppenna requested a review from a team as a code owner June 5, 2026 14:17
@ppenna ppenna changed the title [build] Fix nanvix_binaries build failure on non-English Windows and gate download behind microvm [build] Fix build failure on non-English Windows Jun 5, 2026
@ppenna ppenna self-assigned this Jun 5, 2026
@ppenna ppenna requested a review from huzaifa-d June 5, 2026 14:21
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_binariescertutil SHA256 parsing resilient to non-UTF-8 localized output by using lossy decoding and scanning for the 64-hex digest line.
  • Added a microvm feature to nanvix_binaries and gated the build script’s expensive download/verification work behind CARGO_FEATURE_MICROVM.
  • Updated wxc and lxc feature wiring to enable nanvix_binaries’ new microvm feature 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

Comment thread src/backends/nanvix/binaries/build.rs
Comment thread src/core/wxc/Cargo.toml
Comment thread src/core/lxc/Cargo.toml
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>
@MGudgin
Copy link
Copy Markdown
Member

MGudgin commented Jun 5, 2026

/azp run

@azure-pipelines
Copy link
Copy Markdown

Azure Pipelines successfully started running 1 pipeline(s).

@ppenna ppenna merged commit cca0db8 into microsoft:main Jun 5, 2026
21 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.

build failed on French windows

3 participants