From 3efd0bc4e443132653d42aca1a80b22b14930dd8 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Thu, 7 Nov 2019 11:30:58 +0300 Subject: Build gctba library Issue #268 (bdgwc). The library exports only GC_throw_bad_alloc C++ function. It is intended to solve "undefined reference to GC_throw_bad_alloc" linkage error when the client needs to avoid linking with gccpp library (to avoid "::new" redirection, in turn). * CMakeLists.txt (enable_throw_bad_alloc_library): New option (ON by default). * CMakeLists.txt [enable_cplusplus && enable_throw_bad_alloc_library] (gctba): New library. * Makefile.am [CPLUSPLUS && GC_TBA_LIBRARY] (lib_LTLIBRARIES): Add libgctba.la item. * Makefile.am [CPLUSPLUS && GC_TBA_LIBRARY] (libgctba_la_SOURCES, libgctba_la_LIBADD, libgctba_la_LDFLAGS): New variable. * Makefile.direct: Update head comment (mention gctba.a). * Makefile.direct (bsd-libgctba.a, gctba.a): New target. * NT_MAKEFILE (gctba.lib): Likewise. * WCC_MAKEFILE (gctba.lib): Likewise. * WCC_MAKEFILE [!ENABLE_STATIC] (gctba.dll): Likewise. * Makefile.direct (bsd-libgc.a): Move gctba.a to bsd-libgctba.a. * Makefile.direct (BSD-pkg-install): Copy bsd-libgctba.a; install libgctba.a. * Makefile.direct (c++): Add dependency on gc_badalc.o; call rus, $(AR) and $(RANLIB) for gctba.a. * NT_MAKEFILE (all): Add dependency on gctba.lib. * WCC_MAKEFILE (all): Likewise. * README.QUICK: Update information about "make c++" (reference libgctba.a, libgctba.so and doc/gcinterface.md). * configure.ac (throw-bad-alloc-library): Specify new AC_ARG_ENABLE. * configure.ac (GC_TBA_LIBRARY): New AM_CONDITIONAL. * doc/gcinterface.md (Class inheritance based interface): Add information about libgctba library; document GC_NEW_ABORTS_ON_OOM and GC_INCLUDE_NEW macros. --- doc/gcinterface.md | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'doc') diff --git a/doc/gcinterface.md b/doc/gcinterface.md index cf648cc4..e21efbc9 100644 --- a/doc/gcinterface.md +++ b/doc/gcinterface.md @@ -209,6 +209,15 @@ Linking against `libgccpp` in addition to the `gc` library overrides `::new` (and friends) to allocate traceable but uncollectible memory, making it safe to refer to collectible objects from the resulting memory. +If the user includes `gc_cpp.h` but `::new` should not be overridden then +`libgctba` (in addition to the `gc`) library should be linked with to provide +the definition of `GC_throw_bad_alloc` C++ function used by operator `new` of +class `gc`. Alternatively, the client may define `GC_NEW_ABORTS_ON_OOM` macro +before include of `gc_cpp.h` (this instructs `::new` to issue an abort instead +of throwing an exception), or may define `GC_INCLUDE_NEW` one before include +of `gc_cpp.h` (however, this might not compile or work as expected on some +platforms). + ## C interface It is also possible to use the C interface from `gc.h` directly. On platforms -- cgit v1.2.1