[llvm-commits] [PATCH] Fix $ORIGIN expansion for dynamically linked executables

Bill Wendling wendling at apple.com
Sun Apr 15 21:37:54 PDT 2012


On Apr 15, 2012, at 2:06 PM, Dimitry Andric wrote:

> Hi,
> 
> I recently tried building llvm and clang trunk on FreeBSD with shared
> libraries enabled.  Building went just fine, but during testing each
> llvm executable complained it could not find libLLVM-3.1svn.so.
> 
> It turned out that they all use $ORIGIN in their RPATH section, to find
> any libraries relative to their own installation path.
> 
> However, the necessary ORIGIN flag was not set in their FLAGS (or
> FLAGS_1) section.  It seems you must pass "-z origin" to GNU ld to have
> this flag set in the final executable.
> 
> It's probably that e.g. Linux simply ignores this flag, and always
> expands $ORIGIN anyway, but this is not the case on FreeBSD, and
> possibly on other operating systems too.
> 
> So I would like to propose the attached patch, which passes "-z origin"
> to the linker, in addition to any -rpath option.

I'll let someone who knows the GNU linker better comment, but please try get this into the tree before we branch for 3.1. :)

-bw




More information about the llvm-commits mailing list