From 2bef0a64276df5f4f4a7f54e5757566502951a27 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Wed, 3 Jan 2024 14:10:28 +0100 Subject: [PATCH 1/4] Update to latest master after Zig PR #18160 --- build.zig | 28 ++++++++++++++-------------- src/build/ScdocStep.zig | 4 ++-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/build.zig b/build.zig index a52fd33..35e9e4a 100644 --- a/build.zig +++ b/build.zig @@ -6,7 +6,7 @@ pub fn build(b: *std.Build) !void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - _ = b.addModule("xev", .{ .source_file = .{ .path = "src/main.zig" } }); + _ = b.addModule("xev", .{ .root_source_file = .{ .path = "src/main.zig" } }); const man_pages = b.option( bool, @@ -51,7 +51,7 @@ pub fn build(b: *std.Build) !void { // Our tests require libc on Linux and Mac. Note that libxev itself // does NOT require libc. - const test_libc = switch (target.getOsTag()) { + const test_libc = switch (target.result.os.tag) { .linux, .macos => true, else => false, }; @@ -73,7 +73,7 @@ pub fn build(b: *std.Build) !void { test_step.dependOn(&tests_run.step); // Static C lib - const static_c_lib: ?*std.build.Step.Compile = if (target.getOsTag() != .wasi) lib: { + const static_c_lib: ?*std.Build.Step.Compile = if (target.result.os.tag != .wasi) lib: { const static_lib = b.addStaticLibrary(.{ .name = "xev", .root_source_file = .{ .path = "src/c_api.zig" }, @@ -84,7 +84,7 @@ pub fn build(b: *std.Build) !void { static_lib.linkLibC(); // Link required libraries if targeting Windows - if (target.getOsTag() == .windows) { + if (target.result.os.tag == .windows) { static_lib.linkSystemLibrary("ws2_32"); static_lib.linkSystemLibrary("mswsock"); } @@ -114,7 +114,7 @@ pub fn build(b: *std.Build) !void { // Dynamic C lib. We only build this if this is the native target so we // can link to libxml2 on our native system. - if (target.isNative()) { + if (target.query.isNative()) { const dynamic_lib_name = "xev"; const dynamic_lib = b.addSharedLibrary(.{ @@ -190,14 +190,14 @@ pub fn build(b: *std.Build) !void { fn benchTargets( b: *std.Build, - target: std.zig.CrossTarget, - mode: std.builtin.Mode, + target: std.Build.ResolvedTarget, + mode: std.builtin.OptimizeMode, install: bool, install_name: ?[]const u8, -) !std.StringHashMap(*CompileStep) { +) !std.StringHashMap(*std.Build.Step.Compile) { _ = mode; - var map = std.StringHashMap(*CompileStep).init(b.allocator); + var map = std.StringHashMap(*std.Build.Step.Compile).init(b.allocator); // Open the directory const c_dir_path = (comptime thisDir()) ++ "/src/bench"; @@ -230,7 +230,7 @@ fn benchTargets( .target = target, .optimize = .ReleaseFast, // benchmarks are always release fast }); - c_exe.addModule("xev", b.modules.get("xev").?); + c_exe.root_module.addImport("xev", b.modules.get("xev").?); if (install) { const install_step = b.addInstallArtifact(c_exe, .{ .dest_dir = .{ .override = .{ .custom = "bench" } }, @@ -247,9 +247,9 @@ fn benchTargets( fn exampleTargets( b: *std.Build, - target: std.zig.CrossTarget, - optimize: std.builtin.Mode, - c_lib_: ?*std.build.Step.Compile, + target: std.Build.ResolvedTarget, + optimize: std.builtin.OptimizeMode, + c_lib_: ?*std.Build.Step.Compile, install: bool, install_name: ?[]const u8, ) !void { @@ -288,7 +288,7 @@ fn exampleTargets( .target = target, .optimize = optimize, }); - c_exe.addModule("xev", b.modules.get("xev").?); + c_exe.root_module.addImport("xev", b.modules.get("xev").?); if (install) { const install_step = b.addInstallArtifact(c_exe, .{ .dest_dir = .{ .override = .{ .custom = "example" } }, diff --git a/src/build/ScdocStep.zig b/src/build/ScdocStep.zig index 96ebde7..1c7d4bb 100644 --- a/src/build/ScdocStep.zig +++ b/src/build/ScdocStep.zig @@ -1,7 +1,7 @@ const std = @import("std"); const mem = std.mem; const fs = std.fs; -const Step = std.build.Step; +const Step = std.Build.Step; const Build = std.Build; /// ScdocStep generates man pages using scdoc(1). @@ -46,7 +46,7 @@ pub fn init(builder: *Build) ScdocStep { }; } -fn make(step: *std.build.Step, progress: *std.Progress.Node) !void { +fn make(step: *std.Build.Step, progress: *std.Progress.Node) !void { _ = progress; const self = @fieldParentPtr(ScdocStep, "step", step); From a971e0058d689f3c3b04dc210c809cd4b58c35a7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Jan 2024 16:46:24 -0800 Subject: [PATCH 2/4] update zig --- flake.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/flake.lock b/flake.lock index e6ae48a..aab81d3 100644 --- a/flake.lock +++ b/flake.lock @@ -96,16 +96,16 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1689088367, - "narHash": "sha256-Y2tl2TlKCWEHrOeM9ivjCLlRAKH3qoPUE/emhZECU14=", + "lastModified": 1702350026, + "narHash": "sha256-A+GNZFZdfl4JdDphYKBJ5Ef1HOiFsP18vQe9mqjmUis=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "5c9ddb86679c400d6b7360797b8a22167c2053f8", + "rev": "9463103069725474698139ab10f17a9d125da859", "type": "github" }, "original": { "owner": "NixOS", - "ref": "release-23.05", + "ref": "nixos-23.05", "repo": "nixpkgs", "type": "github" } @@ -126,11 +126,11 @@ "nixpkgs": "nixpkgs_2" }, "locked": { - "lastModified": 1700827703, - "narHash": "sha256-EfM3pRvtb5TrvxURhtI1gEKb/mSXHJx3A/12HOWKOyI=", + "lastModified": 1704500574, + "narHash": "sha256-Ockm1D5QsxdVZZoD0Yf5Kg4FupbVnk3X0RLkc6geRIE=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "2c9179e22a4759c7c88438a4a9eb0f5e3c00d3b0", + "rev": "e056aafd8db157ff7519518a026c5ba7040522cf", "type": "github" }, "original": { From 940c66d1f43b35ae71214a74169382834a37284e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Jan 2024 16:47:16 -0800 Subject: [PATCH 3/4] ci: update windows zig --- .github/workflows/test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ba30d67..02ee994 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -91,7 +91,7 @@ jobs: - name: Install zig uses: goto-bus-stop/setup-zig@v2 with: - version: 0.12.0-dev.1710+2bffd8101 + version: 0.12.0-dev.2058+04ac028a2 - name: test run: zig build test --summary all From ba8986b229c397f6daec6680504ad0bc33bca444 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 5 Jan 2024 16:51:17 -0800 Subject: [PATCH 4/4] update bench to latest zig API --- src/bench/ping-pongs.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bench/ping-pongs.zig b/src/bench/ping-pongs.zig index f72be56..5372f60 100644 --- a/src/bench/ping-pongs.zig +++ b/src/bench/ping-pongs.zig @@ -296,7 +296,7 @@ const Server = struct { // Echo it back const c_echo = self.completion_pool.create() catch unreachable; const buf_write = self.buffer_pool.create() catch unreachable; - std.mem.copy(u8, buf_write, buf.slice[0..n]); + @memcpy(buf_write, buf.slice[0..n]); socket.write(loop, c_echo, .{ .slice = buf_write[0..n] }, Server, self, writeCallback); // Read again