From 4dd58fbf2e2b737564450007d67384ddc28f6a67 Mon Sep 17 00:00:00 2001 From: "Shota Kudo (chaploud)" Date: Mon, 27 Apr 2026 03:09:14 +0900 Subject: [PATCH] fix(build): link libc to cljw / cache_gen / test module The Zig 0.16.0 migration switched several runtime helpers (runtime/lifecycle, lang/builtins/system, lang/interop/classes/file, engine/vm/jit, runtime/io_default) to call std.c.{getcwd, getenv, realpath, write, mprotect} directly because the corresponding std.posix.* surface was removed. build.zig was never updated to link libc explicitly, so the references resolved only on macOS native targets where libc is auto-linked. Linux native builds and all *-macos-none / *-linux-gnu cross-compile targets failed with "dependency on libc must be explicitly specified" (cache_gen ReleaseSafe + zig build test on Linux + every cross-compile job). Set link_libc = true on the test module, the cache_gen module, and the cljw exe module to match the post-migration source-level dependency. F146 still tracks the eventual removal once std.c usages get pure-Zig equivalents. --- build.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build.zig b/build.zig index 6884efb1..a36d0e32 100644 --- a/build.zig +++ b/build.zig @@ -36,9 +36,13 @@ pub fn build(b: *std.Build) void { } else null; // Library module (test root) + // link_libc: std.c.{getcwd,getenv,realpath,mprotect,write} are used by + // runtime/lifecycle, lang/builtins/system, lang/interop/classes/file, + // engine/vm/jit, runtime/io_default. Tracked for removal in F146. const mod = b.addModule("ClojureWasm", .{ .root_source_file = b.path("src/root.zig"), .target = target, + .link_libc = true, }); mod.addImport("build_options", options_module); if (zwasm_mod) |m| mod.addImport("zwasm", m); @@ -53,6 +57,7 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("src/cache_gen.zig"), .target = b.resolveTargetQuery(.{}), .optimize = .ReleaseSafe, + .link_libc = true, }), }); cache_gen.root_module.addImport("build_options", options_module); @@ -78,6 +83,7 @@ pub fn build(b: *std.Build) void { .root_source_file = b.path("src/main.zig"), .target = target, .optimize = optimize, + .link_libc = true, }), }); exe.root_module.addImport("build_options", options_module);