···102102 sed -i $out -E -e "s~NIX_${infixSalt_}$var([^a-zA-Z_]|$)~NIX_$var\1~g"
103103 done
104104 '');
105105+106106+ # The dynamic linker has different names on different platforms.
107107+ dynamicLinker =
108108+ if !nativeLibc then
109109+ (if targetPlatform.system == "i686-linux" then "ld-linux.so.2" else
110110+ if targetPlatform.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
111111+ # ARM with a wildcard, which can be "" or "-armhf".
112112+ if targetPlatform.isArm32 then "ld-linux*.so.3" else
113113+ if targetPlatform.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else
114114+ if targetPlatform.system == "powerpc-linux" then "ld.so.1" else
115115+ if targetPlatform.system == "mips64el-linux" then "ld.so.1" else
116116+ if targetPlatform.system == "x86_64-darwin" then "/usr/lib/dyld" else
117117+ if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" else
118118+ builtins.trace
119119+ "Don't know the name of the dynamic linker for platform ${targetPlatform.config}, so guessing instead."
120120+ null)
121121+ else "";
122122+105123in
106124107125stdenv.mkDerivation {
···144162 }
145163 ''
146164147147- + optionalString (libc != null) (if (!targetPlatform.isDarwin) then ''
165165+ # TODO(@Ericson2314): Unify logic next hash break
166166+ + optionalString (libc != null) (if (targetPlatform.isDarwin) then ''
167167+ echo $dynamicLinker > $out/nix-support/dynamic-linker
168168+169169+ echo "export LD_DYLD_PATH=\"$dynamicLinker\"" >> $out/nix-support/setup-hook
170170+ '' else if dynamicLinker != null then ''
148171 dynamicLinker="${libc_lib}/lib/$dynamicLinker"
149172 echo $dynamicLinker > $out/nix-support/dynamic-linker
150173···157180 # (the *last* value counts, so ours should come first).
158181 echo "-dynamic-linker" $dynamicLinker > $out/nix-support/libc-ldflags-before
159182 '' else ''
160160- echo $dynamicLinker > $out/nix-support/dynamic-linker
183183+ dynamicLinker=`eval 'echo $libc/lib/ld*.so.?'`
184184+ if [ -n "$dynamicLinker" ]; then
185185+ echo $dynamicLinker > $out/nix-support/dynamic-linker
161186162162- echo "export LD_DYLD_PATH=\"$dynamicLinker\"" >> $out/nix-support/setup-hook
187187+ if [ -e ${libc_lib}/lib/32/ld-linux.so.2 ]; then
188188+ echo ${libc_lib}/lib/32/ld-linux.so.2 > $out/nix-support/dynamic-linker-m32
189189+ fi
190190+191191+ ldflagsBefore="-dynamic-linker $dlinker"
192192+ fi
193193+194194+ # The dynamic linker is passed in `ldflagsBefore' to allow
195195+ # explicit overrides of the dynamic linker by callers to gcc/ld
196196+ # (the *last* value counts, so ours should come first).
197197+ echo "$ldflagsBefore" > $out/nix-support/libc-ldflags-before
163198 '')
164199165200 + optionalString (libc != null) ''
···331366 ''
332367 + extraBuildCommands;
333368334334- # The dynamic linker has different names on different Linux platforms.
335335- #
336336- # TODO(1b62c9c06173f4d5e6b090e5ae0c68fa5f478faf): This is not the best way to
337337- # do this. I think the reference should be the style in the gcc-cross-wrapper,
338338- # but to keep a stable stdenv now I do this sufficient if/else.
339339- dynamicLinker =
340340- if !nativeLibc then
341341- (if targetPlatform.system == "i686-linux" then "ld-linux.so.2" else
342342- if targetPlatform.system == "x86_64-linux" then "ld-linux-x86-64.so.2" else
343343- # ARM with a wildcard, which can be "" or "-armhf".
344344- if targetPlatform.isArm32 then "ld-linux*.so.3" else
345345- if targetPlatform.system == "aarch64-linux" then "ld-linux-aarch64.so.1" else
346346- if targetPlatform.system == "powerpc-linux" then "ld.so.1" else
347347- if targetPlatform.system == "mips64el-linux" then "ld.so.1" else
348348- if targetPlatform.system == "x86_64-darwin" then "/usr/lib/dyld" else
349349- if stdenv.lib.hasSuffix "pc-gnu" targetPlatform.config then "ld.so.1" else
350350- abort "Don't know the name of the dynamic linker for this platform.")
351351- else "";
369369+ inherit dynamicLinker;
352370353371 crossAttrs = {
354372 shell = shell.crossDrv + shell.crossDrv.shellPath;