blob: 3b19c08195d804b19996585aec8d287e9681e699 [file] [log] [blame]
#!/bin/bash
set -eu
if [[ "${GOOS}" != "fuchsia" ]]; then
echo >&2 "This script should not be used unless GOOS=fuchsia"
exit 1
fi
case "${GOARCH}" in
arm64)
CLANG_TRIPLE="aarch64-fuchsia";;
amd64)
CLANG_TRIPLE="x86_64-fuchsia";;
*)
echo >&2 "Unsupported architecture: ${GOARCH}"
exit 1;;
esac
extra_args=()
# -Qunused-arguments is used to avoid issues with intermediate builds that don't directly link fdio.
extra_args+=(-Qunused-arguments)
extra_args+=(--sysroot="${ZIRCON_SYSROOT}")
extra_args+=(-I"${FDIO_INCLUDE}")
extra_args+=(-L"${FUCHSIA_SHARED_LIBS}")
clangbin="clang"
if [[ -n "${CLANG_PREFIX}" ]]; then
clangbin="${CLANG_PREFIX}/${clangbin}"
fi
exec "${clangbin}" --target="${CLANG_TRIPLE}" "${extra_args[@]}" "$@"