diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index d6d824132e..a0c8f7891c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,7 +21,7 @@ $ rake --tasks $ rake build:download_prebuilt # Build Ruby (if you need to build Ruby by yourself) -$ rake build:head-wasm32-unknown-wasi-full +$ rake build:head-wasm32-unknown-wasip1-full # Build npm package $ rake npm:ruby-head-wasm-wasi @@ -48,15 +48,15 @@ To select a build profile, see [profiles section in README](https://github.com/r ```console # Build only a specific combination of ruby version, profile, and target -$ rake build:head-wasm32-unknown-wasi-full +$ rake build:head-wasm32-unknown-wasip1-full # Clean up the build directory -$ rake build:head-wasm32-unknown-wasi-full:clean +$ rake build:head-wasm32-unknown-wasip1-full:clean # Force to re-execute "make install" -$ rake build:head-wasm32-unknown-wasi-full:remake +$ rake build:head-wasm32-unknown-wasip1-full:remake # Output is in the `rubies` directory -$ tree -L 3 rubies/head-wasm32-unknown-wasi-full -rubies/head-wasm32-unknown-wasi-full/ +$ tree -L 3 rubies/head-wasm32-unknown-wasip1-full +rubies/head-wasm32-unknown-wasip1-full/ ├── usr │   └── local │   ├── bin diff --git a/README.md b/README.md index fe8d3110c1..f69a0c8006 100644 --- a/README.md +++ b/README.md @@ -40,18 +40,18 @@ Dependencies: [wasmtime](https://github.com/bytecodealliance/wasmtime) ```console $ gem install ruby_wasm # Download a prebuilt Ruby release -$ curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3.3-wasm32-unknown-wasi-full.tar.gz -$ tar xfz ruby-3.3-wasm32-unknown-wasi-full.tar.gz +$ curl -LO https://github.com/ruby/ruby.wasm/releases/latest/download/ruby-3.3-wasm32-unknown-wasip1-full.tar.gz +$ tar xfz ruby-3.3-wasm32-unknown-wasip1-full.tar.gz # Extract ruby binary not to pack itself -$ mv ruby-3.3-wasm32-unknown-wasi-full/usr/local/bin/ruby ruby.wasm +$ mv ruby-3.3-wasm32-unknown-wasip1-full/usr/local/bin/ruby ruby.wasm # Put your app code $ mkdir src $ echo "puts 'Hello'" > src/my_app.rb # Pack the whole directory under /usr and your app dir -$ rbwasm pack ruby.wasm --dir ./src::/src --dir ./ruby-3.3-wasm32-unknown-wasi-full/usr::/usr -o my-ruby-app.wasm +$ rbwasm pack ruby.wasm --dir ./src::/src --dir ./ruby-3.3-wasm32-unknown-wasip1-full/usr::/usr -o my-ruby-app.wasm # Run the packed scripts $ wasmtime my-ruby-app.wasm /src/my_app.rb @@ -110,8 +110,8 @@ A _build_ is a combination of ruby version, _profile_, and _target_. - wasm32-unknown-wasi - Targeting WASI-compatible environments (e.g. Node.js, browsers with polyfill, wasmtime, and so on) + wasm32-unknown-wasip1 + Targeting [WASI Preview1](https://github.com/WebAssembly/WASI/tree/main/legacy/preview1)-compatible environments (e.g. Node.js, browsers with polyfill, wasmtime, and so on) wasm32-unknown-emscripten diff --git a/Rakefile b/Rakefile index f771fbbc8c..5cec1876a8 100644 --- a/Rakefile +++ b/Rakefile @@ -15,7 +15,7 @@ BUILD_PROFILES = %w[full minimal] BUILDS = BUILD_SOURCES .product(BUILD_PROFILES) - .map { |src, profile| [src, "wasm32-unknown-wasi", profile] } + + .map { |src, profile| [src, "wasm32-unknown-wasip1", profile] } + BUILD_SOURCES.map { |src| [src, "wasm32-unknown-emscripten", "full"] } NPM_PACKAGES = [ @@ -29,26 +29,26 @@ NPM_PACKAGES = [ name: "ruby-head-wasm-wasi", ruby_version: "head", gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile", - target: "wasm32-unknown-wasi" + target: "wasm32-unknown-wasip1" }, { name: "ruby-3.3-wasm-wasi", ruby_version: "3.3", gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile", - target: "wasm32-unknown-wasi" + target: "wasm32-unknown-wasip1" }, { name: "ruby-3.2-wasm-wasi", ruby_version: "3.2", gemfile: "packages/npm-packages/ruby-wasm-wasi/Gemfile", - target: "wasm32-unknown-wasi" + target: "wasm32-unknown-wasip1" }, - { name: "ruby-wasm-wasi", target: "wasm32-unknown-wasi" } + { name: "ruby-wasm-wasi", target: "wasm32-unknown-wasip1" } ] STANDALONE_PACKAGES = [ - { name: "ruby", build: "head-wasm32-unknown-wasi-full" }, - { name: "irb", build: "head-wasm32-unknown-wasi-full" } + { name: "ruby", build: "head-wasm32-unknown-wasip1-full" }, + { name: "irb", build: "head-wasm32-unknown-wasip1-full" } ] LIB_ROOT = File.dirname(__FILE__) diff --git a/lib/ruby_wasm/build/product/crossruby.rb b/lib/ruby_wasm/build/product/crossruby.rb index f28c3da94d..12a1b4cc65 100644 --- a/lib/ruby_wasm/build/product/crossruby.rb +++ b/lib/ruby_wasm/build/product/crossruby.rb @@ -293,7 +293,7 @@ def configure_args(build_triple, toolchain) args << %Q(--with-baseruby=#{baseruby_path}) case target - when "wasm32-unknown-wasi" + when /^wasm32-unknown-wasi/ xldflags << @wasi_vfs.lib_wasi_vfs_a if @wasi_vfs # TODO: Find a way to force cast or update API # @type var wasi_sdk_path: untyped diff --git a/lib/ruby_wasm/build/product/openssl.rb b/lib/ruby_wasm/build/product/openssl.rb index 5299aa73ba..5ce127dcea 100644 --- a/lib/ruby_wasm/build/product/openssl.rb +++ b/lib/ruby_wasm/build/product/openssl.rb @@ -42,7 +42,7 @@ def configure_args --libdir=lib -Wl,--allow-undefined ] - if @target.triple == "wasm32-unknown-wasi" + if @target.triple.start_with?("wasm32-unknown-wasi") args.concat %w[ -D_WASI_EMULATED_SIGNAL -D_WASI_EMULATED_PROCESS_CLOCKS diff --git a/lib/ruby_wasm/build/product/product.rb b/lib/ruby_wasm/build/product/product.rb index 6784d689d4..8e0c78ce36 100644 --- a/lib/ruby_wasm/build/product/product.rb +++ b/lib/ruby_wasm/build/product/product.rb @@ -13,7 +13,7 @@ def initialize(target, toolchain) def system_triplet_args args = [] case @target.triple - when "wasm32-unknown-wasi" + when /^wasm32-unknown-wasi/ args.concat(%W[--host wasm32-wasi]) when "wasm32-unknown-emscripten" args.concat(%W[--host wasm32-emscripten]) diff --git a/lib/ruby_wasm/build/product/wasi_vfs.rb b/lib/ruby_wasm/build/product/wasi_vfs.rb index 9366d901a4..1afdd5fb5d 100644 --- a/lib/ruby_wasm/build/product/wasi_vfs.rb +++ b/lib/ruby_wasm/build/product/wasi_vfs.rb @@ -12,7 +12,7 @@ def initialize(build_dir) def lib_product_build_dir File.join( @build_dir, - "wasm32-unknown-wasi", + "wasm32-unknown-wasip1", "wasi-vfs-#{WASI_VFS_VERSION}" ) end diff --git a/lib/ruby_wasm/build/toolchain.rb b/lib/ruby_wasm/build/toolchain.rb index 21287b5295..0347371c7d 100644 --- a/lib/ruby_wasm/build/toolchain.rb +++ b/lib/ruby_wasm/build/toolchain.rb @@ -18,7 +18,7 @@ def check_envvar(name) def self.get(target, build_dir = nil) case target - when "wasm32-unknown-wasi" + when /^wasm32-unknown-wasi/ return RubyWasm::WASISDK.new(build_dir: build_dir) when "wasm32-unknown-emscripten" return RubyWasm::Emscripten.new diff --git a/lib/ruby_wasm/cli.rb b/lib/ruby_wasm/cli.rb index f0f1001e17..b71629c554 100644 --- a/lib/ruby_wasm/cli.rb +++ b/lib/ruby_wasm/cli.rb @@ -50,7 +50,7 @@ def build(args) reconfigure: false, clean: false, ruby_version: "3.3", - target_triplet: "wasm32-unknown-wasi", + target_triplet: "wasm32-unknown-wasip1", profile: "full", stdlib: true, disable_gems: false, diff --git a/lib/ruby_wasm/packager.rb b/lib/ruby_wasm/packager.rb index 7706c5ba58..d926ca66b1 100644 --- a/lib/ruby_wasm/packager.rb +++ b/lib/ruby_wasm/packager.rb @@ -35,7 +35,7 @@ def package(executor, dest_dir, options) fs.remove_non_runtime_files(executor) fs.remove_stdlib(executor) unless options[:stdlib] - if full_build_options[:target] == "wasm32-unknown-wasi" && !support_dynamic_linking? + if full_build_options[:target] == "wasm32-unknown-wasip1" && !support_dynamic_linking? # wasi-vfs supports only WASI target wasi_vfs = RubyWasmExt::WasiVfs.new wasi_vfs.map_dir("/bundle", fs.bundle_dir) @@ -72,7 +72,7 @@ def support_dynamic_linking? # Retrieves the build options used for building Ruby itself. def build_options default = { - target: RubyWasm::Target.new("wasm32-unknown-wasi"), + target: RubyWasm::Target.new("wasm32-unknown-wasip1"), default_exts: ALL_DEFAULT_EXTS } override = @config || {} diff --git a/rakelib/packaging.rake b/rakelib/packaging.rake index 167fcb9244..0f2847972b 100644 --- a/rakelib/packaging.rake +++ b/rakelib/packaging.rake @@ -61,7 +61,7 @@ namespace :npm do end dist_dir = File.join(pkg_dir, "dist") mkdir_p dist_dir - if pkg[:target] == "wasm32-unknown-wasi" + if pkg[:target].start_with?("wasm32-unknown-wasi") Dir.chdir(cwd || base_dir) do sh env, *build_command,