-
Notifications
You must be signed in to change notification settings - Fork 10
WASM: add webassembly-micro-runtime port #120
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
Open
R4ken
wants to merge
1
commit into
master
Choose a base branch
from
jrak/wamr
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| DisableFormat: true | ||
| SortIncludes: Never |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| #include "wasm_export.h" | ||
| #include "example.h" | ||
| #include <string.h> | ||
|
R4ken marked this conversation as resolved.
|
||
| #include <stdio.h> | ||
|
|
||
|
R4ken marked this conversation as resolved.
|
||
| int foo1(wasm_exec_env_t exec_env, int a, int b) | ||
| { | ||
| return a * b + 3; | ||
| } | ||
|
R4ken marked this conversation as resolved.
|
||
|
|
||
| void foo2(wasm_exec_env_t exec_env, unsigned char *msg, uint8_t *buffer, int buf_len) | ||
| { | ||
| strncpy(msg, buffer, buf_len); | ||
| } | ||
|
oI0ck marked this conversation as resolved.
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| #include "wasm_export.h" | ||
|
|
||
| int foo1(wasm_exec_env_t exec_env, int a, int b); | ||
| void foo2(wasm_exec_env_t exec_env, unsigned char *msg, uint8_t *buffer, int buf_len); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #include <stddef.h> | ||
| #include "wasm_export.h" | ||
| #include "example/example.h" | ||
|
|
||
| NativeSymbol native_symbols[] = { | ||
| { "foo1", // the name of WASM function name | ||
| foo1, // the native function pointer | ||
| "(ii)i", // the function prototype signature | ||
| NULL }, | ||
| { "foo2", // the name of WASM function name | ||
| foo2, // the native function pointer | ||
| "($*~)", // the function prototype signature | ||
| NULL } | ||
| }; | ||
|
|
||
| int n_native_symbols = sizeof(native_symbols) / sizeof(NativeSymbol); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| diff --git a/product-mini/platforms/linux/CMakeLists.txt b/product-mini/platforms/linux/CMakeLists.txt | ||
| index cef8329d..af5c2f89 100644 | ||
| --- a/product-mini/platforms/linux/CMakeLists.txt | ||
| +++ b/product-mini/platforms/linux/CMakeLists.txt | ||
| @@ -3,15 +3,17 @@ | ||
|
|
||
| cmake_minimum_required (VERSION 3.14) | ||
|
|
||
| +SET(CMAKE_FIND_ROOT_PATH $ENV{PHOENIX_SYSROOT}) | ||
| + | ||
| include(CheckPIESupported) | ||
|
|
||
| -project (iwasm) | ||
| +project (iwasm C) | ||
|
|
||
| option(BUILD_SHARED_LIBS "Build using shared libraries" OFF) | ||
|
|
||
| set (CMAKE_VERBOSE_MAKEFILE OFF) | ||
|
|
||
| -set (WAMR_BUILD_PLATFORM "linux") | ||
| +set (WAMR_BUILD_PLATFORM "phoenix") | ||
|
|
||
| # Reset default linker flags | ||
| set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "") | ||
| @@ -49,14 +51,19 @@ if (NOT CMAKE_BUILD_TYPE) | ||
| set(CMAKE_BUILD_TYPE Release) | ||
| endif () | ||
|
|
||
| +if (DEFINED TARGET_HAS_TLS) | ||
| + set(TARGET_HAS_TLS 1) | ||
| + message(STATUS "Target supports thread local storage") | ||
| +endif () | ||
| + | ||
| if (NOT DEFINED WAMR_BUILD_INTERP) | ||
| # Enable Interpreter by default | ||
| set (WAMR_BUILD_INTERP 1) | ||
| endif () | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_AOT) | ||
| - # Enable AOT by default. | ||
| - set (WAMR_BUILD_AOT 1) | ||
| + # Disable AOT by default. | ||
| + set (WAMR_BUILD_AOT 0) | ||
| endif () | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_JIT) | ||
| @@ -95,8 +102,8 @@ if (NOT DEFINED WAMR_BUILD_LIB_PTHREAD) | ||
| endif () | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_LIB_WASI_THREADS) | ||
| - # Disable wasi threads library by default | ||
| - set (WAMR_BUILD_LIB_WASI_THREADS 0) | ||
| + # Enable wasi threads library by default | ||
| + set (WAMR_BUILD_LIB_WASI_THREADS 1) | ||
| endif() | ||
|
|
||
| if (NOT DEFINED WAMR_BUILD_MINI_LOADER) | ||
| @@ -125,12 +132,6 @@ if (WAMR_BUILD_DEBUG_INTERP EQUAL 1) | ||
| set (WAMR_BUILD_SIMD 0) | ||
| endif () | ||
|
|
||
| -# if enable wasi-nn, both wasi-nn-backends and iwasm | ||
| -# need to use same WAMR (dynamic) libraries | ||
| -if (WAMR_BUILD_WASI_NN EQUAL 1) | ||
| - set (BUILD_SHARED_LIBS ON) | ||
| -endif () | ||
| - | ||
| set (WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..) | ||
|
|
||
| include (${WAMR_ROOT_DIR}/build-scripts/runtime_lib.cmake) | ||
| @@ -139,10 +140,10 @@ check_pie_supported() | ||
|
|
||
| set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--gc-sections") | ||
|
|
||
| -set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow") | ||
| +set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wshadow -Os") | ||
| # set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wconversion -Wsign-conversion") | ||
|
|
||
| -set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused") | ||
| +set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wformat -Wformat-security -Wno-unused -Os") | ||
|
|
||
| if (WAMR_BUILD_TARGET MATCHES "X86_.*" OR WAMR_BUILD_TARGET STREQUAL "AMD_64") | ||
| if (NOT (CMAKE_C_COMPILER MATCHES ".*clang.*" OR CMAKE_C_COMPILER_ID MATCHES ".*Clang")) | ||
| @@ -162,7 +163,11 @@ endif () | ||
|
|
||
| include (${SHARED_DIR}/utils/uncommon/shared_uncommon.cmake) | ||
|
|
||
| -add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE}) | ||
| +file(GLOB_RECURSE NATIVE_LIBRARIES_SOURCE | ||
| + "${CMAKE_CURRENT_SOURCE_DIR}/native_libs/*.c" | ||
| +) | ||
| + | ||
| +add_executable (iwasm main.c ${UNCOMMON_SHARED_SOURCE} ${NATIVE_LIBRARIES_SOURCE}) | ||
|
|
||
| set_version_info (iwasm) | ||
|
|
||
| @@ -192,7 +197,7 @@ set_target_properties (vmlib PROPERTIES | ||
| POSITION_INDEPENDENT_CODE ON | ||
| ) | ||
|
|
||
| -target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -ldl -lpthread) | ||
| +target_link_libraries (vmlib ${LLVM_AVAILABLE_LIBS} ${UV_A_LIBS} -lm -lpthread) # Removed -ldl because we don't support dynamic linking | ||
|
|
||
| install (TARGETS vmlib | ||
| EXPORT iwasmTargets |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.