ruby_wasm 2.6.1-arm64-darwin → 2.6.2-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: c51811bf667dbcd9db52fa7e46d19c97f38f9e3564fd6171e7ce5e5560a799ab
4
- data.tar.gz: dad2dfe190bc5d95745a3a2b10847f6ad939a4ed6adba5b16b3c1966e762d00c
3
+ metadata.gz: ea2d947360f5567e7f65aa429e99a0a30a559e36a7058c03347335c330a40abf
4
+ data.tar.gz: e524ca2247f46a7234e792a2b242ead266324b9d4fefbb8881c62868ebe98e14
5
5
  SHA512:
6
- metadata.gz: 0b837b64bf0606ca18558345f6f02f3c0bf6375fc91d009e490b28dd7ccf7f15c1819de5b496a79daf0615b1127c393e8b0c3eaa3d3887999aaa108c0a75afaa
7
- data.tar.gz: 9189ea18fffc8117a96581b6aac90e0ba731f1572c32fcd214f14911f159b58f45d6d0a7c8857d7912f5cbcf40f2a0ef446f7462df7b4ebe6ae08a6da4f81efa
6
+ metadata.gz: 7ce16dc71a12e91487beebada654ea97fcec7631e860219f7b34a7bb55bd915b555bf4bc7663451f1c2ae3392faac89bbf05b8b6deacd0535ab40553f48b0296
7
+ data.tar.gz: 88764096d52e0c02bee54aa556114d6fe05d3c40bf98a9d16a6cf8200f299815f82060313d0175316bd085d29e447534198455d18f1186b1556b3fc6c8664559
data/CONTRIBUTING.md CHANGED
@@ -127,5 +127,5 @@ $ npm install --save @ruby/wasm-wasi@latest
127
127
  # or if you want the nightly snapshot
128
128
  $ npm install --save @ruby/wasm-wasi@next
129
129
  # or you can specify the exact snapshot version
130
- $ npm install --save @ruby/wasm-wasi@2.6.1-2024-05-22-a
130
+ $ npm install --save @ruby/wasm-wasi@2.6.2-2024-06-29-a
131
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.6.1/dist/browser.script.iife.js"></script>
26
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.2/dist/browser.script.iife.js"></script>
27
27
  <script type="text/ruby">
28
28
  require "js"
29
29
 
data/Rakefile CHANGED
@@ -68,10 +68,11 @@ class BuildTask < Struct.new(:name, :target, :build_command)
68
68
  def ruby_cache_key
69
69
  return @key if @key
70
70
  require "open3"
71
+ env = { "RUBY_WASM_ROOT" => LIB_ROOT }
71
72
  cmd = build_command + ["--print-ruby-cache-key"]
72
- stdout, status = Open3.capture2(*cmd)
73
+ stdout, status = Open3.capture2(env, *cmd)
73
74
  unless status.success?
74
- raise "Command failed with status (#{status.exitstatus}): #{cmd.join ""}"
75
+ raise "Command failed with status (#{status.exitstatus}): #{cmd.join " "}"
75
76
  end
76
77
  require "json"
77
78
  @key = JSON.parse(stdout)
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.6.1/dist/browser.script.iife.js"></script>
41
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.2/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.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");
54
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.2/dist/browser/+esm";
55
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.2/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.6.1/dist/browser.umd.js"></script>
72
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.2/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.6.1/dist/ruby+stdlib.wasm");
76
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.2/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.6.1/dist/browser.script.iife.js"></script>
131
+ <script src="https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.2/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.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");
146
+ import { DefaultRubyVM } from "https://cdn.jsdelivr.net/npm/@ruby/wasm-wasi@2.6.2/dist/browser/+esm";
147
+ const response = await fetch("https://cdn.jsdelivr.net/npm/@ruby/3.3-wasm-wasi@2.6.2/dist/ruby+stdlib.wasm");
148
148
  const module = await WebAssembly.compileStreaming(response);
149
149
  const { vm } = await DefaultRubyVM(module);
150
150
 
Binary file
Binary file
Binary file
@@ -71,7 +71,6 @@ module RubyWasm
71
71
  return
72
72
  end
73
73
  objdir = product_build_dir crossruby
