-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix multiple-pack for reactor modules
- Loading branch information
1 parent
c3937ee
commit b1e4e5d
Showing
9 changed files
with
133 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
-include ../tools.mk | ||
|
||
check: $(objs) | ||
$(CC) $(LDFLAGS) main.c $(LIB_WASI_VFS) -mexec-model=reactor -o $(TMPDIR)/main.wasm | ||
$(WASI_VFS_CLI) pack $(TMPDIR)/main.wasm --dir ./mnt0::/mnt0 -o $(TMPDIR)/main.stage0.wasm | ||
$(NODE) --experimental-wasi-unstable-preview1 ./check.js $(TMPDIR)/main.stage0.wasm 0 | ||
|
||
$(WASI_VFS_CLI) pack $(TMPDIR)/main.stage0.wasm --dir ./mnt1::/mnt1 -o $(TMPDIR)/main.stage1.wasm | ||
$(NODE) --experimental-wasi-unstable-preview1 ./check.js $(TMPDIR)/main.stage1.wasm 1 | ||
|
||
$(NODE) --experimental-wasi-unstable-preview1 ./check.js \ | ||
--dir=./mnt0::/mnt0 --dir=./mnt1::/mnt1 --dir=./mnt1_1::/mnt1 \ | ||
$(TMPDIR)/main.wasm 2 | ||
$(WASI_VFS_CLI) pack $(TMPDIR)/main.stage1.wasm --dir ./mnt1_1::/mnt1 -o $(TMPDIR)/main.stage2.wasm | ||
$(NODE) --experimental-wasi-unstable-preview1 ./check.js $(TMPDIR)/main.stage2.wasm 2 | ||
|
||
clean: | ||
rm -rf $(TMPDIR)/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const { WASI } = require("wasi"); | ||
const fs = require("fs"); | ||
const process = require("process"); | ||
const path = require("path"); | ||
|
||
const args = process.argv.slice(2); | ||
|
||
const preopens = {}; | ||
while (args.length > 0 && args[0].startsWith("--dir=")) { | ||
// Parse --dir=/foo::/bar | ||
const dir = args.shift().substring("--dir=".length); | ||
const [host, guest] = dir.split("::"); | ||
preopens[guest] = host; | ||
} | ||
|
||
const buffer = fs.readFileSync(args[0]); | ||
const stage = Number(args[1]); | ||
|
||
const wasi = new WASI({ | ||
env: { ...process.env }, | ||
preopens | ||
}); | ||
const m = new WebAssembly.Module(buffer); | ||
const i = new WebAssembly.Instance(m, { | ||
wasi_snapshot_preview1: wasi.wasiImport, | ||
}); | ||
|
||
wasi.initialize(i); | ||
i.exports.check(stage); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
#include "../check.h" | ||
#include <stdio.h> | ||
|
||
#pragma clang diagnostic ignored "-Wunknown-attributes" | ||
__attribute__((export_name("check"))) | ||
int check(int stage) { | ||
if (stage == 0) { | ||
check_file_exists("/mnt0/hello.txt"); | ||
} else if (stage == 1) { | ||
check_file_exists("/mnt0/hello.txt"); | ||
check_file_exists("/mnt1/goodbye.txt"); | ||
} else if (stage == 2) { | ||
check_file_exists("/mnt0/hello.txt"); | ||
check_file_exists("/mnt1/x.txt"); | ||
check_file_not_exists("/mnt1/goodbye.txt"); | ||
} else { | ||
fprintf(stderr, "Unknown stage: %d\n", stage); | ||
return 1; | ||
} | ||
return 0; | ||
} | ||
|
||
int main(int argc, char *argv[]) { | ||
return 1; | ||
} |
Empty file.
Empty file.
Empty file.