[cmake-developers] OpenBSD without SONAME (was: New no-soname-option topic for e.g. Android)

Rolf Eike Beer eike at sf-mail.de
Wed May 28 16:27:02 EDT 2014


Nils Gladitz wrote:
> On 28.05.2014 20:15, Brad King wrote:
> > On 05/28/2014 12:17 PM, Nils Gladitz wrote:
> >> In case you drop "-Wl,-soname" entirely ... how do you work around the
> >> issue of the linker using paths rather than names in NEEDED entries?
> >> Or does the issue not exist on OpenBSD?
> > 
> > This is an important issue.
> > 
> > CMake generates link command lines that refer to library files by path
> > rather than asking the linker to search with a -lfoo option.  This
> > approach ensures the expected library file is linked.  If the library
> > file has no DT_SONAME then some linkers put the path in DT_NEEDED.
> > For example, compare three commands for linking to a /path/to/libfoo.so
> > 
> > file that has no DT_SONAME:
> >   ====================================  ==============================
> >   Command Line                          Result
> >   ====================================  ==============================
> >   cc A.c -o A -L/path/to -lfoo          DT_NEEDED = libfoo.so
> >   cc B.c -o B /path/to/libfoo.so        DT_NEEDED = /path/to/libfoo.so
> >   cd /path && cc C.c -o C to/libfoo.so  DT_NEEDED = to/libfoo.so
> >   ====================================  ==============================
> > 
> > Therefore linking by path to a library requires that the library
> > have a DT_SONAME, or that the linker be modified to do something
> > else for DT_NEEDED.

> I was curious and did a VM install of OpenBSD (5.5) to have a peek.
> Most of this will be obvious to OpenBSD users but this was all rather
> new to me :p ...
> 
> There is a /usr/lib/libz.so.5.0
> There is no /usr/lib/libz.so
> -lz links to /usr/lib/libz.so.5.0 nonetheless

Yes, the linker automatically searches through so.X.Y.

> The library has no SONAME.
> None of the libraries under /usr/lib in the default install seem to have
> an SONAME though I am able to create libraries with SONAME manually.
> 
> The linker does embed paths to libraries in NEEDED entries like it would
> on e.g. GNU/Linux.
> 
> This seems to imply that convention on OpenBSD is indeed to not have any
> SONAMEs at all.
> 
> Given that the topic might have one valid use case after all?

It would be useful as it would allow to drop more OpenBSD downstream patches. 
I tried that, but if you simply remove the SONAME linker flag than e.g. a 
binary in the build tree will not be able to find a library in a sibling 
directory as long as you don't fiddle with LD_LIBRARY_PATH. And that is the 
point where I gave up and decided not to care any more. Solving this issue is 
the hardest part, everything else is rather simple (i.e. all other CMake 
testcases work).

Here are the test failures of that attempt: 
http://open.cdash.org/viewTest.php?onlyfailed&buildid=3335827

Eike
-- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20140528/d59a74db/attachment-0002.sig>


More information about the cmake-developers mailing list