From b32a38ad2753df8df40008e279fb9f645de29c47 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Fri, 2 Jan 2026 22:02:40 -0800 Subject: [PATCH] build: fix file system watching compilation on macOS --- lib/compiler/build_runner.zig | 2 +- lib/std/Build/Watch.zig | 21 +++++++++++---------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/lib/compiler/build_runner.zig b/lib/compiler/build_runner.zig index 0d18d835a4295550f304f1dd1c854e20e6538f89..82fc696618893810090a42a104de7a3e35611560 100644 --- a/lib/compiler/build_runner.zig +++ b/lib/compiler/build_runner.zig @@ -544,7 +544,7 @@ pub fn main(init: process.Init.Minimal) !void { var w: Watch = w: { if (!watch) break :w undefined; if (!Watch.have_impl) fatal("--watch not yet implemented for {t}", .{builtin.os.tag}); - break :w try .init(); + break :w try .init(graph.cache.cwd); }; const now = Io.Clock.Timestamp.now(io, .awake) catch |err| fatal("failed to collect timestamp: {t}", .{err}); diff --git a/lib/std/Build/Watch.zig b/lib/std/Build/Watch.zig index 9042241b5539935956f79d86c1306764f428c8ad..0a0178a018b535f5d06c11275c87753a4a6aef2d 100644 --- a/lib/std/Build/Watch.zig +++ b/lib/std/Build/Watch.zig @@ -99,7 +99,8 @@ const Os = switch (builtin.os.tag) { }; }; - fn init() !Watch { + fn init(cwd_path: []const u8) !Watch { + _ = cwd_path; return .{ .dir_table = .{}, .dir_count = 0, @@ -427,7 +428,8 @@ const Os = switch (builtin.os.tag) { } }; - fn init() !Watch { + fn init(cwd_path: []const u8) !Watch { + _ = cwd_path; return .{ .dir_table = .{}, .dir_count = 0, @@ -658,14 +660,13 @@ const Os = switch (builtin.os.tag) { const EV = std.c.EV; const NOTE = std.c.NOTE; - fn init() !Watch { - const kq_fd = try posix.kqueue(); - errdefer posix.close(kq_fd); + fn init(cwd_path: []const u8) !Watch { + _ = cwd_path; return .{ .dir_table = .{}, .dir_count = 0, .os = .{ - .kq_fd = kq_fd, + .kq_fd = try posix.kqueue(), .handles = .empty, }, .generation = 0, @@ -841,9 +842,9 @@ const Os = switch (builtin.os.tag) { .macos => struct { fse: FsEvents, - fn init() !Watch { + fn init(cwd_path: []const u8) !Watch { return .{ - .os = .{ .fse = try .init() }, + .os = .{ .fse = try .init(cwd_path) }, .dir_count = 0, .dir_table = undefined, .generation = undefined, @@ -863,8 +864,8 @@ const Os = switch (builtin.os.tag) { else => void, }; -pub fn init() !Watch { - return Os.init(); +pub fn init(cwd_path: []const u8) !Watch { + return Os.init(cwd_path); } pub const Match = struct { -- 2.54.0