Skip to content

Commit 4dd58fb

Browse files
committed
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.
1 parent 6faadc5 commit 4dd58fb

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎build.zig‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,13 @@ pub fn build(b: *std.Build) void {
3636
} else null;
3737

3838
// Library module (test root)
39+
// link_libc: std.c.{getcwd,getenv,realpath,mprotect,write} are used by
40+
// runtime/lifecycle, lang/builtins/system, lang/interop/classes/file,
41+
// engine/vm/jit, runtime/io_default. Tracked for removal in F146.
3942
const mod = b.addModule("ClojureWasm", .{
4043
.root_source_file = b.path("src/root.zig"),
4144
.target = target,
45+
.link_libc = true,
4246
});
4347
mod.addImport("build_options", options_module);
4448
if (zwasm_mod) |m| mod.addImport("zwasm", m);
@@ -53,6 +57,7 @@ pub fn build(b: *std.Build) void {
5357
.root_source_file = b.path("src/cache_gen.zig"),
5458
.target = b.resolveTargetQuery(.{}),
5559
.optimize = .ReleaseSafe,
60+
.link_libc = true,
5661
}),
5762
});
5863
cache_gen.root_module.addImport("build_options", options_module);
@@ -78,6 +83,7 @@ pub fn build(b: *std.Build) void {
7883
.root_source_file = b.path("src/main.zig"),
7984
.target = target,
8085
.optimize = optimize,
86+
.link_libc = true,
8187
}),
8288
});
8389
exe.root_module.addImport("build_options", options_module);

0 commit comments

Comments
 (0)