From cea5e3f9a9782853d1cf1158e46715e627c256c7 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Aug 2026 21:49:33 +0200 Subject: [PATCH 1/3] feat(native): load libcurl lazily in crash daemon Default the Native Unix crash daemon to runtime libcurl loading when SENTRY_LINK_CURL=AUTO. Keep explicit SENTRY_LINK_CURL=ON/OFF respected for the daemon. This lets sentry-crash avoid a direct libcurl dependency by default while the SDK continues to link libcurl directly unless configured otherwise. See: https://github.com/getsentry/sentry-native/issues/1852 --- CHANGELOG.md | 1 + CMakeLists.txt | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bd8ed85182..49a87a0668 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,7 @@ - Add `sentry_scope_remove_fingerprint` to remove a fingerprint set on a scope, matching the global `sentry_remove_fingerprint`. ([#1932](https://github.com/getsentry/sentry-native/pull/1932)) - Add `sentry_options_set_before_send_feedback` to filter or enrich user feedback. Feedback does not go through `before_send`. ([#1923](https://github.com/getsentry/sentry-native/pull/1923)) - Unix: Add `SENTRY_LINK_CURL` to control whether the curl transport links `libcurl` directly, loads it dynamically at runtime, or uses the default behavior. ([#1954](https://github.com/getsentry/sentry-native/pull/1954)) +- Native/Unix: The native crash daemon now loads `libcurl` dynamically at runtime by default when `SENTRY_LINK_CURL=AUTO`, avoiding `libcurl` linker work during process startup and significantly speeding up startup time. Explicitly set `SENTRY_LINK_CURL=ON` to link it directly. ([#1955](https://github.com/getsentry/sentry-native/pull/1955)) **Fixes**: diff --git a/CMakeLists.txt b/CMakeLists.txt index e236621727..e955145be8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -875,7 +875,7 @@ elseif(SENTRY_BACKEND_NATIVE) get_target_property(SENTRY_COMPILE_DEFS sentry COMPILE_DEFINITIONS) if(SENTRY_COMPILE_DEFS) # The daemon is always a static executable, never a shared library - list(REMOVE_ITEM SENTRY_COMPILE_DEFS "SENTRY_BUILD_SHARED") + list(REMOVE_ITEM SENTRY_COMPILE_DEFS "SENTRY_BUILD_SHARED" "SENTRY_LINK_CURL") list(FILTER SENTRY_COMPILE_DEFS EXCLUDE REGEX "^SENTRY_INTEGRATION_") target_compile_definitions(sentry-crash PRIVATE ${SENTRY_COMPILE_DEFS}) endif() @@ -910,7 +910,11 @@ elseif(SENTRY_BACKEND_NATIVE) # Transport-specific libraries if(SENTRY_TRANSPORT_CURL) - sentry_target_link_curl(sentry-crash ${_SENTRY_LINK_CURL}) + set(_SENTRY_CRASH_LINK_CURL ${_SENTRY_LINK_CURL}) + if(SENTRY_LINK_CURL STREQUAL "AUTO" AND UNIX) + set(_SENTRY_CRASH_LINK_CURL OFF) + endif() + sentry_target_link_curl(sentry-crash ${_SENTRY_CRASH_LINK_CURL}) endif() if(SENTRY_TRANSPORT_WINHTTP) From 91de051ae334ddefe4d49e1d625f62ba30575869 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Tue, 4 Aug 2026 21:27:55 +0200 Subject: [PATCH 2/3] perf(native): signal daemon ready before transport startup Signal readiness to the parent process before starting the daemon transport. This keeps libcurl loading and curl transport initialization out of the startup handshake, while still starting the transport before the daemon enters its crash wait loop. See: https://github.com/getsentry/sentry-native/issues/1852 --- src/backends/native/sentry_crash_daemon.c | 24 +++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/backends/native/sentry_crash_daemon.c b/src/backends/native/sentry_crash_daemon.c index 6fa65ecd79..06e93bc25c 100644 --- a/src/backends/native/sentry_crash_daemon.c +++ b/src/backends/native/sentry_crash_daemon.c @@ -4620,18 +4620,6 @@ sentry__crash_daemon_main(pid_t app_pid, uint64_t app_tid, HANDLE event_handle, } } - // Transport is already initialized by sentry_options_new(), just start it - if (options->transport) { - SENTRY_DEBUG("Starting transport"); - sentry__transport_startup(options->transport, options); - // Set http_retry after transport startup to keep daemon-side retry - // polling disabled, while letting capture cache consent-revoked - // envelopes in retry format for the app to send on restart. - options->http_retry = ipc->shmem->http_retry; - } else { - SENTRY_WARN("No transport available"); - } - SENTRY_DEBUG("Daemon options fully initialized"); #if defined(SENTRY_PLATFORM_LINUX) || defined(SENTRY_PLATFORM_ANDROID) @@ -4661,6 +4649,18 @@ sentry__crash_daemon_main(pid_t app_pid, uint64_t app_tid, HANDLE event_handle, SENTRY_DEBUG("Signaling ready to parent"); sentry__crash_ipc_signal_ready(ipc); + // Transport is already initialized by sentry_options_new(), just start it + if (options->transport) { + SENTRY_DEBUG("Starting transport"); + sentry__transport_startup(options->transport, options); + // Set http_retry after transport startup to keep daemon-side retry + // polling disabled, while letting capture cache consent-revoked + // envelopes in retry format for the app to send on restart. + options->http_retry = ipc->shmem->http_retry; + } else { + SENTRY_WARN("No transport available"); + } + SENTRY_DEBUG("Entering main loop"); // Daemon main loop From 642f8735b1a5b12304c73aa9dd2776bf3eb2c4b4 Mon Sep 17 00:00:00 2001 From: J-P Nurmi Date: Wed, 5 Aug 2026 16:48:41 +0200 Subject: [PATCH 3/3] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0a05a11273..d9c63cc171 100644 --- a/README.md +++ b/README.md @@ -212,7 +212,8 @@ using `cmake -D BUILD_SHARED_LIBS=OFF ..`. - `SENTRY_LINK_CURL` (Default: `AUTO`): Controls whether the `curl` transport links `libcurl` directly or loads it dynamically at runtime on UNIX targets. Possible values are `AUTO`, `ON`, and - `OFF`. `AUTO` currently behaves like `ON`. + `OFF`. `AUTO` currently behaves like `ON`, except for the native crash daemon + on UNIX targets, where it behaves like `OFF`. - `SENTRY_BUILD_FORCE32` (Default: `OFF`): Forces cross-compilation from 64-bit host to 32-bit target. Only affects Linux.