|
| 1 | +From f9b171d23f881c9bf35e4c42221579f948c38d7 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Ludovic Henry <git@ludovic.dev> |
| 3 | +Date: Wed, 26 Aug 2026 15:37:18 +0200 |
| 4 | +Subject: [PATCH] setup.py: build the crashtracker only where libdatadog |
| 5 | + supports it |
| 6 | +MIME-Version: 1.0 |
| 7 | +Content-Type: text/plain; charset=UTF-8 |
| 8 | +Content-Transfer-Encoding: 8bit |
| 9 | + |
| 10 | +The `crashtracker` feature of src/native pulls in libdd-crashtracker, |
| 11 | +which cannot compile outside x86_64/aarch64 on Linux: |
| 12 | + |
| 13 | + * it depends unconditionally (for `cfg(target_os = "linux")`) on |
| 14 | + libdd-libunwind-sys, whose build script picks the libunwind |
| 15 | + per-architecture static library from `#[cfg(target_arch)]` arms that |
| 16 | + exist for x86_64 and aarch64 only, leaving `arch` undefined |
| 17 | + elsewhere; |
| 18 | + * collector/emitters.rs reads the crash-time register state out of |
| 19 | + `ucontext_t` through the same two-arm `#[cfg(target_arch)]` pattern, |
| 20 | + with no fallback. |
| 21 | + |
| 22 | +Gate the feature on the architectures libdatadog actually implements. |
| 23 | +ddtrace already treats the native crashtracker bindings as optional — |
| 24 | +`ddtrace/internal/core/crashtracking.py` sets `is_available = False` when |
| 25 | +the import fails, and `_check_for_crashtracking_available()` does the |
| 26 | +same — so nothing else needs changing: the wheel simply reports |
| 27 | +crashtracking as unavailable. |
| 28 | + |
| 29 | +Rebased onto 4.15.0: upstream raised the Python-version ceiling on the |
| 30 | +surrounding `rust_features` gate from `sys.version_info < (3, 15)` to |
| 31 | +`< (3, 16)`; unrelated to this change. |
| 32 | + |
| 33 | +Upstream-Status: To upstream [blocked on riscv64 unwinding/ucontext support in libdatadog's libdd-crashtracker] |
| 34 | + |
| 35 | +Signed-off-by: Ludovic Henry <git@ludovic.dev> |
| 36 | +--- |
| 37 | + setup.py | 7 ++++++- |
| 38 | + 1 file changed, 6 insertions(+), 1 deletion(-) |
| 39 | + |
| 40 | +diff --git a/setup.py b/setup.py |
| 41 | +index 393145b..56d1156 100644 |
| 42 | +--- a/setup.py |
| 43 | ++++ b/setup.py |
| 44 | +@@ -314,10 +314,15 @@ def is_64_bit_python(): |
| 45 | + return sys.maxsize > (1 << 32) |
| 46 | + |
| 47 | + |
| 48 | ++# libdatadog's crashtracker unwinds through libdd-libunwind-sys and reads the |
| 49 | ++# signal ucontext register by register, both of which it implements for x86_64 |
| 50 | ++# and aarch64 only. |
| 51 | ++CRASHTRACKER_ARCHS = ("AMD64", "aarch64", "arm64", "x86_64") |
| 52 | ++ |
| 53 | + rust_features = ["stats"] |
| 54 | + if CURRENT_OS in ("Linux", "Darwin") and is_64_bit_python() and sys.version_info < (3, 16): |
| 55 | + rust_features.append("profiling") |
| 56 | +- if not SERVERLESS_BUILD: |
| 57 | ++ if not SERVERLESS_BUILD and platform.machine() in CRASHTRACKER_ARCHS: |
| 58 | + rust_features.append("crashtracker") |
| 59 | + if not SERVERLESS_BUILD: |
| 60 | + rust_features.append("ffe") |
| 61 | +-- |
| 62 | +2.50.1 (Apple Git-155) |
| 63 | + |
0 commit comments