This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Have g++ link in LIBUNWIND if it exists
- From: Steve Ellcey <sje at cup dot hp dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Mon, 18 Mar 2002 10:27:50 -0800 (PST)
- Subject: Re: Have g++ link in LIBUNWIND if it exists
- Reply-to: sje at cup dot hp dot com
Here is a resubmit of a patch to use LIBUNWIND, Benjamin Kosnik said the
libstdc++ part looked OK but he wanted some more comments and I added
those, otherwise the patch is the same. Could someone look at the rest
of the patch and check it in if it is OK. I have a copyright assignment
on file but no write permission.
This is part of the IA64 HP-UX set of changes that I have but David
Mosberger is also interested in support for a libunwind on linux so this
patch should help him as well.
Tested on IA64 HP-UX with and without --enable-libunwind-exceptions set.
Steve Ellcey
sje@cup.hp.com
2002-03-11 Steve Ellcey <sje@cup.hp.com>
* gcc/configure.in (CONFIG_SJLJ_EXCEPTIONS): Add support to set
CONFIG_SJLJ_EXCEPTIONS if --enable-libunwind-exceptions is set.
* gcc/config.in (CONFIG_SJLJ_EXCEPTIONS): Ditto.
* gcc/cp/g++spec.c (lang_specific_driver): Add -lunwind if
CONFIG_SJLJ_EXCEPTIONS is set.
* gcc/libjava/configure.in (LIBUNWINDSPEC): Define LIBUNWINDSPEC
if --enable-libunwind-exceptions is set.
* gcc/libjava/libgcj.spec.in (*lib): Add @LIBUNWINDSPEC@.
* gcc/libstdc++-v3/acinclude.m4 (GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS):
Define GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS to set LIBUNWIND_FLAG if
--enable-libunwind-exceptions is set.
* gcc/libstdc++-v3/configure.in (GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS):
Call new macro to check for libunwind.
* gcc/libstdc++-v3/src/Makefile.am (libstdc___la_LDFLAGS): Add
LIBUNWIND_FLAG to libstdc link line.
*** gcc.orig/gcc/configure.in Mon Mar 11 10:52:48 2002
--- gcc/gcc/configure.in Mon Mar 11 10:58:41 2002
*************** AC_ARG_ENABLE(sjlj-exceptions,
*** 2139,2144 ****
--- 2139,2153 ----
AC_DEFINE_UNQUOTED(CONFIG_SJLJ_EXCEPTIONS, $sjlj,
[Define 0/1 to force the choice for exception handling model.])])
+ # Use libunwind based exception handling.
+ AC_ARG_ENABLE(libunwind-exceptions,
+ [ --enable-libunwind-exceptions force use libunwind for exceptions],
+ use_libunwind_exceptions=$enableval,
+ use_libunwind_exceptions=no)
+ if test x"$use_libunwind_exceptions" = xyes; then
+ AC_DEFINE_UNQUOTED(CONFIG_LIBUNWIND_EXCEPTIONS, 1)
+ fi
+
# Make empty files to contain the specs and options for each language.
# Then add #include lines to for a compiler that has specs and/or options.
*** gcc.orig/gcc/config.in Mon Mar 11 10:55:57 2002
--- gcc/gcc/config.in Thu Jan 10 14:21:38 2002
***************
*** 554,562 ****
/* Define 0/1 to force the choice for exception handling model. */
#undef CONFIG_SJLJ_EXCEPTIONS
- /* Define if you want to link in libunwind for exceptions. */
- #undef CONFIG_LIBUNWIND_EXCEPTIONS
-
/* Bison unconditionally undefines `const' if neither `__STDC__' nor
__cplusplus are defined. That's a problem since we use `const' in
--- 554,559 ----
*** gcc.orig/gcc/cp/g++spec.c Mon Mar 11 10:52:48 2002
--- gcc/gcc/cp/g++spec.c Mon Mar 11 10:57:00 2002
*************** Boston, MA 02111-1307, USA. */
*** 37,42 ****
--- 37,46 ----
#define LIBSTDCXX "-lstdc++"
#endif
+ #ifndef LIBUNWIND
+ #define LIBUNWIND "-lunwind"
+ #endif
+
void
lang_specific_driver (in_argc, in_argv, in_added_libraries)
int *in_argc;
*************** lang_specific_driver (in_argc, in_argv,
*** 261,266 ****
--- 265,274 ----
{
arglist[j++] = LIBSTDCXX;
added_libraries++;
+ #ifdef CONFIG_LIBUNWIND_EXCEPTIONS
+ arglist[j++] = LIBUNWIND;
+ added_libraries++;
+ #endif
}
if (saw_math)
arglist[j++] = saw_math;
*** gcc.orig/libjava/configure.in Mon Mar 11 10:52:48 2002
--- gcc/libjava/configure.in Mon Mar 11 11:20:24 2002
*************** fi
*** 153,158 ****
--- 153,179 ----
AC_LANG_RESTORE
AC_MSG_RESULT($ac_exception_model_name)
+ dnl
+ dnl Check for libunwind exception handling support. If an explicit
+ dnl enable/disable libunwind exceptions is given, use that otherwise
+ dnl default to disable.
+ dnl
+ dnl --enable-libunwind-exceptions forces the use of libunwind.
+ dnl --disable-libunwind-exceptions assumes there is no libunwind.
+ dnl
+ AC_ARG_ENABLE(libunwind-exceptions,
+ [ --enable-libunwind-exceptions force use of libunwind for exceptions],
+ use_libunwind_exceptions=$enableval,
+ use_libunwind_exceptions=no)
+ AC_MSG_RESULT($use_libunwind_exceptions)
+ dnl Option parsed, now set things appropriately
+ if test x"$use_libunwind_exceptions" = xyes; then
+ LIBUNWINDSPEC="-lunwind"
+ else
+ LIBUNWINDSPEC=""
+ fi
+ AC_SUBST(LIBUNWINDSPEC)
+
dnl See if the user wants to disable java.net. This is the mildly
dnl ugly way that we admit that target-side configuration sucks.
AC_ARG_ENABLE(java-net,
*** gcc.orig/libjava/libgcj.spec.in Mon Mar 11 10:52:49 2002
--- gcc/libjava/libgcj.spec.in Mon Mar 11 11:03:37 2002
***************
*** 4,9 ****
# to link with libgcj.
#
%rename lib liborig
! *lib: -lgcj -lm @LIBICONV@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig)
*jc1: @HASH_SYNC_SPEC@ @DIVIDESPEC@ @JC1GCSPEC@ @EXCEPTIONSPEC@ -fkeep-inline-functions
--- 4,9 ----
# to link with libgcj.
#
%rename lib liborig
! *lib: -lgcj -lm @LIBICONV@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @LIBUNWINDSPEC@ @SYSTEMSPEC@ %(libgcc) %(liborig)
*jc1: @HASH_SYNC_SPEC@ @DIVIDESPEC@ @JC1GCSPEC@ @EXCEPTIONSPEC@ -fkeep-inline-functions
*** gcc.orig/libstdc++-v3/acinclude.m4 Mon Mar 11 10:52:49 2002
--- gcc/libstdc++-v3/acinclude.m4 Wed Mar 13 16:06:07 2002
*************** EOF
*** 1415,1420 ****
--- 1415,1449 ----
dnl
+ dnl Check for libunwind exception handling support. If enabled then
+ dnl we assume that the _Unwind_* functions that make up the Unwind ABI
+ dnl (_Unwind_RaiseException, _Unwind_Resume, etc.) are defined by
+ dnl libunwind instead of libgcc and that libstdc++ has a dependency
+ dnl on libunwind as well as libgcc.
+ dnl
+ dnl GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS
+ dnl --enable-libunwind-exceptions forces the use of libunwind.
+ dnl --disable-libunwind-exceptions assumes there is no libunwind.
+ dnl
+ dnl Define _GLIBCPP_LIBUNWIND_EXCEPTIONS if requested.
+ dnl
+ AC_DEFUN(GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS, [
+ AC_MSG_CHECKING([for use of libunwind])
+ AC_ARG_ENABLE(libunwind-exceptions,
+ [ --enable-libunwind-exceptions force use of libunwind for exceptions],
+ use_libunwind_exceptions=$enableval,
+ use_libunwind_exceptions=no)
+ AC_MSG_RESULT($use_libunwind_exceptions)
+ dnl Option parsed, now set things appropriately
+ if test x"$use_libunwind_exceptions" = xyes; then
+ LIBUNWIND_FLAG="-lunwind"
+ else
+ LIBUNWIND_FLAG=""
+ fi
+ AC_SUBST(LIBUNWIND_FLAG)
+
+
+ dnl
dnl Check for ISO/IEC 9899:1999 "C99" support.
dnl
dnl GLIBCPP_ENABLE_C99
*** gcc.orig/libstdc++-v3/configure.in Mon Mar 11 11:24:22 2002
--- gcc/libstdc++-v3/configure.in Mon Mar 11 11:24:46 2002
*************** GLIBCPP_ENABLE_CHEADERS([c_std])
*** 48,53 ****
--- 48,54 ----
GLIBCPP_ENABLE_THREADS
GLIBCPP_ENABLE_CXX_FLAGS([none])
GLIBCPP_ENABLE_SJLJ_EXCEPTIONS
+ GLIBCPP_ENABLE_LIBUNWIND_EXCEPTIONS
GLIBCPP_ENABLE_CONCEPT_CHECKS
*** gcc.orig/libstdc++-v3/src/Makefile.am Mon Mar 11 10:52:49 2002
--- gcc/libstdc++-v3/src/Makefile.am Mon Mar 11 11:09:28 2002
*************** else
*** 84,90 ****
version_arg=
endif
! libstdc___la_LDFLAGS = -version-info @libtool_VERSION@ -lm ${version_arg}
libstdc___la_DEPENDENCIES = $(libstdc___la_LIBADD) linker.map
--- 84,90 ----
version_arg=
endif
! libstdc___la_LDFLAGS = -version-info @libtool_VERSION@ @LIBUNWIND_FLAG@ -lm ${version_arg}
libstdc___la_DEPENDENCIES = $(libstdc___la_LIBADD) linker.map