1#!/bin/sh
2# 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 debug
4# info, so the debug info goes after linking.
5strip= output= previous=
6for arg do
7 shift
8 [ "$previous" = -o ] && output=$arg
9 previous=$arg
10 case $arg in
11 --target=* | -Wl,--no-undefined-version | -Wl,-O1) ;;
12 -Wl,--strip-debug) strip=1 ;;
13 *) set -- "$@" "$arg" ;;
14 esac
15done
16zig cc -target "$ZIG_TARGET" "$@" || exit
17[ -z "$strip" ] ||
18 "$(rustc --print sysroot)/lib/rustlib/$(rustc -vV | sed -n 's/^host: //p')/bin/rust-objcopy" \
19 --strip-debug "$output"