From 95ed1dcae10c9810eec6914c1b9f0f2a27e403d2 Mon Sep 17 00:00:00 2001 From: Mic Bowman Date: Thu, 4 Jan 2024 11:13:25 -0800 Subject: [PATCH] Update WAMR to version 1.3 This is not quite as simple as expected. With our default configuration (LIBC on, WASI off) there are a couple errors in WAMR. Namely that os_is_handle_valid is not defined in sgx-platform.c and there is an include of libc_errno.h that appears to be outside the check for WASI includes. Changes were made to work around these problems. Namely we explicitly include the libc header & source. And we add a file that defines the missing function. Signed-off-by: Mic Bowman --- build/__tools__/build.sh | 1 - common/interpreter/wawaka_wasm/CMakeLists.txt | 15 +++++++++++++-- common/interpreter/wawaka_wasm/wamr_fixes.c | 8 ++++++++ interpreters/wasm-micro-runtime | 2 +- 4 files changed, 22 insertions(+), 4 deletions(-) create mode 100644 common/interpreter/wawaka_wasm/wamr_fixes.c diff --git a/build/__tools__/build.sh b/build/__tools__/build.sh index 401873ee..e6c6daa3 100755 --- a/build/__tools__/build.sh +++ b/build/__tools__/build.sh @@ -42,7 +42,6 @@ while true ; do *) echo "Internal error!" ; exit 1 ;; esac done -TEMP if [ ${F_CLIENT} == "yes" ]; then CMAKE_ARGS="-DBUILD_CLIENT=1 -DBUILD_TRUSTED=0 -DBUILD_UNTRUSTED=0" diff --git a/common/interpreter/wawaka_wasm/CMakeLists.txt b/common/interpreter/wawaka_wasm/CMakeLists.txt index 6fc73083..b4fc3e4d 100644 --- a/common/interpreter/wawaka_wasm/CMakeLists.txt +++ b/common/interpreter/wawaka_wasm/CMakeLists.txt @@ -104,13 +104,18 @@ ENABLE_LANGUAGE (ASM) ################################################################# # WAMR Library ################################################################# - # include the build config template file INCLUDE (${WAMR_ROOT_DIR}/build-scripts/config_common.cmake) INCLUDE (${SHARED_DIR}/platform/${WAMR_BUILD_PLATFORM}/shared_platform.cmake) INCLUDE (${SHARED_DIR}/mem-alloc/mem_alloc.cmake) INCLUDE (${SHARED_DIR}/utils/shared_utils.cmake) + +# this picks up the libc_erro.h, this appears to be an error in WAMR in that the +# test for WASI is AFTER the attempt to include a file that is only available when +# WASI is turned on. +INCLUDE (${SHARED_DIR}/platform/common/libc-util/platform_common_libc_util.cmake) + IF (WAMR_BUILD_LIBC_BUILTIN EQUAL 1) INCLUDE (${IWASM_DIR}/libraries/libc-builtin/libc_builtin.cmake) ENDIF () @@ -126,13 +131,19 @@ ENDIF () ADD_LIBRARY (${IWASM_STATIC_NAME} ${PLATFORM_SHARED_SOURCE} + ${PLATFORM_COMMON_LIBC_UTIL_SOURCE} ${MEM_ALLOC_SHARED_SOURCE} ${UTILS_SHARED_SOURCE} ${LIBC_BUILTIN_SOURCE} ${LIBC_WASI_SOURCE} + ${WAMR_POSIX_SOURCES} ${IWASM_COMMON_SOURCE} ${IWASM_INTERP_SOURCE} - ${IWASM_COMPL_SOURCE}) + ${IWASM_COMPL_SOURCE} + # this is necessary because WAMR currently does not have a definition + # for os_is_handle_valid in the sgx_platform.c file + ${CMAKE_CURRENT_SOURCE_DIR}/wamr_fixes.c + ) TARGET_INCLUDE_DIRECTORIES(${IWASM_STATIC_NAME} PUBLIC ${SHARED_DIR}/include) TARGET_INCLUDE_DIRECTORIES(${IWASM_STATIC_NAME} PUBLIC ${IWASM_DIR}/include) diff --git a/common/interpreter/wawaka_wasm/wamr_fixes.c b/common/interpreter/wawaka_wasm/wamr_fixes.c new file mode 100644 index 00000000..3677a0f2 --- /dev/null +++ b/common/interpreter/wawaka_wasm/wamr_fixes.c @@ -0,0 +1,8 @@ +#include "platform_internal.h" + +bool +os_is_handle_valid(os_file_handle *handle) +{ + assert(handle != NULL); + return *handle > -1; +} diff --git a/interpreters/wasm-micro-runtime b/interpreters/wasm-micro-runtime index fb8727ba..78be2215 160000 --- a/interpreters/wasm-micro-runtime +++ b/interpreters/wasm-micro-runtime @@ -1 +1 @@ -Subproject commit fb8727ba683b3969cc6075356bf109defefe6003 +Subproject commit 78be22159489c691f9162d4f09d9e5307fbb0851