GNU bug report logs - #11064
CRITICAL: libtool makes static linking impossible

Previous Next

Package: libtool;

Reported by: bugdal <at> aerifal.cx

Date: Thu, 22 Mar 2012 06:45:02 UTC

Severity: normal

Full log


View this message in rfc822 format

From: Peter O'Gorman <peter <at> pogma.com>
To: Rich Felker <dalias <at> aerifal.cx>, 11064 <at> debbugs.gnu.org
Subject: bug#11064: CRITICAL: libtool makes static linking impossible
Date: Thu, 22 Mar 2012 16:18:52 -0500
Hi,

[added back the bug email to track this]

On 03/22/2012 11:06 AM, Rich Felker wrote:
> On Thu, Mar 22, 2012 at 10:45:06AM -0500, Peter O'Gorman wrote:
>>
>> does:
>> ../configure CC='gcc -static' CXX='g++ -static' ...
>>
>> work around this for you?
>>
>> I think the -static, -all-static etc libtool flags were meant for
>> Makefiles, not really for user LDFLAGS.
>
> No, it does not. My situation is trying to compile static-linked GNU
> binutils. I tried putting -static in CC (like you suggested), CFLAGS,
> and LDFLAGS. Each time, it appeared on the libtool command line and
> disappeared on the second command line where libtool invoked gcc.

Ok, yes, that's annoying. This workaround just worked for me:

./configure CFLAGS='-static' LDFLAGS='-Xcompiler -static'
make

But my gcc does not error for the unrecognized option during configure, 
it's possible that newer gccs will. That binutils runs configure in 
subdirs during the build makes it even more annoying to work around. If 
your gcc errors out with the -Xcompiler flag, you'll have to make a 
wrapper script for the compiler (one that takes a flag that libtool 
doesn't remove from the link line). Ick.

>
> I also tried -Wl,-Bstatic and that failed because gcc was unaware of
> the static option and passed -lgcc_s to the linker instead of
> -lgcc_eh.

You could have tried -static-libgcc, but ...

>
> The fundamental problem is that libtool has commandeered a command
> line option that's meant for user LDFLAGS (to request a static binary)
> and redefined it to mean "I only want project-internal libraries to be
> linked statically, but I still want my binary dynamic-linked to system
> libraries." And in the process, it's made it completely impossible to
> build static binaries.

I agree this is a problem, will go looking for the history of the 
-static libtool flag and see what we can do.

Peter





This bug report was last modified 13 years and 138 days ago.

Previous Next


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