From cb76e5cd81312e4dba52a06cfc6bc35f795e05bb Mon Sep 17 00:00:00 2001 From: Changqing Jing Date: Sat, 20 Jan 2024 13:30:47 +0800 Subject: Fix emscripten build warning and add missing export (#2367) --- .github/workflows/build.yml | 5 +++-- CMakeLists.txt | 1 + src/c-writer.cc | 2 +- wasm2c/wasm-rt-impl.c | 2 ++ 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 2b086ccf..cf0b710f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -78,8 +78,9 @@ jobs: run: | docker run -di --name emscripten -v $(pwd):/src emscripten/emsdk:latest bash docker exec emscripten emcc -v - docker exec emscripten emcmake cmake . - docker exec emscripten make -j 2 VERBOSE=1 + docker exec emscripten emcmake cmake -B emscripten -DWERROR=ON + docker exec -w /src/emscripten emscripten make -j $(nproc) + wasi: name: wasi runs-on: ubuntu-latest diff --git a/CMakeLists.txt b/CMakeLists.txt index 63f971f7..5b90b50b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -823,6 +823,7 @@ if (EMSCRIPTEN) -sMODULARIZE=1 -sEXPORT_NAME=WabtModule -sWASM=0 + -sEXPORTED_RUNTIME_METHODS=writeAsciiToMemory -Oz ) string(REPLACE ";" " " LIBWABT_LINK_FLAGS_STR "${LIBWABT_LINK_FLAGS}") diff --git a/src/c-writer.cc b/src/c-writer.cc index 0a7cfe3a..0326c886 100644 --- a/src/c-writer.cc +++ b/src/c-writer.cc @@ -1633,7 +1633,7 @@ void CWriter::SerializeFuncType(const FuncType& func_type, *next_byte++ = MangleType(func_type.GetResultType(i)); } - assert(next_byte - mangled_signature == len); + assert(next_byte - mangled_signature == static_cast(len)); // step 4: SHA-256 the whole string sha256({mangled_signature, len}, serialized_type); diff --git a/wasm2c/wasm-rt-impl.c b/wasm2c/wasm-rt-impl.c index 09a28726..57bd74cf 100644 --- a/wasm2c/wasm-rt-impl.c +++ b/wasm2c/wasm-rt-impl.c @@ -148,6 +148,7 @@ static void os_cleanup_signal_handler(void) { #endif #else +#if WASM_RT_USE_MMAP static void* os_mmap(size_t size) { int map_prot = PROT_NONE; int map_flags = MAP_ANONYMOUS | MAP_PRIVATE; @@ -168,6 +169,7 @@ static int os_mprotect(void* addr, size_t size) { static void os_print_last_error(const char* msg) { perror(msg); } +#endif #if WASM_RT_INSTALL_SIGNAL_HANDLER static void os_signal_handler(int sig, siginfo_t* si, void* unused) { -- cgit v1.2.3