Skip to content

Instantly share code, notes, and snippets.

@neoeinstein
Created June 3, 2019 16:30
Show Gist options
  • Save neoeinstein/207c521b7818c9c17b13e5cdd07ad3c9 to your computer and use it in GitHub Desktop.
Save neoeinstein/207c521b7818c9c17b13e5cdd07ad3c9 to your computer and use it in GitHub Desktop.
Wrapper for rustc that handles problems when trying to compile `proptest` with `cargo-tarpaulin` (or in general when using `-C link-dead-code`). Used by setting `RUSTC_WRAPPER=proptest_fix.sh` before executing `cargo-tarpaulin`.
#!/usr/bin/env bash
set -euo pipefail
ARGS=$@
CARGO_HOME=${CARGO_HOME-}
CARGO_PKG_NAME=${CARGO_PKG_NAME-}
if [[ "$CARGO_PKG_NAME" = "proptest" ]]
then
ARGS=()
for i in $*
do
if [[ "$i" = "link-dead-code" ]]
then
ARGS+=" lto=no"
else
ARGS+=" $i"
fi
done
fi
if [[ -f "$CARGO_HOME/bin/sccache" ]]
then
exec $CARGO_HOME/bin/sccache $ARGS
else
exec $ARGS
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment