This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: libstdc++ libtool lossage

On Feb 21, 2002, Richard Henderson <> wrote:

> On Thu, Feb 21, 2002 at 07:51:32PM -0300, Alexandre Oliva wrote:
>> But then, perhaps -shared-libgcc is a do-nothing if no shared libgcc
>> is built already?

> It is.

Ok, so here's the patch I've come up with that addresses the problem
of libstdc++-v3 and libjava not being linked with the shared version
of libgcc.  It has the unfortunate (?) side effect that the two
programs linked in libjava, rmic and rmiregistry, are now explicitly
linked with the shared libgcc, instead of only inheriting that from
libgcj, but that's probably tolerable to avoid the major complications
I'd run into while trying to figure out how to avoid it.  I'm checking
this in.  Tested on athlon-pc-linux-gnu.

Index: ChangeLog
from  Alexandre Oliva  <>

	* (CXX_FOR_TARGET): Add -shared-libgcc for
	libstdc++-v3 and libjava.

Index: libjava/ChangeLog
from  Alexandre Oliva  <>

	* acinclude.m4 (LIB_AC_PROG_CXX): Copied from libstdc++-v3.
	Use it.
	* (LIBLINK): Use CXX (and its tag) for linking.
	* configure, Rebuilt.

RCS file: /cvs/gcc/egcs/,v
retrieving revision 1.118
diff -u -p -r1.118
--- 2002/02/09 03:00:13 1.118
+++ 2002/02/22 01:55:18
@@ -1548,7 +1548,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) echo xgcc ;; *) echo g++ ;; esac` -B$$r/gcc/ -nostdinc++ '$libstdcxx_flags
+  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
Index: libjava/
RCS file: /cvs/gcc/egcs/libjava/,v
retrieving revision 1.200
diff -u -p -r1.200
--- libjava/ 2002/02/21 10:58:12 1.200
+++ libjava/ 2002/02/22 01:55:23
@@ -71,7 +71,7 @@ GCJ_WITH_FLAGS = $(GCJ) --encoding=UTF-8
 GCJCOMPILE = $(LIBTOOL) --tag=GCJ --mode=compile $(GCJ_WITH_FLAGS) -fassume-compiled -fclasspath=$(here) -L$(here) $(JC1FLAGS) -MD -MT $@ -MF $(@:.lo=.d) -c
 GCJLINK = $(LIBTOOL) --tag=GCJ --mode=link $(GCJ) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
-LIBLINK = $(LIBTOOL) --tag=CC --mode=link $(CC) -L$(here) $(JC1FLAGS) $(LDFLAGS) -o $@
+LIBLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXX) -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,
Index: libjava/acinclude.m4
RCS file: /cvs/gcc/egcs/libjava/acinclude.m4,v
retrieving revision 1.16
diff -u -p -r1.16 acinclude.m4
--- libjava/acinclude.m4 2002/02/07 03:24:10 1.16
+++ libjava/acinclude.m4 2002/02/22 01:55:23
@@ -80,7 +80,50 @@ define([AC_PROG_CC_WORKS],[])
+# We use the libstdc++-v3 version of LIB_AC_PROG_CXX, that gets
+# glibcpp_CXX cached instead of CXX.  That's because we're passed a
+# different definition of CXX than other directories, since we don't
+# depend on libstdc++-v3 having already been built.
+dnl Fool anybody using AC_PROG_CXX.
+# Use glibcpp_CXX so that we do not cause CXX to be cached with the
+# flags that come in CXX while configuring libstdc++.  They're different
+# from those used for all other target libraries.  If CXX is set in
+# the environment, respect that here.
+AC_CHECK_PROGS(glibcpp_CXX, $CCC c++ g++ gcc CC cxx cc++, gcc)
+test -z "$glibcpp_CXX" && AC_MSG_ERROR([no acceptable c++ found in \$PATH])
+if test $ac_cv_prog_gxx = yes; then
+  GXX=yes
+dnl Check whether -g works, even if CXXFLAGS is set, in case the package
+dnl plays around with CXXFLAGS (such as to build both debugging and
+dnl normal versions of a library), tasteless as that idea is.
+  ac_test_CXXFLAGS="${CXXFLAGS+set}"
+  if test "$ac_test_CXXFLAGS" = set; then
+    CXXFLAGS="$ac_save_CXXFLAGS"
+  elif test $ac_cv_prog_cxx_g = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-O2"
+  fi
+  GXX=
+  test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
 dnl version is pulled out to make it a bit easier to change using sed.

Alexandre Oliva   Enjoy Guarana', see
Red Hat GCC Developer                  aoliva@{,}
CS PhD student at IC-Unicamp        oliva@{,}
Free Software Evangelist                Professional serial bug killer

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]