This is an archive of the discontinued LLVM Phabricator instance.

[ELF] - Implemented rpath-link command line option.
AbandonedPublic

Authored by grimar on Sep 13 2016, 1:57 AM.

Details

Reviewers
ruiu
rafael
Summary

rpath-link option was ignored before.
This is PR30360, patch fixes that.
Am I missing something ? That looks too much trivial, have no idea why we ignored it before ?

Diff Detail

Event Timeline

grimar updated this revision to Diff 71118.Sep 13 2016, 1:57 AM
grimar retitled this revision from to [ELF] - Implemented rpath-link command line option..
grimar updated this object.
grimar added reviewers: ruiu, rafael.
grimar added subscribers: llvm-commits, grimar, evgeny777.

This would probably work in practice, but the ld.bfd implementation is a bit more nuanced. Specifically, ld.bfd searches the -L path for libraries named on the command line, and it searches the rpath-link path for libraries required by those libraries. That is, it does not search the -L path for libraries needed by libraries. In my humble opinion, this doesn't make much sense and is slightly annoying for the end user. However, if lld wants to be command-line-compatible with ld.bfd, which I think would be wise, it should probably follow suit.

The ld.bfd documentation has a fairly detailed description:

https://sourceware.org/binutils/docs-2.27/ld/Options.html#index-link_002dtime-runtime-library-search-path-232

This would probably work in practice, but the ld.bfd implementation is a bit more nuanced. Specifically, ld.bfd searches the -L path for libraries named on the command line, and it searches the rpath-link path for libraries required by those libraries. That is, it does not search the -L path for libraries needed by libraries. In my humble opinion, this doesn't make much sense and is slightly annoying for the end user. However, if lld wants to be command-line-compatible with ld.bfd, which I think would be wise, it should probably follow suit.

The ld.bfd documentation has a fairly detailed description:

https://sourceware.org/binutils/docs-2.27/ld/Options.html#index-link_002dtime-runtime-library-search-path-232

Yes, that is what I mean when wrote description I think. There is no much sence to split searching I believe.
In lld we always follow the easiest path at first and I do not want to overcomplicate feature until there are reasons to do that.

That makes sense to me. And given that, the patch looks fine (not that my review matters much).

Thanks for your work on this.

joerg added a subscriber: joerg.Sep 13 2016, 10:59 AM

Actually, keeping them separate can be quite important when considering the presence of archive libraries in the build library path (-L) vs the link-time view of the run-time path. This matters for linker script look-up.

Actually, keeping them separate can be quite important when considering the presence of archive libraries in the build library path (-L) vs the link-time view of the run-time path. This matters for linker script look-up.

Sorry, I am missing the idea. Could you provide example to clarify real life usecase you are talking about ?

ruiu edited edge metadata.Sep 13 2016, 1:37 PM

I was bitten by a subtle difference (or a bug) in the file search path code before, which is fixed in r273846. I can tell from that experience that it was not easy to find a bug. If the linker finds another file in a different directory in search paths, it tries to use that file instead of an intended one and eventually fail in a unresolved symbol error or something like that which seems totally unrelated to a search path problem. So my opinion is that we probably should implement what the GNU linker does to avoid such mess in the future. At least we need to understand the exact semantics of the GNU linker.

ELF/Options.td
150

Define rpath_link_eq as an alias for rpath_link.

def alias_rpath_link_eq: J<"rpath-link=">, Alias<rpath_link>;
In D24496#541673, @ruiu wrote:

I was bitten by a subtle difference (or a bug) in the file search path code before, which is fixed in r273846. I can tell from that experience that it was not easy to find a bug. If the linker finds another file in a different directory in search paths, it tries to use that file instead of an intended one and eventually fail in a unresolved symbol error or something like that which seems totally unrelated to a search path problem. So my opinion is that we probably should implement what the GNU linker does to avoid such mess in the future. At least we need to understand the exact semantics of the GNU linker.

When prepared this patch, I just already forgot why we ignored it before, but now I remember: it was D18269,
we desided to ignore it like gold do that time.

grimar abandoned this revision.Mar 30 2017, 1:33 AM