Skip to content

Commit 25fed4e

Browse files
authored
Remove the emscripten compiler and rely on wasi-sdk (#969)
Signed-off-by: James Sturtevant <[email protected]>
1 parent 1960055 commit 25fed4e

File tree

4 files changed

+18
-27
lines changed

4 files changed

+18
-27
lines changed

.github/actions/install-wasi-sdk/action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ runs:
1515
if: runner.os == 'macOS'
1616
shell: bash
1717
- run: |
18-
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw.tar.gz -L | tar xzvf -
18+
curl https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw64.tar.gz -L | tar xzvf -
1919
echo "WASI_SDK_PATH=`pwd`/wasi-sdk-22.0+m" >> $GITHUB_ENV
2020
if: runner.os == 'Windows'
2121
shell: bash

.github/workflows/main.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,6 @@ jobs:
8080
echo $LOCALAPPDATA'\Microsoft\dotnet' >> $GITHUB_PATH
8181
echo $LOCALAPPDATA'\Microsoft\dotnet\tools' >> $GITHUB_PATH
8282
$LOCALAPPDATA/Microsoft/dotnet/dotnet --info
83-
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
84-
curl.exe -OL https://github.com/emscripten-core/emsdk/archive/refs/heads/main.zip
85-
unzip main.zip
86-
cd emsdk-main
87-
./emsdk.bat install 3.1.47
88-
./emsdk.bat activate 3.1.47
8983
if : matrix.os == 'windows-latest'
9084
9185
- run: ci/download-teavm.sh
@@ -103,14 +97,8 @@ jobs:
10397
- uses: acifani/setup-tinygo@v2
10498
with:
10599
tinygo-version: 0.31.0
106-
- name: All but Windows, cargo test --workspace
107-
if : matrix.os != 'windows-latest'
100+
- name: cargo test --workspace
108101
run: cargo test --workspace
109-
- name: Windows, set EMSDK and run cargo test
110-
if : matrix.os == 'windows-latest'
111-
run: |
112-
source ./emsdk-main/emsdk_env.sh
113-
cargo test --workspace
114102

115103
check:
116104
name: Check

crates/csharp/README.txt

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
1-
// generate the c# and the component meta module
1+
## generate the c# and the component module
22

3-
cargo run c-sharp --string-encoding utf8 --out-dir testing-csharp tests/codegen/floats.wit
3+
The following will generate the c# code given a wit file:
44

5-
// to run the runtime tests with Native AOT, you need some additional set up
5+
```bash
6+
cargo run c-sharp --string-encoding utf8 --out-dir testing-csharp tests/codegen/floats.wit
7+
```
68

7-
// install emscripten
8-
curl.exe -OL https://github.com/emscripten-core/emsdk/archive/refs/heads/main.zip
9-
unzip main.zip
10-
cd .\emsdk-main\main\emsdk-main
11-
.\emsdk_env.ps1 activate 3.1.23 --permanant
9+
## Setup
10+
To run the runtime tests with Native AOT, you need some additional set up
1211

12+
```bash
1313
// install wasi-sdk and set env
14-
curl.exe -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw.tar.gz | tar xzvf -
15-
$env:WASI_SDK_PATH="c:\users\jstur\wasi-sdk-22.0+m\"
14+
curl.exe -L https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-22/wasi-sdk-22.0.m-mingw64.tar.gz | tar xzvf -
15+
$env:WASI_SDK_PATH="c:\users\jstur\wasi-sdk-22.0+m\"
16+
```

crates/csharp/src/csproj.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,10 @@ impl CSProjectLLVMBuilder {
104104
</ItemGroup>
105105
106106
<Target Name="CheckWasmSdks">
107-
<Error Text="Emscripten not found, not compiling to WebAssembly. To enable WebAssembly compilation, install Emscripten and ensure the EMSDK environment variable points to the directory containing upstream/emscripten/emcc.bat"
108-
Condition="'$(EMSDK)' == ''" />
107+
<Error Text="Wasi SDK not found, not compiling to WebAssembly. To enable WebAssembly compilation, install Wasi SDK and ensure the WASI_SDK_PATH environment variable points to the directory containing share/wasi-sysroot"
108+
Condition="'$(WASI_SDK_PATH)' == ''" />
109+
<Warning Text="The WASI SDK version is too low. Please use WASI SDK 22 or newer with a 64 bit Clang."
110+
Condition="!Exists('$(WASI_SDK_PATH)/VERSION')" />
109111
</Target>
110112
"#,
111113
);
@@ -115,7 +117,7 @@ impl CSProjectLLVMBuilder {
115117
Inputs=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.c\"
116118
Outputs=\"$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o\"
117119
>
118-
<Exec Command=\"emcc.bat &quot;$(MSBuildProjectDirectory)/{camel}_cabi_realloc.c&quot; -c -o &quot;$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o&quot;\"/>
120+
<Exec Command=\"&quot;$(WASI_SDK_PATH)/bin/clang&quot; --target=wasm32-wasi &quot;$(MSBuildProjectDirectory)/{camel}_cabi_realloc.c&quot; -c -o &quot;$(MSBuildProjectDirectory)/{camel}_cabi_realloc.o&quot;\"/>
119121
</Target>
120122
"
121123
));

0 commit comments

Comments
 (0)