libfaketime: Upgrade to 0.9.13

Release notes:
https://github.com/wolfcw/libfaketime/blob/v0.9.13/NEWS

Drop 0001-Add-const-qualifiers-to-fix-build-with-ISO-C23.patch, it is
merged upstream via PR #525.

Add a patch to fix the build with clang 23, which added
-Wunused-but-set-global and turns the -Werror in src/Makefile into:

  libfaketime.c:340:23: error: variable 'real_lstat' set but not used
    [-Werror,-Wunused-but-set-global]

ftpl_init() resolves every real_* pointer up front by design, so the
ones whose wrappers are not compiled on Linux/glibc end up written and
never read. Annotate those with __attribute__((unused)) rather than
adding -Wno-error=unused-but-set-global to CFLAGS, since the Makefile
has no flag-probing and older clang rejects the unknown warning group
under the same -Werror.

Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
This commit is contained in:
Khem Raj
2026-09-08 08:23:17 -07:00
parent 2fe2f967f9
commit e2cc2b4e02
3 changed files with 70 additions and 36 deletions
@@ -1,34 +0,0 @@
From dbe865dfdba0145d993d70b7fd4ec88b2f47554b Mon Sep 17 00:00:00 2001
From: Tomas Korbar <tkorbar@redhat.com>
Date: Mon, 15 Dec 2025 11:03:21 +0100
Subject: [PATCH] Add const qualifiers to fix build with ISO C23
Fix https://github.com/wolfcw/libfaketime/issues/524
Upstream-Status: Backport [https://github.com/wolfcw/libfaketime/pull/525]
---
src/libfaketime.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/libfaketime.c b/src/libfaketime.c
index ef1dca9..02839c8 100644
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -2666,7 +2666,7 @@ int timespec_get(struct timespec *ts, int base)
static void parse_ft_string(const char *user_faked_time)
{
struct tm user_faked_time_tm;
- char * tmp_time_fmt;
+ const char * tmp_time_fmt;
char * nstime_str;
if (!strncmp(user_faked_time, user_faked_time_saved, BUFFERLEN))
@@ -3338,7 +3338,7 @@ static void prepare_config_contents(char *contents)
bool str_array_contains(const char *haystack, const char *needle)
{
size_t needle_len = strlen(needle);
- char *pos = strstr(haystack, needle);
+ const char *pos = strstr(haystack, needle);
while (pos) {
if (pos == haystack || *(pos - 1) == ',') {
char nextc = *(pos + needle_len);
@@ -0,0 +1,68 @@
From d0fd7b4be89feb6a8809216b0dc1d84299bbad96 Mon Sep 17 00:00:00 2001
From: Khem Raj <khem.raj@oss.qualcomm.com>
Date: Mon, 7 Sep 2026 19:27:57 -0700
Subject: [PATCH] Mark write-only real_* pointers as unused
clang 23 added -Wunused-but-set-global, which together with the -Werror
in src/Makefile breaks the build:
libfaketime.c:340:23: error: variable 'real_lstat' set but not used
[-Werror,-Wunused-but-set-global]
ftpl_init() deliberately resolves every real_* pointer up front ('Look
up all real_* functions. NULL will mark missing ones.'), but several of
them are only consumed on other platforms or under build options that
are off by default, so on Linux/glibc they are written and never read.
Annotate exactly those with __attribute__((unused)). This is understood
by every gcc and clang that can build libfaketime, unlike a
-Wno-error=unused-but-set-global flag, which older compilers reject.
Upstream-Status: Pending
Signed-off-by: Khem Raj <khem.raj@oss.qualcomm.com>
---
src/libfaketime.c | 20 ++++++++++----------
1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/src/libfaketime.c b/src/libfaketime.c
index e674883..2addaab 100644
--- a/src/libfaketime.c
+++ b/src/libfaketime.c
@@ -337,26 +337,26 @@ static __thread bool dont_fake = false;
/* pointers to real (not faked) functions */
static int (*real_stat) (const char *, struct stat *);
static int (*real_fstat) (int, struct stat *);
-static int (*real_lstat) (const char *, struct stat *);
+static int (*real_lstat) (const char *, struct stat *) __attribute__((unused));
#ifndef __ANDROID__
static int (*real_xstat) (int, const char *, struct stat *);
static int (*real_fxstat) (int, int, struct stat *);
-static int (*real_fxstatat) (int, int, const char *, struct stat *, int);
-static int (*real_lxstat) (int, const char *, struct stat *);
+static int (*real_fxstatat) (int, int, const char *, struct stat *, int) __attribute__((unused));
+static int (*real_lxstat) (int, const char *, struct stat *) __attribute__((unused));
#endif
#if !defined(__APPLE__) || !__DARWIN_ONLY_64_BIT_INO_T
#ifndef __ANDROID__
-static int (*real_stat64) (const char *, struct stat64 *);
-static int (*real_xstat64) (int, const char *, struct stat64 *);
-static int (*real_fxstat64) (int, int , struct stat64 *);
-static int (*real_fxstatat64) (int, int , const char *, struct stat64 *, int);
-static int (*real_lxstat64) (int, const char *, struct stat64 *);
+static int (*real_stat64) (const char *, struct stat64 *) __attribute__((unused));
+static int (*real_xstat64) (int, const char *, struct stat64 *) __attribute__((unused));
+static int (*real_fxstat64) (int, int , struct stat64 *) __attribute__((unused));
+static int (*real_fxstatat64) (int, int , const char *, struct stat64 *, int) __attribute__((unused));
+static int (*real_lxstat64) (int, const char *, struct stat64 *) __attribute__((unused));
#endif
#endif
#ifdef STATX_TYPE
-static int (*real_statx) (int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf);
+static int (*real_statx) (int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf) __attribute__((unused));
#endif
-static time_t (*real_time) (time_t *);
+static time_t (*real_time) (time_t *) __attribute__((unused));
#ifndef __ANDROID__
static int (*real_ftime) (struct timeb *);
#endif
@@ -3,10 +3,10 @@ SECTION = "libs"
LICENSE = "GPL-2.0-only"
LIC_FILES_CHKSUM = "file://COPYING;md5=b234ee4d69f5fce4486a80fdaf4a4263"
SRCREV = "3ccdd344aadf1e317156fa5fb7c881f2c4404778"
SRCREV = "86b37fde2fed7336ea2d0c17928e3015a55d9b4a"
SRC_URI = "git://github.com/wolfcw/libfaketime.git;branch=master;tag=v${PV};protocol=https \
file://0001-Add-const-qualifiers-to-fix-build-with-ISO-C23.patch \
file://0001-Mark-write-only-real_-pointers-as-unused.patch \
"
CFLAGS:append:libc-musl = " -D_LARGEFILE64_SOURCE"