nixpkgs/pkgs/build-support/rust/rustc-wrapper/rustc-wrapper.sh
Alyssa Ross 6f8fa05acf
wrapRustc: wrap rustdoc
We need to set -crt-static on musl for rustdoc as well, so let's unify
the wrappers.  Ideally, rather than wrapping rustdoc, we'd have
rustdoc use the wrapped rustc, but that's currently only possible with
an unstable option (--test-builder).

The options set by the wrapper, -C target-feature and --sysroot, are
supported by both rustdoc and rustc, but other flags maybe not be
supported by both, so I've introduced different environment
variables (the existing NIX_RUSTFLAGS and a new NIX_RUSTDOCFLAGS) to
allow those to be set independently.

This fixes cargo-auditable in pkgsMusl., which broke because its
doctests stopped working when -crt-static was moved to the wrapper.

Fixes: 79156bf13a ("rustc: move crt-static default override to wrapper (#291829)")
2024-03-02 13:09:07 +01:00

30 lines
663 B
Bash

#!@shell@
defaultSysroot=(@sysroot@)
for arg; do
case "$arg" in
--sysroot|--sysroot=*)
defaultSysroot=()
;;
--)
break
;;
esac
done
extraBefore=(@defaultArgs@ "${defaultSysroot[@]}")
extraAfter=($@extraFlagsVar@)
# Optionally print debug info.
if (( "${NIX_DEBUG:-0}" >= 1 )); then
echo "extra flags before to @prog@:" >&2
printf " %q\n" "${extraBefore[@]}" >&2
echo "original flags to @prog@:" >&2
printf " %q\n" "$@" >&2
echo "extra flags after to @prog@:" >&2
printf " %q\n" "${extraAfter[@]}" >&2
fi
exec @prog@ "${extraBefore[@]}" "$@" "${extraAfter[@]}"