1#!/bin/sh
2# The linker for x86_64-win7-windows-gnu: llvm-mingw's clang, which links compiler-rt
3# itself, with LLVM's libunwind (static) answering for libgcc's unwinder, and rt/shims.c
4# standing in for the imports Windows 7 lacks.
5set -eu
6here=$(cd "$(dirname "$0")" && pwd)
7clang=$LLVM_MINGW/bin/x86_64-w64-mingw32-clang
8for arg do
9 shift
10 case $arg in
11 -lgcc_eh | -lgcc_s) set -- "$@" -l:libunwind.a ;;
12 -lgcc) ;;
13 *) set -- "$@" "$arg" ;;
14 esac
15done
16work=$(mktemp -d "${TMPDIR:-/tmp}/windows-link.XXXXXX")
17trap 'rm -rf "$work"' EXIT
18"$clang" -O2 -Wall -c "$here/rt/shims.c" -o "$work/shims.o"
19"$clang" "$work/shims.o" "$@"