Enable GC loading from a shared library #10456
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR replaces #10302 as a method for dynamically loading a shared GC library. This new approach has been guided by feedback from @kateinoigakukun and @nobu
The approach taken here is as follows:
--with-shared-gc
RUBY_GC_LIBRARY_PATH
dln_open
), and map theInit_GC
function to a function mapInit_GC
as part ofrb_objspace_alloc
when initialising the GCWhen Ruby is configured without the
--with-shared-gc
flag, no extra code is compiled and so existing behaviour is maintained without any performance penalty.Enabling this feature, but not populating
RUBY_GC_LIBRARY_PATH
will incur a small performance penalty due to the overhead of usinggetenv
to check for the environment variable.The use of
dln.c
rather than usingdlopen
directly, should enable this feature to be supported on all platforms that support loading shared libraries, rather than the initial implementation, which explicitly only supported Linux and MacOS.