[sr #111326] Libtool dangerously adds -L arguments during relinking

Pierre Ossman <[email protected]> Mon, 20 Oct 2025 11:19:07 -0400 (EDT)
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <[email protected]>
--8323329-1402463106-1760973547=:942659
Content-Type: TEXT/plain; CHARSET=utf-8
Content-Transfer-Encoding: QUOTED-PRINTABLE
Content-Disposition: inline

URL:=0A  <https://savannah.gnu.org/support/?111326>=0A=0A                 S=
ummary: Libtool dangerously adds -L arguments during=0Arelinking=0A        =
           Group: GNU Libtool=0A               Submitter: cendossm=0A      =
         Submitted: Mon 20 Oct 2025 03:19:04 PM UTC=0A                Categ=
ory: None=0A                Priority: 5 - Normal=0A                Severity=
: 3 - Normal=0A                  Status: None=0A                 Privacy: P=
ublic=0A             Assigned to: None=0A        Originator Email:=0A      =
       Open/Closed: Open=0A         Discussion Lock: Any=0A        Operatin=
g System: None=0A=0A=0A    ________________________________________________=
_______=0A=0AFollow-up Comments:=0A=0A=0A----------------------------------=
---------------------=0ADate: Mon 20 Oct 2025 03:19:04 PM UTC By: Pierre Os=
sman <cendossm>=0AIf you have internal libraries in a project, then libtool=
 wants to do some=0Arelinking magic when you install them.=0A=0AHowever, it=
 is overly pessimistic about how to link those and adds the line:=0A=0A  -L=
<DESTDIR>/usr/lib -L/usr/lib -linternallib=0A=0AThat second -L should be po=
intless, as the newly built library should be in=0A<DESTDIR>/usr/lib. And i=
t is extremely dangerous, as that -L will not just=0Aaffect -linternallib, =
but everything else that follows.=0A=0AWhen cross compiling between compati=
ble architectures, this breaks=0Aspectacularly. The linker will then grab t=
hings from the build system, instead=0Aof from the correct sysroot.=0A=0Ali=
btool 2.5.1 improved this by looking at lt_sysroot. But that can still be=
=0Afragile, as it's easy to overlook setting up sysroot for libtool as it i=
s=0Aoften not needed.=0A=0AI would request getting rid of that extra -L, at=
 least in most scenarios, to=0Ahave a more reliable result.=0A=0A=0A=0A=0A=
=0A=0A=0A    _______________________________________________________=0A=0AR=
eply to this item at:=0A=0A  <https://savannah.gnu.org/support/?111326>=0A=
=0A_______________________________________________=0AMessage sent via Savan=
nah=0Ahttps://savannah.gnu.org/=0A
--8323329-1402463106-1760973547=:942659
Content-Type: APPLICATION/pgp-signature; name=signature.asc

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

iHUEABYIAB0WIQQk97aszIMMAvLLwm6qLAuaBUf3TgUCaPZS6wAKCRCqLAuaBUf3
Ts6XAQDPFoUCSGyuuwHawtpJs5XCQmsDLjdcsoNe8cR0uTmqHwEA8vhUgRDPma3B
BWrJ3uIU16sBJAIRV0codjPB6lEDlgs=
=aRRE
-----END PGP SIGNATURE-----

--8323329-1402463106-1760973547=:942659--