Skip to content

graff — a fast agentic coding harness in Zig: multi-provider, MCP, workflows, DGM evolution loop, TS/Python SDKs

Python

fix(build): link libc explicitly; Windows has no realpath(3)

justrachbc0920107e1f
diff --git a/build.zig b/build.zig
index 091729a5..773c7e2d 100644
--- a/build.zig
+++ b/build.zig
@@ -47,6 +47,9 @@ pub fn build(b: *std.Build) void {
.target = target,
.optimize = optimize,
.strip = lean_release,
+ // Linux cross-builds (x86_64-linux for in-container evals) must say
+ // libc explicitly; macOS resolves it implicitly and never notices.
+ .link_libc = true,
}),
});
exe.root_module.addOptions("build_options", opts);
@@ -94,6 +97,7 @@ pub fn build(b: *std.Build) void {
.root_source_file = b.path("src/main.zig"),
.target = target,
.optimize = optimize,
+ .link_libc = true, // workspace_switch reaches std.c.getcwd (#721); same as the exe
}),
.filters = test_filters,
});
@@ -191,6 +195,7 @@ pub fn build(b: *std.Build) void {
.target = target,
.optimize = optimize,
.strip = lean_release,
+ .link_libc = true,
}),
});
tui_exe.root_module.addImport("models_rank", models_rank_mod);
diff --git a/src/workspace_switch.zig b/src/workspace_switch.zig
index 82596eb3..b74a9851 100644
--- a/src/workspace_switch.zig
+++ b/src/workspace_switch.zig
@@ -118,6 +118,14 @@ fn zpath(path: []const u8, z: *[std.fs.max_path_bytes + 1]u8) ?[:0]const u8 {
}
fn realpathOs(path: []const u8, out: []u8) ?[]const u8 {
+ if (builtin.os.tag == .windows) {
+ // The Windows CRT has no realpath(3). The cases this resolves are
+ // POSIX ones (/tmp vs /private/tmp, a symlinked worktree parent), and
+ // git porcelain already prints absolute paths, so compare as printed.
+ if (path.len > out.len) return null;
+ @memcpy(out[0..path.len], path);
+ return out[0..path.len];
+ }
var z: [std.fs.max_path_bytes + 1]u8 = undefined;
const src = zpath(path, &z) orelse return null;
const p = std.c.realpath(src, out.ptr) orelse return null;