capy icon indicating copy to clipboard operation
capy copied to clipboard

MacOs arm64 `zig build` - failed

Open ego opened this issue 1 year ago • 8 comments


❯ uname -a
Darwin MacBook-Pro-2 23.5.0 Darwin Kernel Version 23.5.0 RELEASE_ARM64_T6031 arm64

❯ zig version
0.13.0

capy on  master via  ↯ v0.13.0
❯ zig build
/.cache/zig/p/1220bc2612b57b0cfaaecbcac38e3144e5a9362ff668d71eb8334e895047bdbb7148/build.zig:9:33: error: no field named 'path' in union 'Build.LazyPath'
        .root_source_file = .{ .path = "stub.c" },
                                ^~~~
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:2171:22: note: union declared here
pub const LazyPath = union(enum) {
                     ^~~~~
referenced by:
    runBuild__anon_15902: /opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:2116:27
    dependencyInner__anon_14558: /opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:2097:29
    remaining reference traces hidden; use '-freference-trace' to see all reference traces
/.cache/zig/p/1220c94dbcdf5a799ce2b1571978ff3c97bab1341fe329084fcc3c06e5d6375469b9/build.zig:7:56: error: no field named 'path' in union 'Build.LazyPath'
    _ = b.addModule("objc", .{ .root_source_file = .{ .path = "src/main.zig" } });
                                                       ^~~~
/opt/homebrew/Cellar/zig/0.13.0/lib/zig/std/Build.zig:2171:22: note: union declared here
pub const LazyPath = union(enum) {
                     ^~~~~

ego avatar Jul 06 '24 09:07 ego

that's from the zig-objc bindings and zig-build-macos-sdk being outdated

you can edit the cache files directly (obviously somewhat silly) or clone the dependencies and include them locally to fix this

I'll check if the build.zig.zon can be bumped, and/or if the deps themselves need to be updated

Gogopex avatar Jul 08 '24 13:07 Gogopex

that's from the zig-objc bindings and zig-build-macos-sdk being outdated

you can edit the cache files directly (obviously somewhat silly) or clone the dependencies and include them locally to fix this

I'll check if the build.zig.zon can be bumped, and/or if the deps themselves need to be updated

Sorry for bothering, any updates? I can't get how it's happens. Package manager with pinned version and it is didn't works properly.

ego avatar Jul 19 '24 15:07 ego

@ego I gave it a try, but even fixing these issues led me to seeing that the MacOS implementation is still very much in progress. I started working on it, but the breadth somewhat pushed me off.

Unless the capy contributors correct me, I believe MacOS support is simply not present ATM but should be coming!

Gogopex avatar Jul 20 '24 16:07 Gogopex

It builds fine now with 0.13.0-dev.351+64ef45eb0. This issue should be closed.

geon avatar Oct 17 '24 21:10 geon

Grab zig from zig-macos-x86_64-0.13.0-dev.351+64ef45eb0.tar.xz

❯ ./zig version 0.13.0-dev.351+64ef45eb0

❯ rm -r .zig-cache ❯ rm -r /Users/vladi/.cache/zig/

❯ ./zig build
/Users/vladi/.cache/zig/p/122034b3e15d582d8d101a7713e5f13c872b8b8eb6d9cb47515b8e34ee75e122630d/build.zig:13:28: error: no module named 'macos_sdk' available within module root.@dependencies.122034b3e15d582d8d101a7713e5f13c872b8b8eb6d9cb47515b8e34ee75e122630d
    if (add_paths) @import("macos_sdk").addPathsModule(objc);
                           ^~~~~~~~~~~
referenced by:
    runBuild__anon_15362: lib/std/Build.zig:2078:27
    dependencyInner__anon_14531: lib/std/Build.zig:2059:29
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

ego avatar Oct 18 '24 22:10 ego

Hmm. I removed my cache and tried again, and now I can't build.

Not sure what I did to make it work earlier. Will investigate.

geon avatar Oct 19 '24 14:10 geon

I tried again with zig build calculator and suddenly it worked. Then I deleted the cache and it failed building again. Feels like something in the zig build system is nondeterministic?

Just zig build won't work for the macos backend since so much is still missing. The calculator example is one of the few that compiles.

geon avatar Oct 19 '24 16:10 geon

Hey I am very new to zig and I was also trying to build this project on similar hardware.

Here's the stack trace

$ uname -a Darwin macOS 25.0.0 Darwin Kernel Version 25.0.0: Wed Sep 17 21:42:08 PDT 2025; root:xnu-12377.1.9~141/RELEASE_ARM64_T8132 arm64 
$ zig version 
0.15.1 
$ zig build /usr/local/Cellar/zig/0.15.1/lib/zig/std/Io/Writer.zig:1198:9: error: ambiguous format string; specify {f} to call format method, or {any} to skip it
         @compileError("ambiguous format string; specify {f} to call format method, or {any} to skip it");
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 /usr/local/Cellar/zig/0.15.1/lib/zig/std/Io/Writer.zig:700:25: note: called at comptime here
         try w.printValue(
             ~~~~~~~~~~~~^
 /usr/local/Cellar/zig/0.15.1/lib/zig/std/fmt.zig:629:20: note: called at comptime here
     dw.writer.print(fmt, args) catch |err| switch (err) {
     ~~~~~~~~~~~~~~~^~~~~~~~~~~
 /usr/local/Cellar/zig/0.15.1/lib/zig/std/fmt.zig:658:83: note: called at comptime here
 pub inline fn comptimePrint(comptime fmt: []const u8, args: anytype) *const [count(fmt, args):0]u8 { 
                                                                             ~~~~~^~~~~~~~~~~
 build_capy.zig:298:44: note: generic function instantiated here
         @compileError(std.fmt.comptimePrint("unsupported Zig version ({}). Zig 0.14.1 is required.", .{@import("builtin").zig_version}));
                       ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 referenced by:
     CapyBuildOptions: build.zig:3:38
     build: build.zig:136:21
     6 reference(s) hidden; use '-freference-trace=8' to see all references
 ~/.cache/zig/p/zigimg-0.1.0/build.zig:15:10: error: no field named 'root_source_file' in struct 'Build.TestOptions' 
        .root_source_file = b.path("zigimg.zig"),
          ^~~~~~~~~~~~~~~~
 /usr/local/Cellar/zig/0.15.1/lib/zig/std/Build.zig:856:25: note: struct declared here
 pub const TestOptions = struct {
                         ^~~~~~
 android/build/auto-detect.zig:336:32: error: root source file struct 'Io' has no member named 'bufferedWriter'         var buf_writer = std.io.bufferedWriter(file.writer());
                          ~~~~~~^~~~~~~~~~~~~~~
 /usr/local/Cellar/zig/0.15.1/lib/zig/std/Io.zig:1:1: note: struct declared here
 const builtin = @import("builtin");
 ^~~~~
 build.zig:74:58: error: struct 'array_list.Aligned([]const u8,null)' has no member named 'init'
                 var libraries = std.ArrayList([]const u8).init(b.allocator);
                                 ~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~
 /usr/local/Cellar/zig/0.15.1/lib/zig/std/array_list.zig:606:12: note: struct declared here
     return struct {
            ^~~~~~  

I also want to understand the problem and contribute in any form possible. Thank you.

ak95asb avatar Oct 10 '25 06:10 ak95asb