libtool
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Libtool mishandling of C++ libraries requiring -pthread


From: Bob Friesenhahn
Subject: Re: Libtool mishandling of C++ libraries requiring -pthread
Date: Wed, 1 Feb 2012 17:49:16 -0600 (CST)
User-agent: Alpine 2.01 (GSO 1266 2009-07-14)

On Wed, 1 Feb 2012, Russ Allbery wrote:

I think the primary question is why Libtool is using -nostdlib when
linking C++ libraries.  The bug discussion at:

   http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460

says that it's because of some other issue with libstdc++ linkage with
dlopened modules depending on C++ libraries, but this dates from 2005, and
breaking C++ libraries that need threading seems like a bad outcome.  Does
this problem still exist?  Can this workaround just be dropped?

My memory is fading, but I do know that libtool used to use the linker directly to perform linking, but then gradually transitioned to using the compiler for linking as much as possible. Adding -nostdlib causes the compiler to behave more like the linker, while retaining some secret nuances (e.g. things that allow C++ exceptions to work) that the compiler adds.

Libtool queries GCC to determine where its libraries reside (might not be in a system location), and the libraries and options which will be used. Unfortunately, GCC has bugs which cause it to lie about what it will do and not adjust its response based on options like -m64 and -pthread. Libtool wants to know about all the libraries which will be involved in the link since it adds such information to the .la files. If the standard C++ library is a static library, then libtool needs to know about that and postpone linking with it, or build dependent code as static, since it should not link a static library into a shared library or DLL.

The libltdl module loader does need to load the dependency libraries since the system might not do this at all, or might not do it fully or correctly. It can't do this without knowing the libraries used. This has been known to be a definite factor for C-language modules which link with C++ libraries.

If Gary is reading this, I assume that his memory would be better than mine and perhaps he can add some wisdom.

Note that the GCC maintainters closed the bug requesting -pthread still
add -lpthread even under -nostdlib as invalid.

I would have done the same.

The easiest fix is likely for libtool to know that if -pthread was specified to the compiler that it should add -lthread while linking.

Bob
--
Bob Friesenhahn
address@hidden, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,    http://www.GraphicsMagick.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]