This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
RFA: Enable gcc configure option --enable-__cxa_atexit by default
- From: Nick Clifton <nickc at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Fri, 17 Feb 2006 11:16:07 +0000
- Subject: RFA: Enable gcc configure option --enable-__cxa_atexit by default
Hi Guys,
I would like to permission to apply the following patch. It changes
the configure script in the GCC sub-directory so that the configure
option --enable-__cxa_atexit is on by default.
The reason for enabling the option is that it is required for the
G++ compiler to produce static destructors that fully comply with
the C++ specification. A problem with the current compiler's
ordering of destructors was recently reported, and this turned out
to be due to this configure option being disabled:
http://gcc.gnu.org/ml/gcc-bugs/2006-02/msg01294.html
The reason that this option is not currently enabled by default is,
I believe, due to the fact that it requires a non-standard function
to present in the target C library, to whit: __cxa_atexit(). This
function is however present in both glibc and newlib (and maybe
other C libraries, I have not tested them), and if it is not present
then the compiler's old behaviour can be restored by configuring
with --disable-__cxa_atexit or else compiling the target application
with -fno-use-cxa-atexit.
I believe that it is better to generate correct C++ code by default,
even at the risk of upsetting users who are building cross compilers
for targets with C libraries that do not include the __cxa_atexit
function.
Tested by building two different toolchains twice (once with the
patch applied and once without) and then running the G++ testsuite
and comparing the results. First was an x86 linux native. (It was
an x86_64 running Red Hat Enterprise Linux 4 in 64-bit mode if this
matters). This host provides a glibc that includes the
__cxa_atexit() function. This G++ regression test showed that the
patch fixed 2 unexpected failures and changes one XFAIL to an XPASS:
PASS: g++.dg/eh/cleanup1.C (test for excess errors)
PASS: g++.dg/opt/inline4.C (test for excess errors)
XPASS: g++.old-deja/g++.other/init5.C execution test
I did try to build a Solaris native toolchain, but I could not
complete the builds. Not because of this patch but because I cannot
seem to get any version of gcc to build under Solaris. I always end
up with errors about unaligned relocations (usually in libiberty)
and I do not know how to prevent them.
The other test was a Linux hosted arm-elf cross compiler. This
toolchain includes a build of newlib which does contain the
__cxa_atexit function. The G++ regression test showed that only one
result had changed: the XPASS of g++.old-deja/g++.other/init5.C.
So - may I apply this patch ?
Cheers
Nick
gcc/ChangeLog
2006-02-15 Nick Clifton <nickc@redhat.com>
* configure.ac (__cxa_atexit): Enable by default since it
provides correct behaviour of C++ destructors.
* configure: Regenerate.
Index: gcc/configure.ac
===================================================================
--- gcc/configure.ac (revision 111019)
+++ gcc/configure.ac (working copy)
@@ -667,7 +667,7 @@
# Enable __cxa_atexit for C++.
AC_ARG_ENABLE(__cxa_atexit,
[ --enable-__cxa_atexit enable __cxa_atexit for C++],
-[], [])
+[], [enable___cxa_atexit=yes])
# Enable C extension for decimal float if target supports it.
AC_ARG_ENABLE(decimal-float,