Skip to content

build(native): exclude daemon-only sources from libsentry.so - #2031

Open
jpnurmi wants to merge 1 commit into
masterfrom
jpnurmi/build/native-daemon
Open

build(native): exclude daemon-only sources from libsentry.so#2031
jpnurmi wants to merge 1 commit into
masterfrom
jpnurmi/build/native-daemon

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Aug 28, 2026

Copy link
Copy Markdown
Collaborator

Move the client-side launcher from the daemon to the backend, and stop building daemon-only crash processing, minidump writers, and remote unwinding into libsentry.so.

sentry-crash previously copied all sources from the sentry target, so daemon-only crash processing, minidump, and remote unwinding sources were also built into libsentry.so. Add those sources directly to sentry-crash instead. Keep daemon_start in the native backend because launching the handler remains a client-side responsibility.

This slices off ~9% from libsentry.so [1], and removes the following large stack frames:

  • sentry__write_minidump: 1,216,336 bytes
  • sentry__process_crash: 18,368 bytes
  • enrich_frame_with_symbol: 14,592 bytes
  • write_attachment_to_envelope: 8,448 bytes

Note: the source split does not preclude a potential future in-process mode.

Before vs. after

Before (Linux x86_64)

  • libsentry.so: 2.7MiB
  • sentry-crash: 3.4MiB
Stack frame Size (bytes)
sentry__write_minidump 1,216,336
sentry__process_crash 18,368
enrich_frame_with_symbol 14,592
sentry__crash_daemon_start 8,528
write_attachment_to_envelope.isra 8,448
crash_signal_handler 6,336
native_backend_shutdown 5,184
elf_locate_symtab 4,400
sentry__crash_daemon_main 4,256
find_mem_range_from_fd 4,192
sentry__path_absolute 4,128
sentry__path_current_exe 4,128
sentry__crash_handler_init 2,224
ensure_installed 2,208
sentry_value_new_stacktrace 2,160
sentry__unwind_stack_libunwind 2,128
write_thread_context 1,792
ptrace_capture_thread.isra 1,296
build_stacktrace_for_thread 1,216
handler 1,088

After (Linux x86_64)

  • libsentry.so: 2.5MiB
  • sentry-crash: 3.4MiB
Stack frame Size (bytes)
daemon_start 8,528
crash_signal_handler 6,336
native_backend_shutdown 5,184
find_mem_range_from_fd 4,192
sentry__path_absolute 4,128
sentry__path_current_exe 4,128
sentry__crash_handler_init 2,224
ensure_installed 2,208
sentry_value_new_stacktrace 2,160
sentry__unwind_stack_libunwind 2,128
handler 1,088

Commands for reference:

# lib size
cmake -S . -B build -DSENTRY_BACKEND=native -DCMAKE_BUILD_TYPE=Release && cmake --build build --target sentry --target sentry-crash --parallel && stat -c '%s %n' build/libsentry.so build/sentry-crash | numfmt --field=1 --to=iec-i --suffix=B

# stack usage
cmake -S . -B build-stack -DSENTRY_BACKEND=native -DCMAKE_C_FLAGS=-fstack-usage -DCMAKE_CXX_FLAGS=-fstack-usage && cmake --build build-stack --target sentry && find build-stack -path '*/CMakeFiles/sentry.dir/*.su'   -exec awk -F '\t' '{
    fn = $1
    sub(/^.*:[0-9]+:[0-9]+:/, "", fn)
    print $2, fn
  }' {} + |   sort -k1,1nr -k2,2 | head -n 20

[1] 55kb/622kb in Release mode / 252kb/2.7mb in ReleaseWithDbg on Linux x86_64

`sentry-crash` previously copied all sources from the `sentry` target,
so daemon-only crash processing, minidump, and remote unwinding sources
were also built into `libsentry.so`.

Add those sources directly to `sentry-crash` instead. Keep `daemon_start`
in the native backend because launching the handler remains a client-side
responsibility.

This removes the following Linux x86_64 stack frames from `libsentry.so`:

- `sentry__write_minidump`: 1,216,336 bytes
- `sentry__process_crash`: 18,368 bytes
- `enrich_frame_with_symbol`: 14,592 bytes
- `write_attachment_to_envelope`: 8,448 bytes

The source split does not preclude a potential future in-process mode.
@codecov

codecov Bot commented Aug 28, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 57.72358% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.34%. Comparing base (719803e) to head (736b4ea).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2031      +/-   ##
==========================================
+ Coverage   74.21%   74.34%   +0.12%     
==========================================
  Files         104      104              
  Lines       26627    26623       -4     
  Branches     4844     4844              
==========================================
+ Hits        19762    19793      +31     
+ Misses       5519     5491      -28     
+ Partials     1346     1339       -7     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant