diff --git a/expected/wasm32-wasip2/defined-symbols.txt b/expected/wasm32-wasip2/defined-symbols.txt index c23a9f83e..1381ce3b9 100644 --- a/expected/wasm32-wasip2/defined-symbols.txt +++ b/expected/wasm32-wasip2/defined-symbols.txt @@ -566,7 +566,6 @@ explicit_bzero expm1 expm1f expm1l -exports_wasi_cli_run_run fabs fabsf fabsl diff --git a/libc-bottom-half/crt/crt1-command.c b/libc-bottom-half/crt/crt1-command.c index 0f05ccb78..fb4fafec4 100644 --- a/libc-bottom-half/crt/crt1-command.c +++ b/libc-bottom-half/crt/crt1-command.c @@ -3,6 +3,7 @@ #endif #include +#include extern void __wasi_init_tp(void); extern void __wasm_call_ctors(void); @@ -58,3 +59,15 @@ void _start(void) { } #endif } + + +#ifdef __wasip2__ +#include + +// The wasi:cli/run export for wasip2 components. This is only linked for +// command-style executables, not reactors. +bool exports_wasi_cli_run_run(void) { + __wasilibc_initialize_environ(); + return __main_void() == 0; +} +#endif diff --git a/libc-bottom-half/sources/__main_void.c b/libc-bottom-half/sources/__main_void.c index f65cd0c4c..89e9d4696 100644 --- a/libc-bottom-half/sources/__main_void.c +++ b/libc-bottom-half/sources/__main_void.c @@ -108,12 +108,3 @@ __attribute__((__weak__, nodebug)) int __main_void(void) { return __main_argc_argv(argc, argv); #endif } - -#ifdef __wasip2__ -bool exports_wasi_cli_run_run(void) { - // TODO: this is supposed to be unnecessary, but functional/env.c fails - // without it - __wasilibc_initialize_environ(); - return __main_void() == 0; -} -#endif