Skip to content

Commit

Permalink
ld-wrapper: use a temporary file for reponse file
Browse files Browse the repository at this point in the history
This changes ld-wrapper to use a temporary file for the response file
passed to ld instead of using process substitution.

ld64 does not handle long command-lines when reading from the response
file, which defeats the point of using a response file to handle long
command-lines. cctools-port was patched to work around this, but nixpkgs
is now using Apple’s source release directly instead of the port.

Since it’s preferable not to patch Apple’s release heavily (to reduce
the difficulty of updating to new versions and to match upstream’s
behavior), use the approach that was adopted in cc-wrapper to work
around issues with response files in newer versions of clang.

Related PRs (cctools-port):
- #213831
- tpoechtrager/cctools-port#132

Related PRs (cc-wrapper):
- #245282
- #258608
  • Loading branch information
reckenrode committed Jul 13, 2024
1 parent 5a56b5d commit 1cb1853
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions pkgs/build-support/bintools-wrapper/ld-wrapper.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,10 +257,13 @@ PATH="$path_backup"
# Old bash workaround, see above.

if (( "${NIX_LD_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then
@prog@ @<(printf "%q\n" \
${extraBefore+"${extraBefore[@]}"} \
${params+"${params[@]}"} \
${extraAfter+"${extraAfter[@]}"})
responseFile=$(mktemp "${TMPDIR:-/tmp}/ld-params.XXXXXX")
trap 'rm -f -- "$responseFile"' EXIT
printf "%q\n" \
${extraBefore+"${extraBefore[@]}"} \
${params+"${params[@]}"} \
${extraAfter+"${extraAfter[@]}"} > "$responseFile"
@prog@ "@$responseFile"
else
@prog@ \
${extraBefore+"${extraBefore[@]}"} \
Expand Down

0 comments on commit 1cb1853

Please sign in to comment.