Would I be lucky enough to learn that IC has an equivalent module (complete or under development) that also provides these target specific low-level filesystem, etc calls?
As I mentioned in the other thread, the IC does not natively support these system calls. However, there is a community project that translates some of these to syscalls that the IC does support:
You can see there which syscalls are supported. If your program needs to make syscalls that are unsupported (like socket stuff), it won’t run on the IC. But if you can avoid them, there is a good chance you can make this work.
You need these files for the next step: When you compile your Ruby code, there should be a linking phase. These files (or just one of them) need to be passed as an argument there. What tool are you using to compile Ruby to Wasm? Hopefully you can follow the docs to find the right argument…
The result should be a .wasm file with the polyfill library included.
The component-adapter is related to the component model and therefore wasip2. But I would not target that now, because ic-wasi-polyfill targets wasip1. So this seems irrelevant here and now.
Edit: Actually, it depends on how ruby.wasm is built. Not sure.
Reading https://github.com/ruby/ruby.wasm/blob/main/README.md it seems to me like you don’t have to compile your app to Wasm. Instead, the linked project has already compiled the Ruby runtime to Wasm. I think they expect the users to “pack” their Ruby app into the pre-built runtime Wasm (probably by writing the user app to a custom section in the Wasm binary) and then deploy that pre-built, edited Wasm artifact on their host (browser, Wasmtime, or in our case, the IC).
The problem is that the pre-built Wasm is compiled to a target we do not support, wasm32-unknown-wasip1. So what you should try to make this all work is to figure out how to build that ruby.wasm yourself. If you can do that, you can build this artifact with the polyfill library object files (you listed them above) linked in, and then follow the steps as normally.
I was targeting here under the hope that I could apply the polyfills at the snapshot level, sort of stub out the system calls with what IC responds to.
Perhaps that was naive because I was just chasing the function names shown in the error haha.
Agree, you may recall of my original posts, I was suggesting that y’all might want to define a target triplet to facilitate this kind of conversation. Something like wasm32-unknown-icp
I did find the spot in the code where I can fork and customize this. Also read up a bit on FFI like you mentioned. I’ll dig deeper into the code generating the pre-builts now.
remove this from LDFLAGS -Xlinker\ stack-size=16777216
Alternatively, I could try to adapt the wasi handler (starting at line 62). But I rememer you said wasi isn’t supported, so I suspect i gain nothing from the extra complexity that one contains