Skip to content

Commit

Permalink
Enable both wasip1 and wasip2 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
rajsite committed Aug 10, 2024
1 parent a5394f4 commit a8824d2
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: make install-wasi-sdk
- run: make vwasi
- run: make vwasip1
- run: make vwasip2
- run: |
git clone https://github.com/juj/emsdk.git
cd emsdk
Expand Down Expand Up @@ -110,7 +111,8 @@ jobs:
registry-url: 'https://registry.npmjs.org'
- run: npm ci
- run: make install-wasi-sdk
- run: make vwasi
- run: make vwasip1
- run: make vwasip2
- run: choco install make -y
- run: choco install gnuwin32-coreutils.portable -y
- uses: actions/setup-python@v5
Expand Down
4 changes: 1 addition & 3 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@
!/dist/wasm32-unknown-emscripten/release/*.*
!/dist/wasm32-unknown-emscripten/debug/*.*
!/dist/wasm32-unknown-emscripten/profile/*.*
!/dist/wasm32-wasi/release/*.*
!/dist/wasm32-wasi/debug/*.*
!/dist/wasm32-wasi/profile/*.*
!/dist/wasm32-wasi*/**

!/source/core/*.js
/source/core/library_*.js
Expand Down
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ simple v32 v64 help:
vjs js:
cd make-it && make vjs

vwasi:
cd make-it && make vwasi TARGET=wasm32-wasip2
vwasip1 vwasip2:
cd make-it && make $@

install-wasi-sdk:
cd make-it && make install-wasi-sdk
Expand Down
8 changes: 4 additions & 4 deletions make-it/EmMakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ MKDIR="mkdir"

VIREO_SDK=..

TARGETS_SUPPORTED=asmjs-unknown-emscripten wasm32-unknown-emscripten wasm32-wasip2
TARGETS_SUPPORTED=asmjs-unknown-emscripten wasm32-unknown-emscripten wasm32-wasip1 wasm32-wasip2
TARGET=wasm32-unknown-emscripten

ifeq ($(filter $(TARGET), $(TARGETS_SUPPORTED)),)
Expand Down Expand Up @@ -88,7 +88,7 @@ else
endif
endif
WASI_SDK_PATH=$(VIREO_SDK)/wasi-sdk-${WASI_VERSION_FULL}-${WASI_SDK_TARGET}
WASI_CC=${WASI_SDK_PATH}/bin/clang++ --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot --target=wasm32-wasip2
WASI_CC=${WASI_SDK_PATH}/bin/clang++ --sysroot=${WASI_SDK_PATH}/share/wasi-sysroot --target=${TARGET}

# release config
EM_OPTFLAG = -O3
Expand Down Expand Up @@ -121,7 +121,7 @@ ifeq ($(TARGET), wasm32-unknown-emscripten)
MAINOBJ =
endif

ifeq ($(TARGET), wasm32-wasip2)
ifeq ($(filter wasm32-wasi, $(TARGET)),)
EMCC=$(WASI_CC)
TARGET_FLAG = -DkVireoOS_wasi -DVIREO_STDIO -DVIREO_FILESYSTEM -DVIREO_FILESYSTEM_DIRLIST
MAINOBJ = $(OBJS)/main.bc
Expand All @@ -134,7 +134,7 @@ endif
# NO_DYNAMIC_EXECUTION=1 Allows Vireo to be used in CSP environments where eval() is forbidden: https://github.com/kripken/emscripten/blob/master/src/settings.js#L563
EM_OPT = $(EM_OPTFLAGS) $(TARGET_FLAG) -std=c++14 -fno-exceptions -Werror --memory-init-file 0 -s NO_DYNAMIC_EXECUTION=1 -s MODULARIZE=1 -s EXPORT_NAME=VireoCreateCoreModule -s EXPORT_ES6=1 -s USE_ES6_IMPORT_META=0 --minify 0 -s NO_FILESYSTEM=1 -s ABORTING_MALLOC=0
WASI_OPT = $(EM_OPTFLAGS) $(TARGET_FLAG) -std=c++14 -fno-exceptions -Werror
ifeq ($(TARGET), wasm32-wasip2)
ifeq ($(filter wasm32-wasi, $(TARGET)),)
EM_OPT=$(WASI_OPT)
endif
EMFLAGS = -I$(INCDIR) $(EM_OPT)
Expand Down
7 changes: 5 additions & 2 deletions make-it/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,11 @@ lARMv5:
vjs:
emmake make -f EmMakefile vjs

vwasi:
make -f EmMakefile vwasi
vwasip1:
make -f EmMakefile TARGET=wasm32-wasip1 vwasi

vwasip2:
make -f EmMakefile TARGET=wasm32-wasip2 vwasi

install-wasi-sdk:
make -f EmMakefile install-wasi-sdk
Expand Down
2 changes: 1 addition & 1 deletion test-it/wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
const path = require('node:path');
const {argv} = require('node:process');
const wasm = await WebAssembly.compile(
await readFile(path.join(__dirname, '../dist/wasm32-wasi/release/vireo.wasm'))
await readFile(path.join(__dirname, '../dist/wasm32-wasip1/release/vireo.wasm'))
);
const wasi = new WASI({
args: argv.slice(1),
Expand Down

0 comments on commit a8824d2

Please sign in to comment.