Enable WASI feature, enhance security and add SGX sample (#142)

Change emcc to clang
Refine interpreter to improve perforamnce
This commit is contained in:
Weining
2019-11-20 21:16:36 +08:00
committed by wenyongh
parent 29c7c743e9
commit 27f246b5f3
159 changed files with 9543 additions and 3789 deletions

View File

@ -16,7 +16,7 @@ set (BUILD_AS_64BIT_SUPPORT "YES")
# Set BUILD_TARGET, currently values supported:
# "X86_64", "AMD_64", "X86_32", "ARM_32", "MIPS_32", "XTENSA_32"
if (NOT BUILD_TARGET)
if (NOT DEFINED BUILD_TARGET)
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
if (BUILD_AS_64BIT_SUPPORT STREQUAL "YES")
# Build as X86_64 by default in 64-bit platform

View File

@ -63,15 +63,18 @@ for i in `ls *.c`
do
APP_SRC="$i ${APP_LIB_SRC}"
OUT_FILE=${i%.*}.wasm
emcc -O3 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
-I${APP_LIBS}/extension/connection \
-I${APP_LIBS}/extension/gui \
-DENABLE_WGL=1 \
-s WASM=1 -s SIDE_MODULE=1 -s ASSERTIONS=1 -s STACK_OVERFLOW_CHECK=2 \
-s TOTAL_MEMORY=65536 -s TOTAL_STACK=4096 \
-s "EXPORTED_FUNCTIONS=['_on_init', '_on_destroy', '_on_request', '_on_response', \
'_on_sensor_event', '_on_timer_callback', '_on_connection_data', '_on_widget_event']" \
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
clang-8 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
-I${APP_LIBS}/extension/connection \
-I${APP_LIBS}/extension/gui \
-DENABLE_WGL=1 \
--target=wasm32 -O3 -z stack-size=4096 -Wl,--initial-memory=65536 \
-Wl,--allow-undefined \
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
-Wl,--export=on_init -Wl,--export=on_destroy \
-Wl,--export=on_request -Wl,--export=on_response \
-Wl,--export=on_sensor_event -Wl,--export=on_timer_callback \
-Wl,--export=on_connection_data -Wl,--export=on_widget_event \
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
echo "build ${OUT_FILE} success"
else

View File

@ -55,13 +55,16 @@ for i in `ls *.c | grep -v gui`
do
APP_SRC="$i ${APP_LIB_SRC}"
OUT_FILE=${i%.*}.wasm
emcc -O3 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
-I${APP_LIBS}/extension/connection \
-s WASM=1 -s SIDE_MODULE=1 -s ASSERTIONS=1 -s STACK_OVERFLOW_CHECK=2 \
-s TOTAL_MEMORY=65536 -s TOTAL_STACK=4096 \
-s "EXPORTED_FUNCTIONS=['_on_init', '_on_destroy', '_on_request', '_on_response', \
'_on_sensor_event', '_on_timer_callback', '_on_connection_data']" \
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
clang-8 -I${APP_LIBS}/base -I${APP_LIBS}/extension/sensor -I${NATIVE_LIBS} \
-I${APP_LIBS}/extension/connection \
--target=wasm32 -O3 -z stack-size=4096 -Wl,--initial-memory=65536 \
-Wl,--allow-undefined \
-Wl,--no-threads,--strip-all,--no-entry -nostdlib \
-Wl,--export=on_init -Wl,--export=on_destroy \
-Wl,--export=on_request -Wl,--export=on_response \
-Wl,--export=on_sensor_event -Wl,--export=on_timer_callback \
-Wl,--export=on_connection_data \
-o ${OUT_DIR}/wasm-apps/${OUT_FILE} ${APP_SRC}
if [ -f ${OUT_DIR}/wasm-apps/${OUT_FILE} ]; then
echo "build ${OUT_FILE} success"
else

View File

@ -2,4 +2,5 @@ extern void iwasm_main();
int main(int argc, char *argv[])
{
iwasm_main(argc, argv);
return 0;
}

View File

@ -22,7 +22,7 @@ char label_count1_str[11] = { 0 };
void timer1_update(user_timer_t timer1)
{
if ((count % 100) == 0) {
sprintf(count_str, "%d", count / 100);
snprintf(count_str, sizeof(count_str), "%d", count / 100);
wgl_label_set_text(count_label, count_str);
}
++count;
@ -63,7 +63,8 @@ static void btn_event_cb(wgl_obj_t btn, wgl_event_t event)
{
if(event == WGL_EVENT_RELEASED) {
label_count1_value++;
sprintf(label_count1_str, "%d", label_count1_value);
snprintf(label_count1_str, sizeof(label_count1_str),
"%d", label_count1_value);
wgl_label_set_text(label_count1, label_count1_str);
}
}

View File

@ -24,7 +24,7 @@ char label_count1_str[11] = { 0 };
void timer1_update(user_timer_t timer1)
{
if ((count % 100) == 0) {
sprintf(count_str, "%d", count / 100);
snprintf(count_str, sizeof(count_str), "%d", count / 100);
lv_label_set_text(count_label, count_str);
}
++count;
@ -65,7 +65,8 @@ static void btn_event_cb(lv_obj_t *btn, lv_event_t event)
{
if(event == LV_EVENT_RELEASED) {
label_count1_value--;
sprintf(label_count1_str, "%d", label_count1_value);
snprintf(label_count1_str, sizeof(label_count1_str),
"%d", label_count1_value);
lv_label_set_text(label_count1, label_count1_str);
if (label_count1_value == 0)
label_count1_value = 100;