News for hackers. Stuff that matters.
Re:Rpath, or why lld doesn’t work on NixOS by wyldfire on Tuesday March 15, 2022 @08:32PM (#30693784)
> That something is rpath (also known as RUNPATH)

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.

Re:Rpath, or why lld doesn’t work on NixOS by nemetroid on Tuesday March 15, 2022 @08:40PM (#30693853)
RPATH and RUNPATH are indeed different. However, I believe the -rpath flag is used to set either (--enable/disable-new-dtags determines which one is used), so the confusion is understandable.
Re:Rpath, or why lld doesn’t work on NixOS by skainswoo on Tuesday March 15, 2022 @09:41PM (#30694271)
What is the distinction between them? I always thought they were the same thing.
Re:Rpath, or why lld doesn’t work on NixOS by stabbles on Wednesday March 16, 2022 @06:45AM (#30697248)
Depends on your libc.

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

Re:Rpath, or why lld doesn’t work on NixOS by wyldfire on Tuesday March 15, 2022 @10:11PM (#30694482)
The difference IIRC is the order they're used by the dynamic loader. One is prior to searching LD_LIBRARY_PATH, the other after.
Re:Rpath, or why lld doesn’t work on NixOS by nemetroid on Wednesday March 16, 2022 @04:36AM (#30696558)
There's also a difference for transitive dependencies. From the Linux manpage for ld.so, about RUNPATH:

> 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.