[sr #111392] libtool -export-symbols does not work for NetBSD shared libraries

"Taylor R. Campbell" <[email protected]> Tue, 10 Mar 2026 00:31:55 -0400 (EDT)
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
--8323329-1714636915-1773117115=:1016867
Content-Type: TEXT/plain; CHARSET=utf-8
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-Disposition: inline

URL:=0A  <https://savannah.gnu.org/support/?111392>=0A=0A                 S=
ummary: libtool -export-symbols does not work for NetBSD=0Ashared libraries=
=0A                   Group: GNU Libtool=0A               Submitter: riastr=
adh=0A               Submitted: Tue 10 Mar 2026 04:31:51 AM UTC=0A         =
       Category: None=0A                Priority: 5 - Normal=0A            =
    Severity: 3 - Normal=0A                  Status: None=0A               =
  Privacy: Public=0A             Assigned to: None=0A        Originator Ema=
il:=0A             Open/Closed: Open=0A         Discussion Lock: Unlocked=
=0A        Operating System: *BSD=0A=0A=0A    _____________________________=
__________________________=0A=0AFollow-up Comments:=0A=0A=0A---------------=
----------------------------------------=0ADate: Tue 10 Mar 2026 04:31:51 A=
M UTC By: Taylor R. Campbell <riastradh>=0ASee attached reproducer to creat=
e a library with two symbols, foo and bar, of=0Awhich only foo is supposed =
to be exported.=0A=0AExpected output, as observed with libtool 2.4.7 under =
Debian 12:=0A=0A$ ./syms.sh=0Adynamic symbols:=0AD foo=0Asymbols:=0AD foo=
=0A=0AActual output, as observed with libtool 2.4.7 under NetBSD 9:=0A=0A$ =
./syms.sh=0Adynamic symbols:=0AD _end=0AT _fini=0AT _init=0AD bar=0AD foo=
=0Asymbols:=0AD foo=0A=0AThe reason is that libtool translates -export-symb=
ols into=0A-Wl,-retain-symbols-file, a GNU ld(1) option that affects the .s=
ymtab section=0Abut not the .dynsym section.  So it doesn't change what sym=
bols are exported=0Ato clients of the shared library.=0A=0AInstead, on NetB=
SD, for shared libraries, libtool should use the same version=0Ascript mech=
anism that it does on GNU/Linux platforms: a single anonymous=0Aversion wit=
h { global: foo; local: * }, fed into ld(1) with=0A-Wl,-version-script.  (A=
nd -Wl,-retain-symbols-file probably isn't useful for=0Ashared libraries ei=
ther; it is less effective at saving space than stripping=0Asymbols altoget=
her, and less useful for diagnostics than not stripping them.)=0A=0ACaveat:=
 Since this changes the ABI of the resulting libraries by _deleting_=0Asymb=
ols, in principle it requires a shared library major bump for any=0Alibrari=
es built with -export-symbols.=0A=0A=0A=0A=0A=0A=0A    ____________________=
___________________________________=0AFile Attachments:=0A=0AName: syms.sh =
                       Size: 593B=0A    <https://file.savannah.gnu.org/file=
/syms.sh?file_id=3D58325>=0A=0A=0A=0A    AGPL NOTICE=0A=0AThese attachments=
 are served by Savane. You can download the corresponding=0Asource code of =
Savane at=0Ahttps://savannah.gnu.org/source/savane-5479f0ac3e1f014845fd281c=
379bc3ccb7a72723.tar.gz=0A=0A    __________________________________________=
_____________=0A=0AReply to this item at:=0A=0A  <https://savannah.gnu.org/=
support/?111392>=0A=0A_______________________________________________=0AMes=
sage sent via Savannah=0Ahttps://savannah.gnu.org/=0A
--8323329-1714636915-1773117115=:1016867
Content-Type: APPLICATION/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaa+euwAKCRCqLAuaBUf3
Tq4BAP9ZIb9y3Rm42nb7OiUPepwpkdoIkKWs7aQ0qdu9HODRhwD+OmzBJqsfijBa
A+584d4rQrf/I0Wb4Lp5go0UNKhTbwQ=
=+CR/
-----END PGP SIGNATURE-----

--8323329-1714636915-1773117115=:1016867--