From cdd8dc5f47c3704ca851e66ac422053d6746d97c Mon Sep 17 00:00:00 2001 From: Daniel Kraus Date: Tue, 14 Jul 2026 09:56:31 +0200 Subject: [PATCH] Require exactly Zig 0.15.2 to build the native module A minimum_zig_version in build.zig.zon rejects older Zig before the build script compiles, and a comptime guard in build.zig rejects any version other than 0.15.2 with an explicit error, which also surfaces in ghostel-module-compile's compilation buffer and the auto-install build log. State the exact version requirement in the README. --- README.org | 6 +++++- build.zig | 8 ++++++++ build.zig.zon | 1 + lisp/ghostel.el | 8 ++++---- 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/README.org b/README.org index de3ae370..f204e900 100644 --- a/README.org +++ b/README.org @@ -155,7 +155,8 @@ binaries are available for: - =aarch64-windows= If you prefer to build from source or need a different platform, you will also -need [[https://ziglang.org/][Zig]] 0.15.2 - see [[#building-from-source][Building from source]]. +need *exactly* [[https://ziglang.org/][Zig]] 0.15.2 - older or newer Zig versions will not build. See +[[#building-from-source][Building from source]]. * Installation :properties: @@ -264,6 +265,9 @@ Building is only needed if you do not want the pre-built binaries. Ghostel vendors a generated =vendor/emacs-module.h=, so normal builds do not require local Emacs headers. +Building requires *exactly* [[https://ziglang.org/][Zig]] 0.15.2 - older or newer Zig versions will not build. +Check your installed version with =zig version=. + #+begin_src sh git clone https://github.com/dakra/ghostel.git cd ghostel diff --git a/build.zig b/build.zig index 9f1379f3..c7ed88f6 100644 --- a/build.zig +++ b/build.zig @@ -1,6 +1,14 @@ const std = @import("std"); +const builtin = @import("builtin"); const module_version = @import("src/version.zig").version; +// Keep in sync with build.zig.zon (minimum_zig_version) and the CI workflows. +const required_zig = std.SemanticVersion{ .major = 0, .minor = 15, .patch = 2 }; +comptime { + if (builtin.zig_version.order(required_zig) != .eq) + @compileError("ghostel requires exactly Zig 0.15.2, found " ++ builtin.zig_version_string); +} + const vendored_emacs_module_dir = "vendor"; pub fn build(b: *std.Build) void { diff --git a/build.zig.zon b/build.zig.zon index ba8fa251..9c213642 100644 --- a/build.zig.zon +++ b/build.zig.zon @@ -1,6 +1,7 @@ .{ .name = .ghostel, .version = "0.44.0", + .minimum_zig_version = "0.15.2", .paths = .{""}, .fingerprint = 0x5a44bdd1198a0f4b, .dependencies = .{ diff --git a/lisp/ghostel.el b/lisp/ghostel.el index ec2e3644..16d1be0d 100644 --- a/lisp/ghostel.el +++ b/lisp/ghostel.el @@ -73,10 +73,10 @@ ;; ;; Native module: ;; -;; A pre-built binary is downloaded automatically on first use. To -;; build from source instead (requires Zig 0.15.2+), run zig build --prefix . -;; from the project root, or M-x ghostel-module-compile. M-x -;; ghostel-download-module re-fetches the pre-built binary. +;; A pre-built binary is downloaded automatically on first use. +;; To build from source instead (requires exactly Zig 0.15.2), run +;; zig build --prefix . from the project root, or M-x ghostel-module-compile. +;; M-x ghostel-download-module re-fetches the pre-built binary. ;; ;; See also: evil-ghostel.el (evil-mode integration), ghostel-compile.el ;; (TTY-backed M-x compile replacement), ghostel-eshell.el (eshell