summaryrefslogtreecommitdiff
path: root/vm_core.h
diff options
context:
space:
mode:
authorAlan Wu <XrXr@users.noreply.github.com>2022-11-17 17:33:18 -0500
committerAlan Wu <XrXr@users.noreply.github.com>2022-11-25 16:21:40 -0500
commit790cf4b6d0475614afb127b416e87cfa39044d67 (patch)
treed04089ae209b4c3b27b6ab68097a6065d3583520 /vm_core.h
parente15cd01149afe4924460f81cb6e27dd96de06657 (diff)
downloadruby-790cf4b6d0475614afb127b416e87cfa39044d67.tar.gz
Fix autoload status of statically linked extensions
Previously, for statically-linked extensions, we used `vm->loading_table` to delay calling the init function until the extensions are required. This caused the extensions to look like they are in the middle of being loaded even before they're required. (`rb_feature_p()` returned true with a loading path output.) Combined with autoload, queries like `defined?(CONST)` and `Module#autoload?` were confused by this and returned nil incorrectly. RubyGems uses `defined?` to detect if OpenSSL is available and failed when OpenSSL was available in builds using `--with-static-linked-ext`. Use a dedicated table for the init functions instead of adding them to the loading table. This lets us remove some logic from non-EXTSTATIC builds. [Bug #19115]
Diffstat (limited to 'vm_core.h')
-rw-r--r--vm_core.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/vm_core.h b/vm_core.h
index 9c016de8fd..b3613367a6 100644
--- a/vm_core.h
+++ b/vm_core.h
@@ -538,6 +538,10 @@ struct rb_iseq_struct {
#define ISEQ_BODY(iseq) ((iseq)->body)
+#ifndef EXTSTATIC
+#define EXTSTATIC 0
+#endif
+
#ifndef USE_LAZY_LOAD
#define USE_LAZY_LOAD 0
#endif
@@ -704,6 +708,11 @@ typedef struct rb_vm_struct {
VALUE loaded_features_realpaths;
struct st_table *loaded_features_index;
struct st_table *loading_table;
+#if EXTSTATIC
+ // For running the init function of statically linked
+ // extensions when they are loaded
+ struct st_table *static_ext_inits;
+#endif
/* signal */
struct {