Skip to content

Commit 7e60b86

Browse files
authoredSep 7, 2021
Add ia32 support and fix compiling issue for RT-Thread (bytecodealliance#730)
1 parent 336abc2 commit 7e60b86

File tree

10 files changed

+25
-69
lines changed

10 files changed

+25
-69
lines changed
 

Diff for: ‎SConscript

+4-14
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,10 @@ cwd = GetCurrentDir()
1414
list = os.listdir(cwd)
1515

1616
if GetDepend(['PKG_USING_WAMR']):
17-
wamr_entry_sconscript = os.path.join(cwd, "product-mini", "platforms", "rt-thread", 'SConscript')
17+
wamr_entry_sconscript = os.path.join(cwd, "product-mini", "platforms", "rt-thread", 'SConscript')
18+
wamr_runlib_sconscript = os.path.join(cwd, "build-scripts", 'SConscript')
1819

19-
if os.path.isfile(wamr_entry_sconscript):
20-
objs = objs + SConscript(wamr_entry_sconscript)
21-
else:
22-
print("[WAMR] entry script wrong:", wamr_entry_sconscript)
23-
Return('objs')
24-
25-
wamr_runlib_sconsript = os.path.join(cwd, "build-scripts", 'SConscript')
26-
27-
if os.path.isfile(wamr_runlib_sconsript):
28-
objs = objs + SConscript(wamr_runlib_sconsript)
29-
else:
30-
print("[WAMR] runtime lib script wrong:", wamr_runlib_sconsript)
20+
objs = objs + SConscript(wamr_entry_sconscript)
21+
objs = objs + SConscript(wamr_runlib_sconscript)
3122

3223
Return('objs')
33-

Diff for: ‎build-scripts/SConscript

+4-33
Original file line numberDiff line numberDiff line change
@@ -11,78 +11,49 @@ cwd = GetCurrentDir()
1111
objs = []
1212

1313
WAMR_ROOT_DIR = os.path.join(cwd, "..")
14-
15-
16-
SHARED_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'shared')
17-
18-
IWASM_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'iwasm')
19-
20-
APP_MGR_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-mgr')
21-
14+
SHARED_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'shared')
15+
IWASM_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'iwasm')
16+
APP_MGR_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-mgr')
2217
APP_FRAMEWORK_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'app-framework')
23-
24-
DEPS_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'deps')
18+
DEPS_DIR = os.path.join(WAMR_ROOT_DIR, 'core', 'deps')
2519

2620
if GetDepend(['WAMR_BUILD_INTERP']):
2721
script_path = os.path.join(IWASM_DIR, 'interpreter', 'SConscript')
2822
objs += SConscript(script_path)
2923

30-
3124
if GetDepend(['WAMR_BUILD_AOT']):
3225
script_path = os.path.join(IWASM_DIR, 'aot', 'SConscript')
3326
objs += SConscript(script_path)
3427
if GetDepend(['WAMR_BUILD_JIT']):
3528
script_path = os.path.join(IWASM_DIR, 'compilation', 'SConscript')
3629
objs += SConscript(script_path)
3730

38-
3931
if GetDepend(['WAMR_BUILD_APP_FRAMEWORK']):
4032
objs += SConscript(os.path.join(APP_FRAMEWORK_DIR, 'SConscript'))
4133
objs += SConscript(os.path.join(SHARED_DIR, 'coap', 'SConscript'))
4234
objs += SConscript(os.path.join(APP_MGR_DIR, 'app-manager', 'SConscript'))
4335
objs += SConscript(os.path.join(APP_MGR_DIR, 'app-mgr-shared', 'SConscript'))
4436

45-
46-
4737
if GetDepend(['WAMR_BUILD_LIBC_BUILTIN']):
4838
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-builtin', 'SConscript'))
4939

50-
51-
5240
if GetDepend(['WAMR_BUILD_LIBC_WASI']):
5341
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-wasi', 'SConscript'))
5442

55-
5643
if GetDepend(['WAMR_BUILD_LIB_PTHREAD']):
5744
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-pthread', 'SConscript'))
58-
# TODO: 这里加一下
59-
60-
61-
62-
# if (WAMR_BUILD_THREAD_MGR EQUAL 1)
63-
# include (${IWASM_DIR}/libraries/thread-mgr/thread_mgr.cmake)
64-
# endif ()
6545

6646
if GetDepend(['WAMR_BUILD_THREAD_MGR']):
6747
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'thread-mgr', 'SConscript'))
6848

69-
70-
71-
# if (WAMR_BUILD_LIBC_EMCC EQUAL 1)
72-
# include (${IWASM_DIR}/libraries/libc-emcc/libc_emcc.cmake)
73-
# endif()
74-
7549
if GetDepend(['WAMR_BUILD_LIBC_EMCC']):
7650
objs += SConscript(os.path.join(IWASM_DIR, 'libraries', 'libc-emmc', 'SConscript'))
7751

7852
objs += SConscript(os.path.join(cwd, 'SConscript_config'));
7953

80-
8154
objs += SConscript(os.path.join(SHARED_DIR, 'platform', 'rt-thread', 'SConscript'))
8255
objs += SConscript(os.path.join(SHARED_DIR, 'mem-alloc', 'SConscript'))
8356
objs += SConscript(os.path.join(IWASM_DIR, 'common', 'SConscript'))
8457
objs += SConscript(os.path.join(SHARED_DIR, 'utils', 'SConscript'))
8558

86-
87-
8859
Return('objs')

Diff for: ‎build-scripts/SConscript_config

+5-9
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ from building import *
1111

1212
Import('rtconfig')
1313

