This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: -shared-libgcc vs. -static -static-libgcc
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Richard Henderson <rth at redhat dot com>
- Cc: Benjamin Kosnik <bkoz at redhat dot com>, gcc dot gnu dot org at redhat dot lsd dot ic dot unicamp dot br, gcc-patches at gcc dot gnu dot org, libstdc++-v3 at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: 28 Feb 2002 21:49:21 -0300
- Subject: Re: -shared-libgcc vs. -static -static-libgcc
- Organization: GCC Team, Red Hat
- References: <Pine.SOL.3.91.1020227171642.15292A-100000@taarna.cygnus.com><orr8n6b5zu.fsf@free.redhat.lsd.ic.unicamp.br><20020228101644.B30279@redhat.com>
On Feb 28, 2002, Richard Henderson <rth@redhat.com> wrote:
> On Thu, Feb 28, 2002 at 01:11:17AM -0300, Alexandre Oliva wrote:
>> and libjava binaries no longer depend directly on libgcc_s, as intended.
> Err, no. If a java binary throws or catches exceptions,
> and given the style of use of exceptions in java this is
> exceedingly likely, then the binary should link against
> libgcc_s so that it acquires the proper symbol versions.
Yeah. I wish I had made that note when I first made the change....
Well, here's a revised patch that does not touch libstdc++-v3 nor
libjava (but that fixes the libstdc++-v3 -static problem because of
the change in gcc.c), and adds the note where it should have been put
in the first place. I'm checking this in mainline and 3.1 branch.
Index: ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* configure.in (libstdcxx_flags): Don't add libstdc++-v3 flags for
libjava.
(CXX_FOR_TARGET): Explain why -shared-libgcc here.
Index: configure.in
===================================================================
RCS file: /cvs/gcc/egcs/configure.in,v
retrieving revision 1.119
diff -u -p -r1.119 configure.in
--- configure.in 2002/02/22 03:21:02 1.119
+++ configure.in 2002/03/01 00:46:26
@@ -50,7 +50,7 @@ fi
libstdcxx_version="target-libstdc++-v3"
# Don't use libstdc++-v3's flags to configure/build itself.
-libstdcxx_flags='`case $$dir in libstdc++-v3) ;; *) test ! -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/testsuite_flags || $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/testsuite_flags --build-includes;; esac` -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs'
+libstdcxx_flags='`case $$dir in libstdc++-v3 | libjava) ;; *) test ! -f $$r/$(TARGET_SUBDIR)/libstdc++-v3/testsuite_flags || $(SHELL) $$r/$(TARGET_SUBDIR)/libstdc++-v3/testsuite_flags --build-includes;; esac` -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src -L$$r/$(TARGET_SUBDIR)/libstdc++-v3/src/.libs'
# these tools are built for the host environment
# Note, the powerpc-eabi build depends on sim occurring before gdb in order to
@@ -1548,6 +1548,9 @@ fi
if test "x${CXX_FOR_TARGET+set}" = xset; then
:
elif test -d ${topsrcdir}/gcc; then
+ # We add -shared-libgcc to CXX_FOR_TARGET whenever we use xgcc instead
+ # of g++ for linking C++ or Java, because g++ has -shared-libgcc by
+ # default whereas gcc does not.
CXX_FOR_TARGET='$$r/gcc/`case $$dir in libstdc++-v3 | libjava) echo xgcc -shared-libgcc ;; *) echo g++ ;; esac` -B$$r/gcc/ -nostdinc++ '$libstdcxx_flags
elif test "$host" = "$target"; then
CXX_FOR_TARGET='$(CXX)'
Index: gcc/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* gcc.c (init_gcc_specs): Get -static and -static-libgcc to
override -shared and -shared-libgcc.
Index: gcc/gcc.c
===================================================================
RCS file: /cvs/gcc/egcs/gcc/gcc.c,v
retrieving revision 1.297
diff -u -p -r1.297 gcc.c
--- gcc/gcc.c 2002/02/27 18:47:12 1.297
+++ gcc/gcc.c 2002/03/01 00:46:35
@@ -1414,18 +1414,18 @@ init_gcc_specs (obstack, shared_name, st
{
char *buf;
- buf = concat ("%{!shared:%{!shared-libgcc:", static_name, " ",
+ buf = concat ("%{static|static-libgcc:", static_name, " ", eh_name,
+ "}%{!static:%{!static-libgcc:",
+ "%{!shared:%{!shared-libgcc:", static_name, " ",
eh_name, "}%{shared-libgcc:", shared_name, " ",
- static_name, "}}",
- "%{shared:%{static-libgcc:", static_name, " ",
- eh_name, "}%{!static-libgcc:",
+ static_name, "}}%{shared:",
#ifdef LINK_EH_SPEC
"%{shared-libgcc:", shared_name,
"}%{!shared-libgcc:", static_name, "}",
#else
shared_name,
#endif
- "}}", NULL);
+ "}}}", NULL);
obstack_grow (obstack, buf, strlen (buf));
free (buf);
--
Alexandre Oliva Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist Professional serial bug killer