On Sat, Apr 6, 2013 at 10:43 AM, Peter Kleiweg <
pkle...@xs4all.nl> wrote:
> Op zaterdag 6 april 2013 15:52:05 UTC+2 schreef Ian Lance Taylor het
> volgende:
>
>> Now that we use external linking, this is going to be pushed into the
>
>
> What's that, external linking?
On tip, when using cgo, which is the only case in which a shared
library can arise, the Go linker will invoke the system linker to
finish the link.
>> space of the external linker. External linkers historically do not
>> add -L options to the shared library search path, because it leads to
>> a problem that is the reverse of the one you cite. At runtime, the
>> program can wind up searching many directories unnecessarily. This is
>> particularly bad when those directories are mounted using NFS or FUSE
>> or some such technology.
>>
>> From Go's perspective it would be easy to say "whenever we pass a -L
>> option to the system linker, also pass a -Wl,-rpath option." It would
>> also be easy for the gcc driver to do this, and it would be easy for
>> an ELF linker to do this. The question, then, is whether the go tool
>> should behave differently from those older tools.
>
>
> Yes, do it differently. Go was meant to make life easier. It doesn't use
> download, extract, configure, make, make install, it uses go get, which is
> enough most of the time. I say, make it work too in those cases where now it
> doesn't work because of missing paths to C libraries.
>
> For the user it's simple: a program should work, or it is useless. So, make
> it work, without the need of special actions by the user.
As I tried to explain, if we make that change, it will work for a
different set of people and fail for a different set of people. It's
not as though the change would be right for everybody. It might be
the right choice for Go, but it's not going to be the right choice for
everybody.
> So yes, pass that option to the linker. If it is not necessary, the linker
> drops it anyway. If it is necessary to run the program, than add it.
You need to think about the case in which the library is in different
places at link time and at run time, which is common when distributing
binary programs.
>> Ideally pkg-config would provide the right answer. It does have
>> support for this. So one question to ask would be why pkg-config
>> isn't doing the right thing for the library in question.
>
>
> Because it is also used to build binary distributions of programs?
pkg-config is used to provide the correct set of options to include a
shared library in your program. It provides -L options to use. So it
could also provide -Wl,-rpath options.
Ian