This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: PATCH: Add --enable-__cxa_atexit
- From: "H . J . Lu" <hjl at lucon dot org>
- To: Zack Weinberg <zack at codesourcery dot com>
- Cc: Jack Howarth <howarth at nitro dot msbb dot uc dot edu>, gcc-patches at gcc dot gnu dot org
- Date: Fri, 31 May 2002 11:44:17 -0700
- Subject: Re: PATCH: Add --enable-__cxa_atexit
- References: <200205310627.CAA13821@nitro.msbb.uc.edu> <200205311604.MAA14609@nitro.msbb.uc.edu> <20020531104311.A25686@lucon.org> <20020531182118.GL16702@codesourcery.com>
On Fri, May 31, 2002 at 11:21:18AM -0700, Zack Weinberg wrote:
> On Fri, May 31, 2002 at 10:43:11AM -0700, H . J . Lu wrote:
> > +# Enable __cxa_atexit for C++.
> > +AC_ARG_ENABLE(__cxa_atexit,
> > +[ --enable-__cxa_atexit enable __cxa_atexit for C++],
> > +[], [enable___cxa_atexit=no])
> > +if test x$enable___cxa_atexit != xno; then
> > + AC_DEFINE(ENABLE_CXA_ATEXIT, 1,
> > + [Define if you want to use __cxa_atexit, rather than, atexit to
> > + register C++ destructors for local statics and global objects.])
> > +fi
>
> 1) Why is this an --enable switch rather than a tm.h #define? This is
> the major concern with the patch.
There is no way to reliably check if target's __cxa_atexit is available
and correct. Think about cross compiler. I couldn't even figure out
a clean way to check if it is available for cross compiler. I don't
want to enable it for Linux by default since it is a relatively new
feature in glibc.
>
> 2) No comma after "than".
> 3) Call the macro DEFAULT_USE_CXA_ATEXIT.
>
Here is an update.
Thanks.
H.J.
----
2002-05-31 H.J. Lu (hjl@gnu.org)
* configure.in: Add --enable-__cxa_atexit.
* configure: Regenerated.
* config.in: Likewise.
* defaults.h (DEFAULT_USE_CXA_ATEXIT): New. Defined to be 0 if
not defined.
2002-05-31 H.J. Lu (hjl@gnu.org)
* decl2.c (flag_use_cxa_atexit): Set to DEFAULT_USE_CXA_ATEXIT.
--- gcc/config.in.atexit Thu May 23 16:28:28 2002
+++ gcc/config.in Fri May 31 11:36:31 2002
@@ -296,6 +296,10 @@
every opportunity. This is extremely expensive. */
#undef ENABLE_GC_ALWAYS_COLLECT
+/* Define if you want to use __cxa_atexit, rather than atexit to
+ register C++ destructors for local statics and global objects. */
+#undef DEFAULT_USE_CXA_ATEXIT
+
/* Define if you want the C and C++ compilers to support multibyte
character sets for source code. */
#undef MULTIBYTE_CHARS
--- gcc/configure.in.atexit Fri May 31 11:33:23 2002
+++ gcc/configure.in Fri May 31 11:34:07 2002
@@ -259,6 +259,16 @@ elif test x$withval != xno; then
cpp_install_dir=$withval
fi])
+# Enable __cxa_atexit for C++.
+AC_ARG_ENABLE(__cxa_atexit,
+[ --enable-__cxa_atexit enable __cxa_atexit for C++],
+[], [enable___cxa_atexit=no])
+if test x$enable___cxa_atexit != xno; then
+ AC_DEFINE(DEFAULT_USE_CXA_ATEXIT, 1,
+ [Define if you want to use __cxa_atexit, rather than atexit to
+ register C++ destructors for local statics and global objects.])
+fi
+
# Enable Multibyte Characters for C/C++
AC_ARG_ENABLE(c-mbchar,
[ --enable-c-mbchar enable multibyte characters for C and C++],
--- gcc/cp/decl2.c.atexit Tue Apr 30 10:11:37 2002
+++ gcc/cp/decl2.c Fri May 31 11:36:07 2002
@@ -376,7 +376,7 @@ int flag_weak = 1;
/* Nonzero to use __cxa_atexit, rather than atexit, to register
destructors for local statics and global objects. */
-int flag_use_cxa_atexit;
+int flag_use_cxa_atexit = DEFAULT_USE_CXA_ATEXIT;
/* Maximum template instantiation depth. This limit is rather
arbitrary, but it exists to limit the time it takes to notice
--- gcc/defaults.h.atexit Sun May 19 21:43:24 2002
+++ gcc/defaults.h Fri May 31 11:35:49 2002
@@ -462,4 +462,10 @@ You Lose! You must define PREFERRED_DEB
#define MODE_BASE_REG_CLASS(MODE) BASE_REG_CLASS
#endif
+/* Determine if __cxa_atexit, rather than atexit is used to register
+ C++ destructors for local statics and global objects. */
+#ifndef DEFAULT_USE_CXA_ATEXIT
+#define DEFAULT_USE_CXA_ATEXIT 0
+#endif
+
#endif /* ! GCC_DEFAULTS_H */