diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05ea01c..068c240 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -2,16 +2,16 @@ name: CI on: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ "**" ] + branches: ["**"] concurrency: group: ${{ github.workflow }}-${{ github.ref }}-ci cancel-in-progress: true env: - ZIG_VERSION: 0.14.1 + ZIG_VERSION: 0.16.0 jobs: build-test: @@ -20,7 +20,7 @@ jobs: strategy: fail-fast: false matrix: - os: [ ubuntu-latest, macos-latest, windows-latest ] + os: [ubuntu-latest, macos-latest, windows-latest] steps: - uses: actions/checkout@v4 diff --git a/.gitignore b/.gitignore index d8c8979..03cb27d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ -.zig-cache -zig-out +.zig-cache/ +zig-out/ +zig-pkg/ diff --git a/build.zig b/build.zig index cd117d0..57a40b8 100644 --- a/build.zig +++ b/build.zig @@ -8,15 +8,15 @@ pub fn build(b: *std.Build) !void { const upstream = b.dependency("blst", .{}); - var c_flags = std.ArrayList([]const u8).init(b.allocator); - defer c_flags.deinit(); + var c_flags = std.ArrayList([]const u8).empty; + defer c_flags.deinit(b.allocator); - try c_flags.append("-fno-builtin"); - try c_flags.append("-Wno-unused-function"); - try c_flags.append("-Wno-unused-command-line-argument"); + try c_flags.append(b.allocator, "-fno-builtin"); + try c_flags.append(b.allocator, "-Wno-unused-function"); + try c_flags.append(b.allocator, "-Wno-unused-command-line-argument"); if (target.result.cpu.arch == .x86_64) { - try c_flags.append("-mno-avx"); // avoid costly transitions + try c_flags.append(b.allocator, "-mno-avx"); // avoid costly transitions } const lib = b.addLibrary(.{ @@ -33,7 +33,15 @@ pub fn build(b: *std.Build) !void { if (portable) { lib.root_module.addCMacro("__BLST_PORTABLE__", ""); } else { - if (std.Target.x86.featureSetHas(target.result.cpu.features, .adx)) { + // Guard __ADX__ check to x86_64 only. + // std.Target.x86.featureSetHas on non-x86 cpu features is meaningless — + // the feature indices differ per-arch and may accidentally return true + // for unrelated ARM features, incorrectly defining __ADX__ and breaking + // symbol resolution (server.c then references ctx_* symbols that don't + // exist in the mach-o/elf ARM64 assembly). + if (target.result.cpu.arch == .x86_64 and + std.Target.x86.featureSetHas(target.result.cpu.features, .adx)) + { lib.root_module.addCMacro("__ADX__", ""); } } @@ -45,10 +53,11 @@ pub fn build(b: *std.Build) !void { { lib.root_module.addCMacro("__BLST_NO_ASM__", ""); } + lib.installHeader(upstream.path("bindings/blst.h"), "blst.h"); lib.installHeader(upstream.path("bindings/blst_aux.h"), "blst_aux.h"); - lib.addCSourceFiles(.{ + lib.root_module.addCSourceFiles(.{ .root = upstream.path(""), .files = &.{ "src/server.c", diff --git a/build.zig.zon b/build.zig.zon index 4289b59..fb02aa9 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -5,7 +5,7 @@ .fingerprint = 0x97ffb139ce317072, // Changing this has security and trust implications. - .minimum_zig_version = "0.14.1", + .minimum_zig_version = "0.16.0", .dependencies = .{ .blst = .{