Skip to content
This repository has been archived by the owner on Mar 24, 2022. It is now read-only.

Commit

Permalink
use wasi sdk 12 (#615)
Browse files Browse the repository at this point in the history
* lucet-wasi-sdk: wasi sdk 12 no longer supports `--no-threads`

* dockerfile: use wasi-sdk 12

* ci: use wasi-sdk 12

* lucet-runtime: fix tests for wasi-sdk-12 by rewriting use_allocator.c in wat

use_allocator.c was a fixture used for tests that manipulated the size
of linear memory. written in C, it depended heavily on the implemention
of wasi-libc's allocator, which changed from sdk-11 to sdk-12. Rather
than try to depend on the new (still fragile) behavior these tests were
rewritten in pure wat, with a much simpler allocator behavior that just
expands the linear memory. The tests were modified to observe this new
behavior.
  • Loading branch information
Pat Hickey committed Dec 4, 2020
1 parent a893069 commit 8fa8a4a
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 76 deletions.
6 changes: 3 additions & 3 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,10 @@ commands:
name: "Install wasi-sdk"
command: |
set -x
curl -sS -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk-11.0-macos.tar.gz
tar xf wasi-sdk-11.0-macos.tar.gz
curl -sS -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz
tar xf wasi-sdk-12.0-macos.tar.gz
sudo mkdir -p /opt/wasi-sdk
sudo mv wasi-sdk-11.0/* /opt/wasi-sdk/
sudo mv wasi-sdk-12.0/* /opt/wasi-sdk/
- run:
name: "Make target: test-ci"
command: |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/mac-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ jobs:
- name: Install wasi-sdk (macos)
run: |
curl -sS -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk-11.0-macos.tar.gz
tar xf wasi-sdk-11.0-macos.tar.gz
curl -sS -L -O https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk-12.0-macos.tar.gz
tar xf wasi-sdk-12.0-macos.tar.gz
sudo mkdir -p /opt/wasi-sdk
sudo mv wasi-sdk-11.0/* /opt/wasi-sdk/
sudo mv wasi-sdk-12.0/* /opt/wasi-sdk/
- name: Test Lucet
run: make test-ci
Expand Down
6 changes: 3 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ RUN rustup target add wasm32-wasi
# Optional additional Rust programs
RUN cargo install --debug rsign2 cargo-audit mdbook

RUN curl -sSLO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-11/wasi-sdk_11.0_amd64_ubuntu20.04.deb \
&& dpkg -i wasi-sdk_11.0_amd64_ubuntu20.04.deb \
&& rm -f wasi-sdk_11.0_amd64_ubuntu20.04.deb
RUN curl -sSLO https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk_12.0_amd64.deb \
&& dpkg -i wasi-sdk_12.0_amd64.deb \
&& rm -f wasi-sdk_12.0_amd64.deb

ENV WASI_SDK=/opt/wasi-sdk

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
(module
(memory 1)
;; Expand the wasm heap and initialize it to a value.
;; sets out-pointer to -1 if heap expansion fails.
;; Parameters are:
;; 0. initialization value (byte)
;; 1. size (in wasm pages)
;; 2. out-pointer to store start address of expanded heap
;; Locals are:
;; 3. expanded heap start page
(func $expand_and_memset (export "expand_and_memset") (param i32 i32 i32)
(local i32)
(local.set 3 (memory.grow (local.get 1)))
(if (i32.eq (local.get 3) (i32.const -1))
(then (i32.store (local.get 2) (i32.const -1)))
(else
(i32.store (local.get 2) (i32.mul (local.get 3) (i32.const 65536)))
(call $memset (i32.load (local.get 2)) (local.get 0) (i32.mul (local.get 1) (i32.const 65536)))
)
)
)


;; memset
;; parameters are
;; 0. pointer to start of region
;; 1. constant value (byte)
;; 2. size of region, in bytes
;; locals are
;; 3. current pointer
(func $memset (export "memset") (param i32 i32 i32)
(local i32)
(local.set 3 (local.get 0))
(loop
(i32.store8 (local.get 3) (local.get 1))
(local.set 3 (i32.add (local.get 3) (i32.const 1)))
(br_if 0 (i32.lt_u (local.get 3) (i32.add (local.get 0) (local.get 2))))
)
)

;; increment_ptr
;; increment the byte at the pointer
;; parameters are
;; 0. pointer to byte
(func $increment_ptr (export "increment_ptr") (param i32)
(i32.store8 (local.get 0)
(i32.add (i32.const 1) (i32.load (local.get 0))))
)

)
3 changes: 1 addition & 2 deletions lucet-runtime/lucet-runtime-tests/src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ where
let workdir = TempDir::new().expect("create working directory");

let wasm_build = Link::new(&[c_file])
.with_cflag("-nostartfiles")
.with_link_opt(LinkOpt::NoDefaultEntryPoint)
.with_cflag("-mexec-model=reactor")
.with_link_opt(LinkOpt::AllowUndefinedAll)
.with_link_opt(LinkOpt::ExportAll);

Expand Down
Loading

0 comments on commit 8fa8a4a

Please sign in to comment.