These result in basically an empty static (or even dynamic with addSharedLibrary) file when its supposed to generate one with the exported inc_many function. Would like to know if i'm missing something in the build.zig or if it's an actual bug to make an issue for.
build.zig:
const std = @import("std");
pub fn build(b: *std.Build) void {
const optimize = b.standardOptimizeOption(.{});
const target = b.standardTargetOptions(.{});
const lib = b.addStaticLibrary(.{
.name = "adder",
.target = target,
.optimize = optimize,
});
const dep = b.addStaticLibrary(.{
.name = "add",
.target = target,
.optimize = optimize,
});
dep.addCSourceFile(.{ .file = .{ .path = "./add.cpp" }, .flags = &.{} });
dep.linkLibCpp();
lib.linkLibrary(dep);
b.installArtifact(lib);
}
add.cpp:
#include <cstdint>
#include <cstddef>
extern "C" {
// Something vectorizable to have a large binary output on -O3
void inc_many(uint32_t* array, size_t len) {
if (len == 0 || len % 8 != 0) return;
for (size_t i = 0; i < len; i++)
array[i] += 1;
}
}