mirror of
https://github.com/daeuniverse/honk.git
synced 2026-12-05 16:02:23 +00:00
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.
48 lines
1.6 KiB
Bash
Executable File
48 lines
1.6 KiB
Bash
Executable File
#!/bin/sh
|
|
# zig cc wrapper for cross builds that involve cmake-based crates (boring-sys).
|
|
#
|
|
# Under cross compilation CMake injects clang-style target flags
|
|
# (`--target=<triple>` in flags, `-target <triple>` right after the compiler)
|
|
# into the ASM rule (boring-sys sets CMAKE_*_COMPILER_TARGET). Real GCC
|
|
# rejects the option and zig rejects the Rust triple spelling
|
|
# (`x86_64-unknown-linux-musl` vs zig's `x86_64-linux-musl`). This wrapper
|
|
# strips every target flag form and re-anchors on the zig-style target from
|
|
# $ZIGCC_TARGET.
|
|
#
|
|
# Usage:
|
|
# ZIGCC_TARGET=x86_64-linux-musl \
|
|
# CC_x86_64_unknown_linux_musl=/path/to/ci/zigcc \
|
|
# CXX_x86_64_unknown_linux_musl=/path/to/ci/zigcxx \
|
|
# CARGO_TARGET_X86_64_UNKNOWN_LINUX_MUSL_LINKER=/path/to/ci/zigcc \
|
|
# cargo build --target x86_64-unknown-linux-musl ...
|
|
#
|
|
# Note: the filtered args are intentionally re-split on newlines — CMake and
|
|
# compiler invocations pass them pre-split and none contain spaces here.
|
|
if [ -z "$ZIGCC_TARGET" ]; then
|
|
echo "zigcc: ZIGCC_TARGET is not set (e.g. x86_64-linux-musl)" >&2
|
|
exit 1
|
|
fi
|
|
|
|
kept=
|
|
skip_next=0
|
|
for arg in "$@"; do
|
|
if [ "$skip_next" = 1 ]; then
|
|
skip_next=0
|
|
continue
|
|
fi
|
|
case "$arg" in
|
|
--target=*) ;;
|
|
-target | --target) skip_next=1 ;;
|
|
# rustc passes these for aarch64-linux-gnu; zig's linker driver
|
|
# rejects them (lld handles the errata workarounds itself).
|
|
-Wl,--fix-cortex-a53-843419 | -Wl,--fix-cortex-a53-835769) ;;
|
|
*)
|
|
kept="$kept
|
|
$arg"
|
|
;;
|
|
esac
|
|
done
|
|
|
|
# shellcheck disable=SC2046
|
|
exec zig cc -target "$ZIGCC_TARGET" $(printf '%s' "$kept" | tail -n +2)
|