responsie file logic

This commit is contained in:
Moritz Angermann 2021-02-09 09:46:47 +08:00
parent ece4c62d4b
commit 11b4d6c633
No known key found for this signature in database
GPG Key ID: A98C646D142C675F
3 changed files with 17 additions and 5 deletions

View File

@ -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

View File

@ -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"
}

View File

@ -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