Search order:
glibc: rpath > LD_LIBRARY_PATH > runpath > ld.so.cache > default paths.
musl: LD_LIBRARY_PATH > rpath=runpath > default paths.
Search path inheritance:
glibc: rpaths are inherited: When exe depends on libx depends on liby, then liby first considers its own rpaths, then libx's rpaths, then exe's rpaths. HOWEVER if liby specifies runpath, it will not consider rpaths from parents.
musl: rpaths and runpaths are the same and always inherited.
I verified the glibc/musl sources when writing https://github.com/haampie/libtree
> Such directories are searched only to find those objects required by DT_NEEDED (direct dependencies) entries and do not apply to those objects' children, which must themselves have their own DT_RUNPATH entries. This is unlike DT_RPATH, which is applied to searches for all children in the dependency tree.
Pretty sure that runpath and rpath are distinct and have slightly distinct behavior. Can't fault you much for making the mistake, though. The two are not given names to be easily distinguished.