51 lines · bash
1#! @shell@2 3source @out@/nix-support/utils.bash4 5expandResponseParams "$@"6 7output="a.out"8should_add_repro=true9newparams=()10for arg in "${params[@]}"; do11 case "$arg" in12 -r|--version)13 should_add_repro=false14 ;;15 *)16 ;;17 esac18 case "$prev" in19 -o)20 output="$arg"21 newparams+=("$arg")22 ;;23 *)24 if [ -e "$arg.nolldrepro" ]; then25 newparams+=("$arg.nolldrepro")26 else27 newparams+=("$arg")28 fi29 ;;30 esac31 prev="$arg"32done33 34export LLD_REPRODUCE="$output.repro.tar"35if @targetPrefix@nix-wrap-lld "${newparams[@]}"; then36 if $should_add_repro; then37 @lz4@ -c "$LLD_REPRODUCE" > "$LLD_REPRODUCE.lz4"38 mv "$output" "$output.nolldrepro"39 @targetPrefix@objcopy --add-section ".lld_repro=$LLD_REPRODUCE.lz4" "$output.nolldrepro" "$output"40 rm -f "$LLD_REPRODUCE.lz4"41 fi42 exitcode=043else44 # Some Nix packages don't link with lld so just use bfd instead.45 @targetPrefix@ld.bfd "${newparams[@]}"46 exitcode=$?47fi48 49rm -f "$LLD_REPRODUCE"50exit $exitcode51