Implement multi-module feature and bulk-memory feature (#271)
Refine wasm loader and aot loader Fix potential issue of os_mmap/os_munmap Update document
This commit is contained in:
41
samples/multi-module/wasm-apps/CMakeLists.txt
Normal file
41
samples/multi-module/wasm-apps/CMakeLists.txt
Normal file
@ -0,0 +1,41 @@
|
||||
cmake_minimum_required(VERSION 2.8)
|
||||
project(wasm-apps)
|
||||
|
||||
set(CMAKE_VERBOSE_MAKEFILE on)
|
||||
|
||||
set(WAMR_ROOT_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../..)
|
||||
set(CLANG_COMMAND "/opt/wasi-sdk/bin/clang")
|
||||
|
||||
set(CLANG_FLAGS --target=wasm32 -nostdlib)
|
||||
set(CLANG_FLAGS ${CLANG_FLAGS} -Wl,--no-entry,--allow-undefined,--export-all)
|
||||
|
||||
set(SOURCE_A ${CMAKE_CURRENT_SOURCE_DIR}/mA.c)
|
||||
add_custom_command(
|
||||
OUTPUT mA.wasm
|
||||
COMMENT "Transform mA.C to mA.WASM"
|
||||
COMMAND ${CLANG_COMMAND} ${CLANG_FLAGS} -o mA.wasm ${SOURCE_A}
|
||||
DEPENDS ${SOURCE_A}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
set(SOURCE_B ${CMAKE_CURRENT_SOURCE_DIR}/mB.c)
|
||||
add_custom_command(
|
||||
OUTPUT mB.wasm
|
||||
COMMENT "Transform mB.C to mB.WASM"
|
||||
COMMAND ${CLANG_COMMAND} ${CLANG_FLAGS} -o mB.wasm ${SOURCE_B}
|
||||
DEPENDS ${SOURCE_B}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
set(SOURCE_C ${CMAKE_CURRENT_SOURCE_DIR}/mC.c)
|
||||
add_custom_command(
|
||||
OUTPUT mC.wasm
|
||||
COMMENT "Transform mC.C to mC.WASM"
|
||||
COMMAND ${CLANG_COMMAND} ${CLANG_FLAGS} -o mC.wasm ${SOURCE_C}
|
||||
DEPENDS ${SOURCE_C}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
add_custom_target(wasm-modules ALL
|
||||
DEPENDS mA.wasm mB.wasm mC.wasm
|
||||
)
|
||||
5
samples/multi-module/wasm-apps/mA.c
Normal file
5
samples/multi-module/wasm-apps/mA.c
Normal file
@ -0,0 +1,5 @@
|
||||
int
|
||||
A()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
16
samples/multi-module/wasm-apps/mB.c
Normal file
16
samples/multi-module/wasm-apps/mB.c
Normal file
@ -0,0 +1,16 @@
|
||||
__attribute__((import_module("mA")))
|
||||
__attribute__((import_name("A"))) extern int
|
||||
A();
|
||||
|
||||
int
|
||||
B()
|
||||
{
|
||||
return 11;
|
||||
}
|
||||
|
||||
int
|
||||
call_A()
|
||||
{
|
||||
return A();
|
||||
}
|
||||
|
||||
25
samples/multi-module/wasm-apps/mC.c
Normal file
25
samples/multi-module/wasm-apps/mC.c
Normal file
@ -0,0 +1,25 @@
|
||||
__attribute__((import_module("mA")))
|
||||
__attribute__((import_name("A"))) extern int
|
||||
A();
|
||||
|
||||
__attribute__((import_module("mB")))
|
||||
__attribute__((import_name("B"))) extern int
|
||||
B();
|
||||
|
||||
int
|
||||
C()
|
||||
{
|
||||
return 12;
|
||||
}
|
||||
|
||||
int
|
||||
call_A()
|
||||
{
|
||||
return A();
|
||||
}
|
||||
|
||||
int
|
||||
call_B()
|
||||
{
|
||||
return B();
|
||||
}
|
||||
Reference in New Issue
Block a user