zig
zig copied to clipboard
Stage4 execution panic. MachO.zig:2231 attempt to use null value: self.data_const_section_index.?
Zig Version
0.11.0-dev.1884+2641feb9b
Steps to Reproduce and Observed Behavior
Hi,
A little out of my depths. First time trying to compile and run zig. I feel like I followed each step correctly, but when I run stage4/bin/zig build test-std -Denable-llvm -Dskip-release -Dskip-non-native
, I get the following errors:
thread 8208053 panic: attempt to use null value
$CODE/zig/src/link/MachO.zig:2231:57: 0x103288aab in getDeclOutputSection (zig)
break :blk self.data_const_section_index.?;
^
$CODE/zig/src/link/MachO.zig:2197:49: 0x1032886d3 in getOrCreateAtomForDecl (zig)
.section = self.getDeclOutputSection(decl_index),
^
$CODE/zig/src/link/MachO.zig:2142:55: 0x10329aff3 in updateDecl (zig)
const atom_index = try self.getOrCreateAtomForDecl(decl_index);
^
$CODE/zig/src/link.zig:520:77: 0x1030a62eb in updateDecl (zig)
.macho => return @fieldParentPtr(MachO, "base", base).updateDecl(module, decl_index),
^
$CODE/zig/src/Module.zig:6457:29: 0x1030a5da7 in linkerUpdateDecl (zig)
comp.bin_file.updateDecl(mod, decl_index) catch |err| switch (err) {
^
$CODE/zig/src/Compilation.zig:3280:52: 0x10321c3eb in processOneJob (zig)
try module.linkerUpdateDecl(decl_index);
^
$CODE/zig/src/Compilation.zig:3234:30: 0x1030e6f57 in performAllTheWork (zig)
try processOneJob(comp, work_item);
^
$CODE/zig/src/Compilation.zig:2425:31: 0x1030e321b in update (zig)
try comp.performAllTheWork(main_progress_node);
^
$CODE/zig/src/main.zig:3641:20: 0x1031095a7 in updateModule (zig)
try comp.update();
^
$CODE/zig/src/main.zig:4314:21: 0x1030051e3 in cmdBuild (zig)
updateModule(gpa, comp, .none) catch |err| switch (err) {
^
$CODE/zig/src/main.zig:294:24: 0x102fcf3e3 in mainArgs (zig)
return cmdBuild(gpa, arena, cmd_args);
^
$CODE/zig/src/main.zig:207:20: 0x102fce07b in main (zig)
return mainArgs(gpa, arena, args);
^
$CODE/zig/lib/std/start.zig:617:37: 0x102fd0497 in main (zig)
const result = root.main() catch |err| {
I'm on Ventura 13.2, with an M2.
I created my stage4 using:
stage3/bin/zig build -p stage4 -Dno-lib
and created my stage3 using:
cmake .. -DZIG_STATIC_LLVM=ON -DCMAKE_PREFIX_PATH="/opt/llvm/;/opt/local/" -DCMAKE_BUILD_TYPE=Release -GNinja
Following these directions to build LLVM.
If I try to run the tests with stage3, I have no problem.
Expected Behavior
stage4 to run like stage3.
I got this working, when building stage4, I added the -Denable-llvm
flag.
So instead of what's in the documentation:
stage3/bin/zig build -p stage4 -Dno-lib
I used:
stage3/bin/zig build -p stage4 -Dno-lib -Denable-llvm
Not sure if I did something else wrong, or if I have a weird setup, or if the documentation should be updated though.
The first time you produced a zig build that did not have LLVM enabled, so it used the (work-in-progress) aarch64 backend, and ran into a bug. If your goal was to work on the aarch64 backend, that would have been exactly what you wanted.
Using -Denable-llvm or not are both valid choices when developing. Contributors should be aware of zig build -h
to see the available options.