Browse Source

wasm-micro-runtime: update to 2.2.0 (#6841)

* wamr:update to 2.2.0

* clean

* fmt

* Add `log` syslink for android platform

* try with `add_syslinks("android")`

* retry with `add_syslinks("log", "android")`

* try resolve android link to `log` library

* fixup
Saikari 5 months ago
parent
commit
4855d9fca0

+ 27 - 0
packages/w/wasm-micro-runtime/patches/2.2.0/fix-windows.patch

@@ -0,0 +1,27 @@
+diff --git a/core/shared/platform/windows/win_clock.c b/core/shared/platform/windows/win_clock.c
+index ec0bc85..53f9bdb 100644
+--- a/core/shared/platform/windows/win_clock.c
++++ b/core/shared/platform/windows/win_clock.c
+@@ -10,9 +10,19 @@
+ #define NANOSECONDS_PER_SECOND 1000000000ULL
+ #define NANOSECONDS_PER_TICK 100
+ 
+-extern NTSTATUS
+-NtQueryTimerResolution(PULONG MinimumResolution, PULONG MaximumResolution,
+-                       PULONG CurrentResolution);
++#ifndef __kernel_entry
++#define __kernel_entry
++#endif
++#ifndef NTAPI
++#define NTAPI
++#endif
++#ifndef _Out_
++#define _Out_
++#endif
++extern __kernel_entry NTSTATUS NTAPI
++NtQueryTimerResolution(_Out_ PULONG MinimumResolution,
++                       _Out_ PULONG MaximumResolution,
++                       _Out_ PULONG CurrentResolution);
+ 
+ static __wasi_errno_t
+ calculate_monotonic_clock_frequency(uint64 *out_frequency)

+ 26 - 0
packages/w/wasm-micro-runtime/patches/2.2.0/log-link-android.patch

@@ -0,0 +1,26 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 40658e9..237bb62 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -172,6 +172,10 @@ if (WAMR_BUILD_STATIC)
+       target_link_libraries(iwasm_static PRIVATE ntdll)
+     endif()
+ 
++    if (ANDROID)
++      target_link_libraries(iwasm_static PRIVATE log)
++    endif()
++
+     install (TARGETS iwasm_static ARCHIVE DESTINATION lib)
+ endif ()
+ 
+@@ -194,6 +198,10 @@ if (WAMR_BUILD_SHARED)
+       target_link_libraries(iwasm_shared PRIVATE ntdll)
+     endif()
+ 
++    if (ANDROID)
++      target_link_libraries(iwasm_shared PRIVATE log)
++    endif()
++
+     install (TARGETS iwasm_shared LIBRARY DESTINATION lib)
+ endif ()
+ 

+ 17 - 1
packages/w/wasm-micro-runtime/xmake.lua

@@ -6,6 +6,7 @@ package("wasm-micro-runtime")
     add_urls("https://github.com/bytecodealliance/wasm-micro-runtime/archive/refs/tags/WAMR-$(version).tar.gz", {excludes = {"*/language-bindings/python/LICENSE"}})
     add_urls("https://github.com/bytecodealliance/wasm-micro-runtime.git")
 
+    add_versions("2.2.0", "93b6ba03f681e061967106046b1908631ee705312b9a6410f3baee7af7c6aac9")
     add_versions("1.3.2", "58961ba387ed66ace2dd903597f1670a42b8154a409757ae6f06f43fe867a98c")
     add_versions("1.2.3", "85057f788630dc1b8c371f5443cc192627175003a8ea63c491beaff29a338346")
 
@@ -15,6 +16,16 @@ package("wasm-micro-runtime")
     add_patches("1.3.2", path.join(os.scriptdir(), "patches", "libc_uvwasi.patch"), "e83ff42588cc112588c7fde48a1bd9df7ffa8fa41f70dd99af5d6b0325ce46f7")
     add_patches("1.2.3", path.join(os.scriptdir(), "patches", "libc_uvwasi.patch"), "e83ff42588cc112588c7fde48a1bd9df7ffa8fa41f70dd99af5d6b0325ce46f7")
 
+    -- Resolve re-definition of NtQueryTimerResolution
+    if is_plat("windows") then
+        add_patches("2.2.0", path.join(os.scriptdir(), "patches", "2.2.0", "fix-windows.patch"), "bf6f96c204959361827ac0e3b3da6e686abaaf56b10078c60866639407bc5fb1")
+    end
+
+    -- Resolve missing log library link
+    if is_plat("android") then
+        add_patches("2.2.0", path.join(os.scriptdir(), "patches", "2.2.0", "log-link-android.patch"), "66644a9b86fa26368c029c670f2c5529ba03fba3f5ed6f2aa11f6c359c293cab")
+    end
+
     add_configs("interp", {description = "Enable interpreter", default = true, type = "boolean"})
     add_configs("fast_interp", {description = "Enable fast interpreter", default = false, type = "boolean"})
     add_configs("aot", {description = "Enable AOT", default = false, type = "boolean"})
@@ -35,6 +46,8 @@ package("wasm-micro-runtime")
         add_syslinks("ntdll", "ws2_32")
     elseif is_plat("linux", "bsd") then
         add_syslinks("m", "dl", "pthread")
+    elseif is_plat("android") then
+        add_syslinks("log", "android")
     end
 
     add_deps("cmake")
@@ -56,7 +69,10 @@ package("wasm-micro-runtime")
     end)
 
     on_install("windows", "linux", "macosx", "bsd", "android", function (package)
-        local configs = {"-DWAMR_BUILD_INVOKE_NATIVE_GENERAL=1"}
+        local configs = {
+            "-DWAMR_BUILD_INVOKE_NATIVE_GENERAL=1",
+            "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW"
+        }
         table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
         table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
         if package:is_plat("windows") and (not package:config("shared")) then