Skip to content

Commit 84060ee

Browse files
committed
updating WASI stdio handle initialization and build options for UVWASI
1 parent 216404d commit 84060ee

File tree

5 files changed

+35
-8
lines changed

5 files changed

+35
-8
lines changed

.github/workflows/compilation_on_android_ubuntu.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,11 @@ jobs:
167167
]
168168
os: [ubuntu-22.04]
169169
platform: [android, linux]
170+
include:
171+
# uvwasi with default mode
172+
- platform: linux
173+
make_options_run_mode: ""
174+
make_options_feature: "-DWAMR_BUILD_LIBC_UVWASI=1"
170175
exclude:
171176
# incompatible feature and platform
172177
# incompatible mode and feature

core/iwasm/aot/aot_loader.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4128,10 +4128,16 @@ create_module(char *name, char *error_buf, uint32 error_buf_size)
41284128
#endif
41294129

41304130
#if WASM_ENABLE_LIBC_WASI != 0
4131+
#if WASM_ENABLE_UVWASI == 0
41314132
module->wasi_args.stdio[0] = os_invalid_raw_handle();
41324133
module->wasi_args.stdio[1] = os_invalid_raw_handle();
41334134
module->wasi_args.stdio[2] = os_invalid_raw_handle();
4134-
#endif
4135+
#else
4136+
module->wasi_args.stdio[0] = os_get_invalid_handle();
4137+
module->wasi_args.stdio[1] = os_get_invalid_handle();
4138+
module->wasi_args.stdio[2] = os_get_invalid_handle();
4139+
#endif /* WASM_ENABLE_UVWASI == 0 */
4140+
#endif /* WASM_ENABLE_LIBC_WASI != 0 */
41354141

41364142
return module;
41374143
#if WASM_ENABLE_GC != 0

core/iwasm/common/wasm_runtime_common.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3877,11 +3877,15 @@ wasm_runtime_init_wasi(WASMModuleInstanceCommon *module_inst,
38773877
init_options.allocator = &uvwasi_allocator;
38783878
init_options.argc = argc;
38793879
init_options.argv = (const char **)argv;
3880-
init_options.in = (stdinfd != -1) ? (uvwasi_fd_t)stdinfd : init_options.in;
3881-
init_options.out =
3882-
(stdoutfd != -1) ? (uvwasi_fd_t)stdoutfd : init_options.out;
3883-
init_options.err =
3884-
(stderrfd != -1) ? (uvwasi_fd_t)stderrfd : init_options.err;
3880+
init_options.in = (stdinfd != os_get_invalid_handle())
3881+
? (uvwasi_fd_t)stdinfd
3882+
: init_options.in;
3883+
init_options.out = (stdoutfd != os_get_invalid_handle())
3884+
? (uvwasi_fd_t)stdoutfd
3885+
: init_options.out;
3886+
init_options.err = (stderrfd != os_get_invalid_handle())
3887+
? (uvwasi_fd_t)stderrfd
3888+
: init_options.err;
38853889

38863890
if (dir_count > 0) {
38873891
init_options.preopenc = dir_count;

core/iwasm/interpreter/wasm_loader.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6377,10 +6377,16 @@ create_module(char *name, char *error_buf, uint32 error_buf_size)
63776377
#endif
63786378

63796379
#if WASM_ENABLE_LIBC_WASI != 0
6380+
#if WASM_ENABLE_UVWASI == 0
63806381
module->wasi_args.stdio[0] = os_invalid_raw_handle();
63816382
module->wasi_args.stdio[1] = os_invalid_raw_handle();
63826383
module->wasi_args.stdio[2] = os_invalid_raw_handle();
6383-
#endif
6384+
#else
6385+
module->wasi_args.stdio[0] = os_get_invalid_handle();
6386+
module->wasi_args.stdio[1] = os_get_invalid_handle();
6387+
module->wasi_args.stdio[2] = os_get_invalid_handle();
6388+
#endif /* WASM_ENABLE_UVWASI == 0 */
6389+
#endif /* WASM_ENABLE_LIBC_WASI != 0 */
63846390

63856391
(void)ret;
63866392
return module;

core/iwasm/interpreter/wasm_mini_loader.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3138,10 +3138,16 @@ create_module(char *name, char *error_buf, uint32 error_buf_size)
31383138
#endif
31393139

31403140
#if WASM_ENABLE_LIBC_WASI != 0
3141+
#if WASM_ENABLE_LIBC_UVWASI == 0
31413142
module->wasi_args.stdio[0] = os_invalid_raw_handle();
31423143
module->wasi_args.stdio[1] = os_invalid_raw_handle();
31433144
module->wasi_args.stdio[2] = os_invalid_raw_handle();
3144-
#endif
3145+
#else
3146+
module->wasi_args.stdio[0] = os_get_invalid_handle();
3147+
module->wasi_args.stdio[1] = os_get_invalid_handle();
3148+
module->wasi_args.stdio[2] = os_get_invalid_handle();
3149+
#endif /* WASM_ENABLE_UVWASI == 0 */
3150+
#endif /* WASM_ENABLE_LIBC_WASI != 0 */
31453151

31463152
(void)ret;
31473153
return module;

0 commit comments

Comments
 (0)