diff --git a/build.zig b/build.zig index 8d6faa5158..596adde0cc 100644 --- a/build.zig +++ b/build.zig @@ -140,7 +140,7 @@ pub fn build(b: *std.Build) void { .name = "builtin_compiler", .root_source_file = b.path("src/build/builtin_compiler/main.zig"), .target = b.graph.host, // this runs at build time on the *host* machine! - .optimize = .Debug, // No need to optimize - only compiles builtin modules + .optimize = .ReleaseFast, // Must match playground optimization to ensure struct compatibility // Note: libc linking is handled by add_tracy below (required when tracy is enabled) }); @@ -234,7 +234,7 @@ pub fn build(b: *std.Build) void { .name = "builtin_compiler", .root_source_file = b.path("src/build/builtin_compiler/main.zig"), .target = b.graph.host, - .optimize = .Debug, + .optimize = .ReleaseFast, // Must match playground optimization to ensure struct compatibility }); builtin_compiler_exe_force.root_module.addImport("base", roc_modules.base); diff --git a/src/canonicalize/ModuleEnv.zig b/src/canonicalize/ModuleEnv.zig index ae6094d99f..82223397e1 100644 --- a/src/canonicalize/ModuleEnv.zig +++ b/src/canonicalize/ModuleEnv.zig @@ -1385,12 +1385,12 @@ pub fn getSourceLine(self: *const Self, region: Region) ![]const u8 { return self.common.getSourceLine(region); } -/// Serialized representation of ModuleEnv +/// Serialized representation of ModuleEnv. +/// NOTE: Field order matters for cross-platform compatibility! Keep `module_kind` at the end. pub const Serialized = struct { gpa: [2]u64, // Reserve space for allocator (vtable ptr + context ptr), provided during deserialization common: CommonEnv.Serialized, types: TypeStore.Serialized, - module_kind: ModuleKind, // Must match field order in Self all_defs: CIR.Def.Span, all_statements: CIR.Statement.Span, exports: CIR.Def.Span, @@ -1400,6 +1400,7 @@ pub const Serialized = struct { module_name: [2]u64, // Reserve space for slice (ptr + len), provided during deserialization diagnostics: CIR.Diagnostic.Span, store: NodeStore.Serialized, + module_kind: ModuleKind, /// Serialize a ModuleEnv into this Serialized struct, appending data to the writer pub fn serialize(