summary refs log tree commit diff
diff options
context:
space:
mode:
authorMoritz Angermann <moritz.angermann@gmail.com>2021-02-09 09:46:47 +0800
committerMoritz Angermann <moritz.angermann@gmail.com>2021-02-09 09:46:47 +0800
commit11b4d6c633439c9429b9dc5324e13cf2bf9a4382 (patch)
treef27346a44923c4b868865cc488a2b1e4fa85b8a2
parentece4c62d4b3f6f53935ece6b9cd5efe644cee79b (diff)
downloadnixpkgs-11b4d6c633439c9429b9dc5324e13cf2bf9a4382.tar
nixpkgs-11b4d6c633439c9429b9dc5324e13cf2bf9a4382.tar.gz
nixpkgs-11b4d6c633439c9429b9dc5324e13cf2bf9a4382.tar.bz2
nixpkgs-11b4d6c633439c9429b9dc5324e13cf2bf9a4382.tar.lz
nixpkgs-11b4d6c633439c9429b9dc5324e13cf2bf9a4382.tar.xz
nixpkgs-11b4d6c633439c9429b9dc5324e13cf2bf9a4382.tar.zst
nixpkgs-11b4d6c633439c9429b9dc5324e13cf2bf9a4382.zip
responsie file logic
-rw-r--r--pkgs/build-support/cc-wrapper/cc-wrapper.sh19
-rw-r--r--pkgs/build-support/cc-wrapper/default.nix1
-rw-r--r--pkgs/build-support/expand-response-params/default.nix2
3 files changed, 17 insertions, 5 deletions
diff --git a/pkgs/build-support/cc-wrapper/cc-wrapper.sh b/pkgs/build-support/cc-wrapper/cc-wrapper.sh
index c2e6c140635..d26b284ed3f 100644
--- a/pkgs/build-support/cc-wrapper/cc-wrapper.sh
+++ b/pkgs/build-support/cc-wrapper/cc-wrapper.sh
@@ -180,7 +180,18 @@ fi
 
 PATH="$path_backup"
 # Old bash workaround, see above.
-exec @prog@ \
-    ${extraBefore+"${extraBefore[@]}"} \
-    ${params+"${params[@]}"} \
-    ${extraAfter+"${extraAfter[@]}"}
+
+if (( "${NIX_CC_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
+    RESPONSE_FILE=$(mktemp)
+    printf "%q\n" \
+       ${extraBefore+"${extraBefore[@]}"} \
+       ${params+"${params[@]}"} \
+       ${extraAfter+"${extraAfter[@]}"} \
+       > "${RESPONSE_FILE}"
+    exec @prog@ "@${RESPONSE_FILE}"
+else
+    exec @prog@ \
+       ${extraBefore+"${extraBefore[@]}"} \
+       ${params+"${params[@]}"} \
+       ${extraAfter+"${extraAfter[@]}"}
+fi
diff --git a/pkgs/build-support/cc-wrapper/default.nix b/pkgs/build-support/cc-wrapper/default.nix
index 8de2366ff5f..77ec0930e85 100644
--- a/pkgs/build-support/cc-wrapper/default.nix
+++ b/pkgs/build-support/cc-wrapper/default.nix
@@ -121,6 +121,7 @@ stdenv.mkDerivation {
         local dst="$1"
         local wrapper="$2"
         export prog="$3"
+        export use_response_file_by_default=${if isClang then "1" else "0"}
         substituteAll "$wrapper" "$out/bin/$dst"
         chmod +x "$out/bin/$dst"
       }
diff --git a/pkgs/build-support/expand-response-params/default.nix b/pkgs/build-support/expand-response-params/default.nix
index 2a4bee74197..402f0071a53 100644
--- a/pkgs/build-support/expand-response-params/default.nix
+++ b/pkgs/build-support/expand-response-params/default.nix
@@ -10,7 +10,7 @@ stdenv.mkDerivation {
     src=$PWD
   '';
   buildPhase = ''
-    "$CC" -std=c99 -O3 -o "expand-response-params" expand-response-params.c
+    NIX_CC_USE_RESPONSE_FILE=0 "$CC" -std=c99 -O3 -o "expand-response-params" expand-response-params.c
   '';
   installPhase = ''
     mkdir -p $prefix/bin