cc-wrapper: Hardcode path to mktemp and rm if possible (#349589)

This commit is contained in:
Artturin 2024-10-24 20:05:23 +03:00 committed by GitHub
commit 22feb8f7ca
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 2 deletions

View File

@ -251,8 +251,8 @@ if [[ -e @out@/nix-support/cc-wrapper-hook ]]; then
fi
if (( "${NIX_CC_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
responseFile=$(mktemp "${TMPDIR:-/tmp}/cc-params.XXXXXX")
trap 'rm -f -- "$responseFile"' EXIT
responseFile=$(@mktemp@ "${TMPDIR:-/tmp}/cc-params.XXXXXX")
trap '@rm@ -f -- "$responseFile"' EXIT
printf "%q\n" \
${extraBefore+"${extraBefore[@]}"} \
${params+"${params[@]}"} \

View File

@ -743,6 +743,8 @@ stdenvNoCC.mkDerivation {
# TODO(@sternenseemann): rename env var via stdenv rebuild
shell = getBin runtimeShell + runtimeShell.shellPath or "";
gnugrep_bin = optionalString (!nativeTools) gnugrep;
rm = if nativeTools then "rm" else lib.getExe' coreutils "rm";
mktemp = if nativeTools then "mktemp" else lib.getExe' coreutils "mktemp";
# stdenv.cc.cc should not be null and we have nothing better for now.
# if the native impure bootstrap is gotten rid of this can become `inherit cc;` again.
cc = optionalString (!nativeTools) cc;

View File

@ -131,6 +131,9 @@ in stdenv.mkDerivation {
ASAN_OPTIONS=use_sigaltstack=0 ${emulator} ./sanitizers
''}
echo "Check whether CC with NIX_CC_USE_RESPONSE_FILE hardcodes all required binaries..." >&2
NIX_CC_USE_RESPONSE_FILE=1 ${CC} -v
touch $out
'';