ruby_wasm 2.5.2-arm64-darwin → 2.6.1-arm64-darwin

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 0bc9bf417e81232b7ad9cc364ac5f43198922e4daf28c1f033c340c4a49930c2
4
- data.tar.gz: bdda5e2d30ef54b607c596fe62a067bc52033954dc96721a060ce73f8e16f3e8
3
+ metadata.gz: c51811bf667dbcd9db52fa7e46d19c97f38f9e3564fd6171e7ce5e5560a799ab
4
+ data.tar.gz: dad2dfe190bc5d95745a3a2b10847f6ad939a4ed6adba5b16b3c1966e762d00c
5
5
  SHA512:
6
- metadata.gz: 1ce149c253ad849a6cffa1dfde843fd254d8930cf1082ff53ddd1056022acff6176156539c1126ccf3ade4fc8a8b1b72d1cb31e7e7fe132f2cfd443c7c8c31cb
7
- data.tar.gz: 4cad8ce6d5e581baaa25247723389308bb479841421745f68d13884ce17e5f95f42bbb281c52915312599100e6bc7ac8cc009d00b8ed6e4d49afe376931c5da0
6
+ metadata.gz: 0b837b64bf0606ca18558345f6f02f3c0bf6375fc91d009e490b28dd7ccf7f15c1819de5b496a79daf0615b1127c393e8b0c3eaa3d3887999aaa108c0a75afaa
7
+ data.tar.gz: 9189ea18fffc8117a96581b6aac90e0ba731f1572c32fcd214f14911f159b58f45d6d0a7c8857d7912f5cbcf40f2a0ef446f7462df7b4ebe6ae08a6da4f81efa
data/CONTRIBUTING.md CHANGED
@@ -6,9 +6,11 @@ This document describes development setup and pointers for diving into this proj
6
6
  ## Install dependencies
7
7
 
8
8
  ```console
9
- $ git clone https://github.com/ruby/ruby.wasm
9
+ $ git clone https://github.com/ruby/ruby.wasm --recursive
10
10
  $ cd ruby.wasm
11
11
  $ ./bin/setup
12
+ # Just for building vendor/jco (will be removed soon)
13
+ $ rustup target add wasm32-wasi
12
14
  # Compile extension library
13
15
  $ bundle exec rake compile
14
16
  $ rake --tasks
@@ -110,7 +112,8 @@ $ git commit -m"Bump version to 0.6.0"
110
112
  $ git tag 0.6.0
111
113
  $ git push origin 0.6.0
112
114
  $ for pkg in pkg/ruby_wasm-*; do gem push $pkg; done
113
- $ (cd packages/gems/js/ && gem build && gem push js-*.gem)
115
+ $ gem build && gem push ruby_wasm-*.gem && rm ruby_wasm-*.gem
116
+ $ (cd packages/gems/js/ && gem build && gem push js-*.gem && rm js-*.gem)
114
117
  ```
115
118
 
116
119
  ## Release Channels
@@ -124,5 +127,5 @@ $ npm install --save @ruby/wasm-wasi@latest
124
127
  # or if you want the nightly snapshot
125
128
  $ npm install --save @ruby/wasm-wasi@next
126
129
  # or you can specify the exact snapshot version
127
- $ npm install --save @ruby/wasm-wasi@2.5.2-2024-05-04-a
130
+ $ npm install --save @ruby/wasm-wasi@2.6.1-2024-05-22-a
128
131
  ```
data/README.md CHANGED
@@ -23,7 +23,7 @@ Create and save `index.html` page with the following contents:
23
23
 
24
24
  ```html
25
25
  <html>
26
- <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/browser.script.iife.js"></script>
26
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/browser.script.iife.js"></script>
27
27
  <script type="text/ruby">
28
28
  require "js"
29
29
 
data/docs/cheat_sheet.md CHANGED
@@ -38,7 +38,7 @@ The easiest way to run Ruby on browser is to use `browser.script.iife.js` script
38
38
 
39
39
  ```html
40
40
  <html>
41
- <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/browser.script.iife.js"></script>
41
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/browser.script.iife.js"></script>
42
42
  <script type="text/ruby">
43
43
  require "js"
44
44
  JS.global[:document].write "Hello, world!"
@@ -51,8 +51,8 @@ If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` pa
51
51
  ```html
52
52
  <html>
53
53
  <script type="module">
54
- import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.5.2/dist/browser/+esm";
55
- const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/ruby+stdlib.wasm");
54
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.1/dist/browser/+esm";
55
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/ruby+stdlib.wasm");
56
56
  const module = await WebAssembly.compileStreaming(response);
57
57
  const { vm } = await DefaultRubyVM(module);
58
58
 
@@ -69,11 +69,11 @@ If you want to control Ruby VM from JavaScript, you can use `@ruby/wasm-wasi` pa
69
69
 
70
70
  ```html
71
71
  <html>
72
- <script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.5.2/dist/browser.umd.js"></script>
72
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.1/dist/browser.umd.js"></script>
73
73
  <script>
74
74
  const main = async () => {
75
75
  const { DefaultRubyVM } = window["ruby-wasm-wasi"];
76
- const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/ruby+stdlib.wasm");
76
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/ruby+stdlib.wasm");
77
77
  const module = await WebAssembly.compileStreaming(response);
78
78
  const { vm } = await DefaultRubyVM(module);
79
79
 
@@ -128,7 +128,7 @@ end
128
128
 
129
129
  ```html
130
130
  <html>
131
- <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/browser.script.iife.js"></script>
131
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/browser.script.iife.js"></script>
132
132
  <script type="text/ruby" data-eval="async">
133
133
  require "js"
134
134
 
@@ -143,8 +143,8 @@ Or using `@ruby/wasm-wasi` package API `RubyVM#evalAsync`:
143
143
  ```html
144
144
  <html>
145
145
  <script type="module">
146
- import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.5.2/dist/browser/+esm";
147
- const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.5.2/dist/ruby+stdlib.wasm");
146
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.1/dist/browser/+esm";
147
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.1/dist/ruby+stdlib.wasm");
148
148
  const module = await WebAssembly.compileStreaming(response);
149
149
  const { vm } = await DefaultRubyVM(module);
150
150
 
@@ -0,0 +1,3 @@
1
+ ## Extension library for `ruby_wasm` gem
2
+
3
+ This library exposes WebAssembly tools and utilities from Rust ecosystem as Ruby API.
Binary file
Binary file
Binary file
@@ -34,6 +34,7 @@ module RubyWasm
34
34
  def make_args(crossruby)
35
35
  make_args = []
36
36
  make_args << "CC=#{@toolchain.cc}"
37
+ make_args << "CXX=#{@toolchain.cc}"
37
38
  make_args << "LD=#{@toolchain.ld}"
38
39
  make_args << "AR=#{@toolchain.ar}"
39
40
  make_args << "RANLIB=#{@toolchain.ranlib}"
@@ -41,7 +42,7 @@ module RubyWasm
41
42
  make_args
42
43
  end
43
44
 
44
- def build(executor, crossruby)
45
+ def build(executor, crossruby, extra_mkargs = [])
45
46
  objdir = product_build_dir crossruby
46
47
  executor.mkdir_p objdir
47
48
  do_extconf executor, crossruby
@@ -53,7 +54,8 @@ module RubyWasm
53
54
  "-C",
54
55
  "#{objdir}",
55
56
  *make_args(crossruby),
56
- build_target
57
+ build_target,
58
+ *extra_mkargs
57
59
  # A ext can provide link args by link.filelist. It contains only built archive file by default.
58
60
  unless File.exist?(linklist(crossruby))
59
61
  executor.write(
@@ -186,7 +188,7 @@ module RubyWasm
186
188
  def build_exts(executor)
187
189
  @user_exts.each do |prod|
188
190
  executor.begin_section prod.class, prod.name, "Building"
189
- prod.build(executor, self)
191
+ prod.build(executor, self, [])
190
192
  executor.end_section prod.class, prod.name
191
193
  end
192
194
  end
@@ -297,8 +299,7 @@ module RubyWasm
297
299
  end
298
300
 
299
301
  def extinit_c_erb
300
- lib_root = File.expand_path("../../../../..", __FILE__)
301
- File.join(lib_root, "ext", "extinit.c.erb")
302
+ File.expand_path("../crossruby/extinit.c.erb", __FILE__)
302
303
  end
303
304
 
304
305
  def baseruby_path
@@ -26,6 +26,7 @@ module RubyWasm
26
26
  def tools_args
27
27
  args = []
28
28
  args << "CC=#{@toolchain.cc}"
29
+ args << "CXX=#{@toolchain.cxx}"
29
30
  args << "LD=#{@toolchain.ld}"
30
31
  args << "AR=#{@toolchain.ar}"
31
32
  args << "RANLIB=#{@toolchain.ranlib}"
@@ -4,7 +4,7 @@ module RubyWasm
4
4
 
5
5
  def initialize(
6
6
  build_dir:,
7
- revision: "v0.24.0"
7
+ revision: "67e17745a417d07852cc283d1399d210d4d659cc"
8
8
  )
9
9
  @build_dir = build_dir
10
10
  @tool_dir = File.join(@build_dir, "toolchain", "wit-bindgen-#{revision}")
@@ -43,7 +43,7 @@ module RubyWasm
43
43
  tool
44
44
  end
45
45
 
46
- %i[cc ranlib ld ar].each do |name|
46
+ %i[cc cxx ranlib ld ar].each do |name|
47
47
  define_method(name) do
48
48
  @tools_cache ||= {}
49
49
  @tools_cache[name] ||= find_tool(name)
@@ -84,6 +84,7 @@ module RubyWasm
84
84
 
85
85
  @tools = {
86
86
  cc: "#{wasi_sdk_path}/bin/clang",
87
+ cxx: "#{wasi_sdk_path}/bin/clang++",
87
88
  ld: "#{wasi_sdk_path}/bin/clang",
88
89
  ar: "#{wasi_sdk_path}/bin/llvm-ar",
89
90
  ranlib: "#{wasi_sdk_path}/bin/llvm-ranlib"
@@ -178,7 +179,7 @@ module RubyWasm
178
179
 
179
180
  class Emscripten < Toolchain
180
181
  def initialize
181
- @tools = { cc: "emcc", ld: "emcc", ar: "emar", ranlib: "emranlib" }
182
+ @tools = { cc: "emcc", cxx: "em++", ld: "emcc", ar: "emar", ranlib: "emranlib" }
182
183
  @name = "emscripten"
183
184
  end
184
185
 
data/lib/ruby_wasm/cli.rb CHANGED
@@ -53,6 +53,8 @@ module RubyWasm
53
53
  target_triplet: "wasm32-unknown-wasip1",
54
54
  profile: "full",
55
55
  stdlib: true,
56
+ without_stdlib_components: [],
57
+ dest_dir: nil,
56
58
  disable_gems: false,
57
59
  gemfile: nil,
58
60
  patches: [],
@@ -104,10 +106,18 @@ module RubyWasm
104
106
  options[:stdlib] = stdlib
105
107
  end
106
108
 
109
+ opts.on("--without-stdlib COMPONENT", "Exclude stdlib component") do |component|
110
+ options[:without_stdlib_components] << component
111
+ end
112
+
107
113
  opts.on("--disable-gems", "Disable gems") do
108
114
  options[:disable_gems] = true
109
115
  end
110
116
 
117
+ opts.on("--dest-dir PATH", "(Experimental) Destination directory") do |path|
118
+ options[:dest_dir] = path
119
+ end
120
+
111
121
  opts.on("-p", "--patch PATCH", "Apply a patch") do |patch|
112
122
  options[:patches] << patch
113
123
  end
@@ -149,7 +159,9 @@ module RubyWasm
149
159
 
150
160
  require "tmpdir"
151
161
 
152
- if options[:save_temps]
162
+ if dest_dir = options[:dest_dir]
163
+ self.do_build(executor, dest_dir, packager, options)
164
+ elsif options[:save_temps]
153
165
  tmpdir = Dir.mktmpdir
154
166
  self.do_build(executor, tmpdir, packager, options)
155
167
  @stderr.puts "Temporary files are saved to #{tmpdir}"
@@ -12,7 +12,7 @@ class RubyWasm::Packager::Core
12
12
 
13
13
  extend Forwardable
14
14
 
15
- def_delegators :build_strategy, :cache_key, :artifact, :build_and_link_exts
15
+ def_delegators :build_strategy, :cache_key, :artifact, :build_gem_exts, :link_gem_exts
16
16
 
17
17
  private
18
18
 
@@ -37,7 +37,11 @@ class RubyWasm::Packager::Core
37
37
  raise NotImplementedError
38
38
  end
39
39
 
40
- def build_and_link_exts(executor, module_bytes)
40
+ def build_gem_exts(executor, gem_home)
41
+ raise NotImplementedError
42
+ end
43
+
44
+ def link_gem_exts(executor, ruby_root, gem_home, module_bytes)
41
45
  raise NotImplementedError
42
46
  end
43
47
 
@@ -55,6 +59,14 @@ class RubyWasm::Packager::Core
55
59
  end
56
60
  end
57
61
 
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
+
58
70
  def cache_key(digest)
59
71
  raise NotImplementedError
60
72
  end
@@ -93,20 +105,24 @@ class RubyWasm::Packager::Core
93
105
  build.crossruby.artifact
94
106
  end
95
107
 
96
- def build_and_link_exts(executor, module_bytes)
108
+ def build_gem_exts(executor, gem_home)
97
109
  build = derive_build
98
- self.build_exts(executor, build)
99
- self.link_exts(executor, build)
110
+ self._build_gem_exts(executor, build, gem_home)
100
111
  end
101
112
 
102
- def link_exts(executor, build)
103
- ruby_root = build.crossruby.dest_dir
113
+ def link_gem_exts(executor, ruby_root, gem_home, module_bytes)
114
+ build = derive_build
115
+ self._link_gem_exts(executor, build, ruby_root, gem_home, module_bytes)
116
+ end
104
117
 
105
- libraries = [File.join(ruby_root, "usr", "local", "bin", "ruby")]
118
+ def _link_gem_exts(executor, build, ruby_root, gem_home, module_bytes)
119
+ libraries = []
106
120
 
107
121
  # TODO: Should be computed from dyinfo of ruby binary
108
122
  wasi_libc_shared_libs = [
109
123
  "libc.so",
124
+ "libc++.so",
125
+ "libc++abi.so",
110
126
  "libwasi-emulated-getpid.so",
111
127
  "libwasi-emulated-mman.so",
112
128
  "libwasi-emulated-process-clocks.so",
@@ -119,13 +135,18 @@ class RubyWasm::Packager::Core
119
135
  wasi_sdk_path = toolchain.wasi_sdk_path
120
136
  libraries << File.join(wasi_sdk_path, "share/wasi-sysroot/lib/wasm32-wasi", lib)
121
137
  end
122
- wasi_adapter = RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1("command")
138
+ wasi_adapter = RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1(wasi_exec_model)
123
139
  adapters = [wasi_adapter]
124
- dl_openable_libs = Dir.glob(File.join(ruby_root, "usr", "local", "lib", "ruby", "**", "*.so"))
140
+ dl_openable_libs = []
141
+ dl_openable_libs << [File.dirname(ruby_root), Dir.glob(File.join(ruby_root, "lib", "ruby", "**", "*.so"))]
142
+ dl_openable_libs << [gem_home, Dir.glob(File.join(gem_home, "**", "*.so"))]
143
+
125
144
  linker = RubyWasmExt::ComponentLink.new
126
145
  linker.use_built_in_libdl(true)
127
146
  linker.stub_missing_functions(false)
128
- linker.validate(true)
147
+ linker.validate(ENV["RUBYWASM_SKIP_LINKER_VALIDATION"] != "1")
148
+
149
+ linker.library("ruby", module_bytes, false)
129
150
 
130
151
  libraries.each do |lib|
131
152
  # Non-DL openable libraries should be referenced as base name
@@ -135,12 +156,14 @@ class RubyWasm::Packager::Core
135
156
  linker.library(lib_name, module_bytes, false)
136
157
  end
137
158
 
138
- dl_openable_libs.each do |lib|
139
- # DL openable lib_name should be a relative path from ruby_root
140
- lib_name = "/" + Pathname.new(lib).relative_path_from(Pathname.new(ruby_root)).to_s
141
- module_bytes = File.binread(lib)
142
- RubyWasm.logger.info "Linking #{lib_name} (#{module_bytes.size} bytes)"
143
- linker.library(lib_name, module_bytes, true)
159
+ dl_openable_libs.each do |root, libs|
160
+ libs.each do |lib|
161
+ # DL openable lib_name should be a relative path from ruby_root
162
+ lib_name = "/" + Pathname.new(lib).relative_path_from(Pathname.new(File.dirname(root))).to_s
163
+ module_bytes = File.binread(lib)
164
+ RubyWasm.logger.info "Linking #{lib_name} (#{module_bytes.size} bytes)"
165
+ linker.library(lib_name, module_bytes, true)
166
+ end
144
167
  end
145
168
 
146
169
  adapters.each do |adapter|
@@ -148,29 +171,36 @@ class RubyWasm::Packager::Core
148
171
  # e.g. wasi_snapshot_preview1.command.wasm -> wasi_snapshot_preview1
149
172
  adapter_name = adapter_name.split(".")[0]
150
173
  module_bytes = File.binread(adapter)
174
+ RubyWasm.logger.info "Linking adapter #{adapter_name}=#{adapter} (#{module_bytes.size} bytes)"
151
175
  linker.adapter(adapter_name, module_bytes)
152
176
  end
153
177
  return linker.encode()
154
178
  end
155
179
 
156
- def build_exts(executor, build)
180
+ def _build_gem_exts(executor, build, gem_home)
157
181
  exts = specs_with_extensions.flat_map do |spec, exts|
158
182
  exts.map do |ext|
159
183
  ext_feature = File.dirname(ext) # e.g. "ext/cgi/escape"
160
184
  ext_srcdir = File.join(spec.full_gem_path, ext_feature)
161
185
  ext_relative_path = File.join(spec.full_name, ext_feature)
162
- RubyWasm::CrossRubyExtProduct.new(
186
+ prod = RubyWasm::CrossRubyExtProduct.new(
163
187
  ext_srcdir,
164
188
  build.toolchain,
165
189
  features: @packager.features,
166
190
  ext_relative_path: ext_relative_path
167
191
  )
192
+ [prod, spec]
168
193
  end
169
194
  end
170
195
 
171
- exts.each do |prod|
196
+ exts.each do |prod, spec|
197
+ libdir = File.join(gem_home, "gems", spec.full_name, spec.raw_require_paths.first)
198
+ extra_mkargs = [
199
+ "sitearchdir=#{libdir}",
200
+ "sitelibdir=#{libdir}",
201
+ ]
172
202
  executor.begin_section prod.class, prod.name, "Building"
173
- prod.build(executor, build.crossruby)
203
+ prod.build(executor, build.crossruby, extra_mkargs)
174
204
  executor.end_section prod.class, prod.name
175
205
  end
176
206
  end
@@ -301,15 +331,19 @@ class RubyWasm::Packager::Core
301
331
  build
302
332
  end
303
333
 
304
- def build_and_link_exts(executor, module_bytes)
334
+ def build_gem_exts(executor, gem_home)
335
+ # No-op because we already built extensions as part of the Ruby build
336
+ end
337
+
338
+ def link_gem_exts(executor, ruby_root, gem_home, module_bytes)
305
339
  return module_bytes unless @packager.features.support_component_model?
306
340
 
307
341
  linker = RubyWasmExt::ComponentEncode.new
308
- linker.validate(true)
342
+ linker.validate(ENV["RUBYWASM_SKIP_LINKER_VALIDATION"] != "1")
309
343
  linker.module(module_bytes)
310
344
  linker.adapter(
311
345
  "wasi_snapshot_preview1",
312
- File.binread(RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1("reactor"))
346
+ File.binread(RubyWasm::Packager::ComponentAdapter.wasi_snapshot_preview1(wasi_exec_model))
313
347
  )
314
348
 
315
349
  linker.encode()
@@ -38,6 +38,23 @@ class RubyWasm::Packager::FileSystem
38
38
  File.write(rbconfig, rbconfig_contents)
39
39
  end
40
40
 
41
+ def remove_stdlib_component(executor, component)
42
+ RubyWasm.logger.info "Removing stdlib component: #{component}"
43
+ case component
44
+ when "enc"
45
+ # Remove all encodings except for encdb.so and transdb.so
46
+ enc_dir = File.join(@ruby_root, "lib", "ruby", ruby_version, "wasm32-wasi", "enc")
47
+ puts File.join(enc_dir, "**/*.so")
48
+ Dir.glob(File.join(enc_dir, "**/*.so")).each do |entry|
49
+ next if entry.end_with?("encdb.so", "transdb.so")
50
+ RubyWasm.logger.debug "Removing stdlib encoding: #{entry}"
51
+ executor.rm_rf entry
52
+ end
53
+ else
54
+ raise "Unknown stdlib component: #{component}"
55
+ end
56
+ end
57
+
41
58
  def package_gems
42
59
  @packager.specs.each do |spec|
43
60
  RubyWasm.logger.info "Packaging gem: #{spec.full_name}"
@@ -32,11 +32,19 @@ class RubyWasm::Packager
32
32
 
33
33
  wasm_bytes = File.binread(File.join(fs.ruby_root, "bin", "ruby"))
34
34
 
35
+ ruby_core.build_gem_exts(executor, fs.bundle_dir)
36
+
35
37
  fs.package_gems
36
38
  fs.remove_non_runtime_files(executor)
37
- fs.remove_stdlib(executor) unless options[:stdlib]
39
+ if options[:stdlib]
40
+ options[:without_stdlib_components].each do |component|
41
+ fs.remove_stdlib_component(executor, component)
42
+ end
43
+ else
44
+ fs.remove_stdlib(executor)
45
+ end
38
46
 
39
- if full_build_options[:target] == "wasm32-unknown-wasip1"
47
+ if full_build_options[:target] == "wasm32-unknown-wasip1" && !features.support_dynamic_linking?
40
48
  # wasi-vfs supports only WASI target
41
49
  wasi_vfs = RubyWasmExt::WasiVfs.new
42
50
  wasi_vfs.map_dir("/bundle", fs.bundle_dir)
@@ -44,7 +52,7 @@ class RubyWasm::Packager
44
52
 
45
53
  wasm_bytes = wasi_vfs.pack(wasm_bytes)
46
54
  end
47
- wasm_bytes = ruby_core.build_and_link_exts(executor, wasm_bytes)
55
+ wasm_bytes = ruby_core.link_gem_exts(executor, fs.ruby_root, fs.bundle_dir, wasm_bytes)
48
56
 
49
57
  wasm_bytes = RubyWasmExt.preinitialize(wasm_bytes) if options[:optimize]
50
58
  wasm_bytes
@@ -1,3 +1,3 @@
1
1
  module RubyWasm
2
- VERSION = "2.5.2"
2
+ VERSION = "2.6.1"
3
3
  end
data/package-lock.json CHANGED
@@ -9,6 +9,7 @@
9
9
  "packages/npm-packages/*"
10
10
  ],
11
11
  "devDependencies": {
12
+ "@bytecodealliance/jco": "./vendor/jco",
12
13
  "@playwright/test": "^1.43.1",
13
14
  "@rollup/plugin-json": "^6.1.0",
14
15
  "rollup": "^4.17.2"
@@ -4783,7 +4784,7 @@
4783
4784
  },
4784
4785
  "packages/npm-packages/ruby-3.2-wasm-wasi": {
4785
4786
  "name": "@ruby/3.2-wasm-wasi",
4786
- "version": "2.5.2",
4787
+ "version": "2.6.1",
4787
4788
  "license": "MIT",
4788
4789
  "dependencies": {
4789
4790
  "@ruby/wasm-wasi": "^2.0.0"
@@ -4791,7 +4792,7 @@
4791
4792
  },
4792
4793
  "packages/npm-packages/ruby-3.3-wasm-wasi": {
4793
4794
  "name": "@ruby/3.3-wasm-wasi",
4794
- "version": "2.5.2",
4795
+ "version": "2.6.1",
4795
4796
  "license": "MIT",
4796
4797
  "dependencies": {
4797
4798
  "@ruby/wasm-wasi": "^2.0.0"
@@ -4799,12 +4800,12 @@
4799
4800
  },
4800
4801
  "packages/npm-packages/ruby-head-wasm-emscripten": {
4801
4802
  "name": "@ruby/head-wasm-emscripten",
4802
- "version": "2.5.2",
4803
+ "version": "2.6.1",
4803
4804
  "license": "MIT"
4804
4805
  },
4805
4806
  "packages/npm-packages/ruby-head-wasm-wasi": {
4806
4807
  "name": "@ruby/head-wasm-wasi",
4807
- "version": "2.5.2",
4808
+ "version": "2.6.1",
4808
4809
  "license": "MIT",
4809
4810
  "dependencies": {
4810
4811
  "@ruby/wasm-wasi": "^2.0.0"
@@ -4820,7 +4821,7 @@
4820
4821
  },
4821
4822
  "packages/npm-packages/ruby-wasm-wasi": {
4822
4823
  "name": "@ruby/wasm-wasi",
4823
- "version": "2.5.2",
4824
+ "version": "2.6.1",
4824
4825
  "license": "MIT",
4825
4826
  "dependencies": {
4826
4827
  "tslib": "^2.6.1"
@@ -4838,7 +4839,7 @@
4838
4839
  },
4839
4840
  "vendor/jco": {
4840
4841
  "name": "@bytecodealliance/jco",
4841
- "version": "1.2.1",
4842
+ "version": "1.2.4",
4842
4843
  "dev": true,
4843
4844
  "license": "(Apache-2.0 WITH LLVM-exception)",
4844
4845
  "workspaces": [
data/package.json CHANGED
@@ -7,6 +7,7 @@
7
7
  "devDependencies": {
8
8
  "@playwright/test": "^1.43.1",
9
9
  "@rollup/plugin-json": "^6.1.0",
10
- "rollup": "^4.17.2"
10
+ "rollup": "^4.17.2",
11
+ "@bytecodealliance/jco": "./vendor/jco"
11
12
  }
12
13
  }
@@ -168,7 +168,7 @@ module RubyWasm
168
168
  def feature_name: (CrossRubyProduct crossruby) -> String
169
169
 
170
170
  def make_args: (CrossRubyProduct crossruby) -> Array[String]
171
- def build: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
171
+ def build: (BuildExecutor executor, CrossRubyProduct crossruby, Array[String] extra_mkargs) -> void
172
172
  def do_extconf: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
173
173
  def do_install_rb: (BuildExecutor executor, CrossRubyProduct crossruby) -> void
174
174
 
@@ -242,6 +242,7 @@ module RubyWasm
242
242
  def self.find_path: (String command) -> String?
243
243
  def self.check_executable: (String command) -> String
244
244
  def cc: -> String
245
+ def cxx: -> String
245
246
  def ranlib: -> String
246
247
  def ld: -> String
247
248
  def ar: -> String
@@ -14,10 +14,12 @@ module RubyWasm
14
14
  target_triplet: String,
15
15
  profile: String,
16
16
  stdlib: bool,
17
+ without_stdlib_components: Array[String],
17
18
  disable_gems: bool,
18
19
  gemfile: String?,
19
20
  patches: Array[String],
20
21
  format: String,
22
+ dest_dir: String,
21
23
  }
22
24
 
23
25
  DEFAULT_RUBIES_DIR: string
@@ -23,6 +23,7 @@ class RubyWasm::Packager
23
23
  src: RubyWasm::Packager::build_source,
24
24
  default_exts: String,
25
25
  suffix: String,
26
+ gem_home: String?,
26
27
  }
27
28
 
28
29
  type bytes = String
@@ -56,7 +57,8 @@ class RubyWasm::Packager
56
57
  @packager: RubyWasm::Packager
57
58
  def initialize: (RubyWasm::Packager) -> void
58
59
  def build: (RubyWasm::BuildExecutor, untyped options) -> String
59
- def build_and_link_exts: (RubyWasm::BuildExecutor, bytes module_bytes) -> bytes
60
+ def build_gem_exts: (RubyWasm::BuildExecutor, string gem_home) -> void
61
+ def link_gem_exts: (RubyWasm::BuildExecutor, string ruby_root, string gem_home, bytes module_bytes) -> bytes
60
62
 
61
63
  extend Forwardable
62
64
 
@@ -72,16 +74,18 @@ class RubyWasm::Packager
72
74
  def initialize: (RubyWasm::Packager) -> void
73
75
  def build: (RubyWasm::BuildExecutor, untyped options) -> String
74
76
  def specs_with_extensions: () -> Array[[untyped, Array[string]]]
75
- def build_and_link_exts: (RubyWasm::BuildExecutor, bytes module_bytes) -> bytes
77
+ def build_gem_exts: (RubyWasm::BuildExecutor, string gem_home) -> void
78
+ def link_gem_exts: (RubyWasm::BuildExecutor, string ruby_root, string gem_home, bytes module_bytes) -> bytes
79
+ def wasi_exec_model: () -> String
76
80
  end
77
81
 
78
82
  class DynamicLinking < RubyWasm::Packager::Core::BuildStrategy
79
83
  @build: RubyWasm::Build
80
84
  def derive_build: () -> RubyWasm::Build
81
- def build_exts: (RubyWasm::BuildExecutor, RubyWasm::Build) -> void
82
85
  def name: () -> string
83
86
 
84
- private def link_exts: (RubyWasm::BuildExecutor, RubyWasm::Build) -> bytes
87
+ private def _build_gem_exts: (RubyWasm::BuildExecutor, RubyWasm::Build, string gem_home) -> void
88
+ private def _link_gem_exts: (RubyWasm::BuildExecutor, RubyWasm::Build, string ruby_root, string gem_home, bytes module_bytes) -> bytes
85
89
  end
86
90
 
87
91
  class StaticLinking < RubyWasm::Packager::Core::BuildStrategy
@@ -102,6 +106,7 @@ class RubyWasm::Packager
102
106
  def initialize: (string dest_dir, RubyWasm::Packager) -> void
103
107
  def package_ruby_root: (String tarball, RubyWasm::BuildExecutor) -> void
104
108
  def remove_stdlib: (RubyWasm::BuildExecutor) -> void
109
+ def remove_stdlib_component: (RubyWasm::BuildExecutor, string) -> void
105
110
  def package_gems: () -> void
106
111
 
107
112
  def setup_rb_content: () -> String
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_wasm
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
4
+ version: 2.6.1
5
5
  platform: arm64-darwin
6
6
  authors:
7
7
  - Yuta Saito
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-04 00:00:00.000000000 Z
11
+ date: 2024-05-22 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Ruby to WebAssembly toolkit. This gem takes Ruby code and Gemfile, and
14
14
  packages them with Ruby runtime into a WebAssembly binary.
@@ -32,9 +32,7 @@ files:
32
32
  - docs/cheat_sheet.md
33
33
  - docs/faq.md
34
34
  - exe/rbwasm
35
- - ext/.gitignore
36
- - ext/README.md
37
- - ext/extinit.c.erb
35
+ - ext/ruby_wasm/README.md
38
36
  - lib/ruby_wasm.rb
39
37
  - lib/ruby_wasm/3.1/ruby_wasm.bundle
40
38
  - lib/ruby_wasm/3.2/ruby_wasm.bundle
@@ -46,6 +44,7 @@ files:
46
44
  - lib/ruby_wasm/build/product.rb
47
45
  - lib/ruby_wasm/build/product/baseruby.rb
48
46
  - lib/ruby_wasm/build/product/crossruby.rb
47
+ - lib/ruby_wasm/build/product/crossruby/extinit.c.erb
49
48
  - lib/ruby_wasm/build/product/libyaml.rb
50
49
  - lib/ruby_wasm/build/product/openssl.rb
51
50
  - lib/ruby_wasm/build/product/product.rb
data/ext/.gitignore DELETED
@@ -1,2 +0,0 @@
1
- *.o
2
- link.filelist
data/ext/README.md DELETED
@@ -1,11 +0,0 @@
1
- # Ruby extensions
2
- `ruby.wasm` uses two C extensions to turn Ruby in to a guest module.
3
- The `js` extension enables Ruby to use JavaScript APIs.
4
- The `witapi` extension exports Ruby's interpreter interface to allow the host to use the Ruby interpreter.
5
- In other words, `js` allows Ruby to talk to Javascript and `witapi` allows a host to talk to Ruby.
6
-
7
- Under each subdirectory, there is a `bindgen/*.wit` file outlining the interfaces for each form of communication.
8
- Specifically, `bindgen/rb-js-abi-host.wit` describes embedder's requirements and `bindgen/rb-js-abi-guest.wit` describes exported API from Ruby interpreter.
9
- The `.c` and `.h` files are autogenerated from [wit-bindgen](https://github.com/bytecodealliance/wit-bindgen#host-runtimes-for-components).
10
- You can read more about it in the [contributing guide](/CONTRIBUTING.md#re-bindgen-from-wit-files).
11
- Note that we currently do not use the latest version of wit-bindgen because of how fast it is changing, with features being changed or even [removed](https://github.com/bytecodealliance/wit-bindgen/pull/346) at times.