Skip to content

Commit

Permalink
compiler: Only omit frame pointers by default for ReleaseSmall.
Browse files Browse the repository at this point in the history
Frame pointers make both debugging and profiling work better, and the overhead
is reportedly 1% or less for typical programs [0]. I think the pros outweigh the
cons here. People who *really* care about that 1% can simply use the
-fomit-frame-pointer option to reclaim it. For ReleaseSmall, though, it makes
sense to omit frame pointers by default for the sake of code size, as we already
strip the binary in this case anyway.

Closes ziglang#22161.

[0] https://www.brendangregg.com/blog/2024-03-17/the-return-of-the-frame-pointers.html
  • Loading branch information
alexrp authored and andrewrk committed Dec 8, 2024
1 parent ba37a43 commit e62aac3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Package/Module.zig
Original file line number Diff line number Diff line change
Expand Up @@ -205,8 +205,8 @@ 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 == .Debug) break :b false;
break :b true;
if (optimize_mode == .ReleaseSmall) break :b true;
break :b false;
};

const sanitize_thread = b: {
Expand Down

0 comments on commit e62aac3

Please sign in to comment.