summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <[email protected]>2024-07-04 16:15:00 -0400
committerPeter Zhu <[email protected]>2024-07-05 14:05:58 -0400
commite2ceded2c603f5f35df5c0d8757a48a1fa1f0f8f ()
tree9df2ffda20649762720b7ac67edb4ae7fd299592
parent8fd2df529b8c9a172604c5cde478abe54c30b47d (diff)
Change external GC to use directory at configure
This commit changes the external GC API to use `--with-shared-gc=DIR` at configure time with a directory of the external GC and uses `RUBY_GC_LIBRARY` environment variable to load the external GC at runtime.
-rw-r--r--configure.ac2
-rw-r--r--gc.c35
-rw-r--r--tool/m4/ruby_shared_gc.m429
3 files changed, 54 insertions, 12 deletions
@@ -4751,7 +4751,7 @@ config_summary "target OS" "$target_os"
config_summary "compiler" "$CC"
config_summary "with thread" "$THREAD_MODEL"
config_summary "with coroutine" "$coroutine_type"
-config_summary "with shared GC" "$with_shared_gc"
config_summary "enable shared libs" "$ENABLE_SHARED"
config_summary "dynamic library ext" "$DLEXT"
config_summary "CFLAGS" "$cflags"
@@ -748,14 +748,39 @@ typedef struct gc_function_map {
static rb_gc_function_map_t rb_gc_functions;
-# define RUBY_GC_LIBRARY_PATH "RUBY_GC_LIBRARY_PATH"
static void
ruby_external_gc_init(void)
{
- char *gc_so_path = getenv(RUBY_GC_LIBRARY_PATH);
void *handle = NULL;
- if (gc_so_path && dln_supported_p()) {
char error[1024];
handle = dln_open(gc_so_path, error, sizeof(error));
if (!handle) {
@@ -4625,8 +4650,8 @@ void
Init_GC(void)
{
#if USE_SHARED_GC
- if (getenv(RUBY_GC_LIBRARY_PATH) != NULL && !dln_supported_p()) {
- rb_warn(RUBY_GC_LIBRARY_PATH " is ignored because this executable file can't load extension libraries");
}
#endif
@@ -1,19 +1,36 @@
dnl -*- Autoconf -*-
AC_DEFUN([RUBY_SHARED_GC],[
AC_ARG_WITH(shared-gc,
- AS_HELP_STRING([--with-shared-gc],
- [Enable replacement of Ruby's GC from a shared library.]),
- [with_shared_gc=$withval], [unset with_shared_gc]
)
-AC_SUBST([with_shared_gc])
AC_MSG_CHECKING([if Ruby is build with shared GC support])
-AS_IF([test "$with_shared_gc" = "yes"], [
AC_MSG_RESULT([yes])
AC_DEFINE([USE_SHARED_GC], [1])
], [
AC_MSG_RESULT([no])
- with_shared_gc="no"
AC_DEFINE([USE_SHARED_GC], [0])
])
])dnl