[PATCH] x86_64-pc-solaris2.* GNU ld breakage due to _sol2 emulation detection

2012-07-26 Thread Fabian Groffen
Hi,

Since commit [1] libtool tries to set a 64-bits target for GNU ld.
However, it does so wrongly for x86_64-pc-solaris2.* targets, causing
libtool to believe the linker is called ld_sol2.  There is no such
thing, and it obviously breaks things further down.
Some people wrongly assume there is supposed to be an ld_sol2 on their
systems, e.g. [2].

I think the original change is fragile, because it assumes it has all
CHOSTs matched, then appends _sol2.  In the wild, people have used
amd64-pc-solaris2* too, so perhaps it would be safer if the code only
appended _sol2 if there is actually an explicit target set.

Anyhow, since the 64-bits sparc target is called sparc64-* or sparcv9-*,
the sparc case is already correctly handled, so in the attached patch, I
just added an x86_64-* case, although I could imagine relaxing the i?86
case to *86*-pc-solaris2* too.

In any case, defaulting to a linker called ld_sol2 is wrong.

Regards,
Fabian


[1] http://lists.gnu.org/archive/html/libtool-commit/2011-02/msg0.html
[2] http://osdyson.org/issues/8

-- 
Fabian Groffen
Gentoo on a different level
Unbreak x86_64-pc-solaris2.1[01], it IS 64-bits too.  Without this,
libtool thinks the linker is called ld_sol2.

--- libltdl/m4/libtool.m4
+++ libltdl/m4/libtool.m4
@@ -1383,7 +1383,7 @@
   case $lt_cv_prog_gnu_ld in
   yes*)
 case $host in
-i?86-*-solaris*)
+i?86-*-solaris*|x86_64-*-solaris*)
   LD="${LD-ld} -m elf_x86_64"
   ;;
 sparc*-*-solaris*)


signature.asc
Description: Digital signature


[PATCH] disable de-duplication of postdeps on Solaris

2012-07-26 Thread Fabian Groffen
Hi,

I tracked down an issue on Solaris/OpenSolaris/OpenIndiana where C++
libraries built by libtool would cause abort/traps when an exception was
being thrown.

The underlying cause is that the C-library was linked before libgcc,
leading to the C-library generating the abort before libgcc could do
what it was supposed to do.

I only observed this problem on x86-based Solaris, not on Sparc.  The
reason for this follows from what GCC does to link an object.  It
specifies by default -lgcc -lc -lgcc, however on Sparc systems
(unrelated to Solaris) it adds another -lc because libgcc might need the
C-library in turn. [1]

Libtool apparently figures out what libs to link to by watching what the
compiler does.  It applies duplicate elimination on the result of that
(don't know why) causing -lgcc_s -lc -lgcc_s to be turned into -lc
-lgcc_s.  As result, the library aborts on Solaris when it throws an
exception because -lc comes before -lgcc_s.  On Sparc, the result is
-lgcc_s -lc, probably because both were double.

I'm not sure this can be properly fixed by making sure -lgcc_s -lc
remains, since GCC purposely emits the same library multiple times, so I
decided to just disable the duplicate elimination for Solaris.


[1] http://gcc.gnu.org/ml/gcc-patches/2002-04/msg00176.html

-- 
Fabian Groffen
Gentoo on a different level
On Solaris, catch code for C++ exceptions is in libgcc_s.  The libc has
default catch code as well, that does an abort.  GCC by default emits on
purpose -lgcc_s -lc -lgcc_s.  libtool's de-duplication magic turns this
into -lc -lgcc_s, which unsurprisingly is the wrong order, since
exceptions will be seen by libc first.  Disable de-duplication for this
reason, such that we can have working C++ libtool built libraries.

--- libltdl/config/ltmain.m4sh
+++ libltdl/config/ltmain.m4sh
@@ -398,7 +398,7 @@
   test "$opt_debug" = : || func_append preserve_args " --debug"
 
   case $host in
-*cygwin* | *mingw* | *pw32* | *cegcc*)
+*cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2*)
   # don't eliminate duplications in $postdeps and $predeps
   opt_duplicate_compiler_generated_deps=:
   ;;
--- libltdl/config/ltmain.sh
+++ libltdl/config/ltmain.sh
@@ -1180,7 +1180,7 @@
   test "$opt_debug" = : || func_append preserve_args " --debug"
 
   case $host in
-*cygwin* | *mingw* | *pw32* | *cegcc*)
+*cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2*)
   # don't eliminate duplications in $postdeps and $predeps
   opt_duplicate_compiler_generated_deps=:
   ;;


signature.asc
Description: Digital signature


Re: [PATCH] disable de-duplication of postdeps on Solaris

2012-07-26 Thread Bob Friesenhahn

On Thu, 26 Jul 2012, Fabian Groffen wrote:


Hi,

I tracked down an issue on Solaris/OpenSolaris/OpenIndiana where C++
libraries built by libtool would cause abort/traps when an exception was
being thrown.


This issue has been causing problems for my C++ library for many 
years.  There is even a libtool test case to replicate it.  However, 
it seems that you may have found the cause and the solution for it (I 
have not tested to verify).


This used to be an issue for x86-64 FreeBSD.  I have also observed it 
with some MinGW installations.


Bob
--
Bob Friesenhahn
bfrie...@simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer,http://www.GraphicsMagick.org/