mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-26 00:43:20 +00:00
cc-wrapper: use a temporary file for reponse file
The Darwin stdenv rework conditionally sets `NIX_CC_USE_RESPONSE_FILE` depending on the `ARG_MAX` of the build system. If it is at least 1 MiB, the stdenv passes the arguments on the command-line (like Linux). Otherwise, it falls back to the response file. This was done to prevent intermitent failures with clang 16 being unable to read the response file. Unfortunately, this breaks `gccStdenv` on older Darwin platforms. Note: While the stdenv logic will also be reverted, this change is needed for compatibility with clang 16. GCC is capable of using a response file, but it does not work correctly when the response file is a file descriptor. This can be reproduced using the following sequence of commands: $ nix shell nixpkgs#gcc; NIX_CC_USE_RESPONSE_FILE=1 gcc # Linux /nix/store/9n9gjvzci75gp2sh1c4rh626dhizqynl-binutils-2.39/bin/ld: unrecognized option '-B/nix/store/vnwdak3n1w2jjil119j65k8mw1z23p84-glibc-2.35-224/lib/' /nix/store/9n9gjvzci75gp2sh1c4rh626dhizqynl-binutils-2.39/bin/ld: use the --help option for usage information collect2: error: ld returned 1 exit status # Darwin ld: unknown option: -mmacosx-version-min=11.0 collect2: error: ld returned 1 exit status Instead of using process substitution, create a temporary file and remove it in a trap. This should also prevent the intermitent build failures with clang 16 on older Darwin systems. Fixes #245167
This commit is contained in:
parent
344ec16d0a
commit
6f2b3ba027
@ -246,10 +246,13 @@ if [[ -e @out@/nix-support/cc-wrapper-hook ]]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if (( "${NIX_CC_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
|
if (( "${NIX_CC_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
|
||||||
exec @prog@ @<(printf "%q\n" \
|
responseFile=$(mktemp --tmpdir cc-params.XXXXXX)
|
||||||
|
trap 'rm -f -- "$responseFile"' EXIT
|
||||||
|
printf "%q\n" \
|
||||||
${extraBefore+"${extraBefore[@]}"} \
|
${extraBefore+"${extraBefore[@]}"} \
|
||||||
${params+"${params[@]}"} \
|
${params+"${params[@]}"} \
|
||||||
${extraAfter+"${extraAfter[@]}"})
|
${extraAfter+"${extraAfter[@]}"} > "$responseFile"
|
||||||
|
@prog@ "@$responseFile"
|
||||||
else
|
else
|
||||||
exec @prog@ \
|
exec @prog@ \
|
||||||
${extraBefore+"${extraBefore[@]}"} \
|
${extraBefore+"${extraBefore[@]}"} \
|
||||||
|
Loading…
Reference in New Issue
Block a user