kmod: fix build with gcc14 and musl
This commit is contained in:
parent
fa60f8b037
commit
54b0270d96
111
srcpkgs/kmod/patches/basename.patch
Normal file
111
srcpkgs/kmod/patches/basename.patch
Normal file
@ -0,0 +1,111 @@
|
||||
From 11eb9bc67c319900ab00523997323a97d2d08ad2 Mon Sep 17 00:00:00 2001
|
||||
From: Khem Raj <raj.khem@gmail.com>
|
||||
Date: Sat, 9 Dec 2023 17:35:59 -0800
|
||||
Subject: [PATCH] Use portable implementation for basename API
|
||||
|
||||
musl has removed the non-prototype declaration of basename from
|
||||
string.h [1] which now results in build errors with clang-17+ compiler
|
||||
|
||||
Implement GNU basename behavior using strchr which is portable across libcs
|
||||
|
||||
Fixes
|
||||
../git/tools/kmod.c:71:19: error: call to undeclared function 'basename'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
|
||||
71 | "Commands:\n", basename(argv[0]));
|
||||
| ^
|
||||
|
||||
[1] https://git.musl-libc.org/cgit/musl/commit/?id=725e17ed6dff4d0cd22487bb64470881e86a92e7
|
||||
|
||||
Suggested-by: Rich Felker
|
||||
|
||||
Signed-off-by: Khem Raj <raj.khem@gmail.com>
|
||||
[ Implement a basename() function in missing.h and ensure we always use
|
||||
the right include rather than having a separate gnu_basename() ]
|
||||
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
|
||||
---
|
||||
configure.ac | 4 +++-
|
||||
shared/missing.h | 10 ++++++++++
|
||||
shared/util.c | 2 +-
|
||||
shared/util.h | 1 +
|
||||
tools/kmod.c | 1 +
|
||||
5 files changed, 16 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/configure.ac b/configure.ac
|
||||
index a80780e3..9527aa2a 100644
|
||||
--- a/configure.ac
|
||||
+++ b/configure.ac
|
||||
@@ -53,7 +53,9 @@ CC_CHECK_FUNC_BUILTIN([__builtin_uaddll_overflow], [ ], [ ])
|
||||
AC_CHECK_MEMBERS([struct stat.st_mtim], [], [], [#include <sys/stat.h>])
|
||||
|
||||
# musl 1.0 and bionic 4.4 don't have strndupa
|
||||
-AC_CHECK_DECLS_ONCE([strndupa])
|
||||
+# basename may be only available in libgen.h with the POSIX behavior,
|
||||
+# not desired here
|
||||
+AC_CHECK_DECLS_ONCE([[strndupa], [basename]], [], [], [[#include <string.h>]])
|
||||
|
||||
# RHEL 5 and older do not have be32toh
|
||||
AC_CHECK_DECLS_ONCE([be32toh])
|
||||
diff --git a/shared/missing.h b/shared/missing.h
|
||||
index 26294441..7df62356 100644
|
||||
--- a/shared/missing.h
|
||||
+++ b/shared/missing.h
|
||||
@@ -38,6 +38,7 @@ static inline int finit_module(int fd, const char *uargs, int flags)
|
||||
#endif
|
||||
|
||||
#if !HAVE_DECL_STRNDUPA
|
||||
+#include <string.h>
|
||||
#define strndupa(s, n) \
|
||||
({ \
|
||||
const char *__old = (s); \
|
||||
@@ -48,6 +49,15 @@ static inline int finit_module(int fd, const char *uargs, int flags)
|
||||
})
|
||||
#endif
|
||||
|
||||
+#if !HAVE_DECL_BASENAME
|
||||
+#include <string.h>
|
||||
+static inline const char *basename(const char *s)
|
||||
+{
|
||||
+ const char *p = strrchr(s, '/');
|
||||
+ return p ? p + 1 : s;
|
||||
+}
|
||||
+#endif
|
||||
+
|
||||
#if !HAVE_DECL_BE32TOH
|
||||
#include <endian.h>
|
||||
#include <byteswap.h>
|
||||
diff --git a/shared/util.c b/shared/util.c
|
||||
index e2bab83a..437bc697 100644
|
||||
--- a/shared/util.c
|
||||
+++ b/shared/util.c
|
||||
@@ -172,7 +172,7 @@ char *modname_normalize(const char *modname, char buf[static PATH_MAX], size_t *
|
||||
|
||||
char *path_to_modname(const char *path, char buf[static PATH_MAX], size_t *len)
|
||||
{
|
||||
- char *modname;
|
||||
+ const char *modname;
|
||||
|
||||
modname = basename(path);
|
||||
if (modname == NULL || modname[0] == '\0')
|
||||
diff --git a/shared/util.h b/shared/util.h
|
||||
index c4a3916b..2a377dd6 100644
|
||||
--- a/shared/util.h
|
||||
+++ b/shared/util.h
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
+#include <string.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
diff --git a/tools/kmod.c b/tools/kmod.c
|
||||
index 1015575f..e1a73bea 100644
|
||||
--- a/tools/kmod.c
|
||||
+++ b/tools/kmod.c
|
||||
@@ -24,6 +24,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <shared/util.h>
|
||||
+#include <shared/missing.h>
|
||||
|
||||
#include <libkmod/libkmod.h>
|
||||
|
@ -1,10 +1,10 @@
|
||||
# Template file for 'kmod'
|
||||
pkgname=kmod
|
||||
version=31
|
||||
revision=1
|
||||
revision=2
|
||||
build_style=gnu-configure
|
||||
configure_args="--with-zlib --with-xz --with-zstd"
|
||||
hostmakedepends="pkg-config"
|
||||
hostmakedepends="pkg-config automake autoconf"
|
||||
makedepends="zlib-devel liblzma-devel libzstd-devel"
|
||||
make_dirs="
|
||||
/etc/depmod.d 0755 root root
|
||||
|
Loading…
x
Reference in New Issue
Block a user