Stream: announcements

Topic: Breaking change: `roc build` and platform header


view this post on Zulip Luke Boswell (Dec 09 2025 at 19:34):

G'day all, just wanted to let you know we've merged the roc build PR which has some nice upgrades in it.

Just note that this is a breaking change for the platforms as we introduce a new header section.

I have upgraded the zig template and made a new pre-release here https://github.com/lukewilliamboswell/roc-platform-template-zig/releases/tag/0.5

Note: theres a problem with roc check on an app using a URL package (local using relative paths doesn't have any issue) where it doesn't resolve the platform imports correctly. We decided to merge this PR anyway to prevent further merge conflicts and we are confident we can fix this smaller issue quickly.

If you're interested this is what the new platform/main.roc looks like for the zig template platform. We have a "targets" section which specifies how roc should link the platform and app together. The platform author provides everything pre-built in object files or static libraries for each supported target, and also tells roc where to find these files in the URL package (once unbundled). This removes a lot of hardcoded details from linking and lays the foundation for roc building other non-exectuable binaries like shared libraries (eg WASM modules).

platform ""
    requires {} { main! : List(Str) => Try({}, [Exit(I32)]) }
    exposes [Stdout, Stderr, Stdin]
    packages {}
    provides { main_for_host! : "main_for_host" }
    targets: {
        files: "targets/",
        exe: {
            x64mac: ["libhost.a", app],
            arm64mac: ["libhost.a", app],
            x64musl: ["crt1.o", "libhost.a", app, "libc.a"],
            arm64musl: ["crt1.o", "libhost.a", app, "libc.a"],
            x64win: ["host.lib", app],
            arm64win: ["host.lib", app],
        }
    }

With these changes you can now cross-compile to a linux musl target (x64musl or arm64musl) from any system (as long the platform supports it) by adding a --target flag. For example roc build --target=x64musl path/to/app.roc will produce a fully statically linked app executable that you can transfer to an x64 linux machine and run.

view this post on Zulip Luke Boswell (Dec 09 2025 at 21:09):

roc check issue fixed in https://github.com/roc-lang/roc/pull/8600


Last updated: Dec 21 2025 at 12:15 UTC