mirror of
https://gcc.gnu.org/git/gcc.git
synced 2024-11-23 02:44:18 +08:00
637e3668fd
Implement a long-standing request to support tuning the size of the emergency buffer for allocating exceptions after malloc fails, or to disable that buffer entirely. It's now possible to disable the dynamic allocation of the buffer and use a fixed-size static buffer, via --enable-libstdcxx-static-eh-pool. This is a built-time choice that is baked into libstdc++ and so affects all code linked against that build of libstdc++. The size of the pool can be set by --with-libstdcxx-eh-pool-obj-count=N which is measured in units of sizeof(void*) not bytes. A given exception type such as std::system_error depends on the target, so giving a size in bytes wouldn't be portable across 16/32/64-bit targets. When libstdc++ is configured to use a dynamic buffer, the size of that buffer can now be tuned at runtime by setting the GLIBCXX_TUNABLES environment variable (c.f. PR libstdc++/88264). The number of exceptions to reserve space for is controlled by the "glibcxx.eh_pool.obj_count" and "glibcxx.eh_pool.obj_size" tunables. The pool will be sized to be able to allocate obj_count exceptions of size obj_size*sizeof(void*) and obj_count "dependent" exceptions rethrown by std::rethrow_exception. With the ability to tune the buffer size, we can reduce the default pool size on 32-bit and 16-bit targets. Most users never need to throw 1kB exceptions in parallel from hundreds of threads after malloc is OOM. The users who do need that can use the tunables to select larger sizes. The old defaults can be chosen at runtime by setting GLIBCXX_TUNABLES to: 64-bit: glibcxx.eh_pool.obj_count=64:glibcxx.eh_pool.obj_size=112 32-bit: glibcxx.eh_pool.obj_count=32:glibcxx.eh_pool.obj_size=104 Or approximated by configuring with: 64-bit: --with-libstdcxx-eh-pool-obj-count=252 32-bit: --with-libstdcxx-eh-pool-obj-count=94 libstdc++-v3/ChangeLog: PR libstdc++/68606 * Makefile.in: Regenerate. * acinclude.m4 (GLIBCXX_EMERGENCY_EH_ALLOC): New macro. * configure: Regenerate. * configure.ac: Use GLIBCXX_EMERGENCY_EH_ALLOC. * crossconfig.m4: Check for secure_getenv. * doc/Makefile.in: Regenerate. * doc/xml/manual/configure.xml: Document new configure options. * doc/xml/manual/evolution.xml: Document addition of tunables. * doc/xml/manual/using_exceptions.xml: Document emergency buffer and tunables. * doc/html/*: Regenerate. * include/Makefile.in: Regenerate. * libsupc++/Makefile.am: Use EH_POOL_FLAGS. * libsupc++/Makefile.in: Regenerate. * libsupc++/eh_alloc.cc (EMERGENCY_OBJ_SIZE): Define in units of sizeof(void*) not including the ABI's exception header. (EMERGENCY_OBJ_COUNT): Define as target-independent calculation based on word size. (MAX_OBJ_COUNT): Define macro for upper limit on pool size. (pool) [_GLIBCXX_EH_POOL_STATIC]: Use fixed-size buffer. (pool::buffer_size_in_bytes): New static member function. (pool::pool): Parse GLIBCXX_TUNABLES environment variable to set pool size at runtime. (pool::in_pool): Use std::less<void*> for total order. (__freeres) [_GLIBCXX_EH_POOL_STATIC]: Do nothing. (__cxa_free_exception, __cxa_free_dependent_exception): Add [[unlikely]] attributes. * po/Makefile.in: Regenerate. * python/Makefile.in: Regenerate. * src/Makefile.in: Regenerate. * src/c++11/Makefile.in: Regenerate. * src/c++17/Makefile.in: Regenerate. * src/c++20/Makefile.in: Regenerate. * src/c++98/Makefile.in: Regenerate. * src/filesystem/Makefile.in: Regenerate. * src/libbacktrace/Makefile.in: Regenerate. * testsuite/Makefile.in: Regenerate.
357 lines
9.5 KiB
Plaintext
357 lines
9.5 KiB
Plaintext
dnl
|
|
dnl This file contains details for non-native builds.
|
|
dnl
|
|
|
|
AC_DEFUN([GLIBCXX_CROSSCONFIG],[
|
|
# Base decisions on target environment.
|
|
case "${host}" in
|
|
arm*-*-symbianelf*)
|
|
# This is a freestanding configuration; there is nothing to do here.
|
|
;;
|
|
|
|
avr*-*-*)
|
|
AC_DEFINE(HAVE_ACOSF)
|
|
AC_DEFINE(HAVE_ASINF)
|
|
AC_DEFINE(HAVE_ATAN2F)
|
|
AC_DEFINE(HAVE_ATANF)
|
|
AC_DEFINE(HAVE_CEILF)
|
|
AC_DEFINE(HAVE_COSF)
|
|
AC_DEFINE(HAVE_COSHF)
|
|
AC_DEFINE(HAVE_EXPF)
|
|
AC_DEFINE(HAVE_FABSF)
|
|
AC_DEFINE(HAVE_FLOORF)
|
|
AC_DEFINE(HAVE_FMODF)
|
|
AC_DEFINE(HAVE_FREXPF)
|
|
AC_DEFINE(HAVE_SQRTF)
|
|
AC_DEFINE(HAVE_HYPOTF)
|
|
AC_DEFINE(HAVE_LDEXPF)
|
|
AC_DEFINE(HAVE_LOG10F)
|
|
AC_DEFINE(HAVE_LOGF)
|
|
AC_DEFINE(HAVE_MODFF)
|
|
AC_DEFINE(HAVE_POWF)
|
|
AC_DEFINE(HAVE_SINF)
|
|
AC_DEFINE(HAVE_SINHF)
|
|
AC_DEFINE(HAVE_TANF)
|
|
AC_DEFINE(HAVE_TANHF)
|
|
;;
|
|
|
|
mips*-sde-elf*)
|
|
# These definitions are for the SDE C library rather than newlib.
|
|
SECTION_FLAGS='-ffunction-sections -fdata-sections'
|
|
AC_SUBST(SECTION_FLAGS)
|
|
GLIBCXX_CHECK_COMPILER_FEATURES
|
|
GLIBCXX_CHECK_LINKER_FEATURES
|
|
GLIBCXX_CHECK_MATH_SUPPORT
|
|
GLIBCXX_CHECK_STDLIB_SUPPORT
|
|
|
|
AC_DEFINE(HAVE_FINITE)
|
|
AC_DEFINE(HAVE_HYPOT)
|
|
AC_DEFINE(HAVE_ISNAN)
|
|
AC_DEFINE(HAVE_ISINF)
|
|
|
|
AC_DEFINE(HAVE_LDEXPF)
|
|
AC_DEFINE(HAVE_MODF)
|
|
AC_DEFINE(HAVE_SQRTF)
|
|
;;
|
|
|
|
*-aix*)
|
|
GLIBCXX_CHECK_LINKER_FEATURES
|
|
GLIBCXX_CHECK_MATH_SUPPORT
|
|
GLIBCXX_CHECK_STDLIB_SUPPORT
|
|
AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM)
|
|
AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1)
|
|
# We don't yet support AIX's TLS ABI.
|
|
#GCC_CHECK_TLS
|
|
AM_ICONV
|
|
|
|
AC_DEFINE(HAVE_USELOCALE)
|
|
;;
|
|
|
|
*-darwin*)
|
|
# Darwin versions vary, but the linker should work in a cross environment,
|
|
# so we just check for all the features here.
|
|
# Check for available headers.
|
|
|
|
# Don't call GLIBCXX_CHECK_LINKER_FEATURES, Darwin doesn't have a GNU ld
|
|
GLIBCXX_CHECK_MATH_SUPPORT
|
|
GLIBCXX_CHECK_STDLIB_SUPPORT
|
|
|
|
AC_CHECK_FUNCS(uselocale)
|
|
;;
|
|
|
|
*djgpp)
|
|
# GLIBCXX_CHECK_MATH_SUPPORT
|
|
AC_DEFINE(HAVE_ISINF)
|
|
AC_DEFINE(HAVE_ISNAN)
|
|
AC_DEFINE(HAVE_FINITE)
|
|
AC_DEFINE(HAVE_SINCOS)
|
|
AC_DEFINE(HAVE_HYPOT)
|
|
;;
|
|
|
|
*-freebsd*)
|
|
SECTION_FLAGS='-ffunction-sections -fdata-sections'
|
|
AC_SUBST(SECTION_FLAGS)
|
|
GLIBCXX_CHECK_LINKER_FEATURES
|
|
AC_DEFINE(HAVE_SETENV)
|
|
AC_DEFINE(HAVE_FINITEF)
|
|
AC_DEFINE(HAVE_FINITE)
|
|
AC_DEFINE(HAVE_FREXPF)
|
|
AC_DEFINE(HAVE_HYPOT)
|
|
AC_DEFINE(HAVE_HYPOTF)
|
|
AC_DEFINE(HAVE_ISINF)
|
|
AC_DEFINE(HAVE_ISNAN)
|
|
AC_DEFINE(HAVE_ISNANF)
|
|
|
|
AC_DEFINE(HAVE_ACOSF)
|
|
AC_DEFINE(HAVE_ASINF)
|
|
AC_DEFINE(HAVE_ATAN2F)
|
|
AC_DEFINE(HAVE_ATANF)
|
|
AC_DEFINE(HAVE_CEILF)
|
|
AC_DEFINE(HAVE_COSF)
|
|
AC_DEFINE(HAVE_COSHF)
|
|
AC_DEFINE(HAVE_EXPF)
|
|
AC_DEFINE(HAVE_FABSF)
|
|
AC_DEFINE(HAVE_FLOORF)
|
|
AC_DEFINE(HAVE_FMODF)
|
|
AC_DEFINE(HAVE_FREXPF)
|
|
AC_DEFINE(HAVE_LDEXPF)
|
|
AC_DEFINE(HAVE_LOG10F)
|
|
AC_DEFINE(HAVE_LOGF)
|
|
AC_DEFINE(HAVE_MODFF)
|
|
AC_DEFINE(HAVE_POWF)
|
|
AC_DEFINE(HAVE_SINF)
|
|
AC_DEFINE(HAVE_SINHF)
|
|
AC_DEFINE(HAVE_SQRTF)
|
|
AC_DEFINE(HAVE_TANF)
|
|
AC_DEFINE(HAVE_TANHF)
|
|
if test x"long_double_math_on_this_cpu" = x"yes"; then
|
|
AC_DEFINE(HAVE_FINITEL)
|
|
AC_DEFINE(HAVE_ISINFL)
|
|
AC_DEFINE(HAVE_ISNANL)
|
|
fi
|
|
AC_CHECK_FUNCS(__cxa_thread_atexit)
|
|
AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
|
|
AC_CHECK_FUNCS(timespec_get)
|
|
AC_CHECK_FUNCS(sockatmark)
|
|
AC_CHECK_FUNCS(uselocale)
|
|
;;
|
|
|
|
*-fuchsia*)
|
|
SECTION_FLAGS='-ffunction-sections -fdata-sections'
|
|
AC_SUBST(SECTION_FLAGS)
|
|
;;
|
|
|
|
*-hpux*)
|
|
SECTION_FLAGS='-ffunction-sections -fdata-sections'
|
|
AC_SUBST(SECTION_FLAGS)
|
|
GLIBCXX_CHECK_LINKER_FEATURES
|
|
|
|
# GLIBCXX_CHECK_MATH_SUPPORT
|
|
AC_DEFINE(HAVE_ISNAN)
|
|
AC_DEFINE(HAVE_HYPOT)
|
|
AC_DEFINE(HAVE_ACOSF)
|
|
AC_DEFINE(HAVE_ASINF)
|
|
AC_DEFINE(HAVE_ATANF)
|
|
AC_DEFINE(HAVE_COSF)
|
|
AC_DEFINE(HAVE_COSHF)
|
|
AC_DEFINE(HAVE_SINF)
|
|
AC_DEFINE(HAVE_SINHF)
|
|
AC_DEFINE(HAVE_TANF)
|
|
AC_DEFINE(HAVE_TANHF)
|
|
AC_DEFINE(HAVE_EXPF)
|
|
AC_DEFINE(HAVE_ATAN2F)
|
|
AC_DEFINE(HAVE_FABSF)
|
|
AC_DEFINE(HAVE_FMODF)
|
|
AC_DEFINE(HAVE_FREXPF)
|
|
AC_DEFINE(HAVE_LOGF)
|
|
AC_DEFINE(HAVE_LOG10F)
|
|
AC_DEFINE(HAVE_MODF)
|
|
AC_DEFINE(HAVE_POWF)
|
|
AC_DEFINE(HAVE_SQRTF)
|
|
|
|
# GLIBCXX_CHECK_STDLIB_SUPPORT
|
|
AC_DEFINE(HAVE_STRTOLD)
|
|
|
|
GCC_CHECK_TLS
|
|
;;
|
|
*-linux* | *-uclinux* | *-gnu* | *-kfreebsd*-gnu | *-cygwin* | *-solaris*)
|
|
GLIBCXX_CHECK_COMPILER_FEATURES
|
|
GLIBCXX_CHECK_LINKER_FEATURES
|
|
GLIBCXX_CHECK_MATH_SUPPORT
|
|
GLIBCXX_CHECK_STDLIB_SUPPORT
|
|
AC_DEFINE(_GLIBCXX_USE_DEV_RANDOM)
|
|
AC_DEFINE(_GLIBCXX_USE_RANDOM_TR1)
|
|
GCC_CHECK_TLS
|
|
AC_CHECK_FUNCS(__cxa_thread_atexit_impl)
|
|
AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
|
|
AC_CHECK_FUNCS(timespec_get)
|
|
AC_CHECK_FUNCS(sockatmark)
|
|
AC_CHECK_FUNCS(uselocale)
|
|
AC_CHECK_FUNCS(secure_getenv)
|
|
AM_ICONV
|
|
;;
|
|
*-mingw32*)
|
|
GLIBCXX_CHECK_LINKER_FEATURES
|
|
GLIBCXX_CHECK_MATH_SUPPORT
|
|
GLIBCXX_CHECK_STDLIB_SUPPORT
|
|
AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
|
|
AC_CHECK_FUNCS(_wfopen)
|
|
GCC_CHECK_TLS
|
|
;;
|
|
*-netbsd* | *-openbsd*)
|
|
SECTION_FLAGS='-ffunction-sections -fdata-sections'
|
|
AC_SUBST(SECTION_FLAGS)
|
|
GLIBCXX_CHECK_LINKER_FEATURES
|
|
AC_DEFINE(HAVE_FINITEF)
|
|
AC_DEFINE(HAVE_FINITE)
|
|
AC_DEFINE(HAVE_FREXPF)
|
|
AC_DEFINE(HAVE_HYPOTF)
|
|
AC_DEFINE(HAVE_ISINF)
|
|
AC_DEFINE(HAVE_ISINFF)
|
|
AC_DEFINE(HAVE_ISNAN)
|
|
AC_DEFINE(HAVE_ISNANF)
|
|
if test x"long_double_math_on_this_cpu" = x"yes"; then
|
|
AC_DEFINE(HAVE_FINITEL)
|
|
AC_DEFINE(HAVE_ISINFL)
|
|
AC_DEFINE(HAVE_ISNANL)
|
|
fi
|
|
AC_CHECK_FUNCS(aligned_alloc posix_memalign memalign _aligned_malloc)
|
|
AC_CHECK_FUNCS(timespec_get)
|
|
AC_CHECK_FUNCS(sockatmark)
|
|
;;
|
|
*-qnx6.1* | *-qnx6.2*)
|
|
SECTION_FLAGS='-ffunction-sections -fdata-sections'
|
|
AC_SUBST(SECTION_FLAGS)
|
|
GLIBCXX_CHECK_LINKER_FEATURES
|
|
AC_DEFINE(HAVE_COSF)
|
|
AC_DEFINE(HAVE_COSL)
|
|
AC_DEFINE(HAVE_COSHF)
|
|
AC_DEFINE(HAVE_COSHL)
|
|
AC_DEFINE(HAVE_LOGF)
|
|
AC_DEFINE(HAVE_LOGL)
|
|
AC_DEFINE(HAVE_LOG10F)
|
|
AC_DEFINE(HAVE_LOG10L)
|
|
AC_DEFINE(HAVE_SINF)
|
|
AC_DEFINE(HAVE_SINL)
|
|
AC_DEFINE(HAVE_SINHF)
|
|
AC_DEFINE(HAVE_SINHL)
|
|
;;
|
|
*-tpf)
|
|
SECTION_FLAGS='-ffunction-sections -fdata-sections'
|
|
SECTION_LDFLAGS='-Wl,--gc-sections $SECTION_LDFLAGS'
|
|
AC_SUBST(SECTION_FLAGS)
|
|
AC_DEFINE(HAVE_FINITE)
|
|
AC_DEFINE(HAVE_FINITEF)
|
|
AC_DEFINE(HAVE_FREXPF)
|
|
AC_DEFINE(HAVE_HYPOTF)
|
|
AC_DEFINE(HAVE_ISINF)
|
|
AC_DEFINE(HAVE_ISINFF)
|
|
AC_DEFINE(HAVE_ISNAN)
|
|
AC_DEFINE(HAVE_ISNANF)
|
|
AC_DEFINE(HAVE_SINCOS)
|
|
AC_DEFINE(HAVE_SINCOSF)
|
|
if test x"long_double_math_on_this_cpu" = x"yes"; then
|
|
AC_DEFINE(HAVE_FINITEL)
|
|
AC_DEFINE(HAVE_HYPOTL)
|
|
AC_DEFINE(HAVE_ISINFL)
|
|
AC_DEFINE(HAVE_ISNANL)
|
|
fi
|
|
;;
|
|
*-*vms*)
|
|
# Check for available headers.
|
|
# Don't call GLIBCXX_CHECK_LINKER_FEATURES, VMS doesn't have a GNU ld
|
|
GLIBCXX_CHECK_MATH_SUPPORT
|
|
GLIBCXX_CHECK_STDLIB_SUPPORT
|
|
;;
|
|
*-vxworks*)
|
|
AC_DEFINE(HAVE_ACOSF)
|
|
AC_DEFINE(HAVE_ASINF)
|
|
AC_DEFINE(HAVE_ATAN2F)
|
|
AC_DEFINE(HAVE_ATANF)
|
|
AC_DEFINE(HAVE_CEILF)
|
|
AC_DEFINE(HAVE_COSF)
|
|
AC_DEFINE(HAVE_COSHF)
|
|
AC_DEFINE(HAVE_EXPF)
|
|
AC_DEFINE(HAVE_FABSF)
|
|
AC_DEFINE(HAVE_FLOORF)
|
|
AC_DEFINE(HAVE_FMODF)
|
|
AC_DEFINE(HAVE_HYPOT)
|
|
AC_DEFINE(HAVE_LOG10F)
|
|
AC_DEFINE(HAVE_LOGF)
|
|
AC_DEFINE(HAVE_POWF)
|
|
AC_DEFINE(HAVE_SINF)
|
|
AC_DEFINE(HAVE_SINHF)
|
|
AC_DEFINE(HAVE_SQRTF)
|
|
AC_DEFINE(HAVE_TANF)
|
|
AC_DEFINE(HAVE_TANHF)
|
|
|
|
dnl # Different versions and execution modes implement different
|
|
dnl # subsets of these functions. Instead of hard-coding, test for C
|
|
dnl # declarations in headers. The C primitives could be defined as
|
|
dnl # macros, in which case the tests might fail, and we might have to
|
|
dnl # switch to more elaborate tests.
|
|
GLIBCXX_CHECK_MATH_DECLS([
|
|
acosl asinl atan2l atanl ceill cosl coshl expl fabsl floorl fmodl
|
|
frexpl ldexpl log10l logl modfl powl sinl sinhl sqrtl tanl tanhl hypotl
|
|
ldexpf modff hypotf frexpf])
|
|
dnl # sincosl is the only one missing here, compared with the *l
|
|
dnl # functions in the list guarded by
|
|
dnl # long_double_math_on_this_cpu in configure.ac, right after
|
|
dnl # the expansion of the present macro.
|
|
;;
|
|
*)
|
|
AC_MSG_ERROR([No support for this host/target combination.])
|
|
;;
|
|
esac
|
|
])
|
|
|
|
|
|
dnl
|
|
dnl Check to see if the (math function) argument passed is
|
|
dnl declared when using the c compiler
|
|
dnl
|
|
dnl Define HAVE_CARGF etc if "cargf" is declared
|
|
dnl
|
|
dnl argument 1 is name of function to check
|
|
dnl
|
|
dnl ASSUMES argument is a math function
|
|
dnl
|
|
dnl GLIBCXX_CHECK_MATH_DECL
|
|
AC_DEFUN([GLIBCXX_CHECK_MATH_DECL], [
|
|
AC_CACHE_CHECK([for $1 declaration],
|
|
[glibcxx_cv_func_$1_use], [
|
|
AC_LANG_SAVE
|
|
AC_LANG_C
|
|
AC_TRY_COMPILE([
|
|
#include <math.h>
|
|
#ifdef HAVE_IEEEFP_H
|
|
# include <ieeefp.h>
|
|
#endif
|
|
#undef $1
|
|
], [
|
|
void (*f)(void) = (void (*)(void))$1;
|
|
], [glibcxx_cv_func_$1_use=yes
|
|
], [glibcxx_cv_func_$1_use=no])])
|
|
if test "x$glibcxx_cv_func_$1_use" = xyes; then
|
|
AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_$1]))
|
|
fi
|
|
])
|
|
|
|
dnl
|
|
dnl Check to see whether multiple math functions are
|
|
dnl declared when using the c compiler
|
|
dnl
|
|
dnl Define HAVE_CARGF HAVE_POWL etc if "cargf" and "powl"
|
|
dnl are declared
|
|
dnl
|
|
dnl argument 1 is a word list naming function to check
|
|
dnl
|
|
dnl ASSUMES arguments are math functions
|
|
dnl
|
|
dnl GLIBCXX_CHECK_MATH_DECLS
|
|
AC_DEFUN([GLIBCXX_CHECK_MATH_DECLS], [
|
|
m4_foreach_w([glibcxx_func], [$1], [
|
|
GLIBCXX_CHECK_MATH_DECL(glibcxx_func)
|
|
])
|
|
])
|