Files
honk/ci/zig-bindgen-env
T
glassyiris 8a9752b20a build: fix cross builds, eBPF BTF embedding, and the release workflow
eBPF BTF: build.rs now verifies the object it embeds actually contains
.BTF (aya refuses BTF-less objects at runtime on the gateway), rebuilds
when missing or BTF-less, and strips RUSTFLAGS/CARGO_ENCODED_RUSTFLAGS
from the child env — an environment RUSTFLAGS overrides
crates/honk-ebpf/.cargo/config.toml's --btf flags and silently produces
BTF-less objects (the 'no BTF parsed for object' incident). A stale
BTF-less copy from an earlier build also sat in the musl OUT_DIR
because build.rs never reran there.

Cross builds (ci/zigcc, ci/zigcxx, ci/zig-bindgen-env): boring-sys
needs a clang-compatible toolchain under cross — CMake injects
clang-style --target flags into its ASM rules that real GCC rejects
and zig rejects in Rust-triple spelling, and bindgen needs zig's target
headers instead of the host's. The wrappers strip/rewrite those flags
(plus rustc's aarch64 errata linker args); musl targets link with
-C link-self-contained=no so zig supplies the CRT (duplicate _start
otherwise). Verified locally: x86_64-musl (static, runs), aarch64-gnu
(glibc 2.28), aarch64-musl (static) — all with BTF-ful embedded objects.

Justfile: build-musl uses the zig wrappers; build-ebpf warns on
RUSTFLAGS and verifies .BTF; test-ci mirrors the CI gate; clean-all
also removes the live table-100 policy routes (2023/iptables lines are
now marked legacy); dropped run/deploy/docker* recipes whose scripts/
Dockerfile don't exist in this tree.

release.yml: test job installs cmake+libclang and skips only the 3
known-failing pre-existing tests; build job verifies eBPF BTF and
cross-builds via the zig wrappers (zig 0.14.1) instead of cross.
2026-07-23 03:28:24 +08:00

23 lines
888 B
Bash
Executable File

#!/bin/sh
# Print a BINDGEN_EXTRA_CLANG_ARGS value matching the header setup that
# `zig cc -target <zig-triple>` uses, for cross bindgen runs (boring-sys
# generates its bindings at build time; without target headers bindgen
# either picks up the host's glibc or fails outright).
#
# The flags are parsed from zig's own `zig cc -E -v` output, so this tracks
# the installed zig version and works for any zig target triple.
#
# Usage: export BINDGEN_EXTRA_CLANG_ARGS="$(ci/zig-bindgen-env aarch64-linux-gnu)"
if [ -z "$1" ]; then
echo "usage: $0 <zig-target-triple> (e.g. aarch64-linux-gnu)" >&2
exit 1
fi
zig cc -target "$1" -E -x c /dev/null -v 2>&1 \
| tr ' ' '\n' \
| awk '
/^-triple$/ { getline; printf "--target=%s ", $0 }
/^-isystem$/ { getline; printf "-isystem %s ", $0 }
/^-D$/ { getline; if ($0 != "_DEBUG") printf "-D%s ", $0 }
'