the static-link gate asks the binary, not the build log, because a cache prints nothing
ci / lint the workflow and the shell (push) Successful in 10s
ci / the operator page in a real browser (push) Successful in 2m36s
ci / the same smoke on an image with no base (push) Successful in 4m4s
ci / build the image and smoke it (push) Successful in 4m4s
ci / build, test, smoke (push) Successful in 2m19s
ci / lint the workflow and the shell (push) Successful in 10s
ci / the operator page in a real browser (push) Successful in 2m36s
ci / the same smoke on an image with no base (push) Successful in 4m4s
ci / build the image and smoke it (push) Successful in 4m4s
ci / build, test, smoke (push) Successful in 2m19s
Run 2503 turned a good artifact red: the publish layer was cached, the report layer was cached with it, the build log carried no report lines, and the gate that greps that log found nothing to match. The report is now a script (scripts/aot-link-report.sh) that the build stage copies in and runs, and that CI runs again with `docker run --entrypoint sh … /report.sh` — a container start is never cached, so the gate asks the binary. It exits non-zero when the link names an interpreter or needs a shared object, which is the one claim a scratch layer depends on. Verified here: the script prints `binary bytes: 56820992`, `static-pie linked`, `program headers naming an interpreter: 0`, `NEEDED shared objects: 0`, `static: no interpreter, no NEEDED shared object`, exit 0 — both as a build step and as a `docker run`. .dockerignore keeps `scripts/` out of the context and now makes one named exception for it.
This commit is contained in:
@@ -4,6 +4,10 @@
|
||||
research
|
||||
docs
|
||||
scripts
|
||||
# The one script the build needs inside the image: it is the gate that asks the
|
||||
# AOT binary whether the link is static (Dockerfile.aot-probe, and the
|
||||
# aot-probe.yml job runs it with `docker run`).
|
||||
!scripts/aot-link-report.sh
|
||||
dotnet/**/bin
|
||||
dotnet/**/obj
|
||||
*.db
|
||||
|
||||
@@ -55,19 +55,20 @@ jobs:
|
||||
fi
|
||||
[ -S /var/run/docker.sock ] || { echo "no /var/run/docker.sock on this runner"; exit 1; }
|
||||
|
||||
- name: Build the AOT image and keep the link report
|
||||
# Two builds, one cache. The image build produces the artifact; the
|
||||
# `--target build` build produces the stage that HOLDS the binary, and a
|
||||
# `docker run` of the report script against it always executes — which is
|
||||
# what the gate needs, since a cached build layer prints nothing (run 2503
|
||||
# failed on exactly that).
|
||||
- name: Build the AOT image and ask the binary whether it is static
|
||||
run: |
|
||||
set -eu
|
||||
docker build -f Dockerfile.aot-probe -t "$IMAGE" --progress=plain . 2>&1 | tee /tmp/aot-build.log
|
||||
docker build -f Dockerfile.aot-probe -t "$IMAGE" --progress=plain . 2>&1 \
|
||||
| tail -20
|
||||
printf 'image size: %s\n' "$(docker image ls --format '{{.Size}}' "$IMAGE")"
|
||||
# The gate: the two lines the build stage prints about the binary itself.
|
||||
grep -E 'program headers naming an interpreter: 0$' /tmp/aot-build.log >/dev/null \
|
||||
|| { echo 'the AOT binary names an interpreter — the link is not static'; exit 1; }
|
||||
grep -E 'NEEDED shared objects: 0$' /tmp/aot-build.log >/dev/null \
|
||||
|| { echo 'the AOT binary needs a shared object — the link is not static'; exit 1; }
|
||||
grep -E 'static-pie linked' /tmp/aot-build.log >/dev/null \
|
||||
|| { echo 'file(1) does not call this a static-pie executable'; exit 1; }
|
||||
grep -E 'binary bytes: [0-9]+' /tmp/aot-build.log || true
|
||||
docker build -f Dockerfile.aot-probe --target build -t openwaf-aot-build:ci . 2>&1 \
|
||||
| tail -5
|
||||
docker run --rm --entrypoint sh openwaf-aot-build:ci /report.sh
|
||||
|
||||
# Reported, not gated: what the binary does once it is running. It is
|
||||
# expected to die, and the log line it dies with is the finding.
|
||||
|
||||
+6
-10
@@ -65,16 +65,12 @@ RUN . /rid && dotnet publish OpenWaf.Edge/OpenWaf.Edge.csproj \
|
||||
-o /publish/api \
|
||||
&& mkdir -p /publish/data
|
||||
|
||||
# The static-link claim, checked at build time rather than asserted in a comment:
|
||||
# a fully static executable has no PT_INTERP and `file` calls it static.
|
||||
RUN apk add --no-cache file binutils \
|
||||
&& BIN=/publish/api/OpenWaf.Edge \
|
||||
&& printf 'binary bytes: %s\n' "$(wc -c < "$BIN" | tr -d ' ')" \
|
||||
&& printf 'file says: %s\n' "$(file -b "$BIN")" \
|
||||
&& printf 'program headers naming an interpreter: %s\n' \
|
||||
"$(readelf -l "$BIN" 2>/dev/null | grep -c 'program interpreter' )" \
|
||||
&& printf 'NEEDED shared objects: %s\n' \
|
||||
"$(readelf -d "$BIN" 2>/dev/null | grep -c '(NEEDED)')"
|
||||
# The static-link claim, checked against the binary rather than asserted in a
|
||||
# comment. The same script is what CI runs — see scripts/aot-link-report.sh for
|
||||
# why the gate does not grep this build's log (a cached layer prints nothing, and
|
||||
# run 2503 turned a good artifact red that way).
|
||||
COPY scripts/aot-link-report.sh /report.sh
|
||||
RUN sh /report.sh /publish/api/OpenWaf.Edge
|
||||
|
||||
FROM curlimages/curl:8.10.1 AS geoip
|
||||
ARG DBIP_VERSION
|
||||
|
||||
Executable
+53
@@ -0,0 +1,53 @@
|
||||
#!/bin/sh
|
||||
# The static-link report for the NativeAOT probe image, run INSIDE the build
|
||||
# stage against the binary it just produced.
|
||||
#
|
||||
# Why a script and not a RUN line in the Dockerfile: a cached layer prints
|
||||
# nothing. Measured on Gitea Actions run 2503 — the publish layer was cached, the
|
||||
# report layer was cached with it, the build log carried no report lines, and the
|
||||
# CI gate that greps the log failed on a perfectly good artifact. A `docker run`
|
||||
# of this script always executes, so the gate asks the binary rather than asking
|
||||
# the cache.
|
||||
#
|
||||
# Exits non-zero when the link is NOT fully static, because that is the one claim
|
||||
# Dockerfile.aot-probe makes and the claim a scratch layer depends on: an
|
||||
# interpreter or a NEEDED shared object means the image would be silently
|
||||
# depending on a libc it does not contain.
|
||||
set -eu
|
||||
|
||||
BIN=${1:-/publish/api/OpenWaf.Edge}
|
||||
|
||||
if [ ! -f "$BIN" ]; then
|
||||
printf 'no binary at %s: cannot report\n' "$BIN" >&2
|
||||
exit 2
|
||||
fi
|
||||
|
||||
# file(1) and readelf(1) are not in the SDK image; the AOT toolchain stage has
|
||||
# binutils already, but this runs in any stage that holds the binary.
|
||||
if ! command -v readelf >/dev/null 2>&1; then
|
||||
apk add --no-cache binutils file >/dev/null 2>&1 || {
|
||||
printf 'neither readelf nor a way to install it: cannot report (exit 2), not a pass\n' >&2
|
||||
exit 2
|
||||
}
|
||||
fi
|
||||
|
||||
printf 'binary: %s\n' "$BIN"
|
||||
printf 'binary bytes: %s\n' "$(wc -c < "$BIN" | tr -d ' ')"
|
||||
if command -v file >/dev/null 2>&1; then
|
||||
printf 'file says: %s\n' "$(file -b "$BIN")"
|
||||
fi
|
||||
|
||||
interpreters=$(readelf -l "$BIN" 2>/dev/null | grep -c 'program interpreter' || true)
|
||||
needed=$(readelf -d "$BIN" 2>/dev/null | grep -c '(NEEDED)' || true)
|
||||
printf 'program headers naming an interpreter: %s\n' "$interpreters"
|
||||
printf 'NEEDED shared objects: %s\n' "$needed"
|
||||
|
||||
if [ "$interpreters" != "0" ]; then
|
||||
printf 'NOT static: the binary names a dynamic loader\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ "$needed" != "0" ]; then
|
||||
printf 'NOT static: the binary needs a shared object at run time\n' >&2
|
||||
exit 1
|
||||
fi
|
||||
printf 'static: no interpreter, no NEEDED shared object\n'
|
||||
Reference in New Issue
Block a user