lol

bintools: Add response file support to `ld-wrapper` (#213831)

The motivation behind this is to alleviate the problem
described in https://github.com/NixOS/nixpkgs/issues/41340.
I'm not sure if this completely fixes the problem, but it
eliminates one more area where we can exceed command line
length limits.

This is essentially the same change as in #112449,
except for `ld-wrapper.sh` instead of `cc-wrapper.sh`.

However, that change alone was not enough; on macOS the
`ld` provided by `darwin.cctools` fails if you use process
substitution to generate the response file, so I put up a
PR to fix that:

https://github.com/tpoechtrager/cctools-port/pull/131

… and I included a patch referencing that fix so that the
new `ld-wrapper` still works on macOS.

authored by

Gabriella Gonzalez and committed by
GitHub
79484b17 55aecca3

+26 -5
+4 -1
pkgs/build-support/bintools-wrapper/default.nix
··· 25 , nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" 26 , propagateDoc ? bintools != null && bintools ? man 27 , extraPackages ? [], extraBuildCommands ? "" 28 - , isGNU ? bintools.isGNU or false, isLLVM ? bintools.isLLVM or false 29 , buildPackages ? {} 30 , targetPackages ? {} 31 , useMacosReexportHack ? false ··· 139 local dst="$1" 140 local wrapper="$2" 141 export prog="$3" 142 substituteAll "$wrapper" "$out/bin/$dst" 143 chmod +x "$out/bin/$dst" 144 }
··· 25 , nativeTools, noLibc ? false, nativeLibc, nativePrefix ? "" 26 , propagateDoc ? bintools != null && bintools ? man 27 , extraPackages ? [], extraBuildCommands ? "" 28 + , isGNU ? bintools.isGNU or false 29 + , isLLVM ? bintools.isLLVM or false 30 + , isCCTools ? bintools.isCCTools or false 31 , buildPackages ? {} 32 , targetPackages ? {} 33 , useMacosReexportHack ? false ··· 141 local dst="$1" 142 local wrapper="$2" 143 export prog="$3" 144 + export use_response_file_by_default=${if isCCTools then "1" else "0"} 145 substituteAll "$wrapper" "$out/bin/$dst" 146 chmod +x "$out/bin/$dst" 147 }
+12 -4
pkgs/build-support/bintools-wrapper/ld-wrapper.sh
··· 250 251 PATH="$path_backup" 252 # Old bash workaround, see above. 253 - @prog@ \ 254 - ${extraBefore+"${extraBefore[@]}"} \ 255 - ${params+"${params[@]}"} \ 256 - ${extraAfter+"${extraAfter[@]}"} 257 258 if [ -e "@out@/nix-support/post-link-hook" ]; then 259 source @out@/nix-support/post-link-hook
··· 250 251 PATH="$path_backup" 252 # Old bash workaround, see above. 253 + 254 + if (( "${NIX_LD_USE_RESPONSE_FILE:-@use_response_file_by_default@}" >= 1 )); then 255 + @prog@ @<(printf "%q\n" \ 256 + ${extraBefore+"${extraBefore[@]}"} \ 257 + ${params+"${params[@]}"} \ 258 + ${extraAfter+"${extraAfter[@]}"}) 259 + else 260 + @prog@ \ 261 + ${extraBefore+"${extraBefore[@]}"} \ 262 + ${params+"${params[@]}"} \ 263 + ${extraAfter+"${extraAfter[@]}"} 264 + fi 265 266 if [ -e "@out@/nix-support/post-link-hook" ]; then 267 source @out@/nix-support/post-link-hook
+1
pkgs/os-specific/darwin/binutils/default.nix
··· 89 90 passthru = { 91 inherit targetPrefix; 92 }; 93 94 meta = {
··· 89 90 passthru = { 91 inherit targetPrefix; 92 + isCCTools = true; 93 }; 94 95 meta = {
+9
pkgs/os-specific/darwin/cctools/port.nix
··· 3 , libuuid 4 , libobjc ? null, maloader ? null 5 , enableTapiSupport ? true, libtapi 6 }: 7 8 let ··· 42 patches = [ 43 ./ld-ignore-rpath-link.patch 44 ./ld-rpath-nonfinal.patch 45 ] 46 ++ lib.optional stdenv.isDarwin ./darwin-no-memstream.patch; 47
··· 3 , libuuid 4 , libobjc ? null, maloader ? null 5 , enableTapiSupport ? true, libtapi 6 + , fetchpatch 7 }: 8 9 let ··· 43 patches = [ 44 ./ld-ignore-rpath-link.patch 45 ./ld-rpath-nonfinal.patch 46 + (fetchpatch { 47 + url = "https://github.com/tpoechtrager/cctools-port/commit/4a734070cd2838e49658464003de5b92271d8b9e.patch"; 48 + hash = "sha256-72KaJyu7CHXxJJ1GNq/fz+kW1RslO3UaKI91LhBtiXA="; 49 + }) 50 + (fetchpatch { 51 + url = "https://github.com/MercuryTechnologies/cctools-port/commit/025899b7b3593dedb0c681e689e57c0e7bbd9b80.patch"; 52 + hash = "sha256-SWVUzFaJHH2fu9y8RcU3Nx/QKx60hPE5zFx0odYDeQs="; 53 + }) 54 ] 55 ++ lib.optional stdenv.isDarwin ./darwin-no-memstream.patch; 56