Migrate platform to the new Zig-based Roc compiler#163
Draft
lukewilliamboswell wants to merge 28 commits into
Draft
Migrate platform to the new Zig-based Roc compiler#163lukewilliamboswell wants to merge 28 commits into
lukewilliamboswell wants to merge 28 commits into
Conversation
Port basic-webserver from the old Rust-based Roc compiler to the new
Zig-based compiler and its direct-symbol host ABI.
Platform & ABI:
- Rewrite platform/main.roc to the new header: stateful
`requires { [Model : model] for program { init!, respond! } }`,
`provides { roc_init_for_host, roc_respond_for_host }`, a `hosted {}`
block, and a per-target `targets {}` block.
- Generate and commit the Rust glue (src/roc_platform_abi.rs) via
ci/regenerate_glue.sh.
Host:
- Collapse the 3-crate workspace into a single `staticlib` crate. src/lib.rs
implements the Roc allocator/handler symbols and every hosted_* effect
(stdio, file, env, dir, cmd, path, utc); src/http_server.rs runs the
tokio/hyper loop, calling roc_init_for_host once and roc_respond_for_host
per request (model boxed with a constant refcount, shared across threads).
Modules & examples:
- Port core modules (Stdout, Stderr, IOErr, File, Env, Dir, Cmd, Path, Utc,
Http, InternalHttp) and 11 examples + 4 tests to the new syntax.
- Defer rich modules/examples/tests (Sqlite, Tcp, Url, MultipartFormData,
outbound Http.send!, buffered File reader) to a `.todoroc` extension.
Build & CI:
- Add build.sh (per-target libhost) and commit the musl link inputs.
- Rewrite ci/all_tests.sh and ci.yml to use roc-lang/setup-roc
(nightly-new-compiler) and remove all legacy old-compiler tooling
(nix flake, sync-check/release workflows, expect scripts).
Note: the init exit code uses I64 to work around a glue size-assertion bug
for `Try(Box(_), I32)` on stock roc.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The pinned action SHA predated nightly-new-compiler support (only knew nightly/alpha3/alpha4). Bump to current main. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
lukewilliamboswell
added a commit
to lukewilliamboswell/roc-awesome
that referenced
this pull request
Jun 26, 2026
Graduate basic-webserver from LEGACY into the README Platforms list, marked 🚧 with a link to roc-lang/basic-webserver#163. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Port Sqlite + InternalSqlite from basic-cli (Roc API + the 6 hosted host functions: prepare/bind/columns/column_value/step/reset), with the opaque boxed Stmt handle and a thread-local connection cache. Add the libsqlite3-sys (bundled) dependency, wire the sqlite hosted entries into platform/main.roc (kept last in the hosted block), regenerate the glue, and port examples/sqlite.roc. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Port the URL and multipart/form-data helpers (and the SplitList helper they use) to the new compiler syntax. These are pure Roc (no host functions), so the generated glue is unchanged. Expose Url and MultipartFormData, port tests/url.roc and examples/form-url-encoded.roc. form-file-upload and todos remain deferred (external Base64 package download fails / large Sqlite app respectively). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Port the deferred `Tcp` module and outbound `Http.send!`/`Http.get_utf8!` from the old roc_http crate to the direct-symbol host ABI, mirroring the basic-cli `explore-http` reference. Platform (Roc): - Add platform/Tcp.roc (opaque `Stream : Box(U64)` over a host-side BufReader<TcpStream>; connect/read_up_to/read_exactly/read_until/write). - Extend platform/Http.roc with the `host_send_request!` effect plus `send!`/`get_utf8!`, reusing InternalHttp's to/from-host converters. - Expose + import Tcp in platform/main.roc and append the six tcp/http hosted entries after sqlite (keeps existing glue numbering stable above). - Regenerate src/roc_platform_abi.rs; refresh the renumbered boundary and sqlite type aliases in src/lib.rs. Host (Rust): - Implement hosted_tcp_* (refcounted stream box, ErrorKind->Str mapping, BufRead read_until) and hosted_http_send_request (hyper + hyper-rustls over a thread-local current-thread runtime, run on the spawn_blocking thread; transport failures mapped to reserved status+body sentinels). - Cargo: add hyper-rustls (ring), hyper-util client features; pin zeroize 1.8.2 so the lockfile builds on the stable toolchain. Examples/tests: - Un-defer examples/http.roc, examples/error-handling.roc, tests/tcp.roc (ported to new syntax). Validated: musl host build (ring + sqlite + new code), `roc build` of all examples/tests, and the hello-web smoke test (GET / -> 200). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
WIP