#38 Doesn't write SONAME when lib tool does
Closed 3 years ago by midipix. Opened 3 years ago by rossburton.

Building Berkeley DB with slibtool produces libraries without SONAME fields.

The build log (abridged by hand) with libtool is as follows:

./aarch64-poky-linux-libtool --tag=CC --mode=link aarch64-poky-linux-gcc -avoid-version -rpath /usr/lib -o libdb-5.3.la mut_pthread.lo  [ ... ] -lpthread

aarch64-poky-linux-libtool: link: aarch64-poky-linux-gcc  .libs/mut_pthread.o [...]  -lpthread -Wl,-soname -Wl,libdb-5.3.so -o .libs/libdb-5.3.so

Note the -Wl,-soname -Wl,libdb-5.3.so argument being passed to gcc.

Whereas the same with slibtool:

rlibtool --heuristics=aarch64-poky-linux-libtool --tag=CC --mode=link aarch64-poky-linux-gcc  -avoid-version -rpath /usr/lib -o libdb-5.3.la mut_pthread.lo [ ... ] -lpthread

rlibtool: link: aarch64-poky-linux-gcc .libs/mut_pthread.o -lpthread -shared -fPIC -o .libs/libdb-5.3.so

No soname option, so no SONAME attribute in the library.


Confirmed, however a more accurate description of this issue should read: >>need to set SONAME even with an -avoid-version argument<<

Well, this appears to do the right thing with DB at least:

diff --git a/src/logic/slbt_exec_link.c b/src/logic/slbt_exec_link.c
index f47f01c..1f759ae 100644
--- a/src/logic/slbt_exec_link.c
+++ b/src/logic/slbt_exec_link.c
@@ -1467,6 +1467,16 @@ static int slbt_exec_link_create_library(
                                >= sizeof(soname))
                        return SLBT_BUFFER_ERROR(dctx);

+               *ectx->soname  = "-Wl,-soname";
+               *ectx->lsoname = soname;
+       } else {
+               if ((size_t)snprintf(soname,sizeof(soname),"-Wl,%s%s%s",
+                                       ectx->sonameprefix,
+                                       dctx->cctx->libname,
+                                       dctx->cctx->settings.dsosuffix)
+                               >= sizeof(soname))
+                       return SLBT_BUFFER_ERROR(dctx);
+
                *ectx->soname  = "-Wl,-soname";
                *ectx->lsoname = soname;
        }

I admit that I am basically bashing lines of C together in the hope that it works here.

That indeed is the spirit. As agreed on irc, and given that the fix is trivial and only entails copy-paste from other places in that source files, an alternative fix will shortly follow.

Thanks again for reporting! Fixed in commit 3174324.

Metadata Update from @midipix:
- Issue status updated to: Closed (was: Open)

3 years ago

Login to comment on this ticket.

Metadata