14-
src = Split('''
15-
''')
14+
src = []
1615
objs = []
1716
cwd = GetCurrentDir()
1817

1918
IWASM_INC_DIR = os.path.join(cwd, '..', 'core', 'iwasm', 'include')
2019

21-
# include_directories (${IWASM_DIR}/include)
22-
2320
CPPPATH = [IWASM_INC_DIR]
2421

2522
if rtconfig.BUILD == 'debug':
@@ -48,12 +45,11 @@ if rtconfig.ARCH == 'arm':
4845
print('[WAMR] using armv4')
4946
CPPDEFINES += ['BUILD_TARGET_ARM']
5047
CPPDEFINES += ['RTT_WAMR_BUILD_TARGET_ARMV4']
48+
elif rtconfig.ARCH == 'ia32':
49+
CPPDEFINES += ['BUILD_TARGET_X86_32', 'RTT_WAMR_BUILD_TARGET_X86_32']
5150
else:
5251
print("[WAMR] unknown arch", rtconfig.ARCH)
5352

54-
55-
LIBS = ['m']
56-
5753
if GetDepend(['WAMR_BUILD_INTERP']):
5854
CPPDEFINES += ['WASM_ENABLE_INTERP=1']
5955
if GetDepend(['WAMR_BUILD_FAST_INTERP']):
@@ -114,8 +110,8 @@ if GetDepend(['WAMR_BUILD_TAIL_CALL']):
114110
CPPDEFINES += ['WASM_ENABLE_TAIL_CALL=1']
115111
print('[WAMR] Tail call enabledd')
116112

113+
LIBS = ['m']
117114

118-
group = DefineGroup('wamr_config_common', src, depend = ['PKG_USING_WAMR'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
115+
group = DefineGroup('wamr', src, depend = ['PKG_USING_WAMR'], CPPPATH = CPPPATH, CPPDEFINES = CPPDEFINES, LIBS = LIBS)
119116

120117
Return('group')
121-

Diff for: ‎core/iwasm/aot/SConscript

+3-1
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,16 @@ cwd = GetCurrentDir()
1313
src = Split('''
1414
aot_loader.c
1515
aot_runtime.c
16+
aot_intrinsic.c
1617
''')
1718

1819
if rtconfig.ARCH == 'arm':
1920
if re.match('^cortex-m.*', rtconfig.CPU):
2021
src += ['arch/aot_reloc_thumb.c']
2122
elif re.match('^cortex-a.*', rtconfig.CPU):
2223
src += ['arch/aot_reloc_arm.c']
23-
24+
elif rtconfig.ARCH == 'ia32':
25+
src += ['arch/aot_reloc_x86_32.c']
2426

2527
CPPPATH = [cwd, cwd + '/../include']
2628

Diff for: ‎core/iwasm/common/SConscript

+2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ if rtconfig.ARCH == 'arm':
1818
src += ['arch/invokeNative_thumb.s']
1919
elif re.match('^cortex-a.*', rtconfig.CPU):
2020
src += ['arch/invokeNative_arm.s']
21+
elif rtconfig.ARCH == 'ia32':
22+
src += ['arch/invokeNative_ia32.s']
2123

2224
CPPPATH = [cwd, cwd + '/../include']
2325

Diff for: ‎core/shared/platform/rt-thread/platform_internal.h

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#define BUILD_TARGET "armv6"
2626
#elif defined(RTT_WAMR_BUILD_TARGET_ARMV4)
2727
#define BUILD_TARGET "armv4"
28+
#elif defined(RTT_WAMR_BUILD_TARGET_X86_32)
29+
#define BUILD_TARGET "X86_32"
2830
#else
2931
#error "unsupported aot platform."
3032
#endif

Diff for: ‎core/shared/platform/rt-thread/rtt_platform.c

-2
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,10 @@ void os_munmap(void *addr, size_t size)
180180
rt_free(addr);
181181
}
182182

183-
#ifdef OS_ENABLE_HW_BOUND_CHECK
184183
int os_mprotect(void *addr, size_t size, int prot)
185184
{
186185
return 0;
187186
}
188-
#endif
189187

190188
void os_dcache_flush(void)
191189
{

Diff for: ‎product-mini/platforms/rt-thread/SConscript

+2-6
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,9 @@
66

77
from building import *
88

9-
cwd = GetCurrentDir()
10-
11-
9+
cwd = GetCurrentDir()
1210
src = Glob('*.c')
1311

14-
CPPPATH = [cwd]
15-
16-
group = DefineGroup('iwasm_entry', src, depend = ['PKG_USING_WAMR'], CPPPATH = CPPPATH)
12+
group = DefineGroup('iwasm', src, depend = ['PKG_USING_WAMR'])
1713

1814
Return('group')

Diff for: ‎product-mini/platforms/rt-thread/rtt_wamr_entry.c renamed to ‎product-mini/platforms/rt-thread/iwasm.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -373,18 +373,17 @@ int iwasm(int argc, char **argv)
373373
/* destroy the module instance */
374374
wasm_runtime_deinstantiate(wasm_module_inst);
375375

376-
fail3:
376+
fail3:
377377
/* unload the module */
378378
wasm_runtime_unload(wasm_module);
379379

380-
fail2:
380+
fail2:
381381
/* free the file buffer */
382382
rt_free(wasm_file_buf);
383383

384-
fail1:
384+
fail1:
385385
/* destroy runtime environment */
386386
wasm_runtime_destroy();
387387
return 0;
388388
}
389389
MSH_CMD_EXPORT(iwasm, Embeded VM of WebAssembly);
390-

0 commit comments

Comments
 (0)
Please sign in to comment.