Subject: Multiple bugs related to -no-undefined and -nostdlib

From: Andy Lutomirski <[email-masked]>
Date: Fri, 18 Oct 2013 10:02:15 -0700

Hi-

I recently played with the build system for capnproto
(http://kentonv.github.io/capnproto/), and I think I found at least
three bugs in libtool:

1. -no-undefined is completely broken on Linux (and probably almost
every other non-Windows system).  It should pass -Wl,--no-undefined to
gcc for the link stage when building shared libraries.  It doesn't.
(This appears to be 100% consistent and reproducible.)

When I sent in a patch to work around that (by adding
-Wl,--no-undefined explicitly), other things broke.  So far, I've
discovered:

2. When building a c++ shared library with -pthread, g++ gets called
with -nostdlib [1], and libtool forgets to add -lpthread.  This can be
reproduced on Fedora 19 if you build this and remove the -lpthread
addition:

https://github.com/kentonv/capnproto/commit/798ff87b1b7e0a2da96355a34fa6e0aa10aaae85

3. There are reports of -nostdlib getting used without -lc on Solaris.
 This also breaks if --no-undefined is fixed.

[1] I cannot fathom why libtool thinks that -nostdlib is a good idea,
but I have no intention of adding to that argument.  This bug is about
that fact that -nostdlib is used incorrectly.  It could be fixed
either by removing it or by adding the missing libraries that are
supposed to be implied.

--Andy

-- 
Andy Lutomirski
AMA Capital Management, LLC