I tried to build buzz with zig 0.14.0-dev.656+c15755092
but the build failed.
I followed the instructions from the readme but I got an error from a missing file in pcre2:
install
└─ zig build-lib fs Debug native
└─ zig build-lib pcre2 Debug native 1 errors
error: unable to check cache: stat file '/Users/kristoff/repros/buzz/vendors/pcre2/src/pcre2_chartables.c' failed: FileNotFound
(you might want to update build instructions to reflect that or even better follow my recommendation further down this comment)
So I went into the pcre2 directory, messed around a bit with the shell scripts in there till that file showed up.
Ater that the build encountered this error:
install
└─ zig build-lib os Debug native 1 errors
src/lib/buzz_os.zig:115:5: error: switch must handle all possibilities
switch (err) {
^~~~~~
src/lib/buzz_os.zig:115:5: note: unhandled error value: 'error.ProcessAlreadyExec'
src/lib/buzz_os.zig:115:5: note: unhandled error value: 'error.InvalidProcessGroupId'
src/lib/buzz_os.zig:115:5: note: unhandled error value: 'error.ProcessNotFound'
referenced by:
execute: src/lib/buzz_os.zig:182:25
execute: src/lib/buzz_os.zig:153:5
Since the c dependencies are not packaged with a Zig build I assumed that cross-compilation is off the table and opted for patching the compile error.
This led me to a failure to build which turned out to be a SIGSEGV in the Zig compiler :^)
Process 38390 launched: '/Users/kristoff/zig-src/build/stage3/bin/zig' (arm64)
Process 38390 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
frame #0: 0x000000010aeba77c zig`link.MachO.writeLoadCommands + 1380
zig`link.MachO.writeLoadCommands:
-> 0x10aeba77c <+1380>: ldr w1, [x0, #0x10]
0x10aeba780 <+1384>: add x0, sp, #0x100
0x10aeba784 <+1388>: mov x2, x24
0x10aeba788 <+1392>: bl 0x10ad1c598 ; link.MachO.Symbol.getFile
(lldb) bt
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x10)
* frame #0: 0x000000010aeba77c zig`link.MachO.writeLoadCommands + 1380
frame #1: 0x000000010ad77720 zig`link.MachO.flushModule + 20324
frame #2: 0x000000010abcda14 zig`Compilation.flush + 672
frame #3: 0x000000010abd164c zig`Compilation.update + 9540
frame #4: 0x000000010abe7b1c zig`main.updateModule + 44
frame #5: 0x000000010ac18c30 zig`main.buildOutputType + 51300
frame #6: 0x000000010ab5d230 zig`main + 2568
frame #7: 0x000000018b3aa0e0 dyld`start + 2360
(lldb)
You can definitely reproduce the error if you re-run the command that failed directly, since you won’t see any output from it the first time as it was run by the build runner.
Now it would be nice to be able to offer a well-packaged reproduction to @kubkon, but man submodules are making this a huge pain in the ass.
So I did the only rational thing: nuked every. single. dotgit. directory, and committed every intermediate asset since there’s no way for me to know what’s needed or not.
@kubkon Crash in link.MachO.writeLoadCommands · Issue #20847 · ziglang/zig · GitHub
If I may add some suggestions:
- add a build.zig.zon to your project
- remove all the submodules from vendors/ and turn them all into tarballs that you depend on from your build.zig.zon (all the code that copies files around will work)
- have the invocation of make inside mir be run automatically by your build script as a starting point…
- …and then just replace that makefile with a build.zig
- same with pcre2 since it seems that it needs to be build first
You can find plenty of examples of how to directly depend on C/C++ repos (and how to package them for Zig) in All Your Codebase · GitHub
It’s not trivial to port some C/C++ projects to the Zig build system but man it will make your life easier when developing buzz once you do it.