Skip to content

Commit 054b3a6

Browse files
build(windows): default to static CRT and pinned Z3 packages (#5654)
Use the static CRT for all four Windows executables and link Z3 into the gateway. Reuse the pinned Z3 5.1.0 /MT libraries from GHCR on x64 and ARM64. Build from source when explicitly requested or when the package is unavailable. Closes #5653 Signed-off-by: shailendras <shailendras@nvidia.com>
1 parent b9efa1e commit 054b3a6

20 files changed

Lines changed: 1243 additions & 107 deletions

‎.agents/skills/build-openshell-mxc-windows/SKILL.md‎

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ The Windows build lane is implemented by these tracked files:
104104
| `tasks/rust.toml`, `tasks/test.toml`, and `tasks/markdown.toml` | Windows routing for compiler-bearing checks, explicit Unix-only test skips, and Markdown dependency setup. |
105105
| `tasks/scripts/windows-msvc.ps1` | PowerShell wrapper that enters the Visual Studio developer environment and invokes Cargo. |
106106
| `.github/workflows/windows-msvc.yml` | Opt-in PR lint and test plus advisory `windows` branch cache seeding and dependent binary builds on native x64 and ARM64 runners. |
107+
| `tasks/windows-z3.json` | Pinned Z3 source, package digests, and package compiler baseline. |
108+
| `tasks/scripts/windows-z3.ps1` | Native HTTPS download, integrity validation, and static dependency caching. |
107109
| `.agents/skills/build-openshell-mxc-windows/` | This skill and companion reference material. |
108110

109111
Use the code that is already in the repo. Do not generate a parallel Windows
@@ -203,9 +205,12 @@ from this skill.
203205
| `OPENSHELL_MXC_SKIP_ARM64` | `0` | Set to `1` to skip ARM64 when using `all` tasks. |
204206
| `OPENSHELL_WINDOWS_BUILD_JOBS` | `CARGO_BUILD_JOBS`, then `4` | Positive Cargo job limit used by the wrapper. |
205207
| `CARGO_TARGET_DIR` | `target` under repo root | Override Cargo output location. Use a short absolute path when x64-to-ARM64 builds approach Windows path-length limits. |
206-
| `Z3_LIBRARY_PATH_OVERRIDE` | unset | Directory containing target-compatible system `libz3.lib` and `libz3.dll`, used instead of the prebuilt download. |
208+
| `OPENSHELL_WINDOWS_STATIC_RUNTIME` | `1` | Static CRT/Z3 by default; reuse the pinned GHCR `/MT` package. Set `0` only for legacy shared builds. |
209+
| `OPENSHELL_WINDOWS_Z3_SOURCE` | `0` | Explicitly build pinned Z3 source, overriding a library override. |
210+
| `Z3_SRC_SOURCE_DIR` | unset | Local Z3 5.1.0 source tree; selects source when no library override is supplied. |
211+
| `Z3_LIBRARY_PATH_OVERRIDE` | unset | Directory containing a target-compatible static `/MT` `libz3.lib`; legacy shared overrides apply only in explicit shared mode. |
207212
| `Z3_SYS_Z3_HEADER` | unset | Full `z3.h` path required with a system Z3 library. |
208-
| `Z3_SYS_Z3_VERSION` | `5.1.0` | Pinned official prebuilt Z3 release selected by the wrapper. |
213+
| `Z3_SYS_Z3_VERSION` | `5.1.0` | Solver version pinned with source and package digests in `tasks/windows-z3.json`. |
209214
| `READ_ONLY_GITHUB_TOKEN` | unset | Optional token for the Z3 release lookup; GitHub Actions supplies `github.token`. |
210215
| `RUSTC_WRAPPER` | inherited | The wrapper resolves an available command to an absolute path. If it is unavailable, the wrapper warns and continues without compiler caching. |
211216

@@ -304,7 +309,7 @@ jobs in the current mirror push run, or push a new mirrored commit. The binaries
304309
The ARM64 check/build steps in this x64-host contract are cross-builds. The
305310
wrapper discovers and adds host-native LLVM and Ninja to `PATH`, requires the
306311
ARM64 compiler and Spectre-mitigated libraries, lets ARM64 crypto crates select
307-
`clang-cl`, and downloads the official prebuilt ARM64 Z3 package.
312+
`clang-cl`, and downloads the pinned static ARM64 Z3 package from GHCR.
308313

309314
On ARM64 hosts, validate the native ARM64 check, build, and test path. The
310315
wrapper rejects test targets that do not match the host architecture, so x64
@@ -423,14 +428,11 @@ architecture through Windows system configuration (not an emulated SSH shell),
423428
caches uploads by SHA256, and runs the unchanged real E2E harness. Results and
424429
host probes return to `target/windows-remote-results`, including nonzero test
425430
outcomes. The remote host needs SSH, OpenSSL, and MXC, not a compiler toolchain.
426-
Package the matching `libz3.dll` from the target-specific Cargo cache alongside
427-
the gateway: Windows prebuilt Z3 uses an import library, not static linkage.
428-
The `windows:build:*` tasks now stage the pinned DLL, check PE architecture,
429-
reject conflicting cache hashes, and verify the copied hash. Local MXC E2E
430-
requires the adjacent DLL and reports a preflight error if it is missing.
431-
Use `-Z3DllPath` when discovery is ambiguous. The native Visual C++ runtime
432-
must be present on the remote host. Verify DLL architecture and the gateway
433-
loader before E2E; do not count missing-DLL crashes as MXC enforcement failures.
431+
Default builds embed Z3 and the CRT. The remote helper reads gateway imports
432+
and includes the matching `libz3.dll` only for shared builds. `-Z3DllPath`
433+
continues to select a shared DLL when discovery is ambiguous; those builds
434+
also need the native Visual C++ runtime. Check gateway startup before E2E;
435+
do not count loader failures as MXC enforcement failures.
434436
Verify the SSH host key beforehand. Never send the private SSH key or bundle
435437
the harness signing-key directories. `-SkipBuild` is an explicit stale-artifact
436438
opt-in, not evidence that artifacts match current sources. See the MXC driver
@@ -591,3 +593,32 @@ ETW qualification. Build native release binaries first and set
591593
membership and leaves a results bundle under the target directory. Ordinary MXC
592594
E2E success does not establish ETW audit coverage. Coverage must use structured
593595
JSONL and fail when an expected event is absent or has the wrong OCSF class.
596+
597+
## Static Windows ZIP packages
598+
599+
Windows tasks and CI embed the CRT and Z3 by default. The wrapper loads
600+
`.cargo/windows-static.toml` and downloads the matching static `/MT` package
601+
from `ghcr.io/nvidia/openshell/z3`. `tasks/windows-z3.json` pins Z3 5.1.0,
602+
the source checksum, and each target's OCI, archive, and build-manifest digests.
603+
Native PowerShell performs HTTPS downloads without Docker, ORAS, or GitHub
604+
credentials. `.cache/windows-z3` is cached separately from Rust outputs.
605+
606+
Source compilation occurs only when the package is unavailable or explicitly
607+
requested. Digest/version/architecture mismatches fail. Preserve Ninja,
608+
native Release optimization, source caching outside Cargo pruning, and scoped
609+
stale-generator invalidation. Supplied static `/MT` libraries remain supported.
610+
`OPENSHELL_WINDOWS_STATIC_RUNTIME=0` selects legacy shared behavior; an inherited
611+
shared override otherwise produces a warning and selects the pinned package.
612+
613+
Static release builds audit all four executables' normal/delayed imports and
614+
remove stale staged Z3 DLLs. The remote helper packages the DLL only for shared
615+
builds and preserves `-Z3DllPath` compatibility. The `static_runtime` manual
616+
workflow input defaults to true. Ordinary PR CI keeps its lint/test workload;
617+
it does not build Z3 when the pinned package or verified cache is available.
618+
619+
The explicit `publish_z3` Windows MSVC workflow input builds only the two
620+
native dependency packages and publishes versioned OCI tags. The producer explicitly selects MSVC 14.44 and uses
621+
Release `/MT` without LTO, audits solver imports, and checks SAT/UNSAT before
622+
packaging libraries, headers, license, and build metadata. The workflow refuses to
623+
replace existing tags with different content. Update pins only after verifying public package downloads.
624+
See [the contributor build options](../../../CONTRIBUTING.md#windows-full-build).

‎.agents/skills/build-openshell-mxc-windows/reference.md‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,9 @@ For ARM64, verify the Visual Studio instance contains the ARM64 MSVC tools,
9393
ARM64 Spectre-mitigated libraries, Clang tools, CMake tools, and a Windows SDK.
9494
Clang supplies host-native `libclang.dll` for `bindgen` and `clang-cl.exe` for
9595
ARM64 crypto dependencies such as `aws-lc-sys`. Native and
96-
x64-to-ARM64 builds use the official prebuilt Z3 5.1.0 import library and
97-
`libz3.dll` for the target architecture. Release build tasks stage that DLL
98-
beside the four executables; copy it with them to the runtime host.
96+
x64-to-ARM64 builds use the pinned Z3 5.1.0 static `/MT` GHCR package for the
97+
target architecture. Default builds embed Z3 and the CRT. Explicit shared mode
98+
stages the matching DLL beside the executables.
9999
An x64-to-ARM64 check/build discovers and adds host-native
100100
Ninja to `PATH`, while the crypto crates select `clang-cl`. Use a short
101101
`CARGO_TARGET_DIR` if Windows path-length limits are reached.
@@ -269,3 +269,9 @@ if ($arch -eq [System.Runtime.InteropServices.Architecture]::Arm64) {
269269

270270
Run the full x64-host `windows:ci` lane when build or test behavior changed and
271271
the host can run that lane natively.
272+
273+
Static CRT/Z3 is the default. Reuse the pinned GHCR `/MT` package or supply a
274+
static library/header override. Build checksum-pinned 5.1.0 source only when
275+
requested or the package is unavailable. `OPENSHELL_WINDOWS_STATIC_RUNTIME=0`
276+
retains explicit legacy shared behavior. See `CONTRIBUTING.md` for package
277+
publication and pin updates.

‎.cargo/windows-msvc.toml‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Loaded only by the Windows MSVC wrapper. Keep native Z3 optimized, as the
5+
# previous prebuilt DLL was, without changing Rust application debug profiles.
6+
# z3-sys forwards its OPT_LEVEL/DEBUG settings to the native CMake build.
7+
[profile.dev.package.z3-sys]
8+
opt-level = 3
9+
debug = false
10+
11+
[profile.test.package.z3-sys]
12+
opt-level = 3
13+
debug = false

‎.cargo/windows-static.toml‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
2+
# SPDX-License-Identifier: Apache-2.0
3+
4+
# Explicit Windows package builds only. cc/cmake also consume crt-static.
5+
[target.x86_64-pc-windows-msvc]
6+
rustflags = ["-C", "target-feature=+crt-static"]
7+
8+
[target.aarch64-pc-windows-msvc]
9+
rustflags = ["-C", "target-feature=+crt-static"]

0 commit comments

Comments
 (0)