zig
zig copied to clipboard
Dependency loop detected when depending on custom Build step
Zig Version
0.11.0-dev.1913+95f6a5935
Steps to Reproduce and Observed Behavior
I'm trying to write a custom build step (that generates compile_commands.json).
With the following zig.build file (reduced to a minimum reproduction)
const std = @import("std");
pub fn build(b: *std.Build) void {
var cdb_file_step = std.Build.Step.init(.custom, "cdb_file", b.allocator, makeCdb);
const cdb_step = b.step("cdb", "Create compile_commands.json");
cdb_step.dependOn(&cdb_file_step);
}
fn makeCdb(_: *std.Build.Step) !void {
std.debug.print("./compile_commands.json\n", .{});
}
build fails with
> zig build cdb
error: Dependency loop detected:
thread 1769174 panic: reached unreachable code
/home/smoku/.zig/0.11.0-dev.1913+95f6a5935/files/lib/std/os.zig:1137:23: 0x265cc4 in write (build)
.FAULT => unreachable,
^
/home/smoku/.zig/0.11.0-dev.1913+95f6a5935/files/lib/std/fs/file.zig:1131:33: 0x265ada in write (build)
return os.write(self.handle, bytes);
^
/home/smoku/.zig/0.11.0-dev.1913+95f6a5935/files/lib/std/io/writer.zig:17:32: 0x269848 in write (build)
return writeFn(self.context, bytes);
^
/home/smoku/.zig/0.11.0-dev.1913+95f6a5935/files/lib/std/io/writer.zig:23:46: 0x25c52e in writeAll (build)
index += try self.write(bytes[index..]);
^
/home/smoku/.zig/0.11.0-dev.1913+95f6a5935/files/lib/std/fmt.zig:1058:28: 0x295ef6 in formatBuf__anon_9198 (build)
try writer.writeAll(buf);
^
/home/smoku/.zig/0.11.0-dev.1913+95f6a5935/files/lib/std/fmt.zig:656:45: 0x2693cd in formatType__anon_7060 (build)
return formatBuf(value, options, writer);
^
[...]
Expected Behavior
Running zig build cdb should echo ./compile_commands.json
> zig build cdb
./compile_commands.json