Skip to content

Commit 4da75d9

Browse files
committed
fix(build): preserve vendored Z3 for local gateway artifacts
Signed-off-by: Simon Scatton <[email protected]>
1 parent 53f6682 commit 4da75d9

10 files changed

Lines changed: 36 additions & 6 deletions

File tree

‎CONTRIBUTING.md‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ the `openshell-gateway` binary crate depends on `openshell-server` in turn.
318318
The `openshell-cli` crate does not depend on Z3. The Nix development shell
319319
supplies Z3. For builds outside that shell on macOS and Linux, install the
320320
system Z3 development package; `z3-sys` discovers it through `pkg-config`.
321+
The linker uses the installed static or shared library. The Nix development
322+
shell provides a static Z3 library.
321323

322324
```bash
323325
# macOS
@@ -330,6 +332,17 @@ sudo apt install libz3-dev
330332
sudo dnf install z3-devel
331333
```
332334

335+
To build Z3 from source instead, enable `vendored-z3` (requires CMake and a C++
336+
compiler):
337+
338+
```bash
339+
cargo build -p openshell-prover --features vendored-z3
340+
cargo build -p openshell-prover-cli --features vendored-z3
341+
```
342+
343+
Local gateway image and E2E builds enable `vendored-z3` so their
344+
copied gateway binaries do not need a shared Z3 library in the runtime image.
345+
333346
For x86-64 and ARM64 Windows MSVC builds, use one of these Z3 paths:
334347

335348
- Prebuilt Z3 (the default for `windows:*` tasks): `z3-sys` downloads the

‎Cargo.lock‎

Lines changed: 10 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Cargo.toml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ k8s-openapi = { version = "0.24", features = ["v1_29"] }
143143
uuid = { version = "1.10", features = ["v4"] }
144144
signal-hook = "0.3"
145145

146-
# SMT solver (uses system libz3; Windows build tasks enable the prebuilt release feature)
146+
# SMT solver (system libz3 by default; opt into vendored source or a prebuilt release)
147147
z3 = "0.21"
148148

149149
[workspace.lints.rust]

‎crates/openshell-gateway/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ telemetry = ["openshell-core/telemetry", "openshell-server/telemetry"]
7373
## telemetry-on build. Kept in sync with `default` by
7474
## `rust:verify:defaults-without-telemetry`.
7575
defaults-without-telemetry = ["in-tree-compute-drivers"]
76+
vendored-z3 = ["openshell-server/vendored-z3"]
7677

7778
[lints]
7879
workspace = true

‎crates/openshell-prover-cli/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ name = "openshell-prover"
1515
path = "src/main.rs"
1616

1717
[features]
18+
vendored-z3 = ["openshell-prover/vendored-z3"]
1819
prebuilt-z3 = ["openshell-prover/prebuilt-z3"]
1920

2021
[dependencies]

‎crates/openshell-prover/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ license.workspace = true
1111
repository.workspace = true
1212

1313
[features]
14+
vendored-z3 = ["z3/vendored"]
1415
prebuilt-z3 = ["z3/gh-release"]
1516

1617
[dependencies]

‎crates/openshell-server/Cargo.toml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ default = ["telemetry"]
120120
## On by default; build with `--no-default-features` for a telemetry-free gateway
121121
## that contains no telemetry endpoint, HTTP client, or emission code.
122122
telemetry = ["openshell-core/telemetry"]
123+
vendored-z3 = ["openshell-prover/vendored-z3"]
123124
prebuilt-z3 = ["openshell-prover/prebuilt-z3"]
124125
test-support = []
125126

‎e2e/run.sh‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,8 @@ if [ "${mode}" = host ]; then
263263
echo "==> Building native host openshell-gateway"
264264
mise x -- cargo build "${cargo_jobs[@]}" \
265265
-p openshell-gateway \
266-
--bin openshell-gateway
266+
--bin openshell-gateway \
267+
--features vendored-z3
267268
host_gateway_bin="${target_dir}/debug/openshell-gateway"
268269
else
269270
echo "==> Building Linux openshell-gateway (${linux_gateway_zig_target})"
@@ -278,7 +279,8 @@ else
278279
--release \
279280
--target "${linux_gateway_zig_target}" \
280281
-p openshell-gateway \
281-
--bin openshell-gateway
282+
--bin openshell-gateway \
283+
--features vendored-z3
282284
)
283285
guest_gateway_bin="${target_dir}/${linux_gateway_rust_target}/release/openshell-gateway"
284286
fi

‎e2e/with-kube-gateway.sh‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1045,11 +1045,9 @@ if [ "${OPENSHELL_E2E_KUBE_BUILD_IMAGES}" = "1" ]; then
10451045
fi
10461046
external_gateway="${OPENSHELL_GATEWAY_BIN:-${ROOT}/target/debug/openshell-gateway}"
10471047
external_driver="${OPENSHELL_EXTERNAL_DRIVER_BIN:-${ROOT}/target/debug/openshell-driver-kubernetes}"
1048-
# The test image uses a distroless runtime, so build with the same
1049-
# toolchain-provided static Z3 used by production gateway artifacts.
10501048
if [ -z "${OPENSHELL_GATEWAY_BIN:-}" ]; then
10511049
cargo build -p openshell-gateway --bin openshell-gateway \
1052-
--no-default-features --features telemetry
1050+
--no-default-features --features telemetry,vendored-z3
10531051
fi
10541052
if [ -z "${OPENSHELL_EXTERNAL_DRIVER_BIN:-}" ]; then
10551053
cargo build -p openshell-driver-kubernetes --bin openshell-driver-kubernetes

‎tasks/scripts/stage-prebuilt-binaries.sh‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,9 @@ build_component_for_arch() {
167167
target="$(target_triple "$arch" "$target_libc")"
168168
stage="${ROOT}/deploy/docker/.build/prebuilt-binaries/${arch}"
169169
features="${EXTRA_CARGO_FEATURES:-}"
170+
if [[ "$component" == "gateway" ]]; then
171+
features="${features} vendored-z3"
172+
fi
170173
current_host_os="$(host_os)"
171174
current_host_arch="$(host_arch)"
172175

0 commit comments

Comments
 (0)