Improve RUBY_GC_LIBRARY
Instead of passing the full GC SO file name to RUBY_GC_LIBRARY, we now only need to pass the GC name. For example, before we needed to pass `RUBY_GC_LIBRARY=librubygc.default.so` but now we only need to pass `RUBY_GC_LIBRARY=default`.
This commit is contained in:
parent
047a7750d1
commit
d641b7d172
Notes:
git
2024-10-11 12:56:55 +00:00
2
.github/workflows/ubuntu.yml
vendored
2
.github/workflows/ubuntu.yml
vendored
@ -99,7 +99,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Build shared GC
|
- name: Build shared GC
|
||||||
run: |
|
run: |
|
||||||
echo "RUBY_GC_LIBRARY=librubygc.default.so" >> $GITHUB_ENV
|
echo "RUBY_GC_LIBRARY=default" >> $GITHUB_ENV
|
||||||
make shared-gc SHARED_GC=default
|
make shared-gc SHARED_GC=default
|
||||||
if: ${{ matrix.shared_gc }}
|
if: ${{ matrix.shared_gc }}
|
||||||
|
|
||||||
|
@ -3403,6 +3403,8 @@ AC_DEFINE_UNQUOTED(DLEXT_MAXLEN, `expr $len + 1`)
|
|||||||
test ".$DLEXT" = "." || AC_DEFINE_UNQUOTED(DLEXT, ".$DLEXT")
|
test ".$DLEXT" = "." || AC_DEFINE_UNQUOTED(DLEXT, ".$DLEXT")
|
||||||
AC_SUBST(DLEXT)
|
AC_SUBST(DLEXT)
|
||||||
|
|
||||||
|
AC_DEFINE_UNQUOTED(SOEXT, ".$SOEXT")
|
||||||
|
|
||||||
: "strip" && {
|
: "strip" && {
|
||||||
AC_MSG_CHECKING([for $STRIP flags])
|
AC_MSG_CHECKING([for $STRIP flags])
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM], [AS_IF(
|
AC_LINK_IFELSE([AC_LANG_PROGRAM], [AS_IF(
|
||||||
|
22
gc.c
22
gc.c
@ -659,7 +659,7 @@ ruby_external_gc_init(void)
|
|||||||
char *gc_so_path = NULL;
|
char *gc_so_path = NULL;
|
||||||
void *handle = NULL;
|
void *handle = NULL;
|
||||||
if (gc_so_file) {
|
if (gc_so_file) {
|
||||||
/* Check to make sure that gc_so_file matches /[\w-_.]+/ so that it does
|
/* Check to make sure that gc_so_file matches /[\w-_]+/ so that it does
|
||||||
* not load a shared object outside of the directory. */
|
* not load a shared object outside of the directory. */
|
||||||
for (size_t i = 0; i < strlen(gc_so_file); i++) {
|
for (size_t i = 0; i < strlen(gc_so_file); i++) {
|
||||||
char c = gc_so_file[i];
|
char c = gc_so_file[i];
|
||||||
@ -667,17 +667,27 @@ ruby_external_gc_init(void)
|
|||||||
switch (c) {
|
switch (c) {
|
||||||
case '-':
|
case '-':
|
||||||
case '_':
|
case '_':
|
||||||
case '.':
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Only alphanumeric, dash, underscore, and period is allowed in "RUBY_GC_LIBRARY"\n");
|
fprintf(stderr, "Only alphanumeric, dash, and underscore is allowed in "RUBY_GC_LIBRARY"\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
gc_so_path = alloca(strlen(SHARED_GC_DIR) + strlen(gc_so_file) + 1);
|
size_t gc_so_path_size = strlen(SHARED_GC_DIR "librubygc." SOEXT) + strlen(gc_so_file) + 1;
|
||||||
strcpy(gc_so_path, SHARED_GC_DIR);
|
gc_so_path = alloca(gc_so_path_size);
|
||||||
strcpy(gc_so_path + strlen(SHARED_GC_DIR), gc_so_file);
|
{
|
||||||
|
size_t gc_so_path_idx = 0;
|
||||||
|
#define GC_SO_PATH_APPEND(str) do { \
|
||||||
|
gc_so_path_idx += strlcpy(gc_so_path + gc_so_path_idx, str, gc_so_path_size - gc_so_path_idx); \
|
||||||
|
} while (0)
|
||||||
|
GC_SO_PATH_APPEND(SHARED_GC_DIR);
|
||||||
|
GC_SO_PATH_APPEND("librubygc.");
|
||||||
|
GC_SO_PATH_APPEND(gc_so_file);
|
||||||
|
GC_SO_PATH_APPEND(SOEXT);
|
||||||
|
GC_ASSERT(gc_so_path_idx == gc_so_path_size - 1);
|
||||||
|
#undef GC_SO_PATH_APPEND
|
||||||
|
}
|
||||||
|
|
||||||
handle = dlopen(gc_so_path, RTLD_LAZY | RTLD_GLOBAL);
|
handle = dlopen(gc_so_path, RTLD_LAZY | RTLD_GLOBAL);
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user