I just downloaded the latest master release 0.14.0-dev.1655+4d09fb491 and I’m trying to rebuild zls, however I get a compiler error:
zig build -Doptimize=ReleaseSafe
/home/joe/.local/lib/zig/std/Build/Fuzz/WebServer.zig:633:9: error: expected type 'usize', found 'u64'
file_size,
^~~~~~~~~
/home/joe/.local/lib/zig/std/Build/Fuzz/WebServer.zig:633:9: note: unsigned 32-bit int cannot represent all possible unsigned 64-bit values
/home/joe/.local/lib/zig/std/posix.zig:4697:13: note: parameter type declared here
length: usize,
^~~~~
referenced by:
coverageRun: /home/joe/.local/lib/zig/std/Build/Fuzz/WebServer.zig:562:50
callFn__anon_68434: /home/joe/.local/lib/zig/std/Thread.zig:409:13
10 reference(s) hidden; use '-freference-trace=12' to see all references
Can anyone else reproduce this to confirm this isn’t my mistake? My zls clone is up to date (I have git pulled) and so is my lib/zig directory.
It’s good that you found the issue, but I would expect 32-bit Zig to still be capable of outputting a 64-bit binary, and if your computer is 64-bit, Zig should choose a 64-bit target as default. Maybe this warrants opening an issue.
I don’t think so. That issue just shows that Fuzz.Webserver incorrectly assumes a 64-bit usize. In this case, Zig is choosing the wrong target because of it being 32-bit.
I see. I’m not very familiar with how zig chooses the target but it seems like it defaults to builtin.cpu.arch, which for my installation is x86:
From std.zig.system.resolveTargetQuery:
// Until https://github.com/ziglang/zig/issues/4592 is implemented (support detecting the
// native CPU architecture as being different than the current target), we use this:
const cpu_arch = query.cpu_arch orelse builtin.cpu.arch;