#!/bin/sh
# RUSTC_WRAPPER: SanitizerCoverage (edges + comparisons) for the code under test and the harness.
# Only target-triple crates are instrumented (cargo passes --target for them; build scripts and
# proc macros are built for the host), and never the stitch runtime itself.
rustc="$1"; shift
inst="$STITCH_SANCOV"
case " $* " in *" --target "*) ;; *) inst="";; esac
case " $* " in *" --crate-name stitch "*|*" --crate-name build_script_"*|*"proc-macro"*) inst="";; esac
if [ -n "$inst" ]; then
  exec "$rustc" "$@" -Cpasses=sancov-module -Cllvm-args=-sanitizer-coverage-level=3 \
    -Cllvm-args=-sanitizer-coverage-trace-pc-guard -Cllvm-args=-sanitizer-coverage-trace-compares
fi
exec "$rustc" "$@"
