From 3118542a9e90478cdabf1f2479851f86dd0e94d6 Mon Sep 17 00:00:00 2001 From: Patrycja Date: Sun, 14 Jul 2024 09:20:52 +0200 Subject: [PATCH] Use mallinfo only on target_env=gnu (#32772) mallinfo isn't available on musl, causing linking issues on build; make sure related functions are built only for GNU Libc Signed-off-by: Patrycja Rosa --- components/profile/mem.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/components/profile/mem.rs b/components/profile/mem.rs index 565cae95c53..bd42e5fa93c 100644 --- a/components/profile/mem.rs +++ b/components/profile/mem.rs @@ -394,7 +394,7 @@ mod system_reporter { #[cfg(not(any(target_os = "windows", target_env = "ohos")))] use std::ptr::null_mut; - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", target_env = "gnu"))] use libc::c_int; #[cfg(not(any(target_os = "windows", target_env = "ohos")))] use libc::{c_void, size_t}; @@ -455,12 +455,12 @@ mod system_reporter { request.reports_channel.send(reports); } - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", target_env = "gnu"))] extern "C" { fn mallinfo() -> struct_mallinfo; } - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", target_env = "gnu"))] #[repr(C)] pub struct struct_mallinfo { arena: c_int, @@ -475,7 +475,7 @@ mod system_reporter { keepcost: c_int, } - #[cfg(target_os = "linux")] + #[cfg(all(target_os = "linux", target_env = "gnu"))] fn system_heap_allocated() -> Option { let info: struct_mallinfo = unsafe { mallinfo() }; @@ -494,7 +494,7 @@ mod system_reporter { } } - #[cfg(not(target_os = "linux"))] + #[cfg(not(all(target_os = "linux", target_env = "gnu")))] fn system_heap_allocated() -> Option { None }