GNU bug report logs - #78072
Libtool incorrectly tries to use shared library when linking statically

Previous Next

Package: libtool;

Reported by: Mike Krinkin <krinkin.m.u <at> gmail.com>

Date: Sat, 26 Apr 2025 06:06:04 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Mike Krinkin <krinkin.m.u <at> gmail.com>
To: Ileana Dumitrescu <ileanadumitrescu95 <at> gmail.com>
Cc: 78072 <at> debbugs.gnu.org
Subject: bug#78072: Libtool incorrectly tries to use shared library when linking statically
Date: Mon, 28 Apr 2025 16:47:24 +0100
[Message part 1 (text/plain, inline)]
Hi Ileana,

thank you for the response. I will try to test it out to confirm if your
suggestions will fix the issue, it would take some time though.

The problem in our case though is that colm for us is a dependency - it's
not a project we own.
So while I can apply changes you suggested to test if they work, that's not
a solution we will be able to settle on.

Is there any reason why --static flag that was provided to libtool is not
enough indication to libtool to pick a static library over a shared one
when both are available?
If that behavior could be addressed somehow, IMO, it would be the best.
Otherwise, I think, it would be just much easier for us to drop the la
config alltogether rather than apply patches to a dependency.

On Mon, 28 Apr 2025 at 16:42, Ileana Dumitrescu <
ileanadumitrescu95 <at> gmail.com> wrote:

> On 25/04/2025 21:53, Mike Krinkin wrote:
> > Hi There,
>
> Hi Mike,
>
> Thank you for your bug report!
>
> > I hit a weird behaviour when build colm as part of building Envoy proxy.
> > Cutting through layers of the stack on top of the libtool things here is
> > what things boil down to:
> >
> > 1. we have a project using autogen/configure/libtool that was configured
> > with `--enable-static` and `--disable-shared`
> > 2. when I run make on the project one of the linking steps failed with
> > the following error:
> >
> > ```
> > ld.lld: error: attempted static link of dynamic object
> /usr/lib/libstdc++.so
> > ```
> >
> > There is a lot there, but two things that I believe are particularly
> > relevant are: `--static` and `-lstdc++` flags.
> > I believe that libtool next translated it into an actual command to link
> > the binary and from the logs here is what I saw:
> >
> > It's pretty close to what we asked libtool to do with a few differences:
> > it does not have -lstdc++ flag and instead passes /usr/lib/libstdc++.so
> > along with other object files as input to the linker which obviously
> > does not work.
> >
> > My understanding is that libtool looked at -lstdc++ flag, found a
> > corresponding libstdc++.la file and "resolved" it into a shared library.
> >
> > What I'm baffled by in this case is why did libtool resolve it to a
> > shared library instead of a static one, even though it's clearly a
> > static build?
> > Moreover, even if we wanted to link against the dynamic library, it
> > should be done via -l flag, so what libtool looks very weird - we can't
> > just link shared library as if it was a object file or a static library.
> > Am I missing something or libtool is completely off the mark here and
> > trying to do something weird?
>
> This issue is similar in some ways to a couple of bugs that have been
> reported recently [1] [2]. Since you are using clang, '-static-libstc++'
> is not available, so I think you would need to utilize other libtool
> flags, either '-static-libtool-libs' or '-all-static'. Here [3] is the
> section of the manual that explains them, and it would likely require
> editing your Makefile.am to pass them to libtool.
>
> If updating your project configuration fixes this, I will close the bug.
> Otherwise I will start reviewing the code for a way to fix this
> behaviour.
>
> [1] https://savannah.gnu.org/support/?111184
> [2] https://savannah.gnu.org/support/?111202
> [3] https://www.gnu.org/software/libtool/manual/html_node/Link-mode.html
>
> --
> Ileana Dumitrescu
>
> GPG Public Key: FA26 CA78 4BE1 8892 7F22 B99F 6570 EA01 146F 7354
>
>
[Message part 2 (text/html, inline)]

This bug report was last modified 52 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.