Skip to content

Commit

Permalink
Update WASI SDK to version 21
Browse files Browse the repository at this point in the history
The WAMR upgrade enables an upgrade for WASI SDK.
Needed to add definitions for a few additional
symbols.

Signed-off-by: Mic Bowman <[email protected]>
  • Loading branch information
cmickeyb committed Jan 6, 2024
1 parent 837e2af commit 8183fd5
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 7 deletions.
8 changes: 4 additions & 4 deletions common/interpreter/wawaka_wasm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ enclave with Wawaka enabled, you will need to do the following:
There are many toolchains that could be used to build a WASM code. By default, Wawaka contracts are
compiled with the compilers provided by [WASI SDK](https://github.com/WebAssembly/wasi-sdk). To use
WASI SDK, download and install the appropriate package file from
https://github.com/WebAssembly/wasi-sdk/releases (we have verified that release wasi-sdk-12 works
with WAMR version WAMR-1.1.2).
https://github.com/WebAssembly/wasi-sdk/releases (we have verified that release wasi-sdk-21 works
with WAMR version WAMR-1.3).

```bash
wget -q -P /tmp https://github.com/WebAssembly/wasi-sdk/releases/download/wasi-sdk-12/wasi-sdk_12.0_amd64.deb
Expand All @@ -46,14 +46,14 @@ SDK would be installed in the directory `/opt/wasi-sdk`.
If wawaka is configured as the contract interpreter, the libraries implementing the WASM interpreter
will be built for use with Intel SGX. The source for the WAMR interpreter is
included as a submodule in the interpreters/ folder, and will
always point to the latest tagged commit that we have validated: `WAMR-1.1.2`.
always point to the latest tagged commit that we have validated: `WAMR-1.3`.
If the PDO parent repo was not cloned with the `--recurse-submodules` flag,
you will have to explictly pull the submodule source.

```
cd ${PDO_SOURCE_ROOT}/interpreters/wasm-micro-runtime
git submodule update --init
git checkout WAMR-1.1.2 # optional
git checkout WAMR-1.3 # optional
```

The WAMR API is built during the Wawaka build, so no additional
Expand Down
33 changes: 31 additions & 2 deletions contracts/wawaka/common/Util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,20 @@

#include "Types.h"
#include "Util.h"
#include "WasmExtensions.h"

#ifdef USE_WASI_SDK
#include <new>

// this function does not appear to be defined in the wasi-sdk
// lib c++. we need
// -----------------------------------------------------------------
// these functions do not appear to be defined in the wasi-sdk
// lib c++. an error is generally raised about the failure to link
// an import function. for ones with obvious implements like standard
// new and delete, we provide viable implementation. for others that
// are not supported, a message will be generated and the application
// will abort.
// -----------------------------------------------------------------

std::new_handler std::get_new_handler() _NOEXCEPT
{
return NULL;
Expand All @@ -39,11 +47,32 @@ void * operator new[](size_t sz) throw(std::bad_alloc)
return malloc(sz);
}

void * operator new(size_t sz, std::align_val_t v)
{
CONTRACT_SAFE_LOG(4, "attempt to invoke unsupported aligned allocation");
std::abort();
}

void operator delete(void *ptr) _NOEXCEPT
{
free(ptr);
}

void operator delete(void *ptr, std::align_val_t) _NOEXCEPT
{
CONTRACT_SAFE_LOG(4, "attempt to invoke unsupported aligned deallocation");
std::abort();
}

#include <stdio.h>
int vfprintf(FILE *__restrict, const char *__restrict, __isoc_va_list)
{
CONTRACT_SAFE_LOG(4, "attempt to invoke unsupported vfprintf");
std::abort();

return -1;
}

#endif

/* ----------------------------------------------------------------- *
Expand Down
3 changes: 2 additions & 1 deletion docker/pdo_base.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ RUN apt-get update \
# -----------------------------------------------------------------
# Install WASI toolkit
# -----------------------------------------------------------------
ARG WASI_VERSION=12
##ARG WASI_VERSION=12
ARG WASI_VERSION=21
ARG WASI_PACKAGE="wasi-sdk_${WASI_VERSION}.0_amd64.deb"

WORKDIR /tmp
Expand Down

0 comments on commit 8183fd5

Please sign in to comment.