Explorar o código

Add ia32 support and fix compiling issue for RT-Thread (#730)

Bernard Xiong %!s(int64=4) %!d(string=hai) anos
pai
achega
7e60b8608e

+ 4 - 14
SConscript

@@ -14,20 +14,10 @@ cwd  = GetCurrentDir()
 list = os.listdir(cwd)
 list = os.listdir(cwd)
 
 
 if GetDepend(['PKG_USING_WAMR']):
 if GetDepend(['PKG_USING_WAMR']):
-    wamr_entry_sconscript = os.path.join(cwd, "product-mini", "platforms", "rt-thread", 'SConscript')
+    wamr_entry_sconscript  = os.path.join(cwd, "product-mini", "platforms", "rt-thread", 'SConscript')
+    wamr_runlib_sconscript = os.path.join(cwd, "build-scripts", 'SConscript')
 
 
-    if os.path.isfile(wamr_entry_sconscript):
-        objs = objs + SConscript(wamr_entry_sconscript)
-    else:
-        print("[WAMR] entry script wrong:", wamr_entry_sconscript)
-        Return('objs')
-
-    wamr_runlib_sconsript = os.path.join(cwd, "build-scripts", 'SConscript')
-
-    if os.path.isfile(wamr_runlib_sconsript):
-        objs = objs + SConscript(wamr_runlib_sconsript)
-    else:
-        print("[WAMR] runtime lib script wrong:", wamr_runlib_sconsript)
+    objs = objs + SConscript(wamr_entry_sconscript)
+    objs = objs + SConscript(wamr_runlib_sconscript)
 
 
 Return('objs')
 Return('objs')
-

+ 4 - 33
build-scripts/SConscript

@@ -11,23 +11,16 @@ cwd  = GetCurrentDir()
 objs = []
 objs = []
 
 
 WAMR_ROOT_DIR = os.path.join(cwd, "..")
 WAMR_ROOT_DIR = os.path.join(cwd, "..")
-
-
-SHARED_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'shared')
-
-IWASM_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'iwasm')
-
-APP_MGR_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-mgr')
-
+SHARED_DIR    = os.path.join(WAMR_ROOT_DIR, 'core', 'shared')
+IWASM_DIR     = os.path.join(WAMR_ROOT_DIR, 'core', 'iwasm')
+APP_MGR_DIR   = os.path.join(WAMR_ROOT_DIR, 'core', 'app-mgr')
 APP_FRAMEWORK_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-framework')
 APP_FRAMEWORK_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-framework')
-
-DEPS_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'deps')
+DEPS_DIR      = os.path.join(WAMR_ROOT_DIR, 'core', 'deps')
 
 
 if GetDepend(['WAMR_BUILD_INTERP']):
 if GetDepend(['WAMR_BUILD_INTERP']):
     script_path = os.path.join(IWASM_DIR, 'interpreter', 'SConscript')
     script_path = os.path.join(IWASM_DIR, 'interpreter', 'SConscript')
     objs += SConscript(script_path)
     objs += SConscript(script_path)
 
 
-
 if GetDepend(['WAMR_BUILD_AOT']):
 if GetDepend(['WAMR_BUILD_AOT']):
     script_path = os.path.join(IWASM_DIR, 'aot', 'SConscript')
     script_path = os.path.join(IWASM_DIR, 'aot', 'SConscript')
     objs += SConscript(script_path)
     objs += SConscript(script_path)
@@ -35,54 +28,32 @@ if GetDepend(['WAMR_BUILD_AOT']):
         script_path = os.path.join(IWASM_DIR, 'compilation', 'SConscript')
         script_path = os.path.join(IWASM_DIR, 'compilation', 'SConscript')
         objs += SConscript(script_path)
         objs += SConscript(script_path)
 
 
-
 if GetDepend(['WAMR_BUILD_APP_FRAMEWORK']):
 if GetDepend(['WAMR_BUILD_APP_FRAMEWORK']):
     objs += SConscript(os.path.join(APP_FRAMEWORK_DIR, 'SConscript'))
     objs += SConscript(os.path.join(APP_FRAMEWORK_DIR, 'SConscript'))
     objs += SConscript(os.path.join(SHARED_DIR, 'coap', 'SConscript'))
     objs += SConscript(os.path.join(SHARED_DIR, 'coap', 'SConscript'))
     objs += SConscript(os.path.join(APP_MGR_DIR, 'app-manager', 'SConscript'))
     objs += SConscript(os.path.join(APP_MGR_DIR, 'app-manager', 'SConscript'))
     objs += SConscript(os.path.join(APP_MGR_DIR, 'app-mgr-shared', 'SConscript'))
     objs += SConscript(os.path.join(APP_MGR_DIR, 'app-mgr-shared', 'SConscript'))
 
 
