diff --git a/.agents/skills/build-openshell-mxc-windows/SKILL.md b/.agents/skills/build-openshell-mxc-windows/SKILL.md index 9b6229d96b..403926e5f0 100644 --- a/.agents/skills/build-openshell-mxc-windows/SKILL.md +++ b/.agents/skills/build-openshell-mxc-windows/SKILL.md @@ -264,7 +264,7 @@ MXC on Windows. Each other `compute-driver-*` feature installs its own Windows rejection stub without linking that driver crate. The default `in-tree-compute-drivers` alias enables all five features. An MXC-only build uses `--no-default-features --features compute-driver-mxc` (add `telemetry` -and `bundled-z3` as needed). +and `openshell-server/prebuilt-z3` as needed). | Driver | Windows build behavior | Runtime behavior | |---|---|---| diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 809f4158d2..4038608bd9 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -309,17 +309,15 @@ Project requirements: - Rust 1.94+ - Python 3.11+ - Docker (running) -- CMake 3.16+ (only required when building with the `bundled-z3` feature) ### Z3 installation The `openshell-prover` crate and standalone `openshell-prover-cli` binary link directly against Z3. The `openshell-server` crate depends on the prover, and the `openshell-gateway` binary crate depends on `openshell-server` in turn. -These packages forward a `bundled-z3` feature to -`openshell-prover/bundled-z3`. The `openshell-cli` crate does not depend on Z3. -On macOS and Linux, install the system Z3 development package; `z3-sys` -discovers it through `pkg-config`. +The `openshell-cli` crate does not depend on Z3. The Nix development shell +supplies Z3. For builds outside that shell on macOS and Linux, install the +system Z3 development package; `z3-sys` discovers it through `pkg-config`. ```bash # macOS @@ -332,14 +330,6 @@ sudo apt install libz3-dev sudo dnf install z3-devel ``` -If you prefer not to install Z3 system-wide, use the bundled Z3 feature. This -compiles Z3 from source during the Rust build and requires CMake 3.16+: - -```bash -cargo build -p openshell-prover --features bundled-z3 -cargo build -p openshell-prover-cli --features bundled-z3 -``` - For x86-64 and ARM64 Windows MSVC builds, use one of these Z3 paths: - Prebuilt Z3 (the default for `windows:*` tasks): `z3-sys` downloads the @@ -353,14 +343,12 @@ For x86-64 and ARM64 Windows MSVC builds, use one of these Z3 paths: target-compatible MSVC Z3 library and `Z3_SYS_Z3_HEADER` at the full path to `z3.h`. The `windows:*` tasks use this path automatically when `Z3_LIBRARY_PATH_OVERRIDE` is set. -- Bundled Z3: for direct Cargo builds, pass `--features bundled-z3` so `z3-sys` - builds Z3 from source. `openshell-prover` itself has no `bindgen`/`libclang` dependency, so building just this crate does not require `LIBCLANG_PATH`: ```powershell -cargo build -p openshell-prover --target x86_64-pc-windows-msvc --features bundled-z3 +cargo build -p openshell-prover --target x86_64-pc-windows-msvc --features prebuilt-z3 ``` ### Windows full build diff --git a/Cargo.lock b/Cargo.lock index fe72444b6f..f6bb9117f1 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -9026,15 +9026,6 @@ dependencies = [ "z3-sys", ] -[[package]] -name = "z3-src" -version = "416.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f2af0c6527de39877cf55cb87f233016573eeeb7cf77afdc1469e4b32faef832" -dependencies = [ - "cmake", -] - [[package]] name = "z3-sys" version = "0.11.0" @@ -9044,7 +9035,6 @@ dependencies = [ "pkg-config", "reqwest 0.12.28", "serde_json", - "z3-src", "zip", ] diff --git a/Cargo.toml b/Cargo.toml index f57b22c397..0114edb2d8 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -143,7 +143,7 @@ k8s-openapi = { version = "0.24", features = ["v1_29"] } uuid = { version = "1.10", features = ["v4"] } signal-hook = "0.3" -# SMT solver (uses system libz3; enable z3/bundled via the prover's bundled-z3 feature for local dev without system z3) +# SMT solver (uses system libz3; Windows build tasks enable the prebuilt release feature) z3 = "0.20" [workspace.lints.rust] diff --git a/README.md b/README.md index d441d5bcf9..260d754031 100644 --- a/README.md +++ b/README.md @@ -359,8 +359,8 @@ cargo build --release -p openshell-gateway --no-default-features --features tele # Docker and VM only, with telemetry compiled out. cargo build --release -p openshell-gateway --no-default-features --features compute-driver-docker,compute-driver-vm -# Windows MXC only, with telemetry support and bundled Z3. -cargo build --release -p openshell-gateway --no-default-features --features telemetry,compute-driver-mxc,bundled-z3 +# Windows MXC only, with telemetry support and prebuilt Z3. +cargo build --release -p openshell-gateway --no-default-features --features telemetry,compute-driver-mxc,openshell-server/prebuilt-z3 ``` Regular builds retain their platform driver set through the default `in-tree-compute-drivers` compatibility feature. On Windows, `compute-driver-mxc` selects MXC; the other four features install unsupported-driver stubs. On other platforms, MXC is excluded. diff --git a/architecture/build.md b/architecture/build.md index a75f8ff6ca..88a1b863dc 100644 --- a/architecture/build.md +++ b/architecture/build.md @@ -73,8 +73,8 @@ already satisfies Linux distribution trust-store policy. The workspace uses `z3` versions whose `z3-sys` dependency keeps downloader HTTP/TLS support behind explicit build features, so default system-Z3 builds do -not reintroduce bundled Mozilla roots. Release builds that need bundled Z3 -continue to opt in with `bundled-z3`. +not reintroduce bundled Mozilla roots. Windows builds can explicitly select the +prebuilt Z3 release path. Release workflows build the standalone `openshell-prover` executable for Linux musl x86_64 and aarch64 and macOS Apple Silicon. The standard Debian, RPM, and @@ -91,9 +91,9 @@ The standalone `openshell` CLI is built as a static musl binary so it can run on a wide range of Linux distributions without depending on the host's glibc. Host runtime binaries that use the GNU/Linux runtime environment are GNU-linked. `openshell-gateway` and `openshell-driver-vm` are built with a glibc 2.28 floor. -The gateway bundles z3 into the release binary so Linux packages, standalone -tarballs, and gateway images do not depend on distro-specific z3 shared-library -SONAMEs. +The gateway statically links the target-specific Z3 library supplied by the Nix +toolchain so Linux packages, standalone tarballs, and gateway images do not +depend on distro-specific Z3 shared-library SONAMEs. The workload-side `openshell-sandbox` binary is statically linked with musl so drivers can stage it into an arbitrary agent image without depending on that @@ -123,12 +123,12 @@ otherwise fail with `ProcessFdQuotaExceeded` under macOS's default soft limit of 256. The guard is a no-op on Linux and when `cargo-zigbuild` is absent. Gateway binaries use `cargo zigbuild` with GNU targets pinned to glibc 2.28, including native-architecture builds, so the gateway image, standalone tarballs, and Linux -packages share the same host portability floor. The gateway build enables -`bundled-z3`. Linux VM driver release artifacts use the same glibc floor so -package-managed VM support does not raise the package runtime requirement. -Gateway staging and release workflows set up the Zig C/C++ wrapper before -bundled Z3 builds and verify the maximum referenced `GLIBC_*` symbol version -before publishing or copying artifacts. +packages share the same host portability floor. The gateway build links the +target-specific static Z3 library from the Nix toolchain. Linux VM driver +release artifacts use the same glibc floor so package-managed VM support does +not raise the package runtime requirement. Gateway staging and release +workflows use the target-specific C/C++ toolchain and verify the maximum +referenced `GLIBC_*` symbol version before publishing or copying artifacts. Supervisor staging uses the GNU build path and verifies the glibc 2.28 floor. Sandbox staging uses the static musl build path. Local Docker image tasks infer the target architecture from `DOCKER_PLATFORM` when set. Otherwise, they require @@ -179,8 +179,8 @@ Runtime layout: - **Gateway**: `gcr.io/distroless/cc-debian13:nonroot` base, GNU-linked binary at `/usr/local/bin/openshell-gateway`, runs as UID/GID `1000:1000`. Linux GNU gateway binaries must not reference `GLIBC_*` symbols newer than - `GLIBC_2.28`; release workflows verify this before publishing artifacts. The - gateway bundles z3, so the image does not need a distro-provided z3 runtime. + `GLIBC_2.28`; release workflows verify this before publishing artifacts. Z3 + is statically linked, so the image does not need a distro-provided Z3 runtime. The base is pinned to a multi-architecture digest; distro security updates require refreshing that digest and rebuilding the gateway image. Updating the container's glibc package does not raise the binary's glibc diff --git a/crates/openshell-gateway/Cargo.toml b/crates/openshell-gateway/Cargo.toml index 32dcaeb24c..04115b4c88 100644 --- a/crates/openshell-gateway/Cargo.toml +++ b/crates/openshell-gateway/Cargo.toml @@ -72,7 +72,6 @@ telemetry = ["openshell-core/telemetry", "openshell-server/telemetry"] ## telemetry-on build. Kept in sync with `default` by ## `rust:verify:defaults-without-telemetry`. defaults-without-telemetry = ["in-tree-compute-drivers"] -bundled-z3 = ["openshell-server/bundled-z3"] [lints] workspace = true diff --git a/crates/openshell-prover-cli/Cargo.toml b/crates/openshell-prover-cli/Cargo.toml index 337a97565d..beb2237fab 100644 --- a/crates/openshell-prover-cli/Cargo.toml +++ b/crates/openshell-prover-cli/Cargo.toml @@ -15,7 +15,6 @@ name = "openshell-prover" path = "src/main.rs" [features] -bundled-z3 = ["openshell-prover/bundled-z3"] prebuilt-z3 = ["openshell-prover/prebuilt-z3"] [dependencies] diff --git a/crates/openshell-prover/Cargo.toml b/crates/openshell-prover/Cargo.toml index e39154a537..bc6849fd06 100644 --- a/crates/openshell-prover/Cargo.toml +++ b/crates/openshell-prover/Cargo.toml @@ -11,7 +11,6 @@ license.workspace = true repository.workspace = true [features] -bundled-z3 = ["z3/bundled"] prebuilt-z3 = ["z3/gh-release"] [dependencies] diff --git a/crates/openshell-server/Cargo.toml b/crates/openshell-server/Cargo.toml index 54c44a7bed..42ffc5901f 100644 --- a/crates/openshell-server/Cargo.toml +++ b/crates/openshell-server/Cargo.toml @@ -120,7 +120,6 @@ default = ["telemetry"] ## On by default; build with `--no-default-features` for a telemetry-free gateway ## that contains no telemetry endpoint, HTTP client, or emission code. telemetry = ["openshell-core/telemetry"] -bundled-z3 = ["openshell-prover/bundled-z3"] prebuilt-z3 = ["openshell-prover/prebuilt-z3"] test-support = [] diff --git a/deploy/docker/Dockerfile.cli-macos b/deploy/docker/Dockerfile.cli-macos deleted file mode 100644 index f86cd594b2..0000000000 --- a/deploy/docker/Dockerfile.cli-macos +++ /dev/null @@ -1,131 +0,0 @@ -# syntax=docker/dockerfile:1.6 - -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Cross-compile the openshell CLI binary for macOS aarch64 (Apple Silicon) -# using the osxcross toolchain. Produces a standalone binary — no Python -# wheel wrapping. -# -# Usage: -# docker buildx build -f deploy/docker/Dockerfile.cli-macos \ -# --build-arg OPENSHELL_CARGO_VERSION=0.6.0 \ -# --output type=local,dest=out/ . - -ARG OSXCROSS_IMAGE=ghcr.io/crazy-max/osxcross:latest -ARG PYTHON_IMAGE=public.ecr.aws/docker/library/python:3.12-slim - -FROM ${OSXCROSS_IMAGE} AS osxcross - -FROM ${PYTHON_IMAGE} AS builder - -ARG CARGO_TARGET_CACHE_SCOPE=default - -ENV PATH="/root/.cargo/bin:/usr/local/bin:/osxcross/bin:${PATH}" -ENV LD_LIBRARY_PATH="/osxcross/lib" - -COPY --from=osxcross /osxcross /osxcross - -RUN SDKROOT="$(echo /osxcross/SDK/MacOSX*.sdk)" && ln -sfn "${SDKROOT}" /osxcross/SDK/MacOSX.sdk - -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - ca-certificates \ - clang \ - cmake \ - curl \ - libclang-dev \ - pkg-config \ - && rm -rf /var/lib/apt/lists/* - -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.95.0 - -# aws-lc-sys probes with --target=arm64-apple-macosx and clang then looks for -# arm64-apple-macosx-ld. Provide a linker alias to osxcross ld64. -RUN ln -sf /osxcross/bin/arm64-apple-darwin25.1-ld /usr/local/bin/arm64-apple-macosx-ld - -RUN rustup target add aarch64-apple-darwin - -WORKDIR /build - -ENV CC_aarch64_apple_darwin=oa64-clang -ENV CXX_aarch64_apple_darwin=oa64-clang++ -ENV AR_aarch64_apple_darwin=aarch64-apple-darwin25.1-ar -ENV CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=oa64-clang -ENV CARGO_TARGET_AARCH64_APPLE_DARWIN_AR=aarch64-apple-darwin25.1-ar -ENV SDKROOT=/osxcross/SDK/MacOSX.sdk -ENV MACOSX_DEPLOYMENT_TARGET=13.3 -ENV CFLAGS_aarch64_apple_darwin=--target=arm64-apple-macosx\ -mmacosx-version-min=13.3 -ENV CXXFLAGS_aarch64_apple_darwin=--target=arm64-apple-macosx\ -mmacosx-version-min=13.3 -ENV BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_darwin=--target=arm64-apple-macosx\ -isysroot\ ${SDKROOT} - -# --------------------------------------------------------------------------- -# Stage 1: dependency caching — copy only manifests, create dummy sources, -# build dependencies. This layer is cached unless Cargo.toml/lock changes. -# --------------------------------------------------------------------------- -COPY Cargo.toml Cargo.lock ./ -COPY crates/openshell-bootstrap/Cargo.toml crates/openshell-bootstrap/Cargo.toml -COPY crates/openshell-cli/Cargo.toml crates/openshell-cli/Cargo.toml -COPY crates/openshell-core/Cargo.toml crates/openshell-core/Cargo.toml -COPY crates/openshell-policy/Cargo.toml crates/openshell-policy/Cargo.toml -COPY crates/openshell-providers/Cargo.toml crates/openshell-providers/Cargo.toml -COPY crates/openshell-tui/Cargo.toml crates/openshell-tui/Cargo.toml -COPY crates/openshell-prover/Cargo.toml crates/openshell-prover/Cargo.toml -COPY crates/openshell-core/build.rs crates/openshell-core/build.rs -COPY proto/ proto/ - -# Scope workspace to CLI crates only to avoid compiling unrelated runtimes. -RUN sed -i 's|members = \["crates/\*"\]|members = ["crates/openshell-cli", "crates/openshell-core", "crates/openshell-bootstrap", "crates/openshell-policy", "crates/openshell-prover", "crates/openshell-providers", "crates/openshell-tui"]|' Cargo.toml - -RUN mkdir -p crates/openshell-cli/src \ - crates/openshell-core/src \ - crates/openshell-bootstrap/src \ - crates/openshell-policy/src \ - crates/openshell-providers/src \ - crates/openshell-prover/src \ - crates/openshell-tui/src && \ - echo "fn main() {}" > crates/openshell-cli/src/main.rs && \ - touch crates/openshell-core/src/lib.rs && \ - touch crates/openshell-bootstrap/src/lib.rs && \ - touch crates/openshell-policy/src/lib.rs && \ - touch crates/openshell-providers/src/lib.rs && \ - touch crates/openshell-prover/src/lib.rs && \ - touch crates/openshell-tui/src/lib.rs - -RUN --mount=type=cache,id=cargo-registry-cli-macos,sharing=locked,target=/root/.cargo/registry \ - --mount=type=cache,id=cargo-git-cli-macos,sharing=locked,target=/root/.cargo/git \ - --mount=type=cache,id=cargo-target-cli-macos-${CARGO_TARGET_CACHE_SCOPE},sharing=locked,target=/build/target \ - cargo build --release --target aarch64-apple-darwin -p openshell-cli 2>/dev/null || true - -# --------------------------------------------------------------------------- -# Stage 2: real build -# --------------------------------------------------------------------------- -COPY crates/ crates/ -COPY providers/ providers/ - -# Touch source files to ensure they're rebuilt (not the cached dummy). -RUN touch crates/openshell-cli/src/main.rs \ - crates/openshell-cli/src/lib.rs \ - crates/openshell-bootstrap/src/lib.rs \ - crates/openshell-core/src/lib.rs \ - crates/openshell-policy/src/lib.rs \ - crates/openshell-providers/src/lib.rs \ - crates/openshell-tui/src/lib.rs \ - crates/openshell-core/build.rs \ - proto/*.proto - -# Declare version ARGs here (not earlier) so the git-hash-bearing values do not -# invalidate the expensive dependency-build layers above on every commit. -ARG OPENSHELL_CARGO_VERSION -ARG OPENSHELL_IMAGE_TAG -RUN --mount=type=cache,id=cargo-registry-cli-macos,sharing=locked,target=/root/.cargo/registry \ - --mount=type=cache,id=cargo-git-cli-macos,sharing=locked,target=/root/.cargo/git \ - --mount=type=cache,id=cargo-target-cli-macos-${CARGO_TARGET_CACHE_SCOPE},sharing=locked,target=/build/target \ - if [ -n "${OPENSHELL_CARGO_VERSION:-}" ]; then \ - sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${OPENSHELL_CARGO_VERSION}"'"/}' Cargo.toml; \ - fi && \ - cargo build --release --target aarch64-apple-darwin -p openshell-cli && \ - cp target/aarch64-apple-darwin/release/openshell /openshell - -FROM scratch AS binary -COPY --from=builder /openshell /openshell diff --git a/deploy/docker/Dockerfile.driver-vm-macos b/deploy/docker/Dockerfile.driver-vm-macos deleted file mode 100644 index 438700eb09..0000000000 --- a/deploy/docker/Dockerfile.driver-vm-macos +++ /dev/null @@ -1,119 +0,0 @@ -# syntax=docker/dockerfile:1.6 - -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Cross-compile the openshell-driver-vm binary for macOS aarch64 (Apple -# Silicon) using the osxcross toolchain. -# -# openshell-driver-vm loads libkrun/libkrunfw at runtime via dlopen, so it -# does NOT need Hypervisor.framework headers at build time. Pre-compressed -# runtime artifacts (libkrun, libkrunfw, bundled sandbox/supervisor) are injected via -# the vm-runtime-compressed build context and embedded into the binary via -# include_bytes!(). -# -# Usage: -# docker buildx build -f deploy/docker/Dockerfile.driver-vm-macos \ -# --build-arg OPENSHELL_CARGO_VERSION=0.6.0 \ -# --build-context vm-runtime-compressed=/path/to/compressed-dir \ -# --output type=local,dest=out/ . - -ARG OSXCROSS_IMAGE=ghcr.io/crazy-max/osxcross:latest -ARG PYTHON_IMAGE=public.ecr.aws/docker/library/python:3.12-slim - -FROM ${OSXCROSS_IMAGE} AS osxcross - -FROM ${PYTHON_IMAGE} AS builder - -ARG CARGO_TARGET_CACHE_SCOPE=default - -ENV PATH="/root/.cargo/bin:/usr/local/bin:/osxcross/bin:${PATH}" -ENV LD_LIBRARY_PATH="/osxcross/lib" - -COPY --from=osxcross /osxcross /osxcross - -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - ca-certificates \ - clang \ - cmake \ - curl \ - pkg-config \ - && rm -rf /var/lib/apt/lists/* - -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.95.0 - -RUN rustup target add aarch64-apple-darwin - -WORKDIR /build - -ENV CC_aarch64_apple_darwin=oa64-clang -ENV CXX_aarch64_apple_darwin=oa64-clang++ -ENV AR_aarch64_apple_darwin=aarch64-apple-darwin25.1-ar -ENV CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=oa64-clang -ENV CARGO_TARGET_AARCH64_APPLE_DARWIN_AR=aarch64-apple-darwin25.1-ar - -# aws-lc-sys workaround (in case it ends up in the dep tree via feature unification) -RUN ln -sf /osxcross/bin/arm64-apple-darwin25.1-ld /usr/local/bin/arm64-apple-macosx-ld - -# --------------------------------------------------------------------------- -# Stage 1: dependency caching — copy only manifests, create dummy sources, -# build dependencies. This layer is cached unless Cargo.toml/lock changes. -# --------------------------------------------------------------------------- -COPY Cargo.toml Cargo.lock ./ -COPY crates/openshell-driver-vm/Cargo.toml crates/openshell-driver-vm/Cargo.toml -COPY crates/openshell-driver-vm/build.rs crates/openshell-driver-vm/build.rs -COPY crates/openshell-core/Cargo.toml crates/openshell-core/Cargo.toml -COPY crates/openshell-core/build.rs crates/openshell-core/build.rs -COPY proto/ proto/ - -# Scope workspace to the driver + its only internal dep. -RUN sed -i 's|members = \["crates/\*"\]|members = ["crates/openshell-driver-vm", "crates/openshell-core"]|' Cargo.toml - -RUN mkdir -p crates/openshell-driver-vm/src \ - crates/openshell-core/src && \ - echo "fn main() {}" > crates/openshell-driver-vm/src/main.rs && \ - touch crates/openshell-driver-vm/src/lib.rs && \ - touch crates/openshell-core/src/lib.rs - -# Build deps only (cached layer). The 2>/dev/null || true is a warm-cache -# technique; real source is copied in stage 2. -RUN --mount=type=cache,id=cargo-registry-driver-vm-macos,sharing=locked,target=/root/.cargo/registry \ - --mount=type=cache,id=cargo-git-driver-vm-macos,sharing=locked,target=/root/.cargo/git \ - --mount=type=cache,id=cargo-target-driver-vm-macos-${CARGO_TARGET_CACHE_SCOPE},sharing=locked,target=/build/target \ - cargo build --release --target aarch64-apple-darwin -p openshell-driver-vm 2>/dev/null || true - -# --------------------------------------------------------------------------- -# Stage 2: real build with compressed runtime artifacts -# --------------------------------------------------------------------------- -COPY crates/ crates/ - -# Copy compressed VM runtime artifacts for embedding. -# These are passed in via --build-context vm-runtime-compressed=... -COPY --from=vm-runtime-compressed / /build/vm-runtime-compressed/ - -# Touch source files to ensure they're rebuilt (not the cached dummy). -RUN touch crates/openshell-driver-vm/src/main.rs \ - crates/openshell-driver-vm/src/lib.rs \ - crates/openshell-driver-vm/build.rs \ - crates/openshell-core/src/lib.rs \ - crates/openshell-core/build.rs \ - proto/*.proto - -# Declare version ARGs here (not earlier) so the git-hash-bearing values do not -# invalidate the expensive dependency-build layers above on every commit. -ARG OPENSHELL_CARGO_VERSION -ARG OPENSHELL_IMAGE_TAG -RUN --mount=type=cache,id=cargo-registry-driver-vm-macos,sharing=locked,target=/root/.cargo/registry \ - --mount=type=cache,id=cargo-git-driver-vm-macos,sharing=locked,target=/root/.cargo/git \ - --mount=type=cache,id=cargo-target-driver-vm-macos-${CARGO_TARGET_CACHE_SCOPE},sharing=locked,target=/build/target \ - if [ -n "${OPENSHELL_CARGO_VERSION:-}" ]; then \ - sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${OPENSHELL_CARGO_VERSION}"'"/}' Cargo.toml; \ - fi && \ - OPENSHELL_VM_RUNTIME_COMPRESSED_DIR=/build/vm-runtime-compressed \ - OPENSHELL_IMAGE_TAG="${OPENSHELL_IMAGE_TAG:-dev}" \ - cargo build --release --target aarch64-apple-darwin -p openshell-driver-vm && \ - cp target/aarch64-apple-darwin/release/openshell-driver-vm /openshell-driver-vm - -FROM scratch AS binary -COPY --from=builder /openshell-driver-vm /openshell-driver-vm diff --git a/deploy/docker/Dockerfile.gateway-macos b/deploy/docker/Dockerfile.gateway-macos deleted file mode 100644 index 4ecbac0397..0000000000 --- a/deploy/docker/Dockerfile.gateway-macos +++ /dev/null @@ -1,112 +0,0 @@ -# syntax=docker/dockerfile:1.6 - -# SPDX-FileCopyrightText: Copyright (c) 2025-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved. -# SPDX-License-Identifier: Apache-2.0 - -# Cross-compile the standalone openshell-gateway binary for macOS aarch64 -# (Apple Silicon) using the osxcross toolchain. - -ARG OSXCROSS_IMAGE=ghcr.io/crazy-max/osxcross:latest -ARG PYTHON_IMAGE=public.ecr.aws/docker/library/python:3.12-slim - -FROM ${OSXCROSS_IMAGE} AS osxcross - -FROM ${PYTHON_IMAGE} AS builder - -ARG CARGO_TARGET_CACHE_SCOPE=default - -ENV PATH="/root/.cargo/bin:/usr/local/bin:/osxcross/bin:${PATH}" -ENV LD_LIBRARY_PATH="/osxcross/lib" - -COPY --from=osxcross /osxcross /osxcross - -RUN SDKROOT="$(echo /osxcross/SDK/MacOSX*.sdk)" && ln -sfn "${SDKROOT}" /osxcross/SDK/MacOSX.sdk - -RUN apt-get update && apt-get install -y --no-install-recommends \ - build-essential \ - ca-certificates \ - clang \ - cmake \ - curl \ - libclang-dev \ - pkg-config \ - && rm -rf /var/lib/apt/lists/* - -RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain 1.95.0 - -RUN ln -sf /osxcross/bin/arm64-apple-darwin25.1-ld /usr/local/bin/arm64-apple-macosx-ld - -RUN rustup target add aarch64-apple-darwin - -WORKDIR /build - -ENV CC_aarch64_apple_darwin=oa64-clang -ENV CXX_aarch64_apple_darwin=oa64-clang++ -ENV AR_aarch64_apple_darwin=aarch64-apple-darwin25.1-ar -ENV CARGO_TARGET_AARCH64_APPLE_DARWIN_LINKER=oa64-clang -ENV CARGO_TARGET_AARCH64_APPLE_DARWIN_AR=aarch64-apple-darwin25.1-ar -ENV SDKROOT=/osxcross/SDK/MacOSX.sdk -ENV MACOSX_DEPLOYMENT_TARGET=13.3 -ENV CFLAGS_aarch64_apple_darwin=--target=arm64-apple-macosx\ -mmacosx-version-min=13.3 -ENV CXXFLAGS_aarch64_apple_darwin=--target=arm64-apple-macosx\ -mmacosx-version-min=13.3 -ENV BINDGEN_EXTRA_CLANG_ARGS_aarch64_apple_darwin=--target=arm64-apple-macosx\ -isysroot\ ${SDKROOT} - -COPY Cargo.toml Cargo.lock ./ -COPY crates/openshell-core/Cargo.toml crates/openshell-core/Cargo.toml -COPY crates/openshell-gateway/Cargo.toml crates/openshell-gateway/Cargo.toml -COPY crates/openshell-driver-kubernetes/Cargo.toml crates/openshell-driver-kubernetes/Cargo.toml -COPY crates/openshell-policy/Cargo.toml crates/openshell-policy/Cargo.toml -COPY crates/openshell-prover/Cargo.toml crates/openshell-prover/Cargo.toml -COPY crates/openshell-server/Cargo.toml crates/openshell-server/Cargo.toml -COPY crates/openshell-core/build.rs crates/openshell-core/build.rs -COPY proto/ proto/ - -RUN sed -i 's|members = \["crates/\*"\]|members = ["crates/openshell-gateway", "crates/openshell-server", "crates/openshell-core", "crates/openshell-driver-kubernetes", "crates/openshell-policy", "crates/openshell-prover"]|' Cargo.toml - -RUN mkdir -p crates/openshell-core/src \ - crates/openshell-gateway/src \ - crates/openshell-driver-kubernetes/src \ - crates/openshell-policy/src \ - crates/openshell-prover/src \ - crates/openshell-server/src && \ - touch crates/openshell-core/src/lib.rs && \ - touch crates/openshell-gateway/src/lib.rs && \ - printf 'fn main() {}\n' > crates/openshell-gateway/src/main.rs && \ - touch crates/openshell-driver-kubernetes/src/lib.rs && \ - printf 'fn main() {}\n' > crates/openshell-driver-kubernetes/src/main.rs && \ - touch crates/openshell-policy/src/lib.rs && \ - touch crates/openshell-prover/src/lib.rs && \ - touch crates/openshell-server/src/lib.rs - -RUN --mount=type=cache,id=cargo-registry-gateway-macos,sharing=locked,target=/root/.cargo/registry \ - --mount=type=cache,id=cargo-git-gateway-macos,sharing=locked,target=/root/.cargo/git \ - --mount=type=cache,id=cargo-target-gateway-macos-${CARGO_TARGET_CACHE_SCOPE},sharing=locked,target=/build/target \ - cargo build --release --target aarch64-apple-darwin -p openshell-gateway --features bundled-z3 2>/dev/null || true - -COPY crates/ crates/ -COPY providers/ providers/ - -RUN touch crates/openshell-core/src/lib.rs \ - crates/openshell-gateway/src/lib.rs \ - crates/openshell-gateway/src/main.rs \ - crates/openshell-driver-kubernetes/src/lib.rs \ - crates/openshell-driver-kubernetes/src/main.rs \ - crates/openshell-policy/src/lib.rs \ - crates/openshell-prover/src/lib.rs \ - crates/openshell-server/src/lib.rs \ - crates/openshell-core/build.rs \ - proto/*.proto - -ARG OPENSHELL_CARGO_VERSION -ARG OPENSHELL_IMAGE_TAG -RUN --mount=type=cache,id=cargo-registry-gateway-macos,sharing=locked,target=/root/.cargo/registry \ - --mount=type=cache,id=cargo-git-gateway-macos,sharing=locked,target=/root/.cargo/git \ - --mount=type=cache,id=cargo-target-gateway-macos-${CARGO_TARGET_CACHE_SCOPE},sharing=locked,target=/build/target \ - if [ -n "${OPENSHELL_CARGO_VERSION:-}" ]; then \ - sed -i -E '/^\[workspace\.package\]/,/^\[/{s/^version[[:space:]]*=[[:space:]]*".*"/version = "'"${OPENSHELL_CARGO_VERSION}"'"/}' Cargo.toml; \ - fi && \ - cargo build --release --target aarch64-apple-darwin -p openshell-gateway --features bundled-z3 && \ - cp target/aarch64-apple-darwin/release/openshell-gateway /openshell-gateway - -FROM scratch AS binary -COPY --from=builder /openshell-gateway /openshell-gateway diff --git a/e2e/run.sh b/e2e/run.sh index 5cd9a5be78..a0921051ba 100755 --- a/e2e/run.sh +++ b/e2e/run.sh @@ -263,8 +263,7 @@ if [ "${mode}" = host ]; then echo "==> Building native host openshell-gateway" mise x -- cargo build "${cargo_jobs[@]}" \ -p openshell-gateway \ - --bin openshell-gateway \ - --features bundled-z3 + --bin openshell-gateway host_gateway_bin="${target_dir}/debug/openshell-gateway" else echo "==> Building Linux openshell-gateway (${linux_gateway_zig_target})" @@ -279,8 +278,7 @@ else --release \ --target "${linux_gateway_zig_target}" \ -p openshell-gateway \ - --bin openshell-gateway \ - --features bundled-z3 + --bin openshell-gateway ) guest_gateway_bin="${target_dir}/${linux_gateway_rust_target}/release/openshell-gateway" fi diff --git a/e2e/with-kube-gateway.sh b/e2e/with-kube-gateway.sh index 36c321f071..15a55d265a 100755 --- a/e2e/with-kube-gateway.sh +++ b/e2e/with-kube-gateway.sh @@ -1033,12 +1033,11 @@ if [ "${OPENSHELL_E2E_KUBE_BUILD_IMAGES}" = "1" ]; then fi external_gateway="${OPENSHELL_GATEWAY_BIN:-${ROOT}/target/debug/openshell-gateway}" external_driver="${OPENSHELL_EXTERNAL_DRIVER_BIN:-${ROOT}/target/debug/openshell-driver-kubernetes}" - # The test image uses a distroless runtime, so keep Z3 self-contained just - # like the production gateway image artifact. A host-linked debug binary - # would otherwise require libz3.so from the CI build machine at runtime. + # The test image uses a distroless runtime, so build with the same + # toolchain-provided static Z3 used by production gateway artifacts. if [ -z "${OPENSHELL_GATEWAY_BIN:-}" ]; then cargo build -p openshell-gateway --bin openshell-gateway \ - --no-default-features --features telemetry,bundled-z3 + --no-default-features --features telemetry fi if [ -z "${OPENSHELL_EXTERNAL_DRIVER_BIN:-}" ]; then cargo build -p openshell-driver-kubernetes --bin openshell-driver-kubernetes diff --git a/tasks/ci.toml b/tasks/ci.toml index e2a388e6b1..7f896c570d 100644 --- a/tasks/ci.toml +++ b/tasks/ci.toml @@ -31,7 +31,7 @@ hide = true description = "Build release Rust binaries consumed by the hand-staged snap" run = [ "cargo build --release -p openshell-cli", - "cargo build --release -p openshell-gateway --features bundled-z3", + "cargo build --release -p openshell-gateway", "cargo build --release -p openshell-sandbox", ] diff --git a/tasks/scripts/setup-zig-cc-wrapper.sh b/tasks/scripts/setup-zig-cc-wrapper.sh index c21e0a3487..3ec27868ca 100755 --- a/tasks/scripts/setup-zig-cc-wrapper.sh +++ b/tasks/scripts/setup-zig-cc-wrapper.sh @@ -94,26 +94,6 @@ set(CMAKE_RANLIB "$wrapper_dir/ranlib") set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY) EOF -is_stale_z3_build_dir() { - local build_dir=$1 - - grep -R -q -E \ - 'cargo-zigbuild|zigc(c|xx)-.*unknown-linux-gnu\.[0-9]+\.[0-9]+' \ - "$build_dir/CMakeCache.txt" "$build_dir/CMakeFiles" 2>/dev/null -} - -for profile in release debug; do - z3_build_root="target/$bare_cargo_target/$profile/build" - if [[ -d $z3_build_root ]]; then - while IFS= read -r z3_build_dir; do - if is_stale_z3_build_dir "$z3_build_dir"; then - echo "Removing stale z3-sys CMake cache: $z3_build_dir" >&2 - rm -rf "$z3_build_dir" - fi - done < <(find "$z3_build_root" -mindepth 3 -maxdepth 3 -type d -path "*/z3-sys-*/out/build") - fi -done - target_env=${cargo_target//[-.]/_} bare_target_env=${bare_cargo_target//[-.]/_} diff --git a/tasks/scripts/stage-prebuilt-binaries.sh b/tasks/scripts/stage-prebuilt-binaries.sh index 312cec7a91..e3334dbe5e 100755 --- a/tasks/scripts/stage-prebuilt-binaries.sh +++ b/tasks/scripts/stage-prebuilt-binaries.sh @@ -167,9 +167,6 @@ build_component_for_arch() { target="$(target_triple "$arch" "$target_libc")" stage="${ROOT}/deploy/docker/.build/prebuilt-binaries/${arch}" features="${EXTRA_CARGO_FEATURES:-}" - if [[ "$component" == "gateway" && " ${features} " != *" bundled-z3 "* ]]; then - features="${features} bundled-z3" - fi current_host_os="$(host_os)" current_host_arch="$(host_arch)" diff --git a/tasks/scripts/trivy-scan.sh b/tasks/scripts/trivy-scan.sh index 5d2fd85f75..fbfe6d47c1 100755 --- a/tasks/scripts/trivy-scan.sh +++ b/tasks/scripts/trivy-scan.sh @@ -24,7 +24,6 @@ PREFLIGHT_OFF=(--helm-set agentSandbox.preflight.enabled=false) # These Dockerfiles do not produce release runtime images. SKIP_DOCKERFILES=( --skip-files 'deploy/docker/Dockerfile.ci' - --skip-files 'deploy/docker/Dockerfile.*-macos' ) # Explicit OpenShell variants, including dev/E2E regression coverage.