]> xenbits.xensource.com Git - unikraft/libs/wamr.git/commitdiff
lib/libwamr: Move to musl and address compiler errors RELEASE-0.14.0
authorRobert Klink <roberthklink@gmail.com>
Sat, 15 Jul 2023 13:23:56 +0000 (15:23 +0200)
committerUnikraft <monkey@unikraft.io>
Mon, 7 Aug 2023 14:08:57 +0000 (14:08 +0000)
Move from the `LIBNEWLIBC` and `LIBPTHREAD_EMBEDDED` to `LIBMUSL`.
Changed needed to build lib-wamr were:
* Using the `uk/essentials.h` header for a definition of `offsetof`
* Adding a new `0006` patch file to change `PTHREAD_MUTEX_RECURSIVE_NP` into
`PTHREAD_MUTEX_RECURSIVE` as the former on isn't defined
* Change the `0005` patch file to use modern working unikraft initrd loading
code so it can load the `.wasm` files

Signed-off-by: Robert Klink <roberthklink@gmail.com>
Signed-off-by: Ricardo Mohamedhoesein <rmohamedhoesein3@gmail.com>
Co-authored-by: Ricardo Mohamedhoesein <rmohamedhoesein3@gmail.com>
Reviewed-by: Eduard Vintilă <eduard.vintila47@gmail.com>
Reviewed-by: Stefan Jumarea <stefanjumarea02@gmail.com>
Approved-by: Razvan Deaconescu <razvand@unikraft.io>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Closes: #8

Config.uk
include/bh_platform.h
patches/0005-adapt-main-c-to-unikraft.patch
patches/0006-recursive_np-to-recursive.patch [new file with mode: 0644]

index 49faa6ccb8d42b84f19866fa9afffeb8bc9d4d79..2f2018cccca27f0899d031475a26d6c76a56f216 100644 (file)
--- a/Config.uk
+++ b/Config.uk
@@ -1,9 +1,8 @@
 menuconfig LIBWAMR
        bool "wamr - Intel's WebAssembly Micro Runtime"
        default y
-       select LIBNEWLIBC
+       select LIBMUSL
        select LIBLWIP
-       select LIBPTHREAD_EMBEDDED
        select LIBUKTIME
        select UKUNISTD
           
index 44aedc6bb898d28db487218804890659d3e8ceba..3d1d2d72a23fca5d85d419f0c7595ee8abd8f8de 100644 (file)
@@ -26,6 +26,7 @@
 #include <time.h>
 #include <string.h>
 #include <stdio.h>
+#include <uk/essentials.h>
 
 #ifndef __cplusplus
 int snprintf(char *buffer, size_t count, const char *format, ...);
@@ -111,6 +112,8 @@ typedef int bh_socket_t;
 #  define NULL ((void*) 0)
 #endif
 
+#define offsetof __offsetof
+
 #define bh_assert assert
 
 extern int b_memcpy_s(void * s1, unsigned int s1max, const void * s2,
index c8f73e5cf8afafabd0f857656f483d712d5ed779..3909ddf9567272a72bedbd642b937de5228d18dd 100644 (file)
 -        wasm_printf("%s\n", error_buf);
 -        goto fail4;
 +    /* load from initrd */
-+    struct ukplat_memregion_desc img;
++    struct ukplat_memregion_desc *img;
 +    if (ukplat_memregion_find_initrd0(&img) >= 0) {
-+      wasm_file_buf = (uint8*)img.base;
-+      wasm_file_size = img.len;
++      wasm_file_buf = (uint8*)img->vbase;
++      wasm_file_size = img->len;
 +      
 +      /* load WASM module */
 +      if (!(wasm_module = wasm_runtime_load(wasm_file_buf, wasm_file_size,
diff --git a/patches/0006-recursive_np-to-recursive.patch b/patches/0006-recursive_np-to-recursive.patch
new file mode 100644 (file)
index 0000000..dbf927a
--- /dev/null
@@ -0,0 +1,11 @@
+--- /core/shared-lib/platform/linux/bh_thread.c orig   2023-07-15 14:14:26.388776102 +0200
++++ /core/shared-lib/platform/linux/bh_thread.c        2023-07-15 14:13:17.443138319 +0200
+@@ -176,7 +176,7 @@
+     if (ret)
+         return BHT_ERROR;
+-    pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE_NP);
++    pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_RECURSIVE);
+     ret = pthread_mutex_init(mutex, &mattr);
+     pthread_mutexattr_destroy(&mattr);