Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib/lib-wamr: Move to musl and address compiler errors #8

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Config.uk
Original file line number Diff line number Diff line change
@@ -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

Expand Down
3 changes: 3 additions & 0 deletions include/bh_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -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, ...);
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions patches/0005-adapt-main-c-to-unikraft.patch
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@
- 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,
Expand Down
11 changes: 11 additions & 0 deletions patches/0006-recursive_np-to-recursive.patch
Original file line number Diff line number Diff line change
@@ -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);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you need this change?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is needed as it would otherwise not compile as PTHREAD_MUTEX_RECURSIVE_NP is not defined anywhere in musl pthread library, but PTHREAD_MUTEX_RECURSIVE is.

ret = pthread_mutex_init(mutex, &mattr);
pthread_mutexattr_destroy(&mattr);