I'm a bit confused with a few concepts I guess. First I thought I needed to write my own platform, but it seems to me all a platform does is provide a given set of impure functions.
so probably the right question is „how can I emit a .so file“ (adhering to a given FFI, here: from python. let's assume types only include ints and strings.)?
AFAICS there is just roc build which always creates a binary file (now with interpreter shim, later native). and roc glue for creating platforms, but I don't know about what it expects / how it works, I only know you've been revamping it in #9226.
Is this a missing feature or me not understanding platforms fully?
The platform module header specifies what the build target is. The most common is exe so by default roc build will produce and executable, but you can also use --target to cross-compile or choose a different target the platform author has supported.
If you wanted to you could make a platform that roc build by default produces a dynamic library libsomething.so. A good example is the wasm type platforms that produce a app.wasm by default.
The platform host would be the part the provides the interface with your python. It would use roc glue to assist with the interface to roc.
The roc cli will compile the app, link it with the prebuilt platform host libraries (and any other dependencies provided like stubs or C runtimes etc) -- and produce a binary. Options a platform author could support include executable, static or dynamic library.
Rolling C types by hand that match the entrypoints or hosted effects a platform uses is challenging... glue scripts can take the types from the compiler to codegen this in your favourite language in a nicer type safe idiomatic library.
Thanks! I will have a look at the wasm platform for an example. I take it the workflow isn't really documented anywhere?
Yeah not really documented yet. I've put some stuff out there before.. but its definitely an advanced topic
My rust and zig platform templates are very contemporary and I think the best thing to point at rn
https://github.com/lukewilliamboswell/roc-platform-template-zig
Ive tried to include lots of comments throughout so if you read through I hope it's easier to follow
Last updated: Mar 20 2026 at 12:28 UTC