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 @@...@@ -2,7 +2,7 @@
2# zig cc for $ZIG_TARGET, as `cargo.sh` sets it: the C compiler and linker. zig rejects2# zig cc for $ZIG_TARGET, as `cargo.sh` sets it: the C compiler and linker. zig rejects
3# rustc's --target, --no-undefined-version and -O1, and strips the symbol table with the debug3# rustc's --target, --no-undefined-version and -O1, and strips the symbol table with the debug
4# info, so the debug info goes after linking.4# info, so the debug info goes after linking.
5strip= output= previous=5strip= fix= output= previous=
6for arg do6for arg do
7 shift7 shift
8 [ "$previous" = -o ] && output=$arg8 [ "$previous" = -o ] && output=$arg
...@@ -10,10 +10,28 @@ for arg do...@@ -10,10 +10,28 @@ for arg do
10 case $arg in10 case $arg in
11 --target=* | -Wl,--no-undefined-version | -Wl,-O1) ;;11 --target=* | -Wl,--no-undefined-version | -Wl,-O1) ;;
12 -Wl,--strip-debug) strip=1 ;;12 -Wl,--strip-debug) strip=1 ;;
13 -Wl,--fix-cortex-a53-843419) fix=1 ;;
13 *) set -- "$@" "$arg" ;;14 *) set -- "$@" "$arg" ;;
14 esac15 esac
15done16done
16zig cc -target "$ZIG_TARGET" "$@" || exit17if [ -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
17[ -z "$strip" ] ||35[ -z "$strip" ] ||
18 "$(rustc --print sysroot)/lib/rustlib/$(rustc -vV | sed -n 's/^host: //p')/bin/rust-objcopy" \36 "$(rustc --print sysroot)/lib/rustlib/$(rustc -vV | sed -n 's/^host: //p')/bin/rust-objcopy" \
19 --strip-debug "$output"37 --strip-debug "$output"