diff --git a/docs/deps.zig.md b/docs/deps.zig.md index 56759600fd1ea5e48af5c007750ff0f896073318..dd705ecf0b9852ad049af585421f0cc9262c599f 100644 --- a/docs/deps.zig.md +++ b/docs/deps.zig.md @@ -6,6 +6,10 @@ This file is generated by [`zigmod fetch`](commands/fetch.md) or [`zigmod ci`](c The relative path root to which all dependency sources are saved. Currently always `.zigmod/deps`. > Note: only available when made with `zigmod fetch`. +### `skip_libc` +- Type: `bool` +Bool if you want `deps.zig` to skip calling `linkLibC()` for you. Defaults to `false`. + ### `fetch` - Type: `pub fn (exe: *std.build.LibExeObjStep) void` A helper function to automatically pull in dependencies, purely from the `zig build` system without the need to have `zigmod` installed. diff --git a/src/cmd/fetch.zig b/src/cmd/fetch.zig index 45da76d8a8e837e5588cb916b738982214d67982..5416698d69b54b32ecfd084ae086c7ea691209d8 100644 --- a/src/cmd/fetch.zig +++ b/src/cmd/fetch.zig @@ -54,6 +54,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D try w.writeAll("const string = []const u8;\n"); try w.writeAll("\n"); try w.print("pub const cache = \"{}\";\n", .{std.zig.fmtEscapes(cachepath)}); + try w.writeAll("pub var skip_libc = false;\n"); try w.writeAll("\n"); try w.writeAll( \\pub fn addAllTo(exe: *std.Build.Step.Compile) void { @@ -92,6 +93,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D \\ const result = b.createModule(.{ \\ .target = exe.root_module.resolved_target, \\ }); + \\ const target = result.resolved_target.?.result; \\ if (self.import) |capture| { \\ result.root_source_file = capture[1]; \\ } @@ -117,6 +119,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D \\ link_lib_c = true; \\ } \\ for (self.system_libs) |item| { + \\ if (skip_libc and std.zig.target.isLibCLibName(target, item)) continue; \\ result.linkSystemLibrary(item, .{}); \\ exe.linkSystemLibrary(item); \\ link_lib_c = true; @@ -126,7 +129,7 @@ pub fn create_depszig(alloc: std.mem.Allocator, cachepath: string, dir: std.fs.D \\ exe.linkFramework(item); \\ link_lib_c = true; \\ } - \\ if (link_lib_c) { + \\ if (link_lib_c and !skip_libc) { \\ result.link_libc = true; \\ exe.linkLibC(); \\ }