This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: -shared-libgcc vs. -static -static-libgcc
- From: Alexandre Oliva <aoliva at redhat dot com>
- To: Benjamin Kosnik <bkoz at redhat dot com>, gcc at gcc dot gnu dot org
- Cc: gcc-patches at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org, java-patches at gcc dot gnu dot org
- Date: 28 Feb 2002 01:11:17 -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>
- Rsent-to: libstdc++@gcc.gnu.org, gcc@gcc.gnu.org
On Feb 27, 2002, Benjamin Kosnik <bkoz@redhat.com> wrote:
>> 1) rework init_gcc_specs() again such that -static-libgcc overrides
>> -shared-libgcc in the absence of -shared, just like it does in the
>> presence of -shared
>>
>> 2) rework init_gcc_specs() such that -static alone overrides
>> -shared-libgcc, regardless of -shared
>>
>> 3) arrange for CXX to not be passed with -shared-libgcc to
>> libstdc++-v3 and libgcj, and get -shared-libgcc into CXX only for
>> libtool -shared configuration and shared-library creation.
> Perhaps I'm missing something, but I would think that passing
> -shared-libgcc down as part of CXXFLAGS instead of part of CXX is also a
> possibility.
There's little point in cluttering the top-level configure.in with
such an internal detail of libstdc++-v3 and libjava. I should have
realized this upfront. While at that, I went ahead and removed the
assumption that libjava depends on libstdc++-v3 from libstdcxx_flags,
as I suggested in another thread.
>> I'll look into implementing all of the above, even though any one of
>> them would suffice. But I think having the 3 of them would make it
>> more consistent. Any disagreement?
> I think that would be wonderful.
Ok, here's what I've come up with. Tested on athlon-pc-linux-gnu,
both with and without a recent ld. libstdc++-v3 and libjava built
correctly (i.e., were linked with libgcc_s), and libjava binaries no
longer depend directly on libgcc_s, as intended. I have verified that
we get correct semantics when using -static and -static-libgcc with
and without -shared.
As co-maintainer of configury stuff, I could have checked in most of
this in, and the problem would be solved, but I thought I'd check it
in as a unit, which means I have to wait for approval for the change
in gcc.c. Ok to install?
Index: ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* configure.in (libstdcxx_flags): Don't add libstdc++-v3 flags for
libjava.
(CXX_FOR_TARGET): Don't add -shared-libgcc.
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: libstdc++-v3/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* configure.in (CXXFLAGS): Add -shared-libgcc only while
configuring libtool.
* src/Makefile.am (CXXLINK): Add -shared-libgcc.
* configure, src/Makefile.in: Rebuilt.
Index: libjava/ChangeLog
from Alexandre Oliva <aoliva@redhat.com>
* configure.in (CXXFLAGS): Add -shared-libgcc only while
configuring libtool.
* Makefile.am (LIBLINK): Add -shared-libgcc.
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/02/28 03:11:34
@@ -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,7 +1531,7 @@ fi
if test "x${CXX_FOR_TARGET+set}" = xset; then
:
elif test -d ${topsrcdir}/gcc; then
- CXX_FOR_TARGET='$$r/gcc/`case $$dir in libstdc++-v3 | libjava) echo xgcc -shared-libgcc ;; *) echo g++ ;; esac` -B$$r/gcc/ -nostdinc++ '$libstdcxx_flags
+ CXX_FOR_TARGET='$$r/gcc/`case $$dir in libstdc++-v3 | libjava) echo xgcc ;; *) echo g++ ;; esac` -B$$r/gcc/ -nostdinc++ '$libstdcxx_flags
elif test "$host" = "$target"; then
CXX_FOR_TARGET='$(CXX)'
else
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/02/28 03:11:38
@@ -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);
Index: libstdc++-v3/configure.in
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/configure.in,v
retrieving revision 1.83
diff -u -p -r1.83 configure.in
--- libstdc++-v3/configure.in 2002/02/22 11:36:08 1.83
+++ libstdc++-v3/configure.in 2002/02/28 03:11:38
@@ -29,7 +29,17 @@ AM_CONFIG_HEADER(config.h)
GLIBCPP_CONFIGURE(.)
AC_LIBTOOL_DLOPEN
+
+# Make sure libtool runs the auto-detection of GCC flags using
+# -shared-libgcc, such that we always get libstdc++-v3 linked using this
+# flag.
+ltsave_CXXFLAGS=$CXXFLAGS
+CXXFLAGS=$CXXFLAGS\ -shared-libgcc
+
AM_PROG_LIBTOOL
+
+CXXFLAGS=$ltsave_CXXFLAGS
+
AC_SUBST(enable_shared)
AC_SUBST(enable_static)
Index: libstdc++-v3/src/Makefile.am
===================================================================
RCS file: /cvs/gcc/egcs/libstdc++-v3/src/Makefile.am,v
retrieving revision 1.103
diff -u -p -r1.103 Makefile.am
--- libstdc++-v3/src/Makefile.am 2002/02/14 18:24:12 1.103
+++ libstdc++-v3/src/Makefile.am 2002/02/28 03:11:38
@@ -145,5 +145,5 @@ LTCXXCOMPILE = $(LIBTOOL) --tag CXX --mo
# course is problematic at this point. So, we get the top-level
# directory to configure libstdc++-v3 to use gcc as the C++
# compilation driver.
-CXXLINK = $(LIBTOOL) --tag CXX --mode=link $(CXX) \
+CXXLINK = $(LIBTOOL) --tag CXX --mode=link $(CXX) -shared-libgcc \
@OPT_LDFLAGS@ @SECTION_LDFLAGS@ $(AM_CXXFLAGS) $(LDFLAGS) -o $@
Index: libjava/configure.in
===================================================================
RCS file: /cvs/gcc/egcs/libjava/configure.in,v
retrieving revision 1.115
diff -u -p -r1.115 configure.in
--- libjava/configure.in 2002/02/27 05:32:13 1.115
+++ libjava/configure.in 2002/02/28 03:11:39
@@ -29,7 +29,17 @@ fi
AC_SUBST(INCLTDL)
AC_SUBST(LIBLTDL)
AC_SUBST(DIRLTDL)
+
+# Make sure libtool runs the auto-detection of GCC flags using
+# -shared-libgcc, such that we always get libstdc++-v3 linked using this
+# flag.
+ltsave_CXXFLAGS=$CXXFLAGS
+CXXFLAGS=$CXXFLAGS\ -shared-libgcc
+
AM_PROG_LIBTOOL
+
+CXXFLAGS=$ltsave_CXXFLAGS
+
AC_CONFIG_SUBDIRS($DIRLTDL)
if test -z "$with_target_subdir" || test "$with_target_subdir" = "."; then
Index: libjava/Makefile.am
===================================================================
RCS file: /cvs/gcc/egcs/libjava/Makefile.am,v
retrieving revision 1.202
diff -u -p -r1.202 Makefile.am
--- libjava/Makefile.am 2002/02/25 09:58:12 1.202
+++ libjava/Makefile.am 2002/02/28 03:11:40
@@ -71,7 +71,7 @@ GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8
GCJCOMPILE = $(LIBTOOL) --tag=GCJ --mode=compile $(GCJ_WITH_FLAGS) -fCLASSPATH=$(here) $(JC1FLAGS) -MD -MT $@ -MF $(@:.lo=.d) -c
GCJLINK = $(LIBTOOL) --tag=GCJ --mode=link $(GCJ) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
-LIBLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXX) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
+LIBLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXX) -shared-libgcc -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
## We define this because otherwise libtool can be run with different
## values of `CXX' and will then get confused and fail to work. So,
--
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