nixpkgs/pkgs/development/libraries/glibc/multi.nix
Adam Joseph 0e9ef0a07d cc-wrapper: when merging gcc32 and gcc64, merge libgcc as well
Our gcc_multi and glibc_multi expressions merge together a
32-bit-targeted and 64-bit-targeted gcc.  However they do not thread
through the passthru.libgcc from these merged gccs.

This commit corrects that.

It also extends passthru.libgcc to allow a *list* rather than just a
single outpath.

Resolves part of #221891 (at least getting it back to the error
message it gave before).
2023-05-09 00:16:24 -07:00

38 lines
1 KiB
Nix

{ lib
, runCommand, glibc, glibc32
}:
let
nameVersion = builtins.parseDrvName glibc.name;
glibc64 = glibc;
in
runCommand "${nameVersion.name}-multi-${nameVersion.version}"
# out as the first output is an exception exclusive to glibc
{
outputs = [ "out" "bin" "dev" ]; # TODO: no static version here (yet)
passthru = {
libgcc = lib.lists.filter (x: x!=null) [
(glibc64.libgcc or null)
(glibc32.libgcc or null)
];
};
}
''
mkdir -p "$out/lib"
ln -s '${glibc64.out}'/lib/* "$out/lib"
ln -s '${glibc32.out}/lib' "$out/lib/32"
ln -s lib "$out/lib64"
# fixing ldd RLTDLIST
mkdir -p "$bin/bin"
cp -s '${glibc64.bin}'/bin/* "$bin/bin/"
rm "$bin/bin/ldd"
sed -e "s|^RTLDLIST=.*$|RTLDLIST=\"$out/lib/ld-linux-x86-64.so.2 $out/lib/32/ld-linux.so.2\"|g" \
'${glibc64.bin}/bin/ldd' > "$bin/bin/ldd"
chmod +x "$bin/bin/ldd"
mkdir "$dev"
cp -rs '${glibc32.dev}'/include "$dev/"
chmod +w -R "$dev"
cp -rsf '${glibc64.dev}'/include "$dev/"
''