-
Couldn't load subscription status.
- Fork 728
Add WASM32 Platform #4639
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
base: main
Are you sure you want to change the base?
Add WASM32 Platform #4639
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,19 @@ | |
| #define PLATFORM_API_EXTENSION_H | ||
|
|
||
| #include "platform_common.h" | ||
|
|
||
| #if !defined(__wasm32__) && !defined(__EMSCRIPTEN__) | ||
| #include "platform_wasi_types.h" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why do you avoid using platform_wasi_types.h? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The compilers wasi types get imported by the system libraries, resulting in multiple definitions. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok, i got it. i feel it's cleaner to change our definitions to avoid conflicting with host definitions though. (i'm not asking to change this PR) |
||
| #else | ||
| #include <wasi/api.h> | ||
| #define __WASI_ESUCCESS (0) | ||
| #define __WASI_EINVAL (28) | ||
| #define __WASI_CLOCK_REALTIME (0) | ||
| #define __WASI_CLOCK_MONOTONIC (1) | ||
| #define __WASI_CLOCK_PROCESS_CPUTIME_ID (2) | ||
| #define __WASI_CLOCK_THREAD_CPUTIME_ID (3) | ||
| #endif | ||
|
|
||
| /** | ||
| * The related data structures should be defined | ||
| * in platform_internal.h | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| /* | ||
| * Copyright (C) 2019 Intel Corporation. All rights reserved. | ||
| * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| */ | ||
|
|
||
| #include "platform_api_vmcore.h" | ||
|
|
||
| int | ||
| bh_platform_init() | ||
| { | ||
| return 0; | ||
| } | ||
|
|
||
| void | ||
| bh_platform_destroy() | ||
| {} | ||
|
|
||
| int | ||
| os_printf(const char *format, ...) | ||
| { | ||
| int ret = 0; | ||
| va_list ap; | ||
|
|
||
| va_start(ap, format); | ||
| #ifndef BH_VPRINTF | ||
| ret += vprintf(format, ap); | ||
| #else | ||
| ret += BH_VPRINTF(format, ap); | ||
| #endif | ||
| va_end(ap); | ||
|
|
||
| return ret; | ||
| } | ||
|
|
||
| int | ||
| os_vprintf(const char *format, va_list ap) | ||
| { | ||
| #ifndef BH_VPRINTF | ||
| return vprintf(format, ap); | ||
| #else | ||
| return BH_VPRINTF(format, ap); | ||
| #endif | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| #include "../linux/platform_internal.h" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
|
|
||
| # Copyright (C) 2019 Intel Corporation. All rights reserved. | ||
| # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
|
|
||
| set (PLATFORM_SHARED_DIR ${CMAKE_CURRENT_LIST_DIR}) | ||
|
|
||
| add_definitions(-DBH_PLATFORM_WASM32) | ||
|
|
||
| include_directories(${PLATFORM_SHARED_DIR}) | ||
| include_directories(${PLATFORM_SHARED_DIR}/../include) | ||
|
|
||
| include (${CMAKE_CURRENT_LIST_DIR}/../common/posix/platform_api_posix.cmake) | ||
|
|
||
| file (GLOB_RECURSE source_all ${PLATFORM_SHARED_DIR}/*.c) | ||
|
|
||
| set (PLATFORM_SHARED_SOURCE ${source_all} ${PLATFORM_COMMON_POSIX_SOURCE}) | ||
|
|
||
| file (GLOB header ${PLATFORM_SHARED_DIR}/../include/*.h) | ||
| LIST (APPEND RUNTIME_LIB_HEADER_LIST ${header}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IIUC
WASM_ENABLE_INVOKE_NATIVEis designed to prevent the involvement of runtime built-in functions. In that case,-DWAMR_BUILD_LIBC_BUILTIN=0 -DWAMR_BUILD_LIBC_WASI=0can achieve the same effect, along with-DWAMR_BUILD_QUICK_AOT_ENTRY=0.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i guess it's a good opportunity to replace the heavy ifdef conditions with something easier to maintain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How would a wasm module invoke any native function with those restrictions?