recent wasi-libc is broken if you put main in a library. test case: https://github.com/yamt/garbage/tree/d422b1073125b3fc8f843ce4b12280ab3982fb84/c/main_in_lib ``` spacetanuki% ./build-native.sh spacetanuki% ./a.out this is foo spacetanuki% WASI_SDK=/opt/wasi-sdk-20.0 ./build-wasi.sh spacetanuki% toywasm --wasi a.out this is foo spacetanuki% WASI_SDK=/opt/wasi-sdk-21.0 ./build-wasi.sh spacetanuki% toywasm --wasi a.out Error: [trap] unreachable executed (4): unreachable at 0001a5 frame[ 2] funcpc 0001a5 (<unknown>:undefined_weak:main) callerpc 0022de param [0] = 00000001 param [1] = 00010b30 frame[ 1] funcpc 00226c (<unknown>:__main_void) callerpc 0001df local [0] = 00010b00 local [1] = 00010b30 local [2] = 00010b20 frame[ 0] funcpc 0001ab (<unknown>:_start) local [0] = 00000000 2024-03-16 14:47:15 (1710568035.864123000): [117042600] instance_execute_func failed with -1 2024-03-16 14:47:15 (1710568035.864618000): [117042600] invoke failed with -1 spacetanuki% ``` i guess this is a regression caused by https://github.com/WebAssembly/wasi-libc/pull/429
Activity
sbc100 commentedon Mar 18, 2024
Yes, it looks like its specifically this line: https://github.com/WebAssembly/wasi-libc/pull/429/files#r1290434731.
yamt commentedon Jul 11, 2024
a simpler case (just an empty file w/o main function)
Add crt2-command.o to provide __main_void
Add crt2-command.o to provide __main_void
sunfishcode commentedon Jun 3, 2025
What's needed here is for someone to propose a design that would fix this issue while not breaking no-argument
mainor dynamic libraries.yamt commentedon Jun 3, 2025
you don't like #528 for some reasons?
sunfishcode commentedon Jun 3, 2025
I don't understand what #528 does yet. I'll post more questions there.