Skip to content

Rename wasm32-unknown-wasi to wasm32-unknown-wasip1 in the build system #415

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
fail-fast: false
matrix:
entry:
- { target: wasm32-unknown-wasi }
- { target: wasm32-unknown-wasip1 }
- { target: wasm32-unknown-emscripten }
runs-on: ubuntu-20.04
steps:
Expand Down
12 changes: 6 additions & 6 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -110,8 +110,8 @@ A _build_ is a combination of ruby version, _profile_, and _target_.
</thead>
<tbody>
<tr>
<td><code>wasm32-unknown-wasi</code></td>
<td>Targeting WASI-compatible environments (e.g. Node.js, browsers with polyfill, <a href="https://github.com/bytecodealliance/wasmtime">wasmtime</a>, and so on)</td>
<td><code>wasm32-unknown-wasip1</code></td>
<td>Targeting <a href="https://github.com/WebAssembly/WASI/tree/main/legacy/preview1">WASI Preview1</a> compatible environments (e.g. Node.js, browsers with polyfill, <a href="https://github.com/bytecodealliance/wasmtime">wasmtime</a>, and so on)</td>
</tr>
<tr>
<td><code>wasm32-unknown-emscripten</code></td>
Expand Down
14 changes: 7 additions & 7 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand All @@ -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__)
Expand Down
1 change: 1 addition & 0 deletions builders/wasm32-unknown-wasip1
2 changes: 1 addition & 1 deletion lib/ruby_wasm/build/product/crossruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_wasm/build/product/openssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_wasm/build/product/product.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_wasm/build/product/wasi_vfs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_wasm/build/toolchain.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_wasm/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_wasm/packager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 || {}
Expand Down
2 changes: 1 addition & 1 deletion rakelib/ci.rake
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def rake_task_matrix
task: "standalone:#{pkg[:name]}",
artifact: "packages/standalone/#{pkg[:name]}/dist",
artifact_name: "standalone-#{pkg[:name]}",
builder: "wasm32-unknown-wasi",
builder: "wasm32-unknown-wasip1",
rubies_cache_key: ruby_cache_keys[pkg[:build]]
}
end
Expand Down
2 changes: 1 addition & 1 deletion rakelib/packaging.rake
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion ruby_wasm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
spec.files = Dir.chdir(__dir__) do
`git ls-files -z`.split("\x0").reject do |f|
(f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)}) ||
f.match(%r{\Apackages/})
f.match(%r{\A(?:packages|builders)/})
end
end
spec.bindir = "exe"
Expand Down
Loading