#Strange build issue/error

1 messages · Page 1 of 1 (latest)

fluid river
#

I'm running into a strange build issue and I'd appreciate it if someone offered a second pair of eyes on it.
I have the following library, onnxruntime.zig: https://github.com/recursiveGecko/onnxruntime.zig/blob/master/build.zig
Which is used by another library: Formula-VAD: https://github.com/recursiveGecko/Formula-VAD/blob/main/build.zig
Finally, Formula-VAD is used in the final application, zig-vad: https://gist.github.com/recursiveGecko/691e0e2a47597219785e926fa74a6658

If I cd into formula-vad and run zig build, it works fine, but when I run the build from the final application zig-vad, I get this strange error:

Build Summary: 1/4 steps succeeded; 1 failed (disable with -fno-summary)
install transitive failure
└─ install zig-vad transitive failure
   └─ zig build-exe zig-vad Debug native 1 errors
      └─ zig build-lib kissfft Debug native cached 7ms MaxRSS:34M
lib/formula-vad/src/NSNet2.zig:10:22: error: no package named 'onnxruntime' available within package 'root.formula_vad'
const onnx = @import("onnxruntime");
                     ^~~~~~~~~~~~~
referenced by:
    NSNet2: lib/formula-vad/src/NSNet2.zig:24:17
    remaining reference traces hidden; use '-freference-trace' to see all reference traces

For some reason, the packages aren't being linked up correctly when I build the final application, but I have no idea why :/

long hollow
#

if formula-vad has dependencies, they need to be listed in the module's .dependencies field

#

modules are not flattened, so each module has its own set of dependencies

fluid river
#

I thought as much when I sent that rambling message earlier in #programming-discussion, do you happen do have any examples?

long hollow
#

not with the new build system

fluid river
#

do you mind elaborating on what it is that I'm doing now, then?
Am I, incorrectly, creating an onnxruntime module that's "exposed" to zig-vad, but not formula-vad?

#

which happens in onnxruntime.zig build.zig as zig-vad's exe is passed through

#

thank you random internet person

#

onnxruntime.zig/build.zig, added:

pub fn createModule(b: *std.Build) *std.build.Module {
    return b.createModule(.{
        .source_file = .{ .path = projectPath("src/lib.zig") },
    });
}

Formula-VAD/build.zig, changed:

pub fn linkPackage(
    b: *std.Build,
    exe: *std.Build.CompileStep,
    target: std.zig.CrossTarget,
    optimize: std.builtin.Mode,
) !void {
    const common_options = CommonOptions{
        .target = target,
        .optimize = optimize,
    };

    const pkg = b.createModule(.{
        .source_file = .{ .path = thisFileDir() ++ "/src/package.zig" },
        .dependencies = &.{
            .{
                .name = "onnxruntime",
                .module = onnx.createModule(b),
            }
        },
    });

    exe.addModule("formula_vad", pkg);
    try addKissFFT(b, exe, common_options);
    try addSndfile(b, exe, common_options);
    try addOnnx(b, exe, common_options);
}