Skip to content

Commit b7cb2b9

Browse files
author
lite3-zig
committed
Harden lifecycle behavior and disable prefetch on non-x86
1 parent b4c1562 commit b7cb2b9

4 files changed

Lines changed: 154 additions & 17 deletions

File tree

build.zig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ const std = @import("std");
33
pub fn build(b: *std.Build) void {
44
const target = b.standardTargetOptions(.{});
55
const optimize = b.standardOptimizeOption(.{});
6+
const arch = target.result.cpu.arch;
67

78
// --- Options ---
89
const enable_json = b.option(bool, "json", "Enable JSON conversion support (requires yyjson)") orelse true;
@@ -100,6 +101,11 @@ pub fn build(b: *std.Build) void {
100101
if (enable_error_messages) {
101102
lite3_mod.addCMacro("LITE3_ERROR_MESSAGES", "");
102103
}
104+
// Upstream warns that prefetching can crash on non-x86 targets.
105+
// Keep it enabled on x86/x86_64 and disable elsewhere.
106+
if (arch != .x86 and arch != .x86_64) {
107+
lite3_mod.addCMacro("LITE3_DISABLE_PREFETCHING", "1");
108+
}
103109

104110
const lite3_lib = b.addLibrary(.{
105111
.linkage = .static,

0 commit comments

Comments
 (0)