Browse Source

Fix aot debugger compilation error on windows (#3370)

Fix aot debugger compilation error on windows as reported in #3184.

And update the stack size configuration for product-mini zephyr sample
since the native stack overflow check was enhanced and the zephyr-sdk
was also upgraded.
Wenyong Huang 1 year ago
parent
commit
e11eae93e2

+ 0 - 1
core/iwasm/aot/debug/elf_parser.c

@@ -7,7 +7,6 @@
 #include <assert.h>
 #include <fcntl.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <string.h>
 #include <errno.h>
 #include <stdbool.h>

+ 10 - 3
core/iwasm/aot/debug/jit_debug.c

@@ -24,7 +24,6 @@
 #include <stdio.h>
 #include <assert.h>
 #include <stdlib.h>
-#include <unistd.h>
 #include <string.h>
 #include <errno.h>
 #include <stdbool.h>
@@ -56,6 +55,12 @@ typedef struct JITDescriptor {
     JITCodeEntry *first_entry_;
 } JITDescriptor;
 
+#if defined(_WIN32) || defined(_WIN32_)
+#define attribute_noinline __declspec(noinline)
+#else
+#define attribute_noinline __attribute__((noinline))
+#endif
+
 /* LLVM has already define this */
 #if (WASM_ENABLE_WAMR_COMPILER == 0) && (WASM_ENABLE_JIT == 0)
 /**
@@ -63,9 +68,11 @@ typedef struct JITDescriptor {
  * To prevent GCC from inlining or removing it we place noinline attribute
  * and inline assembler statement inside.
  */
-void __attribute__((noinline)) __jit_debug_register_code();
+void attribute_noinline
+__jit_debug_register_code();
 
-void __attribute__((noinline)) __jit_debug_register_code()
+void attribute_noinline
+__jit_debug_register_code()
 {
     int x;
     *(char *)&x = '\0';

+ 1 - 1
core/iwasm/interpreter/wasm_runtime.c

@@ -1420,7 +1420,7 @@ execute_malloc_function(WASMModuleInstance *module_inst, WASMExecEnv *exec_env,
 #endif
     {
         argc = 1;
-        argv[0] = size;
+        argv[0] = (uint32)size;
     }
 
     /* if __retain is exported, then this module is compiled by

+ 1 - 0
product-mini/platforms/zephyr/simple/prj.conf

@@ -4,3 +4,4 @@
 CONFIG_STACK_SENTINEL=y
 CONFIG_PRINTK=y
 CONFIG_LOG=y
+CONFIG_LOG_BUFFER_SIZE=4096

+ 2 - 15
product-mini/platforms/zephyr/simple/src/main.c

@@ -16,29 +16,16 @@
 #endif /* end of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */
 
 #if defined(BUILD_TARGET_RISCV64_LP64) || defined(BUILD_TARGET_RISCV32_ILP32)
-#if defined(BUILD_TARGET_RISCV64_LP64)
-#define CONFIG_GLOBAL_HEAP_BUF_SIZE 4360
-#define CONFIG_APP_STACK_SIZE 288
-#define CONFIG_MAIN_THREAD_STACK_SIZE 2400
-#else
 #define CONFIG_GLOBAL_HEAP_BUF_SIZE 5120
 #define CONFIG_APP_STACK_SIZE 512
-#define CONFIG_MAIN_THREAD_STACK_SIZE 4096
-#endif
-#define CONFIG_APP_HEAP_SIZE 256
+#define CONFIG_APP_HEAP_SIZE 512
 #else /* else of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */
-
 #define CONFIG_GLOBAL_HEAP_BUF_SIZE WASM_GLOBAL_HEAP_SIZE
 #define CONFIG_APP_STACK_SIZE 8192
 #define CONFIG_APP_HEAP_SIZE 8192
+#endif /* end of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */
 
-#ifdef CONFIG_NO_OPTIMIZATIONS
 #define CONFIG_MAIN_THREAD_STACK_SIZE 8192
-#else
-#define CONFIG_MAIN_THREAD_STACK_SIZE 4096
-#endif
-
-#endif /* end of BUILD_TARGET_RISCV64_LP64 || BUILD_TARGET_RISCV32_ILP32 */
 
 static int app_argc;
 static char **app_argv;