@@ -41,7 +41,7 @@ def build_gem_exts(executor, gem_home)
4141 raise NotImplementedError
4242 end
4343
44- def link_gem_exts ( executor , gem_home , module_bytes )
44+ def link_gem_exts ( executor , ruby_root , gem_home , module_bytes )
4545 raise NotImplementedError
4646 end
4747
@@ -110,15 +110,13 @@ def build_gem_exts(executor, gem_home)
110110 self . _build_gem_exts ( executor , build , gem_home )
111111 end
112112
113- def link_gem_exts ( executor , gem_home , module_bytes )
113+ def link_gem_exts ( executor , ruby_root , gem_home , module_bytes )
114114 build = derive_build
115- self . _link_gem_exts ( executor , build , gem_home )
115+ self . _link_gem_exts ( executor , build , ruby_root , gem_home , module_bytes )
116116 end
117117
118- def _link_gem_exts ( executor , build , gem_home )
119- ruby_root = build . crossruby . dest_dir
120-
121- libraries = [ File . join ( ruby_root , "usr" , "local" , "bin" , "ruby" ) ]
118+ def _link_gem_exts ( executor , build , ruby_root , gem_home , module_bytes )
119+ libraries = [ ]
122120
123121 # TODO: Should be computed from dyinfo of ruby binary
124122 wasi_libc_shared_libs = [
@@ -138,14 +136,16 @@ def _link_gem_exts(executor, build, gem_home)
138136 wasi_adapter = RubyWasm ::Packager ::ComponentAdapter . wasi_snapshot_preview1 ( wasi_exec_model )
139137 adapters = [ wasi_adapter ]
140138 dl_openable_libs = [ ]
141- dl_openable_libs << [ File . join ( ruby_root , "usr" ) , Dir . glob ( File . join ( ruby_root , "usr" , "local" , "lib" , "ruby" , "**" , "*.so" ) ) ]
139+ dl_openable_libs << [ File . dirname ( ruby_root ) , Dir . glob ( File . join ( ruby_root , "lib" , "ruby" , "**" , "*.so" ) ) ]
142140 dl_openable_libs << [ gem_home , Dir . glob ( File . join ( gem_home , "**" , "*.so" ) ) ]
143141
144142 linker = RubyWasmExt ::ComponentLink . new
145143 linker . use_built_in_libdl ( true )
146144 linker . stub_missing_functions ( false )
147145 linker . validate ( ENV [ "RUBYWASM_SKIP_LINKER_VALIDATION" ] != "1" )
148146
147+ linker . library ( "ruby" , module_bytes , false )
148+
149149 libraries . each do |lib |
150150 # Non-DL openable libraries should be referenced as base name
151151 lib_name = File . basename ( lib )
@@ -333,7 +333,7 @@ def build_gem_exts(executor, gem_home)
333333 # No-op because we already built extensions as part of the Ruby build
334334 end
335335
336- def link_gem_exts ( executor , gem_home , module_bytes )
336+ def link_gem_exts ( executor , ruby_root , gem_home , module_bytes )
337337 return module_bytes unless @packager . features . support_component_model?
338338
339339 linker = RubyWasmExt ::ComponentEncode . new
0 commit comments