Skip to content

Commit 61d25c6

Browse files
committed
build.zig: check build/config.h for cmake config
Stage1 doesn't need -Dconfig_h to be specified since it'll find it in the same directory as the executable but since stage2 binary is in `zig-out/bin/zig` it'll not find `config.h` and silently default to static LLVM and fail with a linker error. Also looking for `build/config.h` makes building stage3 work with the same command as building stage2.
1 parent 821c374 commit 61d25c6

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

build.zig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -671,6 +671,13 @@ fn findAndParseConfigH(b: *Builder, config_h_path_option: ?[]const u8) ?CMakeCon
671671
var dir = fs.cwd().openDir(check_dir, .{}) catch unreachable;
672672
defer dir.close();
673673

674+
if (dir.readFileAlloc(b.allocator, "build/config.h", max_config_h_bytes)) |some| {
675+
break :blk some;
676+
} else |err| switch (err) {
677+
error.FileNotFound => {},
678+
else => unreachable,
679+
}
680+
674681
break :blk dir.readFileAlloc(b.allocator, "config.h", max_config_h_bytes) catch |err| switch (err) {
675682
error.FileNotFound => {
676683
const new_check_dir = fs.path.dirname(check_dir);

0 commit comments

Comments
 (0)