$ nix --extra-experimental-features "nix-command flakes" run github:thiagokokada/nix-alien#nix-alien-ld -- ./main
It will create a cached shell in '~/.cache/nix-alien and give you its path. When you open it, you should see the libraries it loads in NIX_LD_LIBRARY_PATH:
I was gonna say, those three libraries appear in the following derivations:
$ nix-locate libc.so.6 | grep glibc
(zsnes.out) 2,550,384 x /nix/store/80h8wkvzf60012mnkik703ifzc1w1kyl-glibc-2.39-31/lib/libc.so.6
(hare.out) 2,122,232 x /nix/store/s5wxag65m62a2bg2lg82jb3nqc42wyi6-glibc-aarch64-unknown-linux-gnu-2.39-31/lib/libc.so.6
(hare.out) 1,759,184 x /nix/store/brnz0ga886s09gkmjd0nwhvirjwaph7w-glibc-riscv64-unknown-linux-gnu-2.39-31/lib/libc.so.6
iconv.out 2,285,600 x /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib/libc.so.6
glibc_multi.out 0 s /nix/store/s4gcddkm2kvb02qnrm2rq22lj8yynqhw-glibc-multi-2.39-31/lib/libc.so.6
glibc_memusage.debug 0 s /nix/store/ssai8vvm9hvhjc7i6acpma6fv66dz19a-glibc-gd-2.39-31-debug/lib/debug/libc.so.6
iconv.debug 0 s /nix/store/0k9qgiqxjlhh71pj7a2czz33ir3nv720-glibc-2.39-31-debug/lib/debug/libc.so.6
glibc_memusage.out 2,285,600 x /nix/store/bimkvwhg1wrg4fmzf6aqhy68m8b12q9a-glibc-gd-2.39-31/lib/libc.so.6
I think just installing glibc_multi will just solve the issue.
It would be nice if we could somehow run inside a shell/environment where no libraries are loaded by default from the system, but turns out it’s not hard to debug the libraries the program needs once you get the hang of it.
ls /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib/ | grep 'lib\(pthread\|resolv\|c\)'
and upthread, ldd seemed to be able to find them:
I notice the dynamic linker ld-linux-x86-64.so.2 resolves to a different path for some reason /nix/store/35pq4hr29c3sl79lgfwgsvd9nwzyp4am-glibc-2.39-5/lib/ld-linux-x86-64.so.2 => /nix/store/apab5i73dqa09wx0q27b6fbhd1r18ihl-glibc-2.39-31/lib64/ld-linux-x86-64.so.2.
Sure, setting LD_LIBRARY_PATH results in a core dump, but that wasn’t the observed error. Using patch-elf --set-interpreter with this /nix/store/35pq....p4am-glib-2.39-5/ didn’t result in the same error, either.