`-fincremental` doesn't build

Hi, I was about to try out -fincremental but I get this error:

thinkpad@fedora:~/code/ochi$ zig build -fincremental
install
└─ install Ochi
   └─ compile exe Ochi Debug native failure
error: thread 10833 panic: REX_GOTPCRELX
       Cannot print stack trace: stack tracing is disabled

error: process terminated with signal ABRT
failed command: /home/thinkpad/.zvm/0.16.0/zig build-exe -ODebug --dep zeit --dep httpz --dep snappy --dep zint --dep c --dep encoding --dep build -Mroot=/home/thinkpad/code/ochi/src/main.zig -ODebug -Mzeit=/home/thinkpad/code/ochi/zig-pkg/zeit-0.6.0-5I6bk7q6AgBdMJxze3D4l9ylQhkviQ_BX9FigDt13MFn/src/zeit.zig -ODebug --dep metrics --dep websocket --dep build=build0 -Mhttpz=/home/thinkpad/code/ochi/zig-pkg/httpz-0.0.0-PNVzrDC4BwANG-9UeHJ5udYPc19jZpm6LbkAtlAElOBk/src/httpz.zig .zig-cache/o/1a4773d71d03a8e5338b0735dc431cf7/libsnappy.a -ODebug -I .zig-cache/o/36e0189990168edb93e5de5403512097 -Msnappy=/home/thinkpad/code/ochi/zig-pkg/snappy-0.1.0-n4AaquQ4AADQScvw9-i6SJvZTTagvxmGgGKnat4T_a4e/src/snappy.zig -ODebug -Mzint=/home/thinkpad/code/ochi/zig-pkg/zint-0.0.3-h0gsmS__AQD_LMS-37DXkuEF8s8W8-WchR76_BpgINIt/src/root.zig .zig-cache/o/71d1cac5b6f079317649fd7cc61f8c2b/libzstd.a -ODebug -I .zig-cache/o/28b86af4fded6644eee5e28d78d27cca -Mc=/home/thinkpad/code/ochi/src/lib/c/c.zig -ODebug --dep c -Mencoding=/home/thinkpad/code/ochi/src/lib/encoding/root.zig -Mbuild=.zig-cache/c/ee31ab6213697d2737530ca5687b79e5/options.zig -ODebug -Mmetrics=/home/thinkpad/code/ochi/zig-pkg/metrics-0.0.0-W7G4eIegAQD4XxA9Co7Atbw59u_2zvxYf406AZuoAHPM/src/metrics.zig -ODebug --dep build=build1 -Mwebsocket=/home/thinkpad/code/ochi/zig-pkg/websocket-0.1.0-ZPISdUU6BAAPe0iZ_JHMVAXaBlz327xZRBrRY06-Vw5h/src/websocket.zig -Mbuild0=.zig-cache/c/588d8e90b2ff6dc0bd7ddf1ba6f5872d/options.zig -Mbuild1=.zig-cache/c/cc544fc8f162c327786efad17dbbf432/options.zig -lc++ -lc --cache-dir .zig-cache --global-cache-dir /home/thinkpad/.cache/zig --name Ochi --zig-lib-dir /home/thinkpad/.zvm/0.16.0/lib/ -fincremental --listen=-

Build Summary: 8/11 steps succeeded (1 failed)
install transitive failure
└─ install Ochi transitive failure
   └─ compile exe Ochi Debug native failure

error: the following build command failed with exit code 1:
.zig-cache/o/6a5298649c74be686157860d1fd643df/build /home/thinkpad/.zvm/0.16.0/zig /home/thinkpad/.zvm/0.16.0/lib /home/thinkpad/code/ochi .zig-cache /home/thinkpad/.cache/zig --seed 0xe378c9ba -Z75698d4b3dac215b -fincremental

This is the build script I was working on, assume these errors are bc of the C library.

const std = @import("std");
const zon = @import("build.zig.zon");

