[Nix-dev] patchelf - why rpath, not runpath?

Eelco Dolstra e.dolstra at tudelft.nl
Mon Aug 31 14:32:45 CEST 2009


Hi,

Lluís Batlle wrote:

> reading from ld.so, I see the order of checking directories for
> libraries goes as follows:
> 1 - rpath
> 2 - $LD_LIBRARY_PATH
> 3 - runpath
> 4 - ld.so.cache
> 5 - default ld.so directories (where glibc has been installed)
> 
> Is there any rationale behind the decision choosing rpath? Wouldn't
> the runpath allow easier library substitution with $LD_LIBRARY_PATH,
> and this would be a benefit?

In stdenv-linux in Nixpkgs we use the RUNPATH exactly for this reason (namely
allowing overriding through $LD_LIBRARY_PATH).  We used to set the RPATH
instead.  See pkgs/development/tools/misc/binutils/default.nix and
new-dtags.patch (which turns on the --enable-new-dtags flag by default).

BTW, binaries with a RUNPATH still have an RPATH, but it's ignored.

Also note that patchelf --set-path actually sets the RUNPATH nowadays unless you
use --force-rpath.

-- 
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/



More information about the nix-dev mailing list