authorclover caruso <git@paperclover.net> 2026-10-10 22:30:04-07:00
committerclover caruso <git@paperclover.net> 2026-10-10 22:56:06-07:00
log33aa2ae19d561e823ca91b18cda8dbb8a4a46597
tree2ce17bd8e0f8d612ee5e1598ef77dc5b3ac5d015
parentf3f419d0b443380b13afb2bdc6847a18b6aff04e
signature Signed by SSH key SHA256:52mNGHRsVFBDED9IAX5pe+LRWUefqTbxEReunq21QvU (~clover)

fix: preserve the Cortex-A53 linker workaround through Zig

Use LLD’s quoted reproduction response to resolve Zig’s libc inputs, then link the final artifact directly with the requested 843419 erratum fix. Both intermediate links stay temporary, and failed relinks preserve the existing output. Assisted-by: gpt-6.1-sol

1 files changed, 20 insertions(+), 2 deletions(-)

platform/linux/cc.sh+20-2
......@@ -2,7 +2,7 @@
22# zig cc for $ZIG_TARGET, as `cargo.sh` sets it: the C compiler and linker. zig rejects
33# rustc's --target, --no-undefined-version and -O1, and strips the symbol table with the debug
44# info, so the debug info goes after linking.
5strip= output= previous=
5strip= fix= output= previous=
66for arg do
77 shift
88 [ "$previous" = -o ] && output=$arg
......@@ -10,10 +10,28 @@ for arg do
1010 case $arg in
1111 --target=* | -Wl,--no-undefined-version | -Wl,-O1) ;;
1212 -Wl,--strip-debug) strip=1 ;;
13 -Wl,--fix-cortex-a53-843419) fix=1 ;;
1314 *) set -- "$@" "$arg" ;;
1415 esac
1516done
16zig cc -target "$ZIG_TARGET" "$@" || exit
17if [ -n "$fix" ]; then
18 work=$(mktemp -d "${TMPDIR:-/tmp}/linux-link.XXXXXX") || exit
19 trap 'rm -rf "$work"' EXIT
20 work=$(cd "$work" && pwd) || exit
21 case $output in /*) ;; *) output=$PWD/$output ;; esac
22 # Zig rejects the erratum flag; LLD's response file preserves its resolved libc inputs.
23 LLD_REPRODUCE="$work/link.tar" \
24 zig cc -target "$ZIG_TARGET" "$@" -o "$work/unpatched" || exit
25 tar -xOf "$work/link.tar" link/response.txt > "$work/response.txt" || exit
26 (
27 unset LLD_REPRODUCE
28 cd / || exit
29 zig ld.lld "@$work/response.txt" --chroot / --fix-cortex-a53-843419 -o "$work/patched"
30 ) || exit
31 mv "$work/patched" "$output" || exit
32else
33 zig cc -target "$ZIG_TARGET" "$@" || exit
34fi
1735[ -z "$strip" ] ||
1836 "$(rustc --print sysroot)/lib/rustlib/$(rustc -vV | sed -n 's/^host: //p')/bin/rust-objcopy" \
1937 --strip-debug "$output"