glibc 2.2.4pre2

Andreas Jaeger aj@suse.de
Thu Aug 9 01:26:00 GMT 2001


Jakub, your patch to crtstuff.c was broken.  You didn't include
"auto-host.h" and therefore HAVE_GAS_HIDDEN was never defined.  Also
__cxa_finalize was not run at all.

I've fixed your patch and generated a new version.  It passed make
check in glibc (current CVS version) on i686-linux including the
tstcxaatexit test.

Bernd, can you add this to 2.95.x, please?

Andreas

--- gcc-2.95.x/gcc/config/alpha/crtbegin.asm.jj     Wed Dec 16 22:00:53 1998
+++ gcc-2.95.x/gcc/config/alpha/crtbegin.asm        Wed Jun 13 12:41:28 2001
@@ -97,6 +97,31 @@ __EH_FRAME_BEGIN__:
  # Support recursive calls to exit.
 $ptr:  .quad   __DTOR_LIST__

+/* A globally unique widget for c++ local destructors to hang off.
+
+   This has a unique value in every dso; in the main program its
+   value is zero.  The object should be protected.  This means the
+   instance in any dso or the main program is not used in any other
+   dso.  The dynamic linker takes care of this.  */
+
+       .global __dso_handle
+       .type __dso_handle,@object
+       .size __dso_handle,8
+#ifdef SHARED
+.section .data
+       .align 3
+__dso_handle:
+       .quad   __dso_handle
+#else
+.section .bss
+       .align 3
+__dso_handle:
+       .zero 8
+#endif
+#ifdef HAVE_GAS_HIDDEN
+       .hidden __dso_handle
+#endif
+
 .text

        .align 3
============================================================
Index: gcc/crtstuff.c
--- gcc-2.95.x/gcc/crtstuff.c	2001/04/03 10:34:32	1.18.4.1
+++ gcc-2.95.x/gcc/crtstuff.c	2001/08/09 06:56:33
@@ -55,6 +55,7 @@ Boston, MA 02111-1307, USA.  */
 #include "defaults.h"
 #include <stddef.h>
 #include "frame.h"
+#include "auto-host.h"
 
 /* We do not want to add the weak attribute to the declarations of these
    routines in frame.h because that will cause the definition of these
@@ -134,7 +135,29 @@ typedef void (*func_ptr) (void);
 #ifdef INIT_SECTION_ASM_OP
 
 #ifdef OBJECT_FORMAT_ELF
+/* Declare the __dso_handle variable.  It should have a unique value
+   in every shared-object; in a main program its value is zero.  The
+   object should in any case be protected.  This means the instance
+   in one DSO or the main program is not used in another object.  The
+   dynamic linker takes care of this.  */
+
+/* XXX Ideally the following should be implemented using
+   __attribute__ ((__visibility__ ("hidden")))
+   but the __attribute__ support is not yet there.  */
+#ifdef HAVE_GAS_HIDDEN
+asm (".hidden\t__dso_handle");
+#endif
+
+#ifdef CRTSTUFFS_O
+void *__dso_handle = &__dso_handle;
+#else
+void *__dso_handle = 0;
+#endif
 
