Open ArjaanBuijk opened 2 years ago
I still think -Wl,--trace-symbol=__wasi_fd_close
is going to be your best starting point. It should tell you which object file is causing that symbol to be include.
If you build with -g
should also easily be able to see where in the resulting .wat
file those imports are used/needed. You can also use wasm-objdump -d -x foo.wasm
to inspect the resulting binary without using wat format.
Out of interest is there some fundamental reason why you don't use those wasi_snapshot_preview1
imports? It is just code size or are you trying to target an environment that doesn't support WASI? If its the latter, it seems rather odd to be using WASI SDK at all. Obviously we always want to generate the smallest possible binaries but targeting non-WASI host environments is probably out of scope of wasi-sdk.
I am writing C++ code for the internet computer, and I am a bit stuck at the moment trying to use strings.
I studied the discussion in this issue in great detail, and I made good progress after I edited the WASI SDK’s Makefile to disable assertions while opting into baremetal mode:
With this patch, I could get the following to work:
I compile it with:
When converting the
ok.wat
usingwasm2wat
, the only import function is the one I specify, and the fileok.wat
is really tiny:This file
ok.wasm
could be deployed without any issues.Then I tried to use a string, and that did not work:
I compile it in the same way, but now the file
nok.wat
is much bigger and contains imports forfd_close
,fd_seek
&fd_write
:I tried to apply the techniques explained in the other issue to hunt down the reason and then patch it, but was not able to.
Any tips how to get rid of these imports would be greatly appreciated.