From 7e25c3426b382493007fa6982873f76baa9d020d Mon Sep 17 00:00:00 2001 From: Weihang Lo Date: Mon, 9 Feb 2026 18:21:08 +0800 Subject: [PATCH] fix(gix-index): handle loongarch64-musl stat struct field names On `loongarch64-unknown-linux-musl` with musl 1.2.3+, the libc `stat` struct uses POSIX timespec fields (`st_mtim`, `st_ctim`) instead of separate seconds and nanoseconds fields (`st_mtime`, `st_mtime_nsec`). This was exposed by libc 0.2.180 which added proper time64 support for this target, causing compilation failures in rust-lang/rust CI. Fixes the same pattern already used for AIX and Hurd targets. --- gix-index/src/fs.rs | 48 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) diff --git a/gix-index/src/fs.rs b/gix-index/src/fs.rs index 2be45bb8d7a..f2ca1ad9124 100644 --- a/gix-index/src/fs.rs +++ b/gix-index/src/fs.rs @@ -54,14 +54,30 @@ impl Metadata { pub fn modified(&self) -> Option { #[cfg(not(windows))] { - #[cfg(not(any(target_os = "aix", target_os = "hurd")))] + #[cfg(not(any( + target_os = "aix", + target_os = "hurd", + all(target_arch = "loongarch64", target_env = "musl") + )))] let seconds = self.0.st_mtime; - #[cfg(any(target_os = "aix", target_os = "hurd"))] + #[cfg(any( + target_os = "aix", + target_os = "hurd", + all(target_arch = "loongarch64", target_env = "musl") + ))] let seconds = self.0.st_mtim.tv_sec; - #[cfg(not(any(target_os = "aix", target_os = "hurd")))] + #[cfg(not(any( + target_os = "aix", + target_os = "hurd", + all(target_arch = "loongarch64", target_env = "musl") + )))] let nanoseconds = self.0.st_mtime_nsec; - #[cfg(any(target_os = "aix", target_os = "hurd"))] + #[cfg(any( + target_os = "aix", + target_os = "hurd", + all(target_arch = "loongarch64", target_env = "musl") + ))] let nanoseconds = self.0.st_mtim.tv_nsec; // All operating systems treat the seconds as offset from unix epoch, hence it must @@ -81,14 +97,30 @@ impl Metadata { pub fn created(&self) -> Option { #[cfg(not(windows))] { - #[cfg(not(any(target_os = "aix", target_os = "hurd")))] + #[cfg(not(any( + target_os = "aix", + target_os = "hurd", + all(target_arch = "loongarch64", target_env = "musl") + )))] let seconds = self.0.st_ctime; - #[cfg(any(target_os = "aix", target_os = "hurd"))] + #[cfg(any( + target_os = "aix", + target_os = "hurd", + all(target_arch = "loongarch64", target_env = "musl") + ))] let seconds = self.0.st_ctim.tv_sec; - #[cfg(not(any(target_os = "aix", target_os = "hurd")))] + #[cfg(not(any( + target_os = "aix", + target_os = "hurd", + all(target_arch = "loongarch64", target_env = "musl") + )))] let nanoseconds = self.0.st_ctime_nsec; - #[cfg(any(target_os = "aix", target_os = "hurd"))] + #[cfg(any( + target_os = "aix", + target_os = "hurd", + all(target_arch = "loongarch64", target_env = "musl") + ))] let nanoseconds = self.0.st_ctim.tv_nsec; // All operating systems treat the seconds as offset from unix epoch, hence it must