summaryrefslogtreecommitdiff
path: root/build
diff options
context:
space:
mode:
Diffstat (limited to 'build')
-rw-r--r--build/patches.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/build/patches.zig b/build/patches.zig
index f58fb926..3d956d26 100644
--- a/build/patches.zig
+++ b/build/patches.zig
@@ -175,8 +175,14 @@ pub fn vaxis(b: *std.Build, patch: *std.Build.Step.Compile, vaxis_dep: *std.Buil
/// zstbi with stb_image and its writer cut out: of it only its resize is
/// left, for a terminal PNG's downscale (build/core.zig, "One PNG
/// decoder"). zstbi.deinit still resets the reader's and the writer's flip
-/// flags, and Image.deinit frees the resize's output.
+/// flags, and Image.deinit frees the resize's output. And no fused
+/// multiply-add in the resize: clang contracts `a * b + c` where the CPU
+/// has one (aarch64 always does), which rounds once, so a PNG downscaled
+/// on an Apple silicon Mac came out pixels apart from Linux's, and the same
+/// bytes must give the same terminal on every machine a client runs on
+/// (docs/zstbi-fp-contract.md).
const zstbi_cut = [_]Edit{
+ .{ .old = "#include <stdlib.h>\n", .new = "#include <stdlib.h>\n#pragma STDC FP_CONTRACT OFF\n" },
.{ .old = "#define STB_IMAGE_IMPLEMENTATION\n#include \"stb_image.h\"\n", .new = "void stbi_set_flip_vertically_on_load(int flag) { (void)flag; }\nvoid stbi_image_free(void *p) { zstbiFreePtr(p); }\n" },
.{ .old = "#define STB_IMAGE_WRITE_IMPLEMENTATION\n#include \"stb_image_write.h\"\n", .new = "void stbi_flip_vertically_on_write(int flag) { (void)flag; }\n" },
};