diff options
Diffstat (limited to 'src/abi.zig')
| -rw-r--r-- | src/abi.zig | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/src/abi.zig b/src/abi.zig index 33f7cd6..9154539 100644 --- a/src/abi.zig +++ b/src/abi.zig @@ -815,17 +815,22 @@ pub const Sketch = struct { }; }; -/// Layout hash of everything above, and of `build`. Changes whenever a shared -/// type does, or the compiler, backend or optimize mode: Zig's own calling -/// convention, which `Host.VTable` and every `std.mem.Allocator` use, differs -/// between backends and modes. -pub const hash: u64 = blk: { +/// `layout_hash` and `build`: changes whenever a shared type does, or the +/// compiler, backend or optimize mode, since Zig's own calling convention +/// (`Host.VTable`, every `std.mem.Allocator`) differs between them. +/// `layout_hash` costs half a second of comptime, so build.zig has +/// `abi_hash.zig` compute it once per change of these files and hands it +/// over as the module `abi_hash`, instead of every sketch's compile doing it. +pub const hash: u64 = std.hash.Wyhash.hash(@import("abi_hash").layout, build); + +/// Hash of every shared type's name and layout. +pub const layout_hash: u64 = blk: { @setEvalBranchQuota(1_000_000); var h: u64 = 0; for (.{ Rect, Color, BlendMode, Corners, Event, Mode, Stream, Input, Image, Audio, Cursor, Voice, Command, gpu.Pass, gpu.Pipeline, gpu.Draw, gpu.Dispatch, gpu.PostProcess, Host, Host.VTable, Context, Field, Layout, Info, Memory, Sketch }) |T| { h = std.hash.Wyhash.hash(h, @typeName(T) ++ layout.signature(T)); } - break :blk std.hash.Wyhash.hash(h, build); + break :blk h; }; /// The compiler, backend and mode of this build, exported by libraries as |
