diff --git a/src/Package/Module.zig b/src/Package/Module.zig index bfcef038edb7..af91b01c9a8e 100644 --- a/src/Package/Module.zig +++ b/src/Package/Module.zig @@ -205,7 +205,12 @@ pub fn create(arena: Allocator, options: CreateOptions) !*Package.Module { const omit_frame_pointer = b: { if (options.inherited.omit_frame_pointer) |x| break :b x; if (options.parent) |p| break :b p.omit_frame_pointer; - if (optimize_mode == .ReleaseSmall) break :b true; + if (optimize_mode == .ReleaseSmall) { + // On x86, in most cases, keeping the frame pointer usually results in smaller binary size. + // This has to do with how instructions for memory access via the stack base pointer register (when keeping the frame pointer) + // are smaller than instructions for memory access via the stack pointer register (when omitting the frame pointer). + break :b !target.cpu.arch.isX86(); + } break :b false; };