zig version
0.6.0+b0684bf08
uname -ra
Darwin Kernel Version 19.6.0: root:xnu-6153.141.1~1/RELEASE_X86_64 x86_64
I created this file
const std = @import("std");
const warn = @import("std").debug.warn;
pub fn main() void {
warn("hello world\n", .{});
}
When I run it, it works okay;
zig run main.zig
hello world
However when I build it, it 'hangs'
zig build main.zig
ps aux | grep -i zig
95060 /usr/local/zig/zig build main.zig
sudo dtruss -acefl -p 95060
95060/0x833fe0: 83180607 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180608 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180610 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180611 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180612 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180613 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180614 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180615 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180616 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180617 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180619 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180620 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180621 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180622 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180623 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180624 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180625 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180626 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180627 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180628 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180630 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180631 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180632 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180633 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180634 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180635 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
95060/0x833fe0: 83180636 3 0 faccessat(0xFFFFFFFFFFFFFFFE, "/build.zig\0", 0x0, 0x0) = -1 2
I do not have a build.zig in the my directory, the only thing I have is main.zig.
I'm guessing that the build.zig file in question is a default one maybe somewhere in the compiler/stdlib??
But I would expect zig to fail with an error if it is unable to faccessat it rather than loop on that syscall.
Interesting, if I remove the main.zig file, so that I'm left with an empty directory; and then I re-run
/usr/local/zig/zig build main.zig the issue still happens
zig build is not valid with a explicit file, and is completely seperate from zig build-exe file.zig, which is I suspect what you intended.
However you should get an error that build.zig does not exist in the current directory, rather than a hang.
Looks suspiciously similar to #6584, the traversal reaches the root and then hangs forever.
Yes, it's the same fucking dirname shit again.
0.7.0 milestone, call me out if I try to post-pone this issue :-)
Most helpful comment
Looks suspiciously similar to #6584, the traversal reaches the root and then hangs forever.
Yes, it's the same fucking
dirnameshit again.