Making RUNPATH redundant for Nix

9 Likes

A double edge sword: LD_LIBRARY_PATH no longer works.

1 Like

But LD_PRELOAD still does. :sweat_smile:

There should be a better gesture if you want to override a library rather than using LD_LIBRARY_PATH in Nix

1 Like

After thinking about it for a while I realized that Nix does not do “dynamic linking” but “deferred linking”. Obviously we should take a cautious approach to changing the link process but at the same time we should recognize we are doing something fundamentally different.

3 Likes

Exactly!
In fact I proposed in our paper submission the thought experiment:

Imagine if the dynamic loader validated the content address so that you could not replace the link with another shared object file.

It really starts to get blurry what is static linking and dynamic linking from a theoretical perspective.

Dynamic linking is supposed to let you swap ABI compatible pieces but what happens when you disallow that but you still load shared objects.

1 Like

Guix implemented a solution to this problem in their package repository last year, relying on dynamic loader caches instead: Taming the ‘stat’ storm with a loader cache — 2021 — Blog — GNU Guix. It’d be interesting to compare notes and if they considered your solution before implementing it.

In a way their solution is more conservative (which is good for such large impact changes), but it seems that the loader cache is a specific feature of the glibc dynamic loader (could be wrong here). Though, we probably need to pay attention to the loader implementation always: Did you test your solution with musl’s loader? Does it translate to macOS’ dylibs?

1 Like

I recommend you read my previous post that has this information as well:

Hosted by Flying Circus.