Skip to content

Build failures on stable Zig 0.16.0 due to std.Io.Threaded #22

Description

@saser

I'm running Zig 0.16.0 stable, or at least that's what it seems like:

$ zig version
0.16.0

In a project freshly created with zig init, I take a dependency on the latest
version of this library:

$ zig fetch --save=bench https://github.com/pyk/bench/archive/main.tar.gz
...

$ cat build.zig.zon
...
    .dependencies = .{
        .bench = .{
            .url = "https://github.com/pyk/bench/archive/main.tar.gz",
            .hash = "bench-0.0.1-zrgM9kItAQBYNwZku-VWyrhSx4CDdlDsapcxjU67t8sk",
        },
    },

...

Then I add it as a dependency of the root module in build.zig:

diff --git a/build.zig b/build.zig
index 6ba0663..09de8f3 100644
--- a/build.zig
+++ b/build.zig
@@ -28,6 +28,7 @@ pub fn build(b: *std.Build) void {
     // to our consumers. We must give it a name because a Zig package can expose
     // multiple modules and consumers will need to be able to specify which
     // module they want to access.
+    const bench = b.dependency("bench", .{ .target = target, .optimize = optimize });
     const mod = b.addModule("zig_bench", .{
         // The root source file is the "entry point" of this module. Users of
         // this module will only be able to access public declarations contained
@@ -39,6 +40,9 @@ pub fn build(b: *std.Build) void {
         // Later on we'll use this module as the root module of a test executable
         // which requires us to specify a target.
         .target = target,
+        .imports = &.{
+            .{ .name = "bench", .module = bench.module("bench") },
+        },
     });

     // Here we define an executable. An executable needs to have a root module

At this point, running zig build fails, showing me an error in the build.zig of this library (so not my project's build.zig):

$ zig build
zig-pkg/bench-0.0.1-zrgM9kItAQBYNwZku-VWyrhSx4CDdlDsapcxjU67t8sk/build.zig:51:38: error: expected 2 argument(s), found 1
    var threaded: std.Io.Threaded = .init(b.allocator);
                                    ~^~~~
/usr/lib/zig/std/Io/Threaded.zig:1607:5: note: function declared here
pub fn init(
~~~~^~
referenced by:
    runBuild__anon_139970: /usr/lib/zig/std/Build.zig:2264:33
    dependencyInner__anon_139940: /usr/lib/zig/std/Build.zig:2245:29
    9 reference(s) hidden; use '-freference-trace=11' to see all references

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions