Skip to content

Conversation

mlugg
Copy link
Member

@mlugg mlugg commented Aug 1, 2025

On macOS, instead of using the broken kqueue implementation, use the File System Events API in the Core Services framework to implement std.Build.Watch. This API is a bit different to others, because it is based on recursive watches, and it also requires using Apple's "dispatch queue" mechanism instead of just being a simple blocking call. The implementation is mostly contained within its own file, as std.Build.Watch.FsEvents, and is designed to not be too tightly coupled to std.Build so that in the future it can potentially be refactored into a more general-purpose filesystem watching tool.

Basic testing from myself, and tests from a few affected users, have confirmed this as working, resolving the longstanding issue that zig build --watch often does not work correctly on macOS.

Resolves: #21905

@mlugg mlugg added release notes This PR should be mentioned in the release notes. zig build system std.Build, the build runner, `zig build` subcommand, package management labels Aug 1, 2025
Copy link
Member

@andrewrk andrewrk left a comment

Choose a reason for hiding this comment

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

Nice job wrangling that FFI.

@mlugg mlugg enabled auto-merge (rebase) August 1, 2025 21:55
@mlugg mlugg merged commit abf1795 into ziglang:master Aug 2, 2025
10 checks passed
@mlugg mlugg deleted the macos-watch branch August 13, 2025 12:21
Techatrix added a commit to ziglang/vscode-zig that referenced this pull request Sep 21, 2025
This issue has been fixed in ziglang/zig#24649. The workaround can be
removed completely when it's safe to assume that the majority of
projects and users have updated to Zig 0.15.
Vexu pushed a commit to ziglang/vscode-zig that referenced this pull request Sep 23, 2025
This issue has been fixed in ziglang/zig#24649. The workaround can be
removed completely when it's safe to assume that the majority of
projects and users have updated to Zig 0.15.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

release notes This PR should be mentioned in the release notes. zig build system std.Build, the build runner, `zig build` subcommand, package management

Projects

None yet

Development

Successfully merging this pull request may close these issues.

--watch does not work on macOS 14.5 when saving from VSCode

2 participants