+/* The __cxa_finalize function may not be available so we use only a
+   weak declaration.  */
+extern void __cxa_finalize (void *) TARGET_ATTRIBUTE_WEAK;
+
 /* Run all the global destructors on exit from the program.  */
  
 /* Some systems place the number of pointers in the first word of the
@@ -164,6 +187,11 @@ __do_global_dtors_aux (void)
 
   if (completed)
     return;
+
+#ifdef CRTSTUFFS_O
+  if (__cxa_finalize)
+    __cxa_finalize (__dso_handle);
+#endif
 
   while (*p)
     {
--- gcc-2.95.x/gcc/configure.in.jj  Wed Oct 13 09:58:02 1999
+++ gcc-2.95.x/gcc/configure.in     Wed Jun 13 12:44:34 2001
@@ -4053,6 +4053,21 @@ EOF
 fi
 AC_MSG_RESULT($gcc_cv_as_subsections)

+AC_MSG_CHECKING(assembler hidden support)
+gcc_cv_as_hidden=
+if test x$gcc_cv_as != x; then
+       # Check if we have .hidden
+       echo "  .hidden foobar" > conftest.s
+       echo "foobar:" >> conftest.s
+       if $gcc_cv_as -o conftest.o conftest.s > /dev/null 2>&1; then
+               AC_DEFINE(HAVE_GAS_HIDDEN, 1,
+                       [Define if your assembler supports .hidden.])
+               gcc_cv_as_hidden="yes"
+       fi
+       rm -f conftest.s conftest.o conftest.nm1 conftest.nm2
+fi
+AC_MSG_RESULT($gcc_cv_as_hidden)
+
 AC_MSG_CHECKING(assembler instructions)
 gcc_cv_as_instructions=
 if test x$gcc_cv_as != x; then
--- gcc-2.95.x/gcc/config.in.jj     Mon Oct 25 10:02:08 1999
+++ gcc-2.95.x/gcc/config.in        Wed Jun 13 12:45:56 2001
2 the beginning of your section */
 #undef HAVE_GAS_SUBSECTION_ORDERING

+/* Define if your assembler supports .hidden. */
+#undef HAVE_GAS_HIDDEN
+
 /* Define if your assembler uses the old HImode fild and fist notation.  */
 #undef HAVE_GAS_FILDS_FISTS



-- 
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE7ckkVOJpWPMJyoSYRAk//AJ4z7cjDCYOThG9gHh3e3dcKtdj7JQCfXvQh
8Szhp0L8mp0a0h1u9EKYXm8=
=xy9U
-----END PGP SIGNATURE-----From jakub@redhat.com Thu Aug 09 01:45:00 2001
From: Jakub Jelinek <jakub@redhat.com>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Use move-if-change in libstdc++-v3
Date: Thu, 09 Aug 2001 01:45:00 -0000
Message-id: <20010809044507.M3862@devserv.devel.redhat.com>
X-SW-Source: 2001-08/msg00463.html
Content-length: 3779

Hi!

