Skip to content

Migrate to new Zig compiler#413

Draft
lukewilliamboswell wants to merge 74 commits into
mainfrom
migrate-zig-compiler
Draft

Migrate to new Zig compiler#413
lukewilliamboswell wants to merge 74 commits into
mainfrom
migrate-zig-compiler

Conversation

@lukewilliamboswell

Copy link
Copy Markdown
Collaborator

No description provided.

Comment thread .github/workflows/ci.yml Fixed
Comment thread .github/workflows/release.yml Fixed
Comment thread .github/workflows/release.yml Fixed
lukewilliamboswell and others added 10 commits January 5, 2026 15:24
Removed Path.type! function which was causing crash: "increfDataPtrC:
ORIGINAL ptr=0x1 is not 8-byte aligned". This appears to be an ABI
issue with opaque types in RocTry with the new compiler.

The function used an opaque type PathType := [IsDir, IsFile, IsSymLink]
which doesn't work correctly in Try results. The three individual
functions (is_file!, is_dir!, is_sym_link!) all work perfectly and
cover the same use cases.

All tests now pass. Path.type! can be investigated as a separate
follow-up issue once the opaque type ABI is better understood.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Restructure Cmd to use opaque type with methods (Cmd := { record }.{ methods })
- Update doc comments to use -> operator syntax instead of deprecated |>
- Delete orphaned examples (dir-test, env-test, file-test, print-test)
- Delete orphaned expect scripts for removed examples
- Delete old tests/ directory with unmigrated tests
- Update all_tests.sh to remove references to deleted examples
- Add test files demonstrating -> operator syntax works

Note: Static dispatch with . syntax crashes compiler (checkDeferredStaticDispatchConstraints)
so we use -> operator syntax instead, which works correctly.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
After compiler fixes for static dispatch, we can now use the idiomatic
. syntax for all methods including effects:

- Update all doc comments to show static dispatch syntax
- Effect methods now work: cmd.exec_exit_code!()
- Builder methods continue to work: Cmd.new("ls").args([])
- Full fluent API: Cmd.new("echo").args(["Hi"]).exec_cmd!()

Previous syntax required:
- . for regular methods
- Qualified calls for effects (Cmd.exec_exit_code!(cmd))

Now all methods use consistent . syntax throughout.

Tests verify:
- Simple method chaining with effects
- Multiline builder patterns
- Output capture via static dispatch
- Complete fluent chains

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Use argc/argv directly instead of std::env::args() because when built
as a static library, the Rust runtime isn't properly initialized and
std::env::args() returns an empty list.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
c_char is u8 on ARM64 Linux but i8 on x86, so use the portable
c_char type from std::ffi for argv handling.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The `git diff | head -50` command can exit with 141 (SIGPIPE) on Linux
when head closes the pipe before git finishes writing. Add `|| true`
to ignore this expected condition.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Limit GITHUB_TOKEN permissions to contents:read by default, as
recommended by GitHub's security scanner. The create-release job
overrides this with contents:write as needed.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@lukewilliamboswell

Copy link
Copy Markdown
Collaborator Author

Next target: JSON parsing

With SQLite, TCP, and the core HTTP client (Http.send! / Http.get_utf8!) now ported and green, the next gap is JSON.

The old Http.get! and the examples/http.todoroc demo both relied on Decode.from_bytes with the Decoding / DecoderFormatting abilities plus the external roc-json package. Neither has been validated against the new Zig compiler yet:

  • Abilities (where body implements Decoding, fmt implements DecoderFormatting) are untried on the new compiler.
  • The roc-json package likely doesn't build on the new compiler in its current form.

So the next piece of work is to either port/port-validate a JSON parsing path (abilities + roc-json, or an alternative), then restore Http.get! and migrate examples/http.todoroc. The core HTTP transport (including HTTPS via rustls/ring, validated under musl) is already in place and doesn't depend on this.

lukewilliamboswell and others added 11 commits June 27, 2026 13:56
HTTP types now come from the shared roc-lang/http 0.1 package (imported via
the platform's `packages` block) instead of the vendored InternalHttp module,
so apps and other packages using the same package see the same nominal
Request/Response/Method types. The platform still supplies the effectful
`Http.send!`/`get_utf8!`, marshalling across the host boundary with a compact
U8 method tag (+ extension string for `Unknown`) and `(Str, Str)` tuple headers.
InternalHttp.roc is removed; the host-glue records moved into Http.roc.

CI is decoupled from a specific roc commit: workflows use roc-lang/setup-roc
(nightly-new-compiler) and all_tests.sh takes roc from PATH. The glue
`--check` is removed — committed src/roc_platform_abi.rs is treated as source
(the end-to-end expect tests guard the ABI; regenerate locally when the
nightly drifts). build.sh now cross-compiles the bundled SQLite to musl via
committed `zig cc`/`zig ar` shims (ci/zig-cc.sh, ci/zig-ar.sh), so CI needs no
musl-gcc. Glue regenerated against roc 8936cf6d (recorded in .roc-version);
full expect suite passes.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
The new compiler's host ABI changes ~daily (a #[repr(C)] struct field reorder
landed between nightly 08aae15 and the following day's build), so tracking
"latest" makes the committed glue drift from CI's compiler and silently breaks
the ABI-sensitive effects (sqlite, http). Pin instead: .roc-version holds the
roc commit and ci/install_roc.sh installs the matching roc-lang/nightlies build
(setup-roc only offers always-latest). Regenerate glue against the pinned
08aae15 and reconcile the host (decref_box_with is 4-arg there). Full expect
suite passes with the pinned compiler.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants