From 985072e2ce4afa4201b49a20154fcc888aaccec5 Mon Sep 17 00:00:00 2001 From: Artturin Date: Fri, 18 Oct 2024 20:50:27 +0300 Subject: [PATCH 1/2] cc-wrapper: Hardcode path to `mktemp` and `rm` if possible These commands are run after the path backup is restored Co-authored-by: IlyaNiklyaev --- pkgs/build-support/cc-wrapper/cc-wrapper.sh | 4 ++-- pkgs/build-support/cc-wrapper/default.nix | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh index 4cc661721f44..a539f9da4318 100644 --- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh +++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh @@ -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[@]}"} \ diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix index 01f91b408e38..37eb6692e731 100644 --- a/pkgs/build-support/cc-wrapper/default.nix +++ b/pkgs/build-support/cc-wrapper/default.nix @@ -741,6 +741,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; From 62f2fc1ae5f6e99d5aa5ae2829730c73a65cf7ed Mon Sep 17 00:00:00 2001 From: Artturin Date: Sat, 19 Oct 2024 00:31:24 +0300 Subject: [PATCH 2/2] tests.cc-wrapper: Add `NIX_CC_USE_RESPONSE_FILE` check --- pkgs/test/cc-wrapper/default.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/test/cc-wrapper/default.nix b/pkgs/test/cc-wrapper/default.nix index 9e25be460e25..61d65784f5b9 100644 --- a/pkgs/test/cc-wrapper/default.nix +++ b/pkgs/test/cc-wrapper/default.nix @@ -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 '';