mknumeric_limits does not use move-if-change, which has the bad effect that
libstdc++-v3 is recompiled uselessly again and again if mknumeric_limit is
for some reason run again.
I experienced this e.g. when building gcc3 rpm: we first do make bootstrap,
then make install with different prefix= so that it gets installed into a
separate subtree. limitsNUMERIC.cc was newer because mknumeric_limits was
run during during make install, which caused libstdc++ to be linked again,
thus libjava be linked again (and for libjava it caused make install to
fail, since libtool was not too happy to see libgcj.la linked to the new
prefixed path and compiled during --mode=relink.
Ok to commit?

2001-08-09  Jakub Jelinek  <jakub@redhat.com>

	* include/Makefile.am (std_limits.h): Use move-if-change.
	* include/Makefile.in: Rebuilt.
	* move-if-change: New.
	* mknumeric_limits: Use move-if-change.

--- libstdc++-v3/include/Makefile.am.jj	Thu Jul 26 09:52:20 2001
+++ libstdc++-v3/include/Makefile.am	Wed Aug  8 17:09:58 2001
@@ -399,7 +399,8 @@ ${target_builddir}/std_limits.h: ${targe
 	CC="$(CC) -I${glibcpp_builddir} -I${target_builddir}/.." \
 	${glibcpp_srcdir}/mknumeric_limits \
 	${glibcpp_builddir} ${glibcpp_srcdir} @GLIBCPP_IS_CROSS_COMPILING@ ;\
-	mv ${glibcpp_builddir}/include/bits/std_limits.h ${target_builddir}
+	$(SHELL) $(glibcpp_srcdir}/move-if-change \
+	  ${glibcpp_builddir}/include/bits/std_limits.h ${target_builddir}/std_limits.h
 
 glibcpp_thread_h = @glibcpp_thread_h@
 uppercase = [ABCDEFGHIJKLMNOPQRSTUVWXYZ_]
--- libstdc++-v3/include/Makefile.in.jj	Thu Jul 26 09:52:20 2001
+++ libstdc++-v3/include/Makefile.in	Wed Aug  8 17:10:42 2001
@@ -591,7 +591,8 @@ ${target_builddir}/std_limits.h: ${targe
 	CC="$(CC) -I${glibcpp_builddir} -I${target_builddir}/.." \
 	${glibcpp_srcdir}/mknumeric_limits \
 	${glibcpp_builddir} ${glibcpp_srcdir} @GLIBCPP_IS_CROSS_COMPILING@ ;\
-	mv ${glibcpp_builddir}/include/bits/std_limits.h ${target_builddir}
+	$(SHELL) ${glibcpp_srcdir}/move-if-change \
+	  ${glibcpp_builddir}/include/bits/std_limits.h ${target_builddir}/std_limits.h
 
 ${thread_builddir}/gthr.h:
 	sed -e '/^#/s/\(${uppercase}${uppercase}*\)/_GLIBCPP_\1/g' \
--- libstdc++-v3/move-if-change.jj	Wed Aug  8 17:02:21 2001
+++ libstdc++-v3/move-if-change	Wed Dec 16 21:57:26 1998
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Like mv $1 $2, but if the files are the same, just delete $1.
+# Status is 0 if $2 is changed, 1 otherwise.
+if
+test -r $2
+then
+if
+cmp -s $1 $2
+then
+echo $2 is unchanged
+rm -f $1
+else
+mv -f $1 $2
+fi
+else
+mv -f $1 $2
+fi
--- libstdc++-v3/mknumeric_limits.jj	Tue Aug  7 11:21:35 2001
+++ libstdc++-v3/mknumeric_limits	Wed Aug  8 17:12:46 2001
@@ -29,9 +29,7 @@ fi
 OUT_H="$BUILD_DIR/include/bits/std_limits.h"
 OUT_C="$BUILD_DIR/src/limitsMEMBERS.cc"
 
-if [ -f $OUT_C ]; then
-    rm -f $OUT_H $OUT_C $OUT_H-t $OUT_C-t
-fi
+rm -f $OUT_H $OUT_H-t $OUT_C-t
 
 SRC_DIR=$2
 if [ ! -d "$SRC_DIR" ]; then
@@ -43,7 +41,8 @@ XCOMPILE=$3
 if [ $XCOMPILE -eq 1 ]; then
   echo "using default values for cross compiles"
   cp $SRC_DIR/include/bits/limits_generic.h $OUT_H
-  cp $SRC_DIR/src/limits_generic.cc $OUT_C
+  cp $SRC_DIR/src/limits_generic.cc $OUT_C-t
+  /bin/sh $SRC_DIR/move-if-change $OUT_C-t $OUT_C
   exit 0;
 fi   
 
@@ -172,11 +171,13 @@ echo "$CC -I$BUILD_DIR -fno-exceptions \
     -o "$BUILD_DIR/src/gen-num-limits" "$SRC_DIR/src/gen-num-limits.cc"
 } || {
   echo "gen-num-limits failed to build, exiting."
+  rm -f $OUT_C
   exit 1
 }
 
 "$BUILD_DIR/src/gen-num-limits" >> $OUT_H-t || {
   echo "gen-num-limits failed to execute, exiting."
+  rm -f $OUT_C
   exit 1
 }
 
@@ -269,5 +270,5 @@ cat <<EOF >> $OUT_C-t
 
 EOF
 
-mv $OUT_C-t $OUT_C
+/bin/sh $SRC_DIR/move-if-change $OUT_C-t $OUT_C
 mv $OUT_H-t $OUT_H

	Jakub



More information about the Gcc-patches mailing list