74
- source = crossruby.source
75
74
  rbconfig_rb = Dir.glob(File.join(crossruby.dest_dir, "usr/local/lib/ruby/*/wasm32-wasi/rbconfig.rb")).first
76
75
  raise "rbconfig.rb not found" unless rbconfig_rb
77
76
  extconf_args = [
@@ -80,7 +79,7 @@ module RubyWasm
80
79
  "--target-rbconfig=#{rbconfig_rb}",
81
80
  ]
82
81
  extconf_args << "--enable-component-model" if @features.support_component_model?
83
- executor.system Gem.ruby, *extconf_args
82
+ executor.system crossruby.baseruby_path, *extconf_args
84
83
  end
85
84
 
86
85
  def do_legacy_extconf(executor, crossruby)
@@ -359,6 +358,10 @@ module RubyWasm
359
358
  args << %Q(wasmoptflags=#{@wasmoptflags.join(" ")})
360
359
  end
361
360
  args << "--disable-install-doc"
361
+ unless @params.target.pic?
362
+ # TODO: Remove this hack after dropping Ruby 3.2 support
363
+ args << "ac_cv_func_dlopen=no"
364
+ end
362
365
  args
363
366
  end
364
367
  end
@@ -56,7 +56,7 @@ module RubyWasm
56
56
  def initialize(
57
57
  wasi_sdk_path = ENV["WASI_SDK_PATH"],
58
58
  build_dir: nil,
59
- version_major: 20,
59
+ version_major: 21,
60
60
  version_minor: 0,
61
61
  binaryen_version: 108
62
62
  )
data/lib/ruby_wasm/cli.rb CHANGED
@@ -216,7 +216,9 @@ module RubyWasm
216
216
  local_source = { type: "local", path: src_name }
217
217
  # @type var local_source: RubyWasm::Packager::build_source
218
218
  local_source = local_source.merge(name: "local", patches: [])
219
- return [local_source, nil]
219
+ # FIXME: We should have a way to specify extensions to be included by users.
220
+ # For now, assume all default extensions available in the head revision are available.
221
+ return [local_source, RubyWasm::Packager::ALL_DEFAULT_EXTS]
220
222
  end
221
223
  # Otherwise, it's an unknown source.
222
224
  raise(
@@ -242,7 +244,7 @@ module RubyWasm
242
244
  },
243
245
  "3.3" => {
244
246
  type: "tarball",
245
- url: "https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.1.tar.gz",
247
+ url: "https://cache.ruby-lang.org/pub/ruby/3.3/ruby-3.3.3.tar.gz",
246
248
  all_default_exts: "bigdecimal,cgi/escape,continuation,coverage,date,dbm,digest/bubblebabble,digest,digest/md5,digest/rmd160,digest/sha1,digest/sha2,etc,fcntl,fiber,gdbm,json,json/generator,json/parser,nkf,objspace,pathname,psych,racc/cparse,rbconfig/sizeof,ripper,stringio,strscan,monitor,zlib,openssl",
247
249
  },
248
250
  "3.2" => {
@@ -67,6 +67,14 @@ class RubyWasm::Packager::Core
67
67
  use_js_gem ? "reactor" : "command"
68
68
  end
69
69
 
70
+ def with_unbundled_env(&block)
71
+ __skip__ = if defined?(Bundler)
72
+ Bundler.with_unbundled_env(&block)
73
+ else
74
+ block.call
75
+ end
76
+ end
77
+
70
78
  def cache_key(digest)
71
79
  raise NotImplementedError
72
80
  end
@@ -87,27 +95,22 @@ class RubyWasm::Packager::Core
87
95
  end
88
96
  build.crossruby.clean(executor) if options[:clean]
89
97
 
90
- do_build =
91
- proc do
92
- build.crossruby.build(
93
- executor,
94
- remake: options[:remake],
95
- reconfigure: options[:reconfigure]
96
- )
97
- end
98
+ self.with_unbundled_env do
99
+ build.crossruby.build(
100
+ executor,
101
+ remake: options[:remake],
102
+ reconfigure: options[:reconfigure]
103
+ )
104
+ end
98
105
 
99
- __skip__ =
100
- if defined?(Bundler)
101
- Bundler.with_unbundled_env(&do_build)
102
- else
103
- do_build.call
104
- end
105
106
  build.crossruby.artifact
106
107
  end
107
108
 
108
109
  def build_gem_exts(executor, gem_home)
109
110
  build = derive_build
110
- self._build_gem_exts(executor, build, gem_home)
111
+ self.with_unbundled_env do
112
+ self._build_gem_exts(executor, build, gem_home)
113
+ end
111
114
  end
112
115
 
113
116
  def link_gem_exts(executor, ruby_root, gem_home, module_bytes)
@@ -178,6 +181,12 @@ class RubyWasm::Packager::Core
178
181
  end
179
182
 
180
183
  def _build_gem_exts(executor, build, gem_home)
184
+ build.toolchain.install
185
+ baseruby = build.baseruby
186
+ unless Dir.exist?(baseruby.install_dir)
187
+ baseruby.build(executor)
188
+ end
189
+
181
190
  exts = specs_with_extensions.flat_map do |spec, exts|
182
191
  exts.map do |ext|
183
192
  ext_feature = File.dirname(ext) # e.g. "ext/cgi/escape"
@@ -269,21 +278,14 @@ class RubyWasm::Packager::Core
269
278
  end
270
279
  build.crossruby.clean(executor) if options[:clean]
271
280
 
272
- do_build =
273
- proc do
274
- build.crossruby.build(
275
- executor,
276
- remake: options[:remake],
277
- reconfigure: options[:reconfigure]
278
- )
279
- end
281
+ self.with_unbundled_env do
282
+ build.crossruby.build(
283
+ executor,
284
+ remake: options[:remake],
285
+ reconfigure: options[:reconfigure]
286
+ )
287
+ end
280
288
 
281
- __skip__ =
282
- if defined?(Bundler)
283
- Bundler.with_unbundled_env(&do_build)
284
- else
285
- do_build.call
286
- end
287
289
  build.crossruby.artifact
288
290
  end
289
291
 
@@ -44,7 +44,7 @@ class RubyWasm::Packager
44
44
  fs.remove_stdlib(executor)
45
45
  end
46
46
 
47
- if full_build_options[:target] == "wasm32-unknown-wasip1" && !features.support_dynamic_linking?
47
+ if full_build_options[:target] == "wasm32-unknown-wasip1" && !features.support_component_model?
48
48
  # wasi-vfs supports only WASI target
49
49
  wasi_vfs = RubyWasmExt::WasiVfs.new
50
50
  wasi_vfs.map_dir("/bundle", fs.bundle_dir)
@@ -54,6 +54,20 @@ class RubyWasm::Packager
54
54
  end
55
55
  wasm_bytes = ruby_core.link_gem_exts(executor, fs.ruby_root, fs.bundle_dir, wasm_bytes)
56
56
 
57
+ if features.support_component_model?
58
+ wasi_virt = RubyWasmExt::WasiVirt.new
59
+ wasi_virt.allow_all
60
+ [
61
+ { guest: "/bundle", host: fs.bundle_dir },
62
+ { guest: "/usr", host: File.dirname(fs.ruby_root) }
63
+ ].each do |map|
64
+ map => { guest:, host: }
65
+ RubyWasm.logger.debug "Adding files into VFS: #{host} => #{guest}"
66
+ wasi_virt.map_dir(guest, host)
67
+ end
68
+ wasm_bytes = wasi_virt.compose(wasm_bytes)
69
+ end
70
+
57
71
  wasm_bytes = RubyWasmExt.preinitialize(wasm_bytes) if options[:optimize]
58
72
  wasm_bytes
59
73
  end
@@ -68,8 +82,9 @@ class RubyWasm::Packager
68
82
  # Retrieves the specs from the Bundler definition, excluding the excluded gems.
69
83
  def specs
70
84
  return [] unless @definition
71
- @specs ||= @definition.resolve.materialize(@definition.requested_dependencies)
85
+ __skip__ = @specs ||= @definition.resolve.materialize(@definition.requested_dependencies)
72
86
  .reject { |spec| EXCLUDED_GEMS.include?(spec.name) }
87
+ .reject { |spec| spec.is_a?(Bundler::LazySpecification) }
73
88
  @specs
74
89
  end
75
90
 
@@ -1,3 +1,3 @@
1
1
  module RubyWasm
2
- VERSION = "2.6.1"
2
+ VERSION = "2.6.2"
3
3
  end