Skip to content

chore: use zig 0.15.1#63

Merged
kivikakk merged 11 commits intokivikakk:mainfrom
Mishieck:chore-use-zig-0.15.1
Feb 20, 2026
Merged

chore: use zig 0.15.1#63
kivikakk merged 11 commits intokivikakk:mainfrom
Mishieck:chore-use-zig-0.15.1

Conversation

@Mishieck
Copy link
Contributor

@Mishieck Mishieck commented Feb 6, 2026

I made the following changes:

  • Updated Zig version to 0.15.1.
  • Updated Zig versions of dependencies to 0.15.1.
  • Added example code for converting Markdown to HTML.
  • Updated GitHub actions to use updated dependencies.

Note

I used mishieck/zunicode instead of gernest/zunicode because the repo only accepts contributions from collaborators.

- Use Zig 0.15.1.
- Use mlugg/setup-zig@v2.
- Use same test setup for all OS platforms.
- Lint `build.zig`.
- Add recipes for fetching Zig packages.
- Add recipe for running example.
- Use descriptive name for file ('to-html').
- Save output HTML in a file.
- Ignore output files in version control.
- Update 'minimum_zig_version'.
- Add 'examples' directory to paths.
Copy link
Owner

@kivikakk kivikakk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! Thank you so much for this. I've noticed a few things that aren't quite working as before, and I don't yet have the Zig context to suggest the corrections myself! 😆

src/main.zig Outdated

if (args.positionals[0]) |pos| {
const markdown = try std.fs.cwd().readFileAlloc(allocator, pos, 1024 * 1024 * 1024);
const markdown = try std.fs.cwd().readFileAlloc(allocator, pos, MAX_BUFFER_SIZE);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This limits the input file to 64KiB.

pub fn readFileAlloc(
    dir: Dir,
    io: Io,
    /// On Windows, should be encoded as [WTF-8](https://wtf-8.codeberg.page/).
    /// On WASI, should be encoded as valid UTF-8.
    /// On other platforms, an opaque sequence of bytes with no particular encoding.
    sub_path: []const u8,
    /// Used to allocate the result.
    gpa: Allocator,
    /// If reached or exceeded, `error.StreamTooLong` is returned instead.
    limit: Io.Limit,
) ReadFileAllocError![]u8 {

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree. The limit is too small. The limit was meant for buffers for streaming. I forgot to use a different value for maximum limits.

Comment on lines +50 to +55
var stdin_reader = std.fs.File.stdin().readerStreaming(&stdin_buf);
var alloc_writer = std.Io.Writer.Allocating.init(allocator);
errdefer alloc_writer.deinit();

_ = try stdin_reader.interface.streamRemaining(&alloc_writer.writer);
const markdown = alloc_writer.written();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something is not going right in the stdin branch:

$ echo hello | zig build run
thread 4416362 panic: Invalid free
/nix/store/k0376vyf5iqm9flh332rm81a7pvw713b-zig-0.15.2/lib/zig/std/heap/debug_allocator.zig:875:49: 0x1010f72cf in free (koino)
            if (bucket.canary != config.canary) @panic("Invalid free");
                                                ^
/nix/store/k0376vyf5iqm9flh332rm81a7pvw713b-zig-0.15.2/lib/zig/std/mem/Allocator.zig:147:25: 0x1010d9107 in free__anon_22796 (koino)
    return a.vtable.free(a.ptr, memory, alignment, ret_addr);
                        ^
/Users/kivikakk/g/koino/src/main.zig:56:29: 0x1010f544f in main (koino)
        defer allocator.free(markdown);
                            ^
/nix/store/k0376vyf5iqm9flh332rm81a7pvw713b-zig-0.15.2/lib/zig/std/start.zig:627:37: 0x1010f6033 in main (koino)
            const result = root.main() catch |err| {
                                    ^
???:?:?: 0x18bec1d53 in ??? (???)
???:?:?: 0x0 in ??? (???)
run
└─ run exe koino failure
error: the following command terminated unexpectedly:
/Users/kivikakk/g/koino/zig-out/bin/koino

Build Summary: 9/11 steps succeeded; 1 failed
run transitive failure
└─ run exe koino failure

error: the following build command failed with exit code 1:
.zig-cache/o/d182dfa2e10cdd8568e99467210dc909/build /nix/store/k0376vyf5iqm9flh332rm81a7pvw713b-zig-0.15.2/bin/zig /nix/store/k0376vyf5iqm9flh332rm81a7pvw713b-zig-0.15.2/lib/zig /Users/kivikakk/g/koino .zig-cache /Users/kivikakk/.cache/zig --seed 0x5010b42d -Z4d21e190086d921a run

I am on 0.15.2, so there's possibly a difference here, but worth seeing if you can reproduce.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll look into it.

try stderr.interface.writeAll("Usage: koino ");
try clap.usage(&stderr.interface, clap.Help, &params);
try stderr.interface.writeAll("\n\nOptions:\n");
try clap.help(&stderr.interface, clap.Help, &params, .{});
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This might need to be flushed? I haven't caught up on the new interface:

$ zig build run -- --help
$

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be flushed. I'll do so.

Comment on lines +11 to +24
fetch-clap:
zig fetch --save https://github.com/Hejsil/zig-clap/archive/refs/tags/0.11.0.tar.gz

fetch-htmlentities:
zig fetch --save git+https://nossa.ee/~talya/htmlentities.zig

fetch-libpcre:
zig fetch --save git+https://github.com/kivikakk/libpcre.zig

fetch-zunicode:
zig fetch --save git+https://github.com/mishieck/zunicode

example:
zig build example
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice!

@kivikakk
Copy link
Owner

kivikakk commented Feb 6, 2026

I used mishieck/zunicode instead of gernest/zunicode because the repo only accepts contributions from collaborators.

Yep, no problems! 👍

@Mishieck
Copy link
Contributor Author

Mishieck commented Feb 6, 2026

What about the failing spec action? I couldn't figure out what goes in vendor/cmark-gfm/test.

- Fix [buffer limit issue](kivikakk#63 (comment)).
- Fix [invalid free issue](kivikakk#63 (comment)).
- [Don't forget to flush](kivikakk#63 (comment))!
@kivikakk
Copy link
Owner

The spec was only failing since the binary itself was crashing — all looks OK now!

@kivikakk kivikakk merged commit 4a87da4 into kivikakk:main Feb 20, 2026
5 checks passed
@Mishieck
Copy link
Contributor Author

The spec was only failing since the binary itself was crashing — all looks OK now!

OK. Great.

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.

2 participants