-
-
 if GetDepend(['WAMR_BUILD_LIBC_BUILTIN']):
 if GetDepend(['WAMR_BUILD_LIBC_BUILTIN']):
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-builtin', 'SConscript'))
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-builtin', 'SConscript'))
 
 
-
-
 if GetDepend(['WAMR_BUILD_LIBC_WASI']):
 if GetDepend(['WAMR_BUILD_LIBC_WASI']):
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-wasi', 'SConscript'))
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-wasi', 'SConscript'))
 
 
-
 if GetDepend(['WAMR_BUILD_LIB_PTHREAD']):
 if GetDepend(['WAMR_BUILD_LIB_PTHREAD']):
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-pthread', 'SConscript'))
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-pthread', 'SConscript'))
-    # TODO: 这里加一下
-
-
-
-# if (WAMR_BUILD_THREAD_MGR EQUAL 1)
-#     include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
-# endif ()
 
 
 if GetDepend(['WAMR_BUILD_THREAD_MGR']):
 if GetDepend(['WAMR_BUILD_THREAD_MGR']):
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'thread-mgr', 'SConscript'))
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'thread-mgr', 'SConscript'))
 
 
-
-
-# if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
-#     include (${IWASM_DIR}/libraries/libc-emcc/libc_emcc.cmake)
-# endif()
-
 if GetDepend(['WAMR_BUILD_LIBC_EMCC']):
 if GetDepend(['WAMR_BUILD_LIBC_EMCC']):
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-emmc', 'SConscript'))
     objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-emmc', 'SConscript'))
 
 
 objs += SConscript(os.path.join(cwd, 'SConscript_config'));
 objs += SConscript(os.path.join(cwd, 'SConscript_config'));
 
 
-
 objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'rt-thread', 'SConscript'))
 objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'rt-thread', 'SConscript'))
 objs += SConscript(os.path.join(SHARED_DIR, 'mem-alloc', 'SConscript'))
 objs += SConscript(os.path.join(SHARED_DIR, 'mem-alloc', 'SConscript'))
 objs += SConscript(os.path.join(IWASM_DIR, 'common', 'SConscript'))
 objs += SConscript(os.path.join(IWASM_DIR, 'common', 'SConscript'))
 objs += SConscript(os.path.join(SHARED_DIR, 'utils', 'SConscript'))
 objs += SConscript(os.path.join(SHARED_DIR, 'utils', 'SConscript'))
 
 
-
-
 Return('objs')
 Return('objs')

+ 5 - 9
build-scripts/SConscript_config

@@ -11,15 +11,12 @@ from building import *
 
 
 Import('rtconfig')
 Import('rtconfig')
 
 
-src = Split('''
-''')
+src  = []
 objs = []
 objs = []
 cwd  = GetCurrentDir()
 cwd  = GetCurrentDir()
 
 
 IWASM_INC_DIR = os.path.join(cwd, '..', 'core', 'iwasm', 'include')
 IWASM_INC_DIR = os.path.join(cwd, '..', 'core', 'iwasm', 'include')
 
 
-# include_directories (${IWASM_DIR}/include)
-
 CPPPATH = [IWASM_INC_DIR]
 CPPPATH = [IWASM_INC_DIR]
 
 
 if rtconfig.BUILD == 'debug':
 if rtconfig.BUILD == 'debug':
@@ -48,12 +45,11 @@ if rtconfig.ARCH == 'arm':
         print('[WAMR] using armv4')
         print('[WAMR] using armv4')
         CPPDEFINES += ['BUILD_TARGET_ARM']
         CPPDEFINES += ['BUILD_TARGET_ARM']
         CPPDEFINES += ['RTT_WAMR_BUILD_TARGET_ARMV4']
         CPPDEFINES += ['RTT_WAMR_BUILD_TARGET_ARMV4']
+elif rtconfig.ARCH == 'ia32':
+   CPPDEFINES += ['BUILD_TARGET_X86_32', 'RTT_WAMR_BUILD_TARGET_X86_32']
 else:
 else:
     print("[WAMR] unknown arch", rtconfig.ARCH)
     print("[WAMR] unknown arch", rtconfig.ARCH)
 
 
-
-LIBS = ['m']
-
 if GetDepend(['WAMR_BUILD_INTERP']):
 if GetDepend(['WAMR_BUILD_INTERP']):
     CPPDEFINES += ['WASM_ENABLE_INTERP=1']
     CPPDEFINES += ['WASM_ENABLE_INTERP=1']
     if GetDepend(['WAMR_BUILD_FAST_INTERP']):
     if GetDepend(['WAMR_BUILD_FAST_INTERP']):
@@ -114,8 +110,8 @@ if GetDepend(['WAMR_BUILD_TAIL_CALL']):
     CPPDEFINES += ['WASM_ENABLE_TAIL_CALL=1']
     CPPDEFINES += ['WASM_ENABLE_TAIL_CALL=1']
     print('[WAMR] Tail call enabledd')
     print('[WAMR] Tail call enabledd')
 
 
+LIBS = ['m']
 
 
-group = DefineGroup('wamr_config_common', src, depend = ['PKG_USING_WAMR'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
+group = DefineGroup('wamr', src, depend = ['PKG_USING_WAMR'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
 
 
 Return('group')
 Return('group')
-

+ 3 - 1
core/iwasm/aot/SConscript

@@ -13,6 +13,7 @@ cwd     = GetCurrentDir()
 src = Split('''
 src = Split('''
 aot_loader.c
 aot_loader.c
 aot_runtime.c
 aot_runtime.c
+aot_intrinsic.c
 ''')
 ''')
 
 
 if rtconfig.ARCH == 'arm':
 if rtconfig.ARCH == 'arm':
@@ -20,7 +21,8 @@ if rtconfig.ARCH == 'arm':
         src += ['arch/aot_reloc_thumb.c']
         src += ['arch/aot_reloc_thumb.c']
     elif re.match('^cortex-a.*', rtconfig.CPU):
     elif re.match('^cortex-a.*', rtconfig.CPU):
         src += ['arch/aot_reloc_arm.c']
         src += ['arch/aot_reloc_arm.c']
-
+elif rtconfig.ARCH == 'ia32':
+    src += ['arch/aot_reloc_x86_32.c']
 
 
 CPPPATH = [cwd, cwd + '/../include']
 CPPPATH = [cwd, cwd + '/../include']
 
 

+ 2 - 0
core/iwasm/common/SConscript

@@ -18,6 +18,8 @@ if rtconfig.ARCH == 'arm':
         src += ['arch/invokeNative_thumb.s']
         src += ['arch/invokeNative_thumb.s']
     elif re.match('^cortex-a.*', rtconfig.CPU):
     elif re.match('^cortex-a.*', rtconfig.CPU):
         src += ['arch/invokeNative_arm.s']
         src += ['arch/invokeNative_arm.s']
+elif rtconfig.ARCH == 'ia32':
+    src += ['arch/invokeNative_ia32.s']
 
 
 CPPPATH = [cwd, cwd + '/../include']
 CPPPATH = [cwd, cwd + '/../include']
 
 

+ 2 - 0
core/shared/platform/rt-thread/platform_internal.h

@@ -25,6 +25,8 @@
 #define BUILD_TARGET "armv6"
 #define BUILD_TARGET "armv6"
 #elif defined(RTT_WAMR_BUILD_TARGET_ARMV4)
 #elif defined(RTT_WAMR_BUILD_TARGET_ARMV4)
 #define BUILD_TARGET "armv4"
 #define BUILD_TARGET "armv4"
+#elif defined(RTT_WAMR_BUILD_TARGET_X86_32)
+#define BUILD_TARGET "X86_32"
 #else
 #else
 #error "unsupported aot platform."
 #error "unsupported aot platform."
 #endif
 #endif

+ 0 - 2
core/shared/platform/rt-thread/rtt_platform.c

@@ -180,12 +180,10 @@ void os_munmap(void *addr, size_t size)
     rt_free(addr);
     rt_free(addr);
 }
 }
 
 
-#ifdef OS_ENABLE_HW_BOUND_CHECK
 int os_mprotect(void *addr, size_t size, int prot)
 int os_mprotect(void *addr, size_t size, int prot)
 {
 {
     return 0;
     return 0;
 }
 }
-#endif
 
 
 void os_dcache_flush(void)
 void os_dcache_flush(void)
 {
 {

+ 2 - 6
product-mini/platforms/rt-thread/SConscript

@@ -6,13 +6,9 @@
 
 
 from building import *
 from building import *
 
 
-cwd     = GetCurrentDir()
-
-
+cwd = GetCurrentDir()
 src = Glob('*.c')
 src = Glob('*.c')
 
 
-CPPPATH = [cwd]
-
-group = DefineGroup('iwasm_entry', src, depend = ['PKG_USING_WAMR'], CPPPATH = CPPPATH)
+group = DefineGroup('iwasm', src, depend = ['PKG_USING_WAMR'])
 
 
 Return('group')
 Return('group')

+ 3 - 4
product-mini/platforms/rt-thread/rtt_wamr_entry.c → product-mini/platforms/rt-thread/iwasm.c

@@ -373,18 +373,17 @@ int iwasm(int argc, char **argv)
     /* destroy the module instance */
     /* destroy the module instance */
     wasm_runtime_deinstantiate(wasm_module_inst);
     wasm_runtime_deinstantiate(wasm_module_inst);
 
 
-    fail3:
+fail3:
     /* unload the module */
     /* unload the module */
     wasm_runtime_unload(wasm_module);
     wasm_runtime_unload(wasm_module);
 
 
-    fail2:
+fail2:
     /* free the file buffer */
     /* free the file buffer */
     rt_free(wasm_file_buf);
     rt_free(wasm_file_buf);
 
 
-    fail1:
+fail1:
     /* destroy runtime environment */
     /* destroy runtime environment */
     wasm_runtime_destroy();
     wasm_runtime_destroy();
     return 0;
     return 0;
 }
 }
 MSH_CMD_EXPORT(iwasm, Embeded VM of WebAssembly);
 MSH_CMD_EXPORT(iwasm, Embeded VM of WebAssembly);
-

+ 0 - 0
product-mini/platforms/rt-thread/rtt_embed_entry.cmake → product-mini/platforms/rt-thread/iwasm.cmake