Closed laytan closed 4 months ago
One, maybe weird thing here is that the end of main
is not the end of the program, this is actually also the case in the js_wasm
targets but worth noting.
Lovely work, much appreciated laytan 💪 Auto bindings generator is at https://github.com/Skytrias/orca-odin which can be used for testing till we merge the generated file in
Changes
Make assertions, panics, type checks, bounds checks etc. go through orca's APIs
This looks a bit sketchy because our runtime is designed around being able to do writes to stderr like it is done on all other targets, but orca has APIs for logging, aborting etc which you can't just write one part of the string to and later another part. + these APIs take (null terminated) cstrings.
For this reason, I added a buffering mechanism that will flush to orca's log once a newline is found.
Set up our entrypoint
We now set up an internal
oc_on_init
andoc_on_terminate
where it sets up the runtime, calls@init
procs, and then calls the user'smain
proc. Same deal withoc_on_terminate
calling@fini
.Users can opt-out of our entry point with
-no-entry-point
and can then provide these exports themselves.Set up allocators
Orca provides a libc malloc API we can easily use
Linking
Uses the output of
orca sdk-path
to automatically link to the needed things for a correct wasm module.What works now
(Tested on Windows and MacOS)
odin build . -target:orca_wasm32 -out:module.wasm
orca bundle module.wasm
results in a valid Orca app that prints "Hello Orca" to the log and shows a blank screen.
@Skytrias Is working on auto-generated bindings for
core:sys/orca
to get to the point of building apps/games with it.I used the in-progress bindings to port the breakout example of Orca and that ran smoothly, so it should just be a matter of adding them.