From: Emil Velikov Date: Sun, 15 Sep 2024 09:11:49 +0000 (+0100) Subject: build: check for open64, stat64 and fopen64 X-Git-Tag: v34~340 X-Git-Url: http://git.ipfire.org/gitweb/gitweb.cgi?a=commitdiff_plain;h=33771fb453833cf44e3d8c32d289bbb69d18e6a8;p=thirdparty%2Fkmod.git build: check for open64, stat64 and fopen64 ... and use behind the respective ifdef HAVE_FOO guards instead of the HAVE_DECL___GLIBC__ currently. Since day one, glibc has declarations for the functions, which was forwarding the normal functions to them, via asm linkage, et al. Aka `extern int open(....) asm_linkage("open64"). In addition, a lot of libraries have grown to depend on the declarations being available and functions being statically exposed via libc.so. Whereas musl pre 1.2.4 (circa 2023) have exposed the symbols statically, without a declaration for well over a decade. Newer musl, no longer expose the symbol in their runtime but have retained the define trick, stating it will be removed in the future. Looking at the bionic front things are somewhat similar. Newer bionic (circa 2019) have a declaration and an inline wrapper open64 function forwarding to open. Throughout 2019, open64 did forward to misc other internal functions thought. Older pre 2019 bionic had a declaration alongside plug exposing the symbol statically in their C runtime.... since 2014. Not sure what they did prior to 2014, it's a target out of scope for us. Considering the above, the most robust approach is to do a check/has function checking. With that, we no longer need the __GLIBC__ guard for the respective functions. Signed-off-by: Emil Velikov Link: https://github.com/kmod-project/kmod/pull/131 Signed-off-by: Lucas De Marchi --- diff --git a/configure.ac b/configure.ac index 863a166a..373250eb 100644 --- a/configure.ac +++ b/configure.ac @@ -40,6 +40,7 @@ AC_PROG_CC_C99 ##################################################################### AC_CHECK_FUNCS_ONCE(__xstat) +AC_CHECK_FUNCS_ONCE([open64 stat64 fopen64]) AC_CHECK_FUNCS_ONCE([__secure_getenv secure_getenv]) CC_CHECK_FUNC_BUILTIN([__builtin_clz]) diff --git a/meson.build b/meson.build index dc0581aa..e37218cf 100644 --- a/meson.build +++ b/meson.build @@ -33,9 +33,14 @@ cdata.set10('_GNU_SOURCE', true) # Function and structure checks ################################################################################ -foreach decl : ['__xstat', '__secure_getenv', 'secure_getenv'] - if cc.has_function(decl, args : '-D_GNU_SOURCE') - cdata.set('HAVE_@0@'.format(decl.to_upper()), true) +_funcs = [ + '__xstat', + 'open64', 'stat64', 'fopen64', + '__secure_getenv', 'secure_getenv', +] +foreach func : _funcs + if cc.has_function(func, args : '-D_GNU_SOURCE') + cdata.set('HAVE_@0@'.format(func.to_upper()), true) endif endforeach diff --git a/testsuite/path.c b/testsuite/path.c index b251fc8a..0c1faea0 100644 --- a/testsuite/path.c +++ b/testsuite/path.c @@ -189,14 +189,20 @@ WRAP_2ARGS(int, -1, stat, struct stat*); WRAP_OPEN(); -#if HAVE_DECL___GLIBC__ +#ifdef HAVE_FOPEN64 WRAP_2ARGS(FILE*, NULL, fopen64, const char*); +#endif +#ifdef HAVE_STAT64 WRAP_2ARGS(int, -1, stat64, struct stat64*); +#endif +#if HAVE_DECL___GLIBC__ struct __stat64_t64; extern int __stat64_time64 (const char *file, struct __stat64_t64 *buf); WRAP_2ARGS(int, -1, __stat64_time64, struct __stat64_t64*); +#endif +#ifdef HAVE_OPEN64 WRAP_OPEN(64); #endif