pub fn build(b: *std.Build) void {
    const target = b.standardTargetOptions(.{});
    const optimize = b.standardOptimizeOption(.{});

    const exe = b.addExecutable(.{
        .name = "Ochi",
        .root_module = b.createModule(.{
            .root_source_file = b.path("src/main.zig"),
            .target = target,
            .optimize = optimize,
        }),
    });

    // 3d party dependencies
    const zeit = b.dependency("zeit", .{
        .target = target,
        .optimize = optimize,
    });

    const httpz = b.dependency("httpz", .{
        .target = target,
        .optimize = optimize,
    });

    const snappy = b.dependency("snappy", .{
        .target = target,
        .optimize = optimize,
    });

    const zint = b.dependency("zint", .{
        .target = target,
        .optimize = optimize,
    });

    // C dependencies
    const zstd_dependency = b.dependency("zstd", .{
        .target = target,
        .optimize = optimize,
    });

    // Create C bindings module
    const cModule = b.createModule(.{
        .root_source_file = b.path("src/lib/c/c.zig"),
        .target = target,
        .optimize = optimize,
    });
    cModule.linkLibrary(zstd_dependency.artifact("zstd"));

    // inner modules
    const encoding_module = b.createModule(.{
        .root_source_file = b.path("src/lib/encoding/root.zig"),
        .target = target,
        .optimize = optimize,
    });
    encoding_module.addImport("c", cModule);

    const options = b.addOptions();

    options.addOption([]const u8, "version", zon.version);
    const test_filter = b.option([]const []const u8, "test-filter", "Test filter");
    exe.root_module.addOptions("build", options);

    exe.root_module.addImport("zeit", zeit.module("zeit"));
    exe.root_module.addImport("httpz", httpz.module("httpz"));
    exe.root_module.addImport("snappy", snappy.module("snappy"));
    exe.root_module.addImport("zint", zint.module("zint"));
    exe.root_module.addImport("c", cModule);
    exe.root_module.addImport("encoding", encoding_module);
    exe.root_module.linkLibrary(zstd_dependency.artifact("zstd"));

    const unit_test = b.addTest(.{
        .root_module = exe.root_module,
        .filters = if (test_filter) |filter| filter else &[_][]const u8{},
        .test_runner = .{ .path = b.path("test_runner.zig"), .mode = .server },
    });

    const encoding_tests = b.addTest(.{
        .root_module = encoding_module,
        .filters = if (test_filter) |filter| filter else &[_][]const u8{},
        .test_runner = .{ .path = b.path("test_runner.zig"), .mode = .server },
    });

    b.installArtifact(exe);

    const run_step = b.step("run", "Run the application");
    runArtifact(b, target, run_step, exe);

    const test_step = b.step("test", "Run the test suite");
    runArtifact(b, target, test_step, unit_test);
    runArtifact(b, target, test_step, encoding_tests);
}

fn runArtifact(
    b: *std.Build,
    target: std.Build.ResolvedTarget,
    step: *std.Build.Step,
    artifact: *std.Build.Step.Compile,
) void {
    step.dependOn(&b.addInstallArtifact(artifact, .{}).step);
    if (!target.query.isNative()) return;

    const run_cmd = b.addRunArtifact(artifact);
    if (b.args) |args| {
        run_cmd.addArgs(args);
    }

    step.dependOn(&run_cmd.step);
}

Furthermore, when I add --watch I get this:

thinkpad@fedora:~/code/ochi$ zig build -fincremental --watch
install
└─ install Ochi
   └─ compile exe Ochi Debug native failure
error: thread 10922 panic: REX_GOTPCRELX
       Cannot print stack trace: stack tracing is disabled

failed command: /home/thinkpad/.zvm/0.16.0/zig build-exe -ODebug --dep zeit --dep httpz --dep snappy --dep zint --dep c --dep encoding --dep build -Mroot=/home/thinkpad/code/ochi/src/main.zig -ODebug -Mzeit=/home/thinkpad/code/ochi/zig-pkg/zeit-0.6.0-5I6bk7q6AgBdMJxze3D4l9ylQhkviQ_BX9FigDt13MFn/src/zeit.zig -ODebug --dep metrics --dep websocket --dep build=build0 -Mhttpz=/home/thinkpad/code/ochi/zig-pkg/httpz-0.0.0-PNVzrDC4BwANG-9UeHJ5udYPc19jZpm6LbkAtlAElOBk/src/httpz.zig .zig-cache/o/1a4773d71d03a8e5338b0735dc431cf7/libsnappy.a -ODebug -I .zig-cache/o/36e0189990168edb93e5de5403512097 -Msnappy=/home/thinkpad/code/ochi/zig-pkg/snappy-0.1.0-n4AaquQ4AADQScvw9-i6SJvZTTagvxmGgGKnat4T_a4e/src/snappy.zig -ODebug -Mzint=/home/thinkpad/code/ochi/zig-pkg/zint-0.0.3-h0gsmS__AQD_LMS-37DXkuEF8s8W8-WchR76_BpgINIt/src/root.zig .zig-cache/o/71d1cac5b6f079317649fd7cc61f8c2b/libzstd.a -ODebug -I .zig-cache/o/28b86af4fded6644eee5e28d78d27cca -Mc=/home/thinkpad/code/ochi/src/lib/c/c.zig -ODebug --dep c -Mencoding=/home/thinkpad/code/ochi/src/lib/encoding/root.zig -Mbuild=.zig-cache/c/ee31ab6213697d2737530ca5687b79e5/options.zig -ODebug -Mmetrics=/home/thinkpad/code/ochi/zig-pkg/metrics-0.0.0-W7G4eIegAQD4XxA9Co7Atbw59u_2zvxYf406AZuoAHPM/src/metrics.zig -ODebug --dep build=build1 -Mwebsocket=/home/thinkpad/code/ochi/zig-pkg/websocket-0.1.0-ZPISdUU6BAAPe0iZ_JHMVAXaBlz327xZRBrRY06-Vw5h/src/websocket.zig -Mbuild0=.zig-cache/c/588d8e90b2ff6dc0bd7ddf1ba6f5872d/options.zig -Mbuild1=.zig-cache/c/cc544fc8f162c327786efad17dbbf432/options.zig -lc++ -lc --cache-dir .zig-cache --global-cache-dir /home/thinkpad/.cache/zig --name Ochi --zig-lib-dir /home/thinkpad/.zvm/0.16.0/lib/ -fincremental --listen=-

                     getPath() was called on a GeneratedFile that wasn't built yet.                                                                                                                                   source package path: /home/thinkpad/code/ochi                                                                                                                                                  Is there a missing Step dependency on step 'compile exe Ochi Debug native'?                                                                                                                      The step was created by this stack trace:                                                                                                                                                  name: 'compile exe Ochi Debug native'. creation stack trace:
/home/thinkpad/.zvm/0.16.0/lib/std/Build/Step/Compile.zig:420:22: 0x158d0d6 in create (std.zig)
        .step = .init(.{
                     ^
/home/thinkpad/.zvm/0.16.0/lib/std/Build.zig:788:19: 0x15c9178 in addExecutable (std.zig)
    return .create(b, .{
                  ^
/home/thinkpad/code/ochi/build.zig:59:32: 0x156e00e in build (build.zig)
    const exe = b.addExecutable(.{                                                                                                                                                                                            ^
/home/thinkpad/.zvm/0.16.0/lib/std/Build.zig:2264:33: 0x156ce0a in runBuild__anon_34168 (std.zig)
        .void => build_zig.build(b),
                                ^
/home/thinkpad/.zvm/0.16.0/lib/compiler/build_runner.zig:463:29: 0x128c524 in main (build_runner.zig)
        try builder.runBuild(root);                                                                                                                                                                                        ^
/home/thinkpad/.zvm/0.16.0/lib/std/start.zig:699:88: 0x1292040 in callMain (std.zig)
    if (fn_info.params[0].type.? == std.process.Init.Minimal) return wrapMain(root.main(.{
                                                                                       ^
/home/thinkpad/.zvm/0.16.0/lib/std/start.zig:190:5: 0x1276201 in _start (std.zig)
    asm volatile (switch (native_arch) {                                                                                                                                                           ^
    The step 'install Ochi' that is missing a dependency on the above step was created by this stack trace:
name: 'install Ochi'. creation stack trace:
/home/thinkpad/.zvm/0.16.0/lib/std/Build/Step/InstallArtifact.zig:71:26: 0x158ab7f in create (std.zig)
        .step = Step.init(.{
                         ^
/home/thinkpad/.zvm/0.16.0/lib/std/Build.zig:1671:39: 0x158a434 in addInstallArtifact (std.zig)
    return Step.InstallArtifact.create(b, artifact, options);
                                      ^
/home/thinkpad/.zvm/0.16.0/lib/std/Build.zig:1661:54: 0x15c3cd6 in installArtifact (std.zig)
    b.getInstallStep().dependOn(&b.addInstallArtifact(artifact, .{}).step);
                                                     ^
/home/thinkpad/code/ochi/build.zig:73:22: 0x156e04b in build (build.zig)
    b.installArtifact(exe);
                     ^
/home/thinkpad/.zvm/0.16.0/lib/std/Build.zig:2264:33: 0x156ce0a in runBuild__anon_34168 (std.zig)
        .void => build_zig.build(b),
                                ^
/home/thinkpad/.zvm/0.16.0/lib/compiler/build_runner.zig:463:29: 0x128c524 in main (build_runner.zig)
        try builder.runBuild(root);
                            ^
/home/thinkpad/.zvm/0.16.0/lib/std/start.zig:699:88: 0x1292040 in callMain (std.zig)
    if (fn_info.params[0].type.? == std.process.Init.Minimal) return wrapMain(root.main(.{
                                                                                       ^
/home/thinkpad/.zvm/0.16.0/lib/std/start.zig:190:5: 0x1276201 in _start (std.zig)
    asm volatile (switch (native_arch) {
    ^
(additional stack frames may have been skipped...)
    Proceeding to panic.
thread 10891 panic: misconfigured build script
/home/thinkpad/.zvm/0.16.0/lib/std/Build.zig:2521:25: 0x13a1105 in getPath4 (std.zig)
                        @panic("misconfigured build script");
                        ^
/home/thinkpad/.zvm/0.16.0/lib/std/Build.zig:2489:24: 0x13a096d in getPath3 (std.zig)
        return getPath4(lazy_path, src_builder, asking_step) catch |err| switch (err) {
                       ^
/home/thinkpad/.zvm/0.16.0/lib/std/Build/Step.zig:528:44: 0x159cfd7 in installFile (std.zig)
    const src_path = src_lazy_path.getPath3(b, s);
                                           ^
/home/thinkpad/.zvm/0.16.0/lib/std/Build/Step/InstallArtifact.zig:140:39: 0x159dac5 in make (std.zig)
        const p = try step.installFile(install_artifact.emitted_bin.?, full_dest_path);
                                      ^
/home/thinkpad/.zvm/0.16.0/lib/std/Build/Step.zig:278:33: 0x1491a7f in make (std.zig)
    const make_result = s.makeFn(s, options);
                                ^
/home/thinkpad/.zvm/0.16.0/lib/compiler/build_runner.zig:1345:26: 0x148fabe in makeStep (build_runner.zig)
        } else if (s.make(.{
                         ^
/home/thinkpad/.zvm/0.16.0/lib/std/Io.zig:1245:17: 0x148f6e5 in start (std.zig)
                _ = @as(Cancelable!void, @call(.auto, function, args_casted.*)) catch {};
                ^
/home/thinkpad/.zvm/0.16.0/lib/std/Io/Threaded.zig:552:22: 0x1248285 in start (std.zig)
            task.func(task.contextPointer());
                     ^
/home/thinkpad/.zvm/0.16.0/lib/std/Io/Threaded.zig:1797:29: 0x1246484 in worker (std.zig)
            runnable.startFn(runnable, &thread, t);
                            ^
/home/thinkpad/.zvm/0.16.0/lib/std/Thread.zig:422:13: 0x1246165 in callFn__anon_27720 (std.zig)
            @call(.auto, f, args);
            ^
/home/thinkpad/.zvm/0.16.0/lib/std/Thread.zig:1431:30: 0x1245f20 in entryFn (std.zig)
                return callFn(f, self.fn_args);
                             ^
/home/thinkpad/.zvm/0.16.0/lib/std/os/linux/x86_64.zig:105:5: 0x1246085 in clone (std.zig)
    asm volatile (
    ^
error: the following build command terminated with signal ABRT:
.zig-cache/o/6a5298649c74be686157860d1fd643df/build /home/thinkpad/.zvm/0.16.0/zig /home/thinkpad/.zvm/0.16.0/lib /home/thinkpad/code/ochi .zig-cache /home/thinkpad/.cache/zig --seed 0x1d25079 -Z5093818d8b990377 -fincremental --watch

I saw this post, not sure if it’s still the case:

Thanks!

1 Like

Here’s the tracking issue:

https://codeberg.org/ziglang/zig/issues/30780

You also need --watch to keep the compiler running because we didn’t implement incremental state serialization yet.

5 Likes