Missing assert.h but only in my CI (alpine container)

I use an alpine container to run my CI.

I get an error that says I am missing assert.h when building a c dependency. I don’t know where im leaking into system installed headers… as far as I know I am not linking system libraries for this build.

here is the build log:

https://ci.codeberg.org/repos/15620/pipeline/136/3

ci
+- cli
   +- install gatorcat
      +- compile exe gatorcat Debug native
         +- translate-c dependency failure
/woodpecker/src/codeberg.org/jeffective/gatorcat/zig-pkg/N-V-__8AAFguAwNEkdXvM1TbN0BxqM3rRii0xaewZl3NVTd1/include/zenoh.h:4:10: fatal error: 'assert.h' not found
#include <assert.h>
         ^
error: process exited with error code 1
failed command: ./.zig-cache/o/70d7c2d107c0118678733cbe11af3103/translate-c /woodpecker/src/codeberg.org/jeffective/gatorcat/zig-pkg/N-V-__8AAFguAwNEkdXvM1TbN0BxqM3rRii0xaewZl3NVTd1/include/zenoh.h -o ./.zig-cache/tmp/20b9e3b0408dc454/dependency.zig -MD -MV -MF ./.zig-cache/tmp/20b9e3b0408dc454/deps.d -isystem /usr/local/include -isystem /usr/include/x86_64-linux-musl -isystem /usr/include -w -resource-dir /woodpecker/src/codeberg.org/jeffective/gatorcat/zig-pkg/aro-0.0.0-JSD1Qi7QNgDnfcrdEJf82v3o6MhZySjYVrtdfEf3E4Se -fmodule-libs

Where in my dependency is it trying to pull in system headers?
https://codeberg.org/jeffective/zenoh-zig/

dependency build.zig
const std = @import("std");
const Translator = @import("translate_c").Translator;

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

    // expose a public module called "zenoh"
    const zenoh = b.addModule("zenoh", .{
        .root_source_file = b.path("src/root.zig"),
        .target = target,
        .optimize = optimize,
        .link_libc = true,
        .link_libcpp = true,
    });

    // download the correct pre-compiled zenoh static library
    const zenoh_c_dep = switch (target.result.cpu.arch) {
        .x86_64 => switch (target.result.os.tag) {
            .windows => switch (target.result.abi) {
                .gnu => b.lazyDependency("zenoh_c_x86_64_windows_gnu", .{}),
                .msvc => b.lazyDependency("zenoh_c_x86_64_windows_msvc", .{}),
                else => @panic("unsupported target"),
            },
            .linux => switch (target.result.abi) {
                .musl => b.lazyDependency("zenoh_c_x86_64_linux_musl", .{}),
                .gnu => b.lazyDependency("zenoh_c_x86_64_linux_gnu", .{}),
                else => @panic("unsupported target"),
            },
            .macos => switch (target.result.abi) {
                .none => b.lazyDependency("zenoh_c_x86_64_macos_none", .{}),
                else => @panic("unsupported target"),
            },
            else => @panic("unsupported target"),
        },
        .aarch64 => switch (target.result.os.tag) {
            .linux => switch (target.result.abi) {
                .musl => b.lazyDependency("zenoh_c_aarch64_linux_musl", .{}),
                .gnu => b.lazyDependency("zenoh_c_aarch64_linux_gnu", .{}),
                else => @panic("unsupported target"),
            },
            .macos => switch (target.result.abi) {
                .none => b.lazyDependency("zenoh_c_aarch64_macos_none", .{}),
                else => @panic("unsupported target"),
            },
            else => @panic("unsupported target"),
        },
        else => @panic("unsupported target"),
    } orelse return;

    const zenoh_c_static_lib_path = switch (target.result.os.tag) {
        .linux, .macos => zenoh_c_dep.path("lib/libzenohc.a"),
        .windows => switch (target.result.abi) {
            .msvc => zenoh_c_dep.path("lib/zenohc.lib"),
            .gnu => zenoh_c_dep.path("lib/libzenohc.a"),
            else => @panic("unsupported target"),
        },
        else => @panic("unsupported target"),
    };

    // expose the functions in the header to zig using translate-c
    const translate_c = b.dependency("translate_c", .{});
    const t: Translator = .init(translate_c, .{
        .c_source_file = zenoh_c_dep.path("include/zenoh.h"),
        .target = target,
        .optimize = optimize,
    });
    zenoh.addImport("zenoh_c", t.mod);

    // link the zenoh static library to zig
    zenoh.addObjectFile(zenoh_c_static_lib_path);
    switch (target.result.os.tag) {
        .windows => {
            zenoh.linkSystemLibrary("ws2_32", .{ .preferred_link_mode = .static });
            zenoh.linkSystemLibrary("iphlpapi", .{ .preferred_link_mode = .static });
            zenoh.linkSystemLibrary("bcrypt", .{ .preferred_link_mode = .static });
        },
        else => {},
    }

    // run some unit tests to sanity check
    const lib_unit_tests = b.addTest(.{
        .root_module = zenoh,
    });
    const run_lib_unit_tests = b.addRunArtifact(lib_unit_tests);
    const test_step = b.step("test", "Run unit tests");
    test_step.dependOn(&run_lib_unit_tests.step);

    // examples
    const examples_tests = b.addTest(.{
        .root_module = b.createModule(.{
            .root_source_file = b.path("examples/root.zig"),
            .target = target,
            .optimize = optimize,
        }),
    });
    examples_tests.root_module.addImport("zenoh", zenoh);
    const run_examples_tests = b.addRunArtifact(examples_tests);
    const examples_step = b.step("examples", "Run the examples.");
    examples_step.dependOn(&run_examples_tests.step);

    // make the default step run the tests
    b.default_step.dependOn(test_step);
    b.default_step.dependOn(examples_step);
}

Could this have something to do with it?

shouldn’t translate-c be using the zig-bundled lib c headers for me?

Since your target is b.standardTargetOptions(.{}) without any cli args, your target is native.

Here are two if statements, which seems to set the libc header include paths. Since your target is native, the second if is used to add include paths for system headers. I would expect the build to succeed when you specify -target x86_64-linux-musl, because this would use the first if to use the zig-bundled lib c headers. (These are only speculations from reading code. I have tested nothing.)

What is the recommended target options then? Should I not use standard target options and just force musl all the time? Seeking advice on conventions here.

Would a (non-existent) user want the default executable to be musl?
I don’t even know what system headers are.

just had to add -Dtarget=x86_64-linux-musl to my zig build ci -Dtarget=x86_64-linux-musl in my ci script.

I’m not sure if I like that the default native build includes system headers but whatever.