From 89c3da90b8edca3d3c5259b86b7a9b94eb3cf9b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A1rton=20Boros?= Date: Fri, 20 Nov 2026 02:41:10 +0200 Subject: [PATCH] fix: bind stat() to __xstat for pre-2.33 glibc hosts Co-Authored-By: Claude Sonnet 5.5 --- src/extension_custom_scripts.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/extension_custom_scripts.c b/src/extension_custom_scripts.c index ef48bfc..fd1daef 100644 --- a/src/extension_custom_scripts.c +++ b/src/extension_custom_scripts.c @@ -3,6 +3,24 @@ #include #include +/* Link against __xstat so the module loads on glibc older than 2.33. */ +#if defined(__linux__) && defined(__GLIBC__) && \ + (defined(__x86_64__) || defined(__aarch64__)) +# if defined(__x86_64__) +# define SUPAUTILS_STAT_COMPAT_VER "GLIBC_2.2.5" +# define SUPAUTILS_STAT_VER 1 +# else +# define SUPAUTILS_STAT_COMPAT_VER "GLIBC_2.17" +# define SUPAUTILS_STAT_VER 0 +# endif +extern int __xstat(int ver, const char *path, struct stat *buf); +__asm__(".symver __xstat,__xstat@" SUPAUTILS_STAT_COMPAT_VER); +# undef stat +# define stat(path, buf) __xstat(SUPAUTILS_STAT_VER, path, buf) +# undef stat64 +# define stat64(path, buf) __xstat(SUPAUTILS_STAT_VER, path, buf) +#endif + /* * A list of extension names which are currently under creation. * Used to detect cyclic dependencies between extensions via