From 9af61100d08d79ec52e98fa34ea36611dcc1c361 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Mon, 14 Jul 2025 20:21:18 +0200 Subject: [PATCH 1/8] build: update to zig-0.15.0-dev.936+fc2c1883b --- build.zig.version | 2 +- build.zig.zon | 4 ++-- zig | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/build.zig.version b/build.zig.version index a803cc2..ca633d3 100644 --- a/build.zig.version +++ b/build.zig.version @@ -1 +1 @@ -0.14.0 +0.15.0-dev.936+fc2c1883b diff --git a/build.zig.zon b/build.zig.zon index 13fc02d..89a76b1 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -9,8 +9,8 @@ .hash = "cbor-1.0.0-RcQE_GDyAABovyRXoYFX8zD_NVOLGDc9l5g09-W-svMR", }, .asio = .{ - .url = "https://github.com/neurocyte/asio/archive/24d28864ec5aae6146d88a172288e3bf3f099734.tar.gz", - .hash = "asio-1.30.2-tLhDdyKA4QBqQFDrsuK_hO1HfqX-DQMl-Sku7yy4vUfM", + .url = "https://github.com/neurocyte/asio/archive/c017afbe65b4b71b5ba3ecaeb6dbc981df75dc9b.tar.gz", + .hash = "asio-1.30.2-tLhDdweB4QAEkwboXZ-EshXBw4Fxs4KGxYhKdR0hu5O1", }, .tracy = .{ .url = "https://github.com/neurocyte/zig-tracy/archive/82f18a661af17089198fb7c489ef253f02b939b5.tar.gz", diff --git a/zig b/zig index 5c7ec91..0e45eb0 100755 --- a/zig +++ b/zig @@ -24,7 +24,7 @@ if [ "$ARCH" == "arm64" ]; then ARCH=aarch64 fi -ZIGVER="zig-$OS-$ARCH-$VERSION" +ZIGVER="zig-$ARCH-$OS-$VERSION" ZIG=$ZIGDIR/$ZIGVER/zig if [ "$1" == "update" ]; then From b7361361bca0c341182ce832bfbc01056bc3d047 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 15 Jul 2025 17:24:30 +0200 Subject: [PATCH 2/8] build: update build for zig-0.15.0-dev.1034+bd97b6618 --- build.zig | 17 +++++++++++------ build.zig.version | 2 +- build.zig.zon | 12 ++++++------ 3 files changed, 18 insertions(+), 13 deletions(-) diff --git a/build.zig b/build.zig index 49e09ef..f43835d 100644 --- a/build.zig +++ b/build.zig @@ -34,10 +34,13 @@ pub fn build(b: *std.Build) void { const asio_dep = b.dependency("asio", mode); const tracy_dep = if (tracy_enabled) b.dependency("tracy", mode) else undefined; - const lib = b.addStaticLibrary(.{ + const lib = b.addLibrary(.{ .name = "thespian", - .target = target, - .optimize = optimize, + .linkage = .static, + .root_module = b.createModule(.{ + .target = target, + .optimize = optimize, + }), }); if (tracy_enabled) { lib.root_module.addCMacro("TRACY_ENABLE", "1"); @@ -90,9 +93,11 @@ pub fn build(b: *std.Build) void { thespian_mod.linkLibrary(lib); const tests = b.addTest(.{ - .root_source_file = b.path("test/tests.zig"), - .target = target, - .optimize = optimize, + .root_module = b.createModule(.{ + .root_source_file = b.path("test/tests.zig"), + .target = target, + .optimize = optimize, + }), }); tests.root_module.addImport("build_options", options_mod); diff --git a/build.zig.version b/build.zig.version index ca633d3..2e95286 100644 --- a/build.zig.version +++ b/build.zig.version @@ -1 +1 @@ -0.15.0-dev.936+fc2c1883b +0.15.0-dev.1034+bd97b6618 diff --git a/build.zig.zon b/build.zig.zon index 89a76b1..12e3649 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,16 +5,16 @@ .dependencies = .{ .cbor = .{ - .url = "https://github.com/neurocyte/cbor/archive/5ea4b7319146f29bb1aa9acf65982feaba9edc3d.tar.gz", - .hash = "cbor-1.0.0-RcQE_GDyAABovyRXoYFX8zD_NVOLGDc9l5g09-W-svMR", + .url = "git+https://github.com/neurocyte/cbor#6eccce0b984296e7d05c20d83933cb31530e4fac", + .hash = "cbor-1.0.0-RcQE_N3yAADXjbyvhsmTQ6lf22l1nYgePq5FT8NaC4ic", }, .asio = .{ - .url = "https://github.com/neurocyte/asio/archive/c017afbe65b4b71b5ba3ecaeb6dbc981df75dc9b.tar.gz", - .hash = "asio-1.30.2-tLhDdweB4QAEkwboXZ-EshXBw4Fxs4KGxYhKdR0hu5O1", + .url = "git+https://github.com/neurocyte/asio#0f1cbf24e5fb6fabe7078a20b76452f42e24a0df", + .hash = "asio-1.30.2-tLhDd0SB4QB1041_DEW_1cvEw8eMfBYLAwjN_G53Fn66", }, .tracy = .{ - .url = "https://github.com/neurocyte/zig-tracy/archive/82f18a661af17089198fb7c489ef253f02b939b5.tar.gz", - .hash = "zig_tracy-0.0.3-5-cp3JZ2AAC6j-gWFhPKXyF6WASJpCzQeNy7Bi712t1a", + .url = "git+https://github.com/neurocyte/zig-tracy#67070c146104d93fd3bed5091738f22e33e13bce", + .hash = "zig_tracy-0.0.3-5-cp3Ht3AAAfHqShKfTK7waFK3Wjd3l2NheiqxvRRAdo", }, }, .paths = .{ From 4d317d7bf02eef26da56eddd2d49e46984b50572 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Tue, 15 Jul 2025 17:35:19 +0200 Subject: [PATCH 3/8] build: update to new writer API in zig-0.15.0-dev.1034+bd97b6618 --- src/thespian.zig | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/thespian.zig b/src/thespian.zig index 9d2b9f4..4fda66a 100644 --- a/src/thespian.zig +++ b/src/thespian.zig @@ -230,15 +230,15 @@ pub fn exit_message(e: anytype, stack_trace: ?*std.builtin.StackTrace) message { var debug_info_arena_allocator: std.heap.ArenaAllocator = std.heap.ArenaAllocator.init(std.heap.page_allocator); defer debug_info_arena_allocator.deinit(); const a = debug_info_arena_allocator.allocator(); - var out = std.ArrayList(u8).init(a); - store_stack_trace(stack_trace_.*, out.writer()); - return message.fmtbuf(&error_message_buffer, .{ "exit", e, out.items }) catch unreachable; + var out: std.Io.Writer.Allocating = .init(a); + store_stack_trace(stack_trace_.*, &out.writer); + return message.fmtbuf(&error_message_buffer, .{ "exit", e, out.getWritten() }) catch unreachable; } else { return message.fmtbuf(&error_message_buffer, .{ "exit", e }) catch unreachable; } } -fn store_stack_trace(stack_trace: std.builtin.StackTrace, writer: anytype) void { +fn store_stack_trace(stack_trace: std.builtin.StackTrace, writer: *std.Io.Writer) void { nosuspend { if (builtin.strip_debug_info) { writer.print("Unable to store stack trace: debug info stripped\n", .{}) catch return; From f823f66c90be839fc30c130d0f7538fd8555a32a Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 22 Aug 2025 13:42:25 +0200 Subject: [PATCH 4/8] build: update to zig-0.15.1 --- build.zig.version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.zig.version b/build.zig.version index 2e95286..e815b86 100644 --- a/build.zig.version +++ b/build.zig.version @@ -1 +1 @@ -0.15.0-dev.1034+bd97b6618 +0.15.1 From 51751adce626a0270baeafdb46280d2210949c20 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 22 Aug 2025 14:07:31 +0200 Subject: [PATCH 5/8] fix: API changes for zig-0.15.1 --- src/thespian.zig | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/thespian.zig b/src/thespian.zig index 4fda66a..caf1d7c 100644 --- a/src/thespian.zig +++ b/src/thespian.zig @@ -30,7 +30,7 @@ pub const sighdl_backtrace = if (builtin.os.tag != .windows) c_posix.sighdl_back pub const max_message_size = 8 * 4096; const message_buf_allocator = std.heap.c_allocator; -threadlocal var message_buffer: std.ArrayList(u8) = std.ArrayList(u8).init(message_buf_allocator); +threadlocal var message_buffer: std.ArrayList(u8) = .empty; threadlocal var error_message_buffer: [256]u8 = undefined; threadlocal var error_buffer_tl: c.thespian_error = .{ .base = null, @@ -147,6 +147,7 @@ pub const message = struct { pub fn fmt(value: anytype) Self { message_buffer.clearRetainingCapacity(); + var writer = std.Io.Writer.Allocating.fromArrayList(message_buf_allocator, &message_buffer); const f = comptime switch (@typeInfo(@TypeOf(value))) { .@"struct" => |info| if (info.is_tuple) fmt_internal @@ -154,15 +155,16 @@ pub const message = struct { @compileError("thespian.message template should be a tuple: " ++ @typeName(@TypeOf(value))), else => fmt_internal_scalar, }; - f(message_buffer.writer(), value) catch |e| std.debug.panic("thespian.message.fmt: {any}", .{e}); + f(&writer.writer, value) catch |e| std.debug.panic("thespian.message.fmt: {any}", .{e}); + message_buffer = writer.toArrayList(); return .{ .buf = message_buffer.items }; } - fn fmt_internal_scalar(writer: std.ArrayList(u8).Writer, value: anytype) !void { + fn fmt_internal_scalar(writer: *std.Io.Writer, value: anytype) !void { return fmt_internal(writer, .{value}); } - fn fmt_internal(writer: std.ArrayList(u8).Writer, value: anytype) !void { + fn fmt_internal(writer: *std.Io.Writer, value: anytype) !void { try cbor.writeValue(writer, value); } @@ -182,9 +184,9 @@ pub const message = struct { } fn fmtbuf_internal(buf: []u8, value: anytype) !Self { - var stream = std.io.fixedBufferStream(buf); - try cbor.writeValue(stream.writer(), value); - return .{ .buf = stream.getWritten() }; + var stream: std.Io.Writer = .fixed(buf); + try cbor.writeValue(&stream, value); + return .{ .buf = stream.buffered() }; } pub fn len(self: Self) usize { @@ -232,7 +234,7 @@ pub fn exit_message(e: anytype, stack_trace: ?*std.builtin.StackTrace) message { const a = debug_info_arena_allocator.allocator(); var out: std.Io.Writer.Allocating = .init(a); store_stack_trace(stack_trace_.*, &out.writer); - return message.fmtbuf(&error_message_buffer, .{ "exit", e, out.getWritten() }) catch unreachable; + return message.fmtbuf(&error_message_buffer, .{ "exit", e, out.writer.buffered() }) catch unreachable; } else { return message.fmtbuf(&error_message_buffer, .{ "exit", e }) catch unreachable; } From 8b2535db199d2215bea438abb323f3e3f6c58d99 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 22 Aug 2025 14:13:25 +0200 Subject: [PATCH 6/8] build: update cbor for zig-0.15.1 --- build.zig.zon | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.zig.zon b/build.zig.zon index 6292670..4d937e6 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,8 +5,8 @@ .dependencies = .{ .cbor = .{ - .url = "git+https://github.com/neurocyte/cbor?ref=master#ba2955fe3aa08456ed61a0e087be1e2ec46927e0", - .hash = "cbor-1.0.0-RcQE_NEzAQAGoED9NqVSWT0fhB8peqbXe99IixQKTeVp", + .url = "git+https://github.com/neurocyte/cbor?ref=master#0708420594f5af0a8289e6e1bae0ae03f011731f", + .hash = "cbor-1.0.0-RcQE_CUwAQChkeU-LO-eTSbLAdRox-wuxUGmi2nDAWri", }, .asio = .{ .url = "git+https://github.com/neurocyte/asio#0f1cbf24e5fb6fabe7078a20b76452f42e24a0df", From d9c93e9783546f2fb040ffcff84576fe46d6495b Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Fri, 22 Aug 2025 14:31:41 +0200 Subject: [PATCH 7/8] fix: update calling convention syntax --- src/thespian.zig | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/thespian.zig b/src/thespian.zig index caf1d7c..78a67ac 100644 --- a/src/thespian.zig +++ b/src/thespian.zig @@ -211,7 +211,7 @@ pub const message = struct { } pub const json_string_view = c.c_string_view; - const json_callback = *const fn (json_string_view) callconv(.C) void; + const json_callback = *const fn (json_string_view) callconv(.c) void; pub fn to_json_cb(self: *const Self, callback: json_callback) void { c.cbor_to_json(self.to(c_buffer_type), callback); @@ -394,7 +394,7 @@ pub const env = struct { return c.thespian_env_enabled(self.env, chan); } - pub const trace_handler = *const fn (c.cbor_buffer) callconv(.C) void; + pub const trace_handler = *const fn (c.cbor_buffer) callconv(.c) void; pub fn on_trace(self: *const Self, h: trace_handler) void { c.thespian_env_on_trace(self.env, h); @@ -450,7 +450,7 @@ pub fn trace(chan: trace_channel, value: anytype) void { pub const context = struct { a: std.mem.Allocator, context: c.thespian_context, - context_destroy: *const fn (?*anyopaque) callconv(.C) void, + context_destroy: *const fn (?*anyopaque) callconv(.c) void, const Self = @This(); @@ -545,7 +545,7 @@ pub fn Receiver(comptime T: type) type { pub fn init(f: FunT, data: T) Self { return .{ .f = f, .data = data }; } - pub fn run(ostate: c.thespian_behaviour_state, from: c.thespian_handle, m: c.cbor_buffer) callconv(.C) c.thespian_result { + pub fn run(ostate: c.thespian_behaviour_state, from: c.thespian_handle, m: c.cbor_buffer) callconv(.c) c.thespian_result { const state: *Self = @ptrCast(@alignCast(ostate orelse unreachable)); reset_error(); return to_result(state.f(state.data, wrap_handle(from), message.from(m))); @@ -624,7 +624,7 @@ fn Behaviour(comptime T: type) type { self.a.destroy(self); } - pub fn run(state: c.thespian_behaviour_state) callconv(.C) c.thespian_result { + pub fn run(state: c.thespian_behaviour_state) callconv(.c) c.thespian_result { const self: *Self = @ptrCast(@alignCast(state orelse unreachable)); defer self.destroy(); reset_error(); @@ -687,7 +687,7 @@ fn ExitHandler(comptime T: type) type { if (self.a) |a_| a_.destroy(self); } - pub fn run(state: c.thespian_exit_handler_state, msg: [*c]const u8, len: usize) callconv(.C) void { + pub fn run(state: c.thespian_exit_handler_state, msg: [*c]const u8, len: usize) callconv(.c) void { const self: *Self = @ptrCast(@alignCast(state orelse unreachable)); defer self.destroy(); self.f(self.data, msg[0..len]); From e9629548ee015d80b5016503a44ada3667d6db98 Mon Sep 17 00:00:00 2001 From: CJ van den Berg Date: Sun, 24 Aug 2025 16:08:32 +0200 Subject: [PATCH 8/8] fix: more zig-0.15 API changes --- src/subprocess.zig | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/subprocess.zig b/src/subprocess.zig index 7a2ee03..ce3e2fb 100644 --- a/src/subprocess.zig +++ b/src/subprocess.zig @@ -111,7 +111,7 @@ const Proc = struct { .parent = tp.self_pid().clone(), .child = child, .tag = try a.dupeZ(u8, tag), - .stdin_buffer = std.ArrayList(u8).init(a), + .stdin_buffer = .empty, }; return tp.spawn_link(a, self, Proc.start, tag); } @@ -120,7 +120,7 @@ const Proc = struct { if (self.fd_stdin) |fd| fd.deinit(); if (self.fd_stdout) |fd| fd.deinit(); if (self.fd_stderr) |fd| fd.deinit(); - self.stdin_buffer.deinit(); + self.stdin_buffer.deinit(self.a); self.parent.deinit(); self.args.deinit(); self.a.free(self.tag); @@ -186,7 +186,7 @@ const Proc = struct { } } else if (try m.match(.{ "stdin", tp.extract(&bytes) })) { if (self.fd_stdin) |fd_stdin| { - self.stdin_buffer.appendSlice(bytes) catch |e| return self.handle_error(e); + self.stdin_buffer.appendSlice(self.a, bytes) catch |e| return self.handle_error(e); fd_stdin.wait_write() catch |e| return self.handle_error(e); self.write_pending = true; }