@@ -19,7 +19,6 @@ def build(executor, options)
1919 def build_strategy
2020 @build_strategy ||=
2121 begin
22- has_exts = @packager . specs . any? { |spec | spec . extensions . any? }
2322 if @packager . features . support_dynamic_linking?
2423 DynamicLinking . new ( @packager )
2524 else
@@ -59,14 +58,6 @@ def specs_with_extensions
5958 end
6059 end
6160
62- def wasi_exec_model
63- # TODO: Detect WASI exec-model from binary exports (_start or _initialize)
64- use_js_gem = @packager . specs . any? do |spec |
65- spec . name == "js"
66- end
67- use_js_gem ? "reactor" : "command"
68- end
69-
7061 def with_unbundled_env ( &block )
7162 __skip__ = if defined? ( Bundler )
7263 Bundler . with_unbundled_env ( &block )
@@ -138,12 +129,16 @@ def _link_gem_exts(executor, build, ruby_root, gem_home, module_bytes)
138129 wasi_sdk_path = toolchain . wasi_sdk_path
139130 libraries << File . join ( wasi_sdk_path , "share/wasi-sysroot/lib/wasm32-wasi" , lib )
140131 end
141- wasi_adapter = RubyWasm ::Packager ::ComponentAdapter . wasi_snapshot_preview1 ( wasi_exec_model )
142- adapters = [ wasi_adapter ]
143132 dl_openable_libs = [ ]
144133 dl_openable_libs << [ File . dirname ( ruby_root ) , Dir . glob ( File . join ( ruby_root , "lib" , "ruby" , "**" , "*.so" ) ) ]
145134 dl_openable_libs << [ gem_home , Dir . glob ( File . join ( gem_home , "**" , "*.so" ) ) ]
146135
136+ has_js_so = dl_openable_libs . any? do |root , libs |
137+ libs . any? { |lib | lib . end_with? ( "/js.so" ) }
138+ end
139+ wasi_adapter = RubyWasm ::Packager ::ComponentAdapter . wasi_snapshot_preview1 ( has_js_so ? "reactor" : "command" )
140+ adapters = [ wasi_adapter ]
141+
147142 linker = RubyWasmExt ::ComponentLink . new
148143 linker . use_built_in_libdl ( true )
149144 linker . stub_missing_functions ( false )
@@ -198,6 +193,8 @@ def _build_gem_exts(executor, build, gem_home)
198193 "BUNDLE_APP_CONFIG" => File . join ( ".bundle" , target_triplet ) ,
199194 "BUNDLE_PATH" => local_path ,
200195 "BUNDLE_WITHOUT" => "build" ,
196+ # Do not auto-switch bundler version by Gemfile.lock
197+ "BUNDLE_VERSION" => "system" ,
201198 # FIXME: BUNDLE_PATH is set as a installation destination here, but
202199 # it is also used as a source of gems to be loaded by RubyGems itself.
203200 # RubyGems loads "psych" gem and if Gemfile includes "psych" gem,
@@ -347,6 +344,14 @@ def build_gem_exts(executor, gem_home)
347344 # No-op because we already built extensions as part of the Ruby build
348345 end
349346
347+ def wasi_exec_model
348+ # TODO: Detect WASI exec-model from binary exports (_start or _initialize)
349+ use_js_gem = @packager . specs . any? do |spec |
350+ spec . name == "js"
351+ end
352+ use_js_gem ? "reactor" : "command"
353+ end
354+
350355 def link_gem_exts ( executor , ruby_root , gem_home , module_bytes )
351356 return module_bytes unless @packager . features . support_component_model?
352357
0 commit comments