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