While looking at one update recently i've seen one upstream disabling
the soname on OpenBSD because of specialtopics.html; they just
wanted to be nice I guess, but this reminded me of this section of
the faqs. Is it still the case to advise people to actively drop
the soname?
A quick and totally unscientific test shows the majority of the
libraries I have in /usr/local/lib have soname defined. Plus, we
have machinery for most build tool to do the right thing(tm).
I did something around the lines of to bulk check the soname:
$ cd /usr/local/lib
$ for i in *.so*; do if ! objdump -x $i | grep -iq soname; \
then echo $i; fi; done | wc -l
133
$ ls *.so* | wc -l
879
(this also picks up stuff that isn't a shared library; but it's an
indication of the trend I guess.)
gkoehler@ also noted that some tools link stuff with "cc -o mybin
subdir/libfun.so.0.0" (instead of "-Lsubdir -lfun") and if
subdir/libfun.so.0.0 hasn't a valid soname then the linker will put
the DT_NEEDED as "subdir/libfun.so.0.0" and when mybin uses DT_RPATH
to look in subdir/ it'll fail bacuse subdir/subdir/libfoo.so.0.0
doesn't exists.
My initial idea was to propose to drop the section but I think it
is still useful to warn against a wrong soname.
Thoughts?
Index: specialtopics.html
===================================================================
RCS file: /home/cvs/www/faq/ports/specialtopics.html,v
retrieving revision 1.89
diff -u -p -r1.89 specialtopics.html
--- specialtopics.html 14 Oct 2022 18:07:42 -0000 1.89
+++ specialtopics.html 4 Nov 2022 10:00:00 -0000
@@ -149,16 +149,11 @@ those libraries set to version 0.0, clea
and when you regenerate the PLIST you should see that it starts to
use the version numbers.
-<h3>Avoid DT_SONAME hardcoding</h3>
+<h3>Check DT_SONAME</h3>
Some ports use the <code>-soname</code> flag of
<a href="https://man.openbsd.org/ld">ld(1)</a> to override the library
specification in the DT_SONAME field.
-Setting DT_SONAME is not a bug itself but is usually not desirable on
-OpenBSD where <a href="https://man.openbsd.org/ld.so">ld.so(1)</a> is smart and
-the ports tree takes care of library versioning.
-Moreover, a wrong soname can result in unusable binaries that depend on this
-library; either always or after some updates to the port containing the
library.
To check if the DT_SONAME field is set, run the following command:
<pre class="cmdbox">
@@ -166,12 +161,13 @@ $ <b>objdump -x /path/to/libfoo.so.0.0 |
SONAME libfoo.so.0.0
</pre>
-As a general rule, <em>setting soname explicitly should be patched out</em>.
-The only exception is a situation when the right soname is recorded
-<em>and</em> it's hard to patch soname-related code out <em>and</em>
-upstream won't accept such a patch.
-In that case the soname should fully match the file name (see the example
-above).
+If it doesn't match the file name and version fully it can result
+in unusable binaries that depend on this library; either always or
+after some updates to the port containing the library.
+
+<p>
+The port should ensure the correct soname is used, or patch it out
+should fixing it become too difficult.
<h3>Try putting all user visible libraries into /usr/local/lib</h3>