autoPatchelfHook not patching all dependencies

I’m getting some confusing autoPatchelfHook behavior. I have a derivation that pulls down a python wheel with binaries and then attempts to patch them with autoPatchelfHook. Without any autoPatchelfHook I get

> ldd result/lib/python3.9/site-packages/jaxlib/ (0x00007fff714fd000) => /usr/lib/x86_64-linux-gnu/ (0x00007ff031943000) => /lib/x86_64-linux-gnu/ (0x00007ff031928000) => /lib/x86_64-linux-gnu/ (0x00007ff031905000) => /lib/x86_64-linux-gnu/ (0x00007ff031713000)
        /lib64/ (0x00007ff031bb4000) => /lib/x86_64-linux-gnu/ (0x00007ff0315c4000)

Ok, makes sense lots of nix-unfriendly paths. Then if I add just nativeBuildInputs = [ autoPatchelfHook ]; I get an error:

autoPatchelfHook could not satisfy dependency

which also makes sense to me, since I need to add those things as dependencies. So I add buildInputs = [ ];, and then everything builds just fine, but I see:

> ldd result/lib/python3.9/site-packages/jaxlib/
result/lib/python3.9/site-packages/jaxlib/ /lib/x86_64-linux-gnu/ version `GLIBC_2.33' not found (required by /nix/store/0kiykyrnrpfhmjwxwx89kxr20hmf5304-gcc-10.3.0-lib/lib/ (0x00007ffc2cb77000) => /nix/store/0kiykyrnrpfhmjwxwx89kxr20hmf5304-gcc-10.3.0-lib/lib/ (0x00007fb9d707c000) => /nix/store/0kiykyrnrpfhmjwxwx89kxr20hmf5304-gcc-10.3.0-lib/lib/ (0x00007fb9d7062000) => /lib/x86_64-linux-gnu/ (0x00007fb9d7026000) => /lib/x86_64-linux-gnu/ (0x00007fb9d6e34000)
        /lib64/ (0x00007fb9d72ca000) => /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib/ (0x00007fb9d6cf3000)

which still appears to contain a bunch of nix-unfriendly paths.

Why isn’t autoPatchelfHook touching these other dependencies? Is everything ok?

The docs seem to indicate that this shouldn’t happen:

By default autoPatchelf will fail as soon as any ELF file requires a dependency which cannot be resolved via the given build inputs.

What happens if you use ldd from nixpkgs? If you don’t have it in your nix environment/shell it is part of glibc-bin, i.e /nix/store/*glibc-*-bin/bin/ldd.

1 Like

Ah interesting… that seems to make quite a difference!

> nix-shell --pure -p glibc
[nix-shell:~/dev/nixpkgs]$ ldd result/lib/python3.9/site-packages/jaxlib/  (0x00007fffc8eec000) => /nix/store/0kiykyrnrpfhmjwxwx89kxr20hmf5304-gcc-10.3.0-lib/lib/ (0x00007f1e86661000) => /nix/store/0kiykyrnrpfhmjwxwx89kxr20hmf5304-gcc-10.3.0-lib/lib/ (0x00007f1e86647000) => /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib/ (0x00007f1e86627000) => /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib/ (0x00007f1e86462000)
        /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib64/ (0x00007f1e868af000) => /nix/store/9bh3986bpragfjmr32gay8p95k91q4gy-glibc-2.33-47/lib/ (0x00007f1e86321000)

If autoPatchelfHook completes successfully is it fair to assume that everything will be linked correctly at runtime then? This looks pretty good AFAICT.

Unfortunately not. In my case patchelf produced broken executables which didn’t run, but given that you have so few dependencies it may be ok. You may want to check the issues page Issues · NixOS/patchelf · GitHub.

1 Like

Sorry to jump here, but it’s one of the first result I get when googling error: auto-patchelf could not satisfy dependency In that case you want to add:

  buildInputs = [

@tobiasBora thank you!