This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: RFA: Enable gcc configure option --enable-__cxa_atexit by default
Hi Joseph,
The default for this option is target-specific - and needs to be so - and
is controlled by default_use_cxa_atexit in config.gcc.
Instead of changing configure.ac, you should change the default setting of
default_use_cxa_atexit to "yes", remove all other settings of it to "yes"
for specific targets, and make every target not presently setting it to
"yes" set it to "no" - so not changing the default behavior at all.
Then, you should identify targets with __cxa_atexit and flip the default
for them. For example, *-*-linux* and *-*-gnu* use glibc, and various
*-*-elf and similar targets can be presumed to have __cxa_atexit (either
they use newlib, or it's the user's responsibility to provide a C library
with the functions GCC expects).
For hosted operating system ports where the version number is part of the
target triplet, the correct default will typically be version-dependent;
see the existing NetBSD handling for an example.
How about this slightly simpler version ?
It simply sets the default value for $default_use_cxa_atexit to "yes"
for *-*-linux* and *-*-elf targets on the assumption that these will use
glibc or newlib. The patch also extends the comment that describes the
default_use_cxa_atexit variable, explaining that it is set to "yes" for
certain targets.
Tested by building an x86 native toolchain and an arm-elf cross compiler
and running the G++ testsuites.
Cheers
Nick
gcc/ChangeLog
2006-02-28 Nick Clifton <nickc@redhat.com>
* config.gcc (default_use_cxa_atexit): Extend the description of
this configure variable. Set its default value to "yes" for
Linux and ELF targets on the assumptions that they will use
glibc and newlib respectively.
Index: gcc/config.gcc
===================================================================
--- gcc/config.gcc (revision 111520)
+++ gcc/config.gcc (working copy)
@@ -34,9 +34,16 @@
# threads support was requested.
#
# default_use_cxa_atexit
-# "no" by default, can be set to "yes" if a target
-# wishes to use __cxa_atexit() by default if the
-# $enable___cxa_atexit variable is not set.
+# The default value for the $enable___cxa_atexit
+# variable. enable___cxa_atexit needs to be set to
+# "yes" for the correct operation of C++ destructors
+# but it relies upon the presence of a non-standard C
+# library function called __cxa_atexit.
+# Since not all C libraries provide __cxa_atexit the
+# default value of $default_use_cxa_atexit is set to
+# "no" except for Linux and NetBSD targets (which are
+# assumed to use glibc) and for ELF targets (which are
+# assumed to use newlib).
#
# gas_flag Either yes or no depending on whether GNU as was
# requested.
@@ -459,6 +466,8 @@
;;
*)
tm_defines="${tm_defines} UCLIBC_DEFAULT=0"
+ # Assume that glibc is being used and so __cxa_atexit is provided.
+ default_use_cxa_atexit=yes
;;
esac
;;
@@ -482,6 +491,8 @@
tm_file="${cpu_type}/${cpu_type}.h i386/unix.h i386/att.h dbxelf.h elfos.h svr4.h linux.h i386/linux.h gnu.h ${tm_file}"
;;
esac
+ # Assume that glibc is being used and so __cxa_atexit is provided.
+ default_use_cxa_atexit=yes
;;
*-*-netbsd*)
tmake_file="t-slibgcc-elf-ver t-libc-ok t-netbsd t-libgcc-pic"
@@ -551,6 +562,10 @@
*) echo 'Unknown thread configuration for VxWorks'; exit 1 ;;
esac
;;
+*-*-elf)
+ # Assume that newlib is being used and so __cxa_atexit is provided.
+ default_use_cxa_atexit=yes
+ ;;
esac
case ${target} in