background_hang_monitor: Add musl compatibility (#33153)

musl does not have libunwind readily available; even if it did, it has
no concept of ucontext (needing an external lib).  Similar to ohos,
disable the background hang monitor and use the DummySampler.

Signed-off-by: A. Wilcox <AWilcox@Wilcox-Tech.com>
This commit is contained in:
A. Wilcox 2024-08-21 16:38:28 -05:00 committed by GitHub
parent 7501e3e12f
commit 0e56241c1b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 19 additions and 4 deletions

View file

@ -25,6 +25,6 @@ serde_json = { workspace = true }
[target.'cfg(target_os = "macos")'.dependencies] [target.'cfg(target_os = "macos")'.dependencies]
mach2 = "0.4" mach2 = "0.4"
[target.'cfg(all(target_os = "linux", not(any(target_arch = "arm", target_arch = "aarch64", target_env = "ohos"))))'.dependencies] [target.'cfg(all(target_os = "linux", not(any(target_arch = "arm", target_arch = "aarch64", target_env = "ohos", target_env = "musl"))))'.dependencies]
nix = { workspace = true, features = ["signal"] } nix = { workspace = true, features = ["signal"] }
unwind-sys = "0.1.4" unwind-sys = "0.1.4"

View file

@ -98,14 +98,24 @@ impl BackgroundHangMonitorRegister for HangMonitorRegister {
let sampler = crate::sampler_mac::MacOsSampler::new_boxed(); let sampler = crate::sampler_mac::MacOsSampler::new_boxed();
#[cfg(all( #[cfg(all(
target_os = "linux", target_os = "linux",
not(any(target_arch = "arm", target_arch = "aarch64", target_env = "ohos")), not(any(
target_arch = "arm",
target_arch = "aarch64",
target_env = "ohos",
target_env = "musl"
)),
))] ))]
let sampler = crate::sampler_linux::LinuxSampler::new_boxed(); let sampler = crate::sampler_linux::LinuxSampler::new_boxed();
#[cfg(any( #[cfg(any(
target_os = "android", target_os = "android",
all( all(
target_os = "linux", target_os = "linux",
any(target_arch = "arm", target_arch = "aarch64", target_env = "ohos") any(
target_arch = "arm",
target_arch = "aarch64",
target_env = "ohos",
target_env = "musl"
)
) )
))] ))]
let sampler = crate::sampler::DummySampler::new_boxed(); let sampler = crate::sampler::DummySampler::new_boxed();

View file

@ -8,7 +8,12 @@ pub mod background_hang_monitor;
mod sampler; mod sampler;
#[cfg(all( #[cfg(all(
target_os = "linux", target_os = "linux",
not(any(target_arch = "arm", target_arch = "aarch64", target_env = "ohos")) not(any(
target_arch = "arm",
target_arch = "aarch64",
target_env = "ohos",
target_env = "musl"
))
))] ))]
mod sampler_linux; mod sampler_linux;
#[cfg(target_os = "macos")] #[cfg(target_os = "macos")]