From 1960055b1abdaed31d15d7d311a6489823b42bcb Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Thu, 6 Jun 2024 12:19:42 -0700 Subject: [PATCH 1/3] Bump the wasi-sdk to 22.0 (#967) Signed-off-by: James Sturtevant --- .devcontainer/Dockerfile | 8 ++++---- .github/actions/install-wasi-sdk/action.yml | 12 ++++++------ crates/csharp/README.txt | 4 ++-- tests/README.md | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 38f2b824d..28815bcc8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -20,9 +20,9 @@ RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/ # [Optional] Uncomment this line to install global node packages. # RUN su vscode -c "source /usr/local/share/nvm/nvm.sh && npm install -g " 2>&1 -RUN cd /opt && curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz \ +RUN cd /opt && curl -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz \ | tar -xz -ENV WASI_SDK_PATH=/opt/wasi-sdk-20.0 +ENV WASI_SDK_PATH=/opt/wasi-sdk-22.0 -RUN echo 'alias clang=/opt/wasi-sdk-20.0/bin/clang' >> /etc/bash.bashrc -RUN echo 'alias clang++=/opt/wasi-sdk-20.0/bin/clang++' >> /etc/bash.bashrc +RUN echo 'alias clang=/opt/wasi-sdk-22.0/bin/clang' >> /etc/bash.bashrc +RUN echo 'alias clang++=/opt/wasi-sdk-22.0/bin/clang++' >> /etc/bash.bashrc diff --git a/.github/actions/install-wasi-sdk/action.yml b/.github/actions/install-wasi-sdk/action.yml index 20a7a4130..9c55fda52 100644 --- a/.github/actions/install-wasi-sdk/action.yml +++ b/.github/actions/install-wasi-sdk/action.yml @@ -5,18 +5,18 @@ runs: using: composite steps: - run: | - curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz -L | tar xzvf - - echo "WASI_SDK_PATH=`pwd`/wasi-sdk-20.0" >> $GITHUB_ENV + curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz -L | tar xzvf - + echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0" >> $GITHUB_ENV if: runner.os == 'Linux' shell: bash - run: | - curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-macos.tar.gz -L | tar xzvf - - echo "WASI_SDK_PATH=`pwd`/wasi-sdk-20.0" >> $GITHUB_ENV + curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-macos.tar.gz -L | tar xzvf - + echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0" >> $GITHUB_ENV if: runner.os == 'macOS' shell: bash - run: | - curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0.m-mingw.tar.gz -L | tar xzvf - - echo "WASI_SDK_PATH=`pwd`/wasi-sdk-20.0+m" >> $GITHUB_ENV + curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw.tar.gz -L | tar xzvf - + echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0+m" >> $GITHUB_ENV if: runner.os == 'Windows' shell: bash - name: Setup `wasm-tools` diff --git a/crates/csharp/README.txt b/crates/csharp/README.txt index bc585dd34..1f04c809c 100644 --- a/crates/csharp/README.txt +++ b/crates/csharp/README.txt @@ -11,5 +11,5 @@ cd .\emsdk-main\main\emsdk-main .\emsdk_env.ps1 activate 3.1.23 --permanant // install wasi-sdk and set env -curl.exe -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0.m-mingw.tar.gz | tar xzvf - -$env:WASI_SDK_PATH="c:\users\jstur\wasi-sdk-20.0+m\" \ No newline at end of file +curl.exe -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw.tar.gz | tar xzvf - +$env:WASI_SDK_PATH="c:\users\jstur\wasi-sdk-22.0+m\" \ No newline at end of file diff --git a/tests/README.md b/tests/README.md index 33225d35b..b58176f6c 100644 --- a/tests/README.md +++ b/tests/README.md @@ -4,7 +4,7 @@ There are a few pre-requisites to testing the project. You only need the languag - WASI SDK - Download from wasi-sdk releases page. If you're using Windows, you need the one with mingw in its name. - - `curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-20/wasi-sdk-20.0-linux.tar.gz` + - `curl -LO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0-linux.tar.gz` - Create an environment variable called `WASI_SDK_PATH`` giving the path where you extracted the WASI SDK download, i.e., the directory containing `bin`/`lib`/`share`` folders. - Compilers for the target language: - Go + TinyGo - https://tinygo.org/ (v0.27.0+) From 25fed4e9a520739e6c0febb4456fb10229a20586 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Thu, 6 Jun 2024 17:47:41 -0700 Subject: [PATCH 2/3] Remove the emscripten compiler and rely on wasi-sdk (#969) Signed-off-by: James Sturtevant --- .github/actions/install-wasi-sdk/action.yml | 2 +- .github/workflows/main.yml | 14 +------------- crates/csharp/README.txt | 21 +++++++++++---------- crates/csharp/src/csproj.rs | 8 +++++--- 4 files changed, 18 insertions(+), 27 deletions(-) diff --git a/.github/actions/install-wasi-sdk/action.yml b/.github/actions/install-wasi-sdk/action.yml index 9c55fda52..48c4be0a3 100644 --- a/.github/actions/install-wasi-sdk/action.yml +++ b/.github/actions/install-wasi-sdk/action.yml @@ -15,7 +15,7 @@ runs: if: runner.os == 'macOS' shell: bash - run: | - curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw.tar.gz -L | tar xzvf - + curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw64.tar.gz -L | tar xzvf - echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0+m" >> $GITHUB_ENV if: runner.os == 'Windows' shell: bash diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index fa77b3849..6d7c3d85c 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -80,12 +80,6 @@ jobs: echo $LOCALAPPDATA'\Microsoft\dotnet' >> $GITHUB_PATH echo $LOCALAPPDATA'\Microsoft\dotnet\tools' >> $GITHUB_PATH $LOCALAPPDATA/Microsoft/dotnet/dotnet --info - echo nativeaot-llvm requires emscripten for its version of clang as wasi-sdk 20 does not work see https://github.com/WebAssembly/wasi-sdk/issues/326 - curl.exe -OL https://github.com/emscripten-core/emsdk/archive/refs/heads/main.zip - unzip main.zip - cd emsdk-main - ./emsdk.bat install 3.1.47 - ./emsdk.bat activate 3.1.47 if : matrix.os == 'windows-latest' - run: ci/download-teavm.sh @@ -103,14 +97,8 @@ jobs: - uses: acifani/setup-tinygo@v2 with: tinygo-version: 0.31.0 - - name: All but Windows, cargo test --workspace - if : matrix.os != 'windows-latest' + - name: cargo test --workspace run: cargo test --workspace - - name: Windows, set EMSDK and run cargo test - if : matrix.os == 'windows-latest' - run: | - source ./emsdk-main/emsdk_env.sh - cargo test --workspace check: name: Check diff --git a/crates/csharp/README.txt b/crates/csharp/README.txt index 1f04c809c..49eb7f886 100644 --- a/crates/csharp/README.txt +++ b/crates/csharp/README.txt @@ -1,15 +1,16 @@ -// generate the c# and the component meta module +## generate the c# and the component module -cargo run c-sharp --string-encoding utf8 --out-dir testing-csharp tests/codegen/floats.wit +The following will generate the c# code given a wit file: -// to run the runtime tests with Native AOT, you need some additional set up +```bash +cargo run c-sharp --string-encoding utf8 --out-dir testing-csharp tests/codegen/floats.wit +``` -// install emscripten -curl.exe -OL https://github.com/emscripten-core/emsdk/archive/refs/heads/main.zip -unzip main.zip -cd .\emsdk-main\main\emsdk-main -.\emsdk_env.ps1 activate 3.1.23 --permanant +## Setup +To run the runtime tests with Native AOT, you need some additional set up +```bash // install wasi-sdk and set env -curl.exe -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw.tar.gz | tar xzvf - -$env:WASI_SDK_PATH="c:\users\jstur\wasi-sdk-22.0+m\" \ No newline at end of file +curl.exe -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw64.tar.gz | tar xzvf - +$env:WASI_SDK_PATH="c:\users\jstur\wasi-sdk-22.0+m\" +``` \ No newline at end of file diff --git a/crates/csharp/src/csproj.rs b/crates/csharp/src/csproj.rs index df7bf438e..e6f62e10d 100644 --- a/crates/csharp/src/csproj.rs +++ b/crates/csharp/src/csproj.rs @@ -104,8 +104,10 @@ impl CSProjectLLVMBuilder { - + + "#, ); @@ -115,7 +117,7 @@ impl CSProjectLLVMBuilder { Inputs=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.c\" Outputs=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o\" > - + " )); From 76c54016b72d2d3443d34b35fc9c592d9cd5f188 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Fri, 7 Jun 2024 14:57:26 -0500 Subject: [PATCH 3/3] Update CLI docs for `wit-bindgen` (#970) Modernize documentation for `wit` and `--world` options. cc #790 --- src/bin/wit-bindgen.rs | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/bin/wit-bindgen.rs b/src/bin/wit-bindgen.rs index 9acb5d9e8..7f05bd88c 100644 --- a/src/bin/wit-bindgen.rs +++ b/src/bin/wit-bindgen.rs @@ -72,14 +72,24 @@ struct Common { #[clap(long = "out-dir")] out_dir: Option, - /// WIT document to generate bindings for. - #[clap(value_name = "DOCUMENT", index = 1)] + /// Location of WIT file(s) to generate bindings for. + /// + /// This path can be either a directory containing `*.wit` files, a `*.wit` + /// file itself, or a `*.wasm` file which is a wasm-encoded WIT package. + /// Most of the time it's likely to be a directory containing `*.wit` files + /// with an optional `deps` folder inside of it. + #[clap(value_name = "WIT", index = 1)] wit: PathBuf, - /// World within the WIT document specified to generate bindings for. + /// Optionally specified world that bindings are generated for. /// - /// This can either be `foo` which is the default world in document `foo` or - /// it's `foo.bar` which is the world named `bar` within document `foo`. + /// Bindings are always generated for a world but this option can be omitted + /// when the WIT package pointed to by the `WIT` option only has a single + /// world. If there's more than one world in the package then this option + /// must be specified to name the world that bindings are generated for. + /// This option can also use the fully qualified syntax such as + /// `wasi:http/proxy` to select a world from a dependency of the main WIT + /// package. #[clap(short, long)] world: Option,