This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ld and rpath in .so


On 1/23/19 7:58 PM, Andrew Bell wrote:
> I have learned that the conda toolchain is built as a cross-toolchain,
> which I believe explains ld ignoring rpath for secondary dependencies.

A cross-toolchain should not ignore rpath, but it may be setup to honour
a sysroot prefix which is pre-pended to the rpath.

> Thanks for reading.
> 
> On Wed, Jan 23, 2019, 5:38 PM Andrew Bell <andrew.bell.ia@gmail.com wrote:
> 
>> Hi,
>>
>> My understanding is that ld will use the RPATH in a shared object to
>> locate secondary shared objects when linking an executable.

Which link? Static link or dynamic link?

At static link time it's the value of -Wl,-rpath or -Wl,-rpath-link.

At dynamic link  time it's the value of DT_RPATH in the dyanmic section.

>> I'm trying to build a conda package and this doesn't seem to be
>> happening.  I can use readelf to verify that the RPATH is set in the linked
>> library to point to the directory containing the secondary libraries, but
>> when I link my executable with the linked library, I get an error saying
>> that the secondary libraries can't be found.  Using -rpath-link on the
>> command line to explicitly specify the path that's embedded in the linked
>> library rpath resolves the issue (though -rpath on the command line
>> fails).  I'm using ld through g++ 7.3.

You have this backward. Using -rpath embeds the path via DT_RPATH, but 
using -rpath-link does not.

Searching -rpath for a cross-linker *requires* --with-sysroot.

>> Is there some circumstance that would cause ld to ignore the
>> rpath embedded in a linked library when attempting to locate a NEEDED
>> item?  Am I misunderstanding something in the way ld locates secondary
>> libraries?

Yes, you need a sysroot path.

-- 
Cheers,
Carlos.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]