Merge pull request #112449 from angerman/angerman/response-files

Add response file support when compiling with clang
This commit is contained in:
John Ericson 2021-03-06 11:24:32 -05:00 committed by GitHub
commit 6979a72840
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 5 deletions

View File

@ -198,7 +198,15 @@ 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
exec @prog@ "@<(printf "%q\n" \
${extraBefore+"${extraBefore[@]}"} \
${params+"${params[@]}"} \
${extraAfter+"${extraAfter[@]}"})"
else
exec @prog@ \
${extraBefore+"${extraBefore[@]}"} \
${params+"${params[@]}"} \
${extraAfter+"${extraAfter[@]}"}
fi

View File

@ -160,6 +160,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