From a0b581b7718e9df474e1e4ca13d0608f593b891a Mon Sep 17 00:00:00 2001 From: Chongyun Lee <45286352+licy183@users.noreply.github.com> Date: Wed, 5 Oct 2022 17:47:31 +0800 Subject: [PATCH] wasmedge: update to 0.11.1 and enable arm --- packages/wasmedge/build.sh | 27 +++---- packages/wasmedge/fix-for-arm.patch | 74 ++++++++++++++++++++ packages/wasmedge/getsockopt-socklen_t.patch | 12 ++-- 3 files changed, 89 insertions(+), 24 deletions(-) create mode 100644 packages/wasmedge/fix-for-arm.patch diff --git a/packages/wasmedge/build.sh b/packages/wasmedge/build.sh index b81c72d7ca..95f79b0ba1 100644 --- a/packages/wasmedge/build.sh +++ b/packages/wasmedge/build.sh @@ -3,15 +3,21 @@ TERMUX_PKG_DESCRIPTION="A lightweight, high-performance, and extensible WebAssem TERMUX_PKG_LICENSE="Apache-2.0" TERMUX_PKG_LICENSE_FILE="LICENSE, LICENSE.spdx" TERMUX_PKG_MAINTAINER="@termux" -TERMUX_PKG_VERSION=0.10.1 +TERMUX_PKG_VERSION=0.11.1 TERMUX_PKG_SRCURL=https://github.com/WasmEdge/WasmEdge/archive/${TERMUX_PKG_VERSION}.tar.gz -TERMUX_PKG_SHA256=f87bf06be0b94e8fcf974b6029f1f7ab46fd7526de33bff70d9cf4117512d07a +TERMUX_PKG_SHA256=85131c93811111424045dda6bd0ca012491b297638a0e7d9387391457aa1a301 TERMUX_PKG_DEPENDS="libc++, libllvm" TERMUX_PKG_BUILD_DEPENDS="boost-headers, boost-static, libllvm-static, libpolly, lld, llvm" TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" -DWASMEDGE_FORCE_DISABLE_LTO=ON " +# WASMEDGE_BUILD_AOT_RUNTIME is not supported on 32-bit archs. +# See https://github.com/WasmEdge/WasmEdge/blob/2414c83047f2bf8fe241716be6ef8c0de34dc245/lib/aot/compiler.cpp#L4874 +if [ $TERMUX_ARCH_BITS = 32 ]; then + TERMUX_PKG_EXTRA_CONFIGURE_ARGS+=" -DWASMEDGE_BUILD_AOT_RUNTIME=OFF" +fi + # Build failure for i686 (0.9.1): # ``` # [...]/wasmedge/src/thirdparty/wasi/api.hpp:55:1: error: static_assert failed @@ -26,27 +32,12 @@ TERMUX_PKG_EXTRA_CONFIGURE_ARGS=" # /home/builder/.termux-build/wasmedge/src/lib/system/allocator.cpp:149:42: error: use of undeclared identifier 'PROT_READ' # if (auto Pointer = mmap(nullptr, Size, PROT_READ | PROT_WRITE, # ^ -# Build failure for arm (0.10.1): -# [23/83] Building CXX object lib/plugin/CMakeFiles/wasmedgePlugin.dir/plugin.cpp.o -# FAILED: lib/plugin/CMakeFiles/wasmedgePlugin.dir/plugin.cpp.o -# ... -# In file included from /home/builder/.termux-build/wasmedge/src/lib/plugin/plugin.cpp:4: -# In file included from /home/builder/.termux-build/wasmedge/src/include/plugin/plugin.h:20: -# In file included from /home/builder/.termux-build/wasmedge/src/include/runtime/instance/module.h:24: -# /home/builder/.termux-build/wasmedge/src/include/runtime/instance/table.h:146:15: error: object of type -# 'std::__vector_base, -# std::allocator>>::value_type' -# (aka 'WasmEdge::Variant') -# cannot be assigned because its copy assignment operator is implicitly deleted -# Refs[Idx] = Val; -# ^ # Both i686 and arm warning (0.10.1): # /home/builder/.termux-build/wasmedge/src/lib/aot/compiler.cpp:1202:24: warning: unused variable 'VectorSize' [-Wunused-variable] # const uint32_t VectorSize = IsFloat ? 4 : 2; # ^ # Upstream doesnt seem to support 32bit platforms well -TERMUX_PKG_BLACKLISTED_ARCHES="arm, i686" +TERMUX_PKG_BLACKLISTED_ARCHES="i686" termux_step_pre_configure() { _NEED_DUMMY_LIBPTHREAD_A= diff --git a/packages/wasmedge/fix-for-arm.patch b/packages/wasmedge/fix-for-arm.patch new file mode 100644 index 0000000000..db779c6548 --- /dev/null +++ b/packages/wasmedge/fix-for-arm.patch @@ -0,0 +1,74 @@ +This reverts commit af59a11d976821c7775fecc1f5cad6c2b6fc728c. +diff --git a/include/common/variant.h b/include/common/variant.h +index dbfaad64..d1e6846f 100644 +--- a/include/common/variant.h ++++ b/include/common/variant.h +@@ -35,7 +35,9 @@ union VariadicUnion { + + template + constexpr VariadicUnion(std::in_place_index_t<0>, Args &&...Values) +- : First(std::forward(Values)...) {} ++ : First() { ++ ::new (&First) FirstT(std::forward(Values)...); ++ } + + template + constexpr VariadicUnion(std::in_place_index_t, Args &&...Values) +@@ -43,28 +45,28 @@ union VariadicUnion { + + template constexpr const T &get() const &noexcept { + if constexpr (std::is_same_v) { +- return First; ++ return *std::launder(reinterpret_cast(&First)); + } else { + return Rest.template get(); + } + } + template constexpr T &get() &noexcept { + if constexpr (std::is_same_v) { +- return First; ++ return *std::launder(reinterpret_cast(&First)); + } else { + return Rest.template get(); + } + } + template constexpr const T &&get() const &&noexcept { + if constexpr (std::is_same_v) { +- return std::move(First); ++ return std::move(*std::launder(reinterpret_cast(&First))); + } else { + return std::move(Rest).template get(); + } + } + template constexpr T &&get() &&noexcept { + if constexpr (std::is_same_v) { +- return std::move(First); ++ return std::move(*std::launder(reinterpret_cast(&First))); + } else { + return std::move(Rest).template get(); + } +@@ -74,7 +76,7 @@ union VariadicUnion { + constexpr T &emplace(Args &&...Values) &noexcept { + if constexpr (std::is_same_v) { + ::new (&First) FirstT(std::forward(Values)...); +- return *std::launder(&First); ++ return *std::launder(reinterpret_cast(&First)); + } else { + return Rest.template emplace(std::forward(Values)...); + } +@@ -84,13 +86,13 @@ union VariadicUnion { + constexpr T &emplace(Args &&...Values) &&noexcept { + if constexpr (std::is_same_v) { + ::new (&First) FirstT(std::forward(Values)...); +- return std::move(*std::launder(&First)); ++ return std::move(*std::launder(reinterpret_cast(&First))); + } else { + return std::move(Rest).template emplace(std::forward(Values)...); + } + } + +- FirstT First; ++ std::aligned_storage_t First; + VariadicUnion Rest; + }; + diff --git a/packages/wasmedge/getsockopt-socklen_t.patch b/packages/wasmedge/getsockopt-socklen_t.patch index 91b157df03..712a678586 100644 --- a/packages/wasmedge/getsockopt-socklen_t.patch +++ b/packages/wasmedge/getsockopt-socklen_t.patch @@ -64,14 +64,14 @@ diff -uNr WasmEdge/lib/host/wasi/wasifunc.cpp WasmEdge.mod/lib/host/wasi/wasifun --- WasmEdge/lib/host/wasi/wasifunc.cpp 2022-07-28 18:56:12.000000000 +0800 +++ WasmEdge.mod/lib/host/wasi/wasifunc.cpp 2022-08-15 01:56:27.730339246 +0800 @@ -2061,7 +2061,7 @@ - Expect - WasiSockGetOpt::body(Runtime::Instance::MemoryInstance *MemInst, int32_t Fd, - uint32_t SockOptLevel, uint32_t SockOptName, -- uint32_t FlagPtr, uint32_t FlagSizePtr) { -+ uint32_t FlagPtr, socklen_t FlagSizePtr) { + Expect WasiSockGetOpt::body(const Runtime::CallingFrame &Frame, + int32_t Fd, uint32_t SockOptLevel, + uint32_t SockOptName, uint32_t FlagPtr, +- uint32_t FlagSizePtr) { ++ socklen_t FlagSizePtr) { + auto *MemInst = Frame.getMemoryByIndex(0); if (MemInst == nullptr) { return __WASI_ERRNO_FAULT; - } @@ -2080,7 +2080,7 @@ WasiSockOptName = *Res; }