This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[libgfortran, libitm] Link with -shared-libgcc
- From: Rainer Orth <ro at CeBiTec dot Uni-Bielefeld dot DE>
- To: gcc-patches at gcc dot gnu dot org
- Cc: fortran at gcc dot gnu dot org, Richard Henderson <rth at redhat dot com>
- Date: Mon, 19 Dec 2011 17:15:00 +0100
- Subject: [libgfortran, libitm] Link with -shared-libgcc
I've just noticed that the superfluous references to
__gcc_personality_v0 aren't created any longer and thus my hack
http://gcc.gnu.org/ml/gcc-patches/2011-11/msg02113.html
isn't needed anymore. When I tried a gas/gld bootstrap on Solaris
11/x86, I still ran into a considerable number of testsuite failures,
though: all libgomp.fortran and 32-bit libitm link tests fail:
/vol/gcc/bin/gld-2.22: ./allocatable1.exe: hidden symbol `_Unwind_Backtrace' in /var/gcc/gcc-4.7.0-20111216/11-gcc-gas-gld/gcc/libgcc_eh.a(unwind-dw2.o) is referenced by DSO
/vol/gcc/bin/gld-2.22: final link failed: Bad value
Indeed, libgfortran.so contains unresolved references to libgcc_s.so
functions:
$ ldd -r libgfortran.so
libquadmath.so.0 => /var/gcc/gcc-4.7.0-20111216/11-gcc-gas-gld/i386-pc-solaris2.11/libquadmath/.libs/libquadmath.so.0
libm.so.2 => /lib/libm.so.2
libc.so.1 => /lib/libc.so.1
symbol not found: _Unwind_Backtrace (./libgfortran.so)
symbol not found: _Unwind_GetIPInfo (./libgfortran.so)
thus needs to be linked with -shared-libgcc. I don't see this with Sun
ld, where -shared implies -shared-libgcc.
The problem isn't observed with the gfortran.* tests since those are
linked with gfortran, which defaults shared_libgcc to 1.
The 32-bit libitm.so suffers from a similar problem:
$ ldd -r ../.libs/libitm.so
libpthread.so.1 => /lib/libpthread.so.1
libc.so.1 => /lib/libc.so.1
symbol not found: _Unwind_DeleteException (../.libs/libitm.so)
libm.so.2 => /lib/libm.so.2
This doesn't occur for 64-bit libitm since the 64-bit Solaris 11 libc
contains the amd64 unwinder.
The patch below fixes both issues and let the i386-pc-solaris2.11
bootstrap complete without unexpected failures.
Ok for mainline?
Rainer
2011-12-18 Rainer Orth <ro@CeBiTec.Uni-Bielefeld.DE>
libitm:
* Makefile.am (libitm_la_LDFLAGS): Add -Wc,-shared-libgcc.
* Makefile.in: Regenerate.
libgfortran:
* Makefile.am (libgfortran_la_LDFLAGS): Add -Wc,-shared-libgcc.
* Makefile.in: Regenerate.
# HG changeset patch
# Parent 6ed25d2abd3e62ff79829913c0399af94d0a6c64
Link with -shared-libgcc
diff --git a/libgfortran/Makefile.am b/libgfortran/Makefile.am
--- a/libgfortran/Makefile.am
+++ b/libgfortran/Makefile.am
@@ -36,7 +36,9 @@ LTLDFLAGS = $(shell $(SHELL) $(top_srcdi
toolexeclib_LTLIBRARIES = libgfortran.la
toolexeclib_DATA = libgfortran.spec
libgfortran_la_LINK = $(LINK) $(libgfortran_la_LDFLAGS)
-libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` $(LTLDFLAGS) $(LIBQUADLIB) -lm $(extra_ldflags_libgfortran) $(version_arg)
+libgfortran_la_LDFLAGS = -version-info `grep -v '^\#' $(srcdir)/libtool-version` \
+ $(LTLDFLAGS) $(LIBQUADLIB) -lm $(extra_ldflags_libgfortran) \
+ $(version_arg) -Wc,-shared-libgcc
libgfortran_la_DEPENDENCIES = $(version_dep) libgfortran.spec $(LIBQUADLIB_DEP)
myexeclib_LTLIBRARIES = libgfortranbegin.la
diff --git a/libitm/Makefile.am b/libitm/Makefile.am
--- a/libitm/Makefile.am
+++ b/libitm/Makefile.am
@@ -54,7 +54,8 @@ libitm_version_info = -version-info $(li
# want or need libstdc++.
libitm_la_DEPENDENCIES = $(libitm_version_dep)
libitm_la_LINK = $(LINK) $(libitm_la_LDFLAGS)
-libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script)
+libitm_la_LDFLAGS = $(libitm_version_info) $(libitm_version_script) \
+ -Wc,-shared-libgcc
libitm_la_SOURCES = \
aatree.cc alloc.cc alloc_c.cc alloc_cpp.cc barrier.cc beginend.cc \
--
-----------------------------------------------------------------------------
Rainer Orth, Center for Biotechnology, Bielefeld University