#!/bin/sh
# Compilers abort or spend the test budget inside LeakSanitizer when the
# suite has preloaded libasan for Python. Drop it for this process only.
# Do not spawn dirname. Under the preloaded sanitizer that coreutils
# binary leaks and aborts before this wrapper can drop LD_PRELOAD.
case $0 in
  */*) _wrap_dir=${0%/*} ;;
  *) _wrap_dir=. ;;
esac
here=$(CDPATH= cd -- "$_wrap_dir" && pwd)
real=${REAL_CC:-}
if [ -z "$real" ]; then
  old_ifs=$IFS
  IFS=:
  for dir in $PATH; do
    [ "$dir" = "$here" ] && continue
    if [ -x "$dir/cc" ]; then
      real=$dir/cc
      break
    fi
  done
  IFS=$old_ifs
fi
if [ -z "$real" ]; then
  echo "cc is not on PATH" >&2
  exit 1
fi
unset LD_PRELOAD
exec "$real" "$@"
