Zig Version
0.16.0-dev.3203+edfc4727e
ZLS Version
0.15.1
Client / Code Editor / Extensions
nvim v0.12.1
Steps to Reproduce and Observed Behavior
- Clone latest zig version from coderberg and build from source to include building LLVM via the zig instructions. This is my build process for zig in pseudo-code:
# LLVM section
git clone --depth 1 --branch release/21.x
cmake ../llvm \
-DCMAKE_INSTALL_PREFIX="$LLVM_INSTALL" \
-DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_PROJECTS="lld;clang" \
-DLLVM_ENABLE_LIBXML2=OFF \
-DLLVM_ENABLE_TERMINFO=OFF \
-DLLVM_ENABLE_LIBEDIT=OFF \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_PARALLEL_LINK_JOBS=1 \
-G Ninja
ninja install
# Zig section
git clone https://codeberg.org/ziglang/zig.git
cmake .. \
-G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="$ZIG_INSTALL" \
-DCMAKE_PREFIX_PATH="$LLVM_INSTALL"
ninja install
# zls section
git clone https://github.com/zigtools/zls.git
zig build -Doptimize=ReleaseSafe
- Error when running
zig build -Doptimize=ReleaseSafe:
build.zig:191:14: error: member function expected 3 argument(s), found 2
b.modules.put("zls", zls_module) catch @panic("OOM");
~~~~~~~~~^~~~
/home/adrian/.local/opt/zig_lang/zigroot/zig-out/lib/zig/std/array_hash_map.zig:469:13: note: function declared here
pub fn put(self: *Self, gpa: Allocator, key: K, value: V) Oom!void {
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Local fix by changing
build.zig by simply passing the build allocator to put:
b.modules.put(b.allocator, "zls", zls_module) catch @panic("OOM");
- Error when running
zig build -Doptimize=ReleaseSafe:
src/Server.zig:602:44: error: expected 3 argument(s), found 1
var watcher: std.json.ObjectMap = .init(arena);
~^~~~
/home/adrian/.local/opt/zig_lang/zigroot/zig-out/lib/zig/std/array_hash_map.zig:168:13: note: function declared here
pub fn init(gpa: Allocator, key_list: []const K, value_list: []const V) Oom!Self {
~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Local fix in
src/Server.zig where I changed std.json.ObjectMap initialization from init(arena) to .empty, and passing the arena allocator to putNoClobber(...). Here is the git diff:
diff --git a/build.zig b/build.zig
index 9f0dfd6f..3f2ecb8f 100644
--- a/build.zig
+++ b/build.zig
@@ -188,7 +188,7 @@ pub fn build(b: *Build) !void {
.build_options = build_options,
.version_data = version_data_module,
});
- b.modules.put("zls", zls_module) catch @panic("OOM");
+ b.modules.put(b.allocator, "zls", zls_module) catch @panic("OOM");
const known_folders_module = b.dependency("known_folders", .{
.target = target,
diff --git a/src/Server.zig b/src/Server.zig
index 80e1366e..7deecdd9 100644
--- a/src/Server.zig
+++ b/src/Server.zig
@@ -599,12 +599,12 @@ fn initializedHandler(server: *Server, arena: std.mem.Allocator, notification: t
if (server.client_capabilities.supports_workspace_did_change_watched_files) {
// `{ "watchers": [ { "globPattern": "**/*.{zig,zon}" } ] }`
- var watcher: std.json.ObjectMap = .init(arena);
- try watcher.putNoClobber("globPattern", .{ .string = "**/*.{zig,zon}" });
+ var watcher: std.json.ObjectMap = .empty;
+ try watcher.putNoClobber(arena, "globPattern", .{ .string = "**/*.{zig,zon}" });
var watchers_arr: std.json.Array = try .initCapacity(arena, 1);
watchers_arr.appendAssumeCapacity(.{ .object = watcher });
- var fs_watcher_obj: std.json.ObjectMap = .init(arena);
- try fs_watcher_obj.putNoClobber("watchers", .{ .array = watchers_arr });
+ var fs_watcher_obj: std.json.ObjectMap = .empty;
+ try fs_watcher_obj.putNoClobber(arena, "watchers", .{ .array = watchers_arr });
const json_val: std.json.Value = .{ .object = fs_watcher_obj };
try server.registerCapability("workspace/didChangeWatchedFiles", json_val);
- After these changes I get a successful
zig build -Doptimize=ReleaseSafe. I also performed a zig build test and got this back, but don't have time to complete passing tests. Just wanted to help out in case this helps at all:
test
└─ run test 478 pass, 11 skip, 1 fail (490 total)
error: 'language_features.cimport.test.zig compile server - translate c' failed:
/home/adrian/.local/opt/zig_lang/zigroot/zig-out/lib/zig/std/Io/Threaded.zig:2854:21: 0x12a3ef9 in batchAwaitConcurrent (std.zig)
return error.Timeout;
^
/home/adrian/.local/opt/zig_lang/zigroot/zig-out/lib/zig/std/Io.zig:592:9: 0x1242936 in awaitConcurrent (std.zig)
return io.vtable.batchAwaitConcurrent(io.userdata, batch, timeout);
^
/home/adrian/.local/opt/zig_lang/zigroot/zig-out/lib/zig/std/Io/File/MultiReader.zig:207:5: 0x14cb999 in fill (std.zig)
try mr.batch.awaitConcurrent(io, timeout);
^
/home/adrian/.local/opt/zig_lang/zls/src/translate_c.zig:226:29: 0x14b73ff in translate (zls.zig)
else => |e| return e,
^
/home/adrian/.local/opt/zig_lang/zls/tests/language_features/cimport.zig:113:19: 0x14bcceb in testTranslate (tests.zig)
var result = (try translate_c.translate(
^
/home/adrian/.local/opt/zig_lang/zls/tests/language_features/cimport.zig:15:19: 0x14bd5fc in test.zig compile server - translate c (tests.zig)
var result1 = try testTranslate(
^
failed command: ./.zig-cache/o/869bf9e6bfa49e520a292290b6586bef/test --cache-dir=./.zig-cache --seed=0x50c42aa0 --listen=-
Build Summary: 55/57 steps succeeded (1 failed); 572/584 tests passed (11 skipped, 1 failed)
test transitive failure
└─ run test 478 pass, 11 skip, 1 fail (490 total)
error: the following build command failed with exit code 1:
.zig-cache/o/3f6978e8efc89eeaffc6f973171332e4/build /home/adrian/.local/opt/zig_lang/zigroot/zig-out/bin/zig /home/adrian/.local/opt/zig_lang/zigroot/zig-out/lib/zig /home/adrian/.local/opt/zig_lang/zls .zig-cache /home/adrian/.cache/zig --seed 0x50c42aa0 -Z964a2bdc5447ccd7 test
Expected Behavior
It should build with the latest nightly build of zig.
Attach ZLS log output
No response
Zig Version
0.16.0-dev.3203+edfc4727e
ZLS Version
0.15.1
Client / Code Editor / Extensions
nvim v0.12.1
Steps to Reproduce and Observed Behavior
zig build -Doptimize=ReleaseSafe:build.zigby simply passing the build allocator to put:zig build -Doptimize=ReleaseSafe:src/Server.zigwhere I changedstd.json.ObjectMapinitialization frominit(arena)to.empty, and passing the arena allocator toputNoClobber(...). Here is thegit diff:zig build -Doptimize=ReleaseSafe. I also performed azig build testand got this back, but don't have time to complete passing tests. Just wanted to help out in case this helps at all:Expected Behavior
It should build with the latest nightly build of zig.
Attach ZLS log output
No response