git.lucas.co / cce-compositor
Wayland compositor (wlroots)
git clone https://git.lucas.co/cce-compositor.git

commit4d84111ecbbdfd16d11a4905d70d417117aeee96
parent2e8d0de018
authorIsaac Freund <[email protected]>
date2024-03-07 16:28
build: enable frame pointers in release safe

These are by default only enabled for debug builds but give a higher
chance of getting a usable stack trace out of bug reports as Zig's
builtin stack trace dumping code doesn't handle their absence well in
all cases yet. The cost should be negligible as river is not CPU-bound.

 build.zig | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/build.zig b/build.zig
index a9a7c1f..5a04f5c 100644
--- a/build.zig
+++ b/build.zig
@@ -19,6 +19,11 @@ pub fn build(b: *Build) !void {
     const strip = b.option(bool, "strip", "Omit debug information") orelse false;
     const pie = b.option(bool, "pie", "Build a Position Independent Executable") orelse false;
 
+    const omit_frame_pointer = switch (optimize) {
+        .Debug, .ReleaseSafe => false,
+        .ReleaseFast, .ReleaseSmall => true,
+    };
+
     const man_pages = b.option(
         bool,
         "man-pages",
@@ -180,6 +185,7 @@ pub fn build(b: *Build) !void {
 
         river.strip = strip;
         river.pie = pie;
+        river.omit_frame_pointer = omit_frame_pointer;
 
         b.installArtifact(river);
     }
@@ -202,6 +208,7 @@ pub fn build(b: *Build) !void {
 
         riverctl.strip = strip;
         riverctl.pie = pie;
+        riverctl.omit_frame_pointer = omit_frame_pointer;
 
         b.installArtifact(riverctl);
     }
@@ -224,6 +231,7 @@ pub fn build(b: *Build) !void {
 
         rivertile.strip = strip;
         rivertile.pie = pie;
+        rivertile.omit_frame_pointer = omit_frame_pointer;
 
         b.installArtifact(rivertile);
     }