Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

chore(cymbal): improve native profiling stacks (#69403)

Hugues Pouillotfa63cfcef1ad
diff --git a/.github/rust-images.yml b/.github/rust-images.yml
index e667d1b30191..b0c139913293 100644
--- a/.github/rust-images.yml
+++ b/.github/rust-images.yml
@@ -37,9 +37,10 @@
- image: cymbal
dockerfile: ./rust/Dockerfile
project: 8dq0xkk0ck
- # Frame pointers so the eBPF profiler can walk cymbal's native stacks on
- # aarch64 (see EXTRA_RUSTFLAGS in rust/Dockerfile).
- extra_rustflags: -C force-frame-pointers=yes
+ # Frame pointers and unwind tables so the profiler can walk Cymbal stacks on
+ # aarch64, including native dependency frames (see rust/Dockerfile).
+ extra_rustflags: -C force-frame-pointers=yes -C force-unwind-tables=yes
+ extra_cflags: -fno-omit-frame-pointer -fasynchronous-unwind-tables
- image: embedding-worker
dockerfile: ./rust/Dockerfile
diff --git a/.github/workflows/_rust-build-images.yml b/.github/workflows/_rust-build-images.yml
index e9ea4cec7e9b..de848b15296a 100644
--- a/.github/workflows/_rust-build-images.yml
+++ b/.github/workflows/_rust-build-images.yml
@@ -172,6 +172,7 @@ jobs:
BIN=${{ matrix.bin || matrix.image }}
BUILD_FEATURES=${{ matrix.features || '' }}
EXTRA_RUSTFLAGS=${{ matrix.extra_rustflags || '' }}
+ EXTRA_CFLAGS=${{ matrix.extra_cflags || '' }}
SCCACHE_WEBDAV_KEY_PREFIX=${{ steps.sccache.outputs.cache-key-prefix }}
secrets: |
SCCACHE_WEBDAV_ENDPOINT=${{ steps.sccache.outputs.endpoint }}
diff --git a/rust/Dockerfile b/rust/Dockerfile
index 701eb359ba4e..2175fd273c82 100644
--- a/rust/Dockerfile
+++ b/rust/Dockerfile
@@ -18,14 +18,15 @@ WORKDIR /app
ARG BIN
ARG BUILD_FEATURES=""
ARG SCCACHE_WEBDAV_KEY_PREFIX
-# Extra rustc flags for specific images, set per-image in
-# .github/rust-images.yml (e.g. cymbal passes -C force-frame-pointers=yes so
-# the eBPF profiler can walk its native stacks on aarch64). Guarded exports
-# below because the RUSTFLAGS env var replaces [build].rustflags from
-# .cargo/config.toml entirely (no merging): when extra flags are set the
-# export re-adds --cfg tokio_unstable, and when unset RUSTFLAGS stays unset so
-# .cargo/config.toml keeps applying.
+# Extra compiler flags for specific images, set per-image in
+# .github/rust-images.yml. Cymbal opts into frame pointers and unwind tables so
+# the profiler can walk Rust and native dependency stacks on aarch64.
+# Guarded RUSTFLAGS exports below because the RUSTFLAGS env var replaces
+# [build].rustflags from .cargo/config.toml entirely (no merging): when extra
+# flags are set the export re-adds --cfg tokio_unstable, and when unset
+# RUSTFLAGS stays unset so .cargo/config.toml keeps applying.
ARG EXTRA_RUSTFLAGS=""
+ARG EXTRA_CFLAGS=""
ENV PROTO_ROOT=../proto SCCACHE_WEBDAV_KEY_PREFIX=${SCCACHE_WEBDAV_KEY_PREFIX}
# Ensure working C compile setup (not installed by default in arm64 images)
@@ -39,6 +40,7 @@ RUN --mount=type=cache,target=/usr/local/cargo/registry,sharing=locked \
--mount=type=cache,target=$SCCACHE_DIR,sharing=locked \
SCCACHE_NO_DAEMON=1 SCCACHE_START_SERVER=1 sccache 2>&1 & \
if [ -n "$EXTRA_RUSTFLAGS" ]; then export RUSTFLAGS="--cfg tokio_unstable $EXTRA_RUSTFLAGS"; fi && \
+ if [ -n "$EXTRA_CFLAGS" ]; then export CFLAGS="$EXTRA_CFLAGS" CXXFLAGS="$EXTRA_CFLAGS" AWS_LC_SYS_CFLAGS="$EXTRA_CFLAGS"; fi && \
cargo chef cook --release --recipe-path recipe.json --bin $BIN ${BUILD_FEATURES:+--features $BUILD_FEATURES} && \
sccache --show-stats
@@ -54,6 +56,7 @@ RUN --mount=type=secret,id=SCCACHE_WEBDAV_ENDPOINT,required=false \
fi && \
SCCACHE_NO_DAEMON=1 SCCACHE_START_SERVER=1 sccache 2>&1 & \
if [ -n "$EXTRA_RUSTFLAGS" ]; then export RUSTFLAGS="--cfg tokio_unstable $EXTRA_RUSTFLAGS"; fi && \
+ if [ -n "$EXTRA_CFLAGS" ]; then export CFLAGS="$EXTRA_CFLAGS" CXXFLAGS="$EXTRA_CFLAGS" AWS_LC_SYS_CFLAGS="$EXTRA_CFLAGS"; fi && \
cargo build --release --bin $BIN ${BUILD_FEATURES:+--features $BUILD_FEATURES} && \
sccache --show-stats