From 3660e02f0d9bedca08e7f562edf861027bb70950 Mon Sep 17 00:00:00 2001 From: Phil Edwards Date: Tue, 2 Sep 2003 18:46:54 +0000 Subject: [PATCH] acinclude.m4 (GLIBCXX_ENABLE_HOSTED): #define _GLIBCXX_HOSTED appropriately. 2003-09-02 Phil Edwards * acinclude.m4 (GLIBCXX_ENABLE_HOSTED): #define _GLIBCXX_HOSTED appropriately. * config.h.in: Add _GLIBCXX_HOSTED. * libsupc++/eh_term_handler.cc: Test it here; initialize __terminate_handler to std::abort if freestanding. * aclocal.m4, configure: Regenerated. * docs/html/configopts.html: Document --disable-hosted-libstdcxx. From-SVN: r71001 --- libstdc++-v3/ChangeLog | 10 ++++++++++ libstdc++-v3/acinclude.m4 | 7 +++++++ libstdc++-v3/aclocal.m4 | 7 +++++++ libstdc++-v3/config.h.in | 3 +++ libstdc++-v3/configure | 9 ++++++++- libstdc++-v3/docs/html/configopts.html | 10 +++++++++- libstdc++-v3/libsupc++/eh_term_handler.cc | 24 ++++++++++++++++------- 7 files changed, 61 insertions(+), 9 deletions(-) diff --git a/libstdc++-v3/ChangeLog b/libstdc++-v3/ChangeLog index 139a75382e5..2d96e45cb3a 100644 --- a/libstdc++-v3/ChangeLog +++ b/libstdc++-v3/ChangeLog @@ -1,3 +1,13 @@ +2003-09-02 Phil Edwards + + * acinclude.m4 (GLIBCXX_ENABLE_HOSTED): #define _GLIBCXX_HOSTED + appropriately. + * config.h.in: Add _GLIBCXX_HOSTED. + * libsupc++/eh_term_handler.cc: Test it here; initialize + __terminate_handler to std::abort if freestanding. + * aclocal.m4, configure: Regenerated. + * docs/html/configopts.html: Document --disable-hosted-libstdcxx. + 2003-08-29 Nathan Myers PR libstdc++/11990 diff --git a/libstdc++-v3/acinclude.m4 b/libstdc++-v3/acinclude.m4 index 5cc4f747313..0ba24bad7fd 100644 --- a/libstdc++-v3/acinclude.m4 +++ b/libstdc++-v3/acinclude.m4 @@ -1276,6 +1276,9 @@ dnl dnl Sets: dnl is_hosted (yes/no) dnl +dnl Defines: +dnl _GLIBCXX_HOSTED (always defined, either to 1 or 0) +dnl AC_DEFUN(GLIBCXX_ENABLE_HOSTED, [ AC_ARG_ENABLE([hosted-libstdcxx], AC_HELP_STRING([--disable-hosted-libstdcxx], @@ -1284,12 +1287,16 @@ AC_DEFUN(GLIBCXX_ENABLE_HOSTED, [ if test "$enable_hosted_libstdcxx" = no; then AC_MSG_NOTICE([Only freestanding libraries will be built]) is_hosted=no + hosted_define=0 enable_abi_check=no enable_libstdcxx_pch=no else is_hosted=yes + hosted_define=1 fi GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes) + AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define, + [Define to 1 if a full hosted library is built, or 0 if freestanding.]) ]) diff --git a/libstdc++-v3/aclocal.m4 b/libstdc++-v3/aclocal.m4 index 47bcaa7da6b..42399080ba3 100644 --- a/libstdc++-v3/aclocal.m4 +++ b/libstdc++-v3/aclocal.m4 @@ -1289,6 +1289,9 @@ dnl dnl Sets: dnl is_hosted (yes/no) dnl +dnl Defines: +dnl _GLIBCXX_HOSTED (always defined, either to 1 or 0) +dnl AC_DEFUN(GLIBCXX_ENABLE_HOSTED, [ AC_ARG_ENABLE([hosted-libstdcxx], AC_HELP_STRING([--disable-hosted-libstdcxx], @@ -1297,12 +1300,16 @@ AC_DEFUN(GLIBCXX_ENABLE_HOSTED, [ if test "$enable_hosted_libstdcxx" = no; then AC_MSG_NOTICE([Only freestanding libraries will be built]) is_hosted=no + hosted_define=0 enable_abi_check=no enable_libstdcxx_pch=no else is_hosted=yes + hosted_define=1 fi GLIBCXX_CONDITIONAL(GLIBCXX_HOSTED, test $is_hosted = yes) + AC_DEFINE_UNQUOTED(_GLIBCXX_HOSTED, $hosted_define, + [Define to 1 if a full hosted library is built, or 0 if freestanding.]) ]) diff --git a/libstdc++-v3/config.h.in b/libstdc++-v3/config.h.in index d61a5845989..0e6bb080c3b 100644 --- a/libstdc++-v3/config.h.in +++ b/libstdc++-v3/config.h.in @@ -878,6 +878,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define to 1 if a full hosted library is built, or 0 if freestanding. */ +#undef _GLIBCXX_HOSTED + /* Define if the compiler is configured for setjmp/longjmp exceptions. */ #undef _GLIBCXX_SJLJ_EXCEPTIONS // diff --git a/libstdc++-v3/configure b/libstdc++-v3/configure index bd222ff37f5..e9e51e36ad6 100755 --- a/libstdc++-v3/configure +++ b/libstdc++-v3/configure @@ -4819,13 +4819,20 @@ fi; { echo "$as_me:$LINENO: Only freestanding libraries will be built" >&5 echo "$as_me: Only freestanding libraries will be built" >&6;} is_hosted=no + hosted_define=0 enable_abi_check=no enable_libstdcxx_pch=no else is_hosted=yes + hosted_define=1 fi +cat >>confdefs.h <<_ACEOF +#define _GLIBCXX_HOSTED $hosted_define +_ACEOF + + # Check for support bits and g++ features that don't require linking. @@ -4862,7 +4869,7 @@ fi; # # Fake what AC_TRY_COMPILE does. XXX Look at redoing this new-style. cat > conftest.$ac_ext << EOF -#line 4865 "configure" +#line 4872 "configure" struct S { ~S(); }; void bar(); void foo() diff --git a/libstdc++-v3/docs/html/configopts.html b/libstdc++-v3/docs/html/configopts.html index 2f16b7a6b2c..2cfec4475c4 100644 --- a/libstdc++-v3/docs/html/configopts.html +++ b/libstdc++-v3/docs/html/configopts.html @@ -146,7 +146,7 @@ options
--enable-libstdcxx-debug

Build separate debug libraries in addition to what is normally built. - By default, the debug libraries are compiled with + By default, the debug libraries are compiled with CXXFLAGS='-g3 -O0' , are installed in ${libdir}/debug, and have the same names and versioning information as the non-debug @@ -273,6 +273,14 @@ options testsuite.

+ +
--disable-hosted-libstdcxx
+

By default, a complete hosted C++ library is built. The + C++ Standard also describes a freestanding environment, + in which only a minimal set of headers are provided. This option + builds such an environment. +

+

Return to the top of the page or to the libstdc++ homepage. diff --git a/libstdc++-v3/libsupc++/eh_term_handler.cc b/libstdc++-v3/libsupc++/eh_term_handler.cc index 15a2cbd92d6..f4f1193e71a 100644 --- a/libstdc++-v3/libsupc++/eh_term_handler.cc +++ b/libstdc++-v3/libsupc++/eh_term_handler.cc @@ -1,5 +1,5 @@ // -*- C++ -*- std::terminate handler -// Copyright (C) 2002 Free Software Foundation +// Copyright (C) 2002, 2003 Free Software Foundation // // This file is part of GCC. // @@ -28,14 +28,24 @@ // the GNU General Public License. #include "unwind-cxx.h" +#include -/* We default to the talkative, informative handler. This pulls in the - demangler, the dyn-string utilities, and elements of the I/O library. - For a low-memory environment, you can return to the earlier "silent death" - handler by including , initializg to "std::abort", and rebuilding - the library. */ +/* We default to the talkative, informative handler in a normal hosted + library. This pulls in the demangler, the dyn-string utilities, and + elements of the I/O library. For a low-memory environment, you can return + to the earlier "silent death" handler by including , initializing + to "std::abort", and rebuilding the library. In a freestanding mode, we + default to this latter approach. */ + +#if ! _GLIBCXX_HOSTED +# include +#endif /* The current installed user handler. */ std::terminate_handler __cxxabiv1::__terminate_handler = - __gnu_cxx::__verbose_terminate_handler; +#if _GLIBCXX_HOSTED + __gnu_cxx::__verbose_terminate_handler; +#else + std::abort; +#endif