public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
To: git-commits@fedoraproject.org
Subject: [rpms/libfaketime] rawhide: Enable LTO
Date: Mon, 07 Sep 2026 10:03:39 GMT [thread overview]
Message-ID: <178877541973.1.340929927112267671.rpms-libfaketime-30b589987141@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/libfaketime
Branch : rawhide
Commit : 30b589987141b7a3f6c36ea10948d25737395185
Author : Petr Písař <ppisar@redhat.com>
Date : 2026-09-07T12:01:24+02:00
Stats : +217/-2 in 2 file(s)
URL : https://src.fedoraproject.org/rpms/libfaketime/c/30b589987141b7a3f6c36ea10948d25737395185?branch=rawhide
Log:
Enable LTO
---
diff --git a/libfaketime-0.9.13-Adapt-symbol-versioning-to-LTO.patch b/libfaketime-0.9.13-Adapt-symbol-versioning-to-LTO.patch
new file mode 100644
index 0000000..9520f50
--- /dev/null
+++ b/libfaketime-0.9.13-Adapt-symbol-versioning-to-LTO.patch
@@ -0,0 +1,214 @@
+From 6a729b7deaf94bb4b8526614190b61472d8b9c87 Mon Sep 17 00:00:00 2001
+From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
+Date: Fri, 4 Sep 2026 14:57:54 +0200
+Subject: [PATCH] Adapt symbol versioning to LTO
+
+If link-time-optimization is requested, the compiler cannot see the
+versioned symbols created with an in-line assembler and optimizes out
+the unversioned function, resulting into a link-time error:
+
+ $ CFLAGS='-O2 -flto=2' make
+ make -C src all
+ make[1]: Entering directory '/tmp/libfaketime/src'
+ cc -o libfaketime.o -c -O2 -flto=2 -std=gnu99 -Wall -Wextra -Werror -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'/usr/local'"' -DLIBDIRNAME='"'/lib/faketime'"' -Wno-nonnull-compare libfaketime.c
+ cc -o ft_sem.o -c -O2 -flto=2 -std=gnu99 -Wall -Wextra -Werror -DFAKE_PTHREAD -DFAKE_STAT -DFAKE_UTIME -DFAKE_SLEEP -DFAKE_TIMERS -DFAKE_INTERNAL_CALLS -fPIC -DPREFIX='"'/usr/local'"' -DLIBDIRNAME='"'/lib/faketime'"' -Wno-nonnull-compare ft_sem.c
+ cc -o libfaketime.so.1 -Wl,-soname,libfaketime.so.1 -Wl,--version-script=libfaketime.map -shared libfaketime.o ft_sem.o -ldl -lm -lrt -lpthread
+ /tmp/ccxGFQ2F.s: Assembler messages:
+ /tmp/ccxGFQ2F.s: Error: invalid attempt to declare external version name as default in symbol `timer_gettime@@GLIBC_2.3.3'
+
+This patch changes the assembler code into compiler attributes, if
+available (from GCC 10), so that the compiler knows about the
+symbols. A function attribute needs to be directly precede a function
+it binds to, so this patch moves the versioning to the functinon
+definitions. The result is that libfaketime can now be compiled with
+LTO.
+---
+ src/libfaketime.c | 64 +++++++++++++++++++++++++++++++----------------
+ 1 file changed, 42 insertions(+), 22 deletions(-)
+
+diff --git a/src/libfaketime.c b/src/libfaketime.c
+index e674883..fbd00f1 100644
+--- a/src/libfaketime.c
++++ b/src/libfaketime.c
+@@ -132,6 +132,14 @@ struct timeb {
+
+ #define BUFFERLEN 256
+
++#ifdef __has_attribute
++#if __has_attribute (__symver__)
++#define SYMVER(FUNCTION_NAME, EXPORTED_SYMBOL) __attribute__ (( __symver__ (#EXPORTED_SYMBOL)))
++#else
++#define SYMVER(FUNCTION_NAME, EXPORTED_SYMBOL) __asm__(".symver " #FUNCTION_NAME ", " #EXPORTED_SYMBOL);
++#endif
++#endif
++
+ static long stat_mtime_nsec(const struct stat *st);
+
+ static long parse_long_setting(const char *name, const char *value)
+@@ -2693,20 +2701,20 @@ static int sem_clockwait_common(sem_t *sem, clockid_t clockid,
+ }
+
+ #ifdef __GLIBC__
++SYMVER(sem_clockwait_230, sem_clockwait@GLIBC_2.30)
+ int sem_clockwait_230(sem_t *sem, clockid_t clockid,
+ const struct timespec *abstime)
+ {
+ return sem_clockwait_common(sem, clockid, abstime);
+ }
+
++SYMVER(sem_clockwait_234, sem_clockwait@@GLIBC_2.34)
+ int sem_clockwait_234(sem_t *sem, clockid_t clockid,
+ const struct timespec *abstime)
+ {
+ return sem_clockwait_common(sem, clockid, abstime);
+ }
+
+-__asm__(".symver sem_clockwait_230, sem_clockwait@GLIBC_2.30");
+-__asm__(".symver sem_clockwait_234, sem_clockwait@@GLIBC_2.34");
+ #else
+ int sem_clockwait(sem_t *sem, clockid_t clockid,
+ const struct timespec *abstime)
+@@ -3044,6 +3052,7 @@ int timer_gettime(timer_t timerid, struct itimerspec *curr_value)
+ /*
+ * Faked timer_settime() compatible with implementation in GLIBC 2.2
+ */
++SYMVER(timer_settime_22, timer_settime@GLIBC_2.2)
+ int timer_settime_22(int timerid, int flags,
+ const struct itimerspec *new_value,
+ struct itimerspec *old_value)
+@@ -3066,6 +3075,7 @@ int timer_settime_22(int timerid, int flags,
+ /*
+ * Faked timer_settime() compatible with implementation in GLIBC 2.3.3
+ */
++SYMVER(timer_settime_233, timer_settime@@GLIBC_2.3.3)
+ int timer_settime_233(timer_t timerid, int flags,
+ const struct itimerspec *new_value,
+ struct itimerspec *old_value)
+@@ -3088,6 +3098,7 @@ int timer_settime_233(timer_t timerid, int flags,
+ /*
+ * Faked timer_gettime() compatible with implementation in GLIBC 2.2
+ */
++SYMVER(timer_gettime_22, timer_gettime@GLIBC_2.2)
+ int timer_gettime_22(timer_t timerid, struct itimerspec *curr_value)
+ {
+ ftpl_init();
+@@ -3107,6 +3118,7 @@ int timer_gettime_22(timer_t timerid, struct itimerspec *curr_value)
+ /*
+ * Faked timer_gettime() compatible with implementation in GLIBC 2.3.3
+ */
++SYMVER(timer_gettime_233, timer_gettime@@GLIBC_2.3.3)
+ int timer_gettime_233(timer_t timerid, struct itimerspec *curr_value)
+ {
+ ftpl_init();
+@@ -3122,11 +3134,6 @@ int timer_gettime_233(timer_t timerid, struct itimerspec *curr_value)
+ FT_COMPAT_GLIBC_2_3_3));
+ }
+ }
+-
+-__asm__(".symver timer_gettime_22, timer_gettime@GLIBC_2.2");
+-__asm__(".symver timer_gettime_233, timer_gettime@@GLIBC_2.3.3");
+-__asm__(".symver timer_settime_22, timer_settime@GLIBC_2.2");
+-__asm__(".symver timer_settime_233, timer_settime@@GLIBC_2.3.3");
+ #endif /* __ANDROID__ */
+
+ #ifdef __linux__
+@@ -3376,6 +3383,8 @@ int clock_gettime(clockid_t clk_id, struct timespec *tp)
+ #ifdef __GLIBC__
+ /* This is used by glibc 32-bit architectures only. */
+ #ifndef FAKETIME_TIME64_BUILD
++/* glibc's 32-bit time64 ABI references these symbols with GLIBC_2.34. */
++SYMVER(__clock_gettime64, __clock_gettime64@GLIBC_2.34)
+ int __clock_gettime64(clockid_t clk_id, struct __timespec64 *tp64)
+ {
+ struct timespec tp;
+@@ -3406,6 +3415,8 @@ int __gettimeofday64(struct __timeval64 *tv64, void *tz)
+ }
+
+ /* This is used by glibc 32-bit architectures only. */
++/* glibc's 32-bit time64 ABI references these symbols with GLIBC_2.34. */
++SYMVER(__time64, __time64@GLIBC_2.34)
+ uint64_t __time64(uint64_t *write_out)
+ {
+ struct timespec tp;
+@@ -3425,10 +3436,6 @@ uint64_t __time64(uint64_t *write_out)
+ }
+ return output;
+ }
+-
+-/* glibc's 32-bit time64 ABI references these symbols with GLIBC_2.34. */
+-__asm__(".symver __clock_gettime64, __clock_gettime64@GLIBC_2.34");
+-__asm__(".symver __time64, __time64@GLIBC_2.34");
+ #endif
+ #endif
+
+@@ -4967,6 +4974,13 @@ struct pthread_cond_monotonic {
+
+ static struct pthread_cond_monotonic *monotonic_conds = NULL;
+
++#ifndef __ANDROID__
++#if defined __ARM_ARCH || defined FORCE_PTHREAD_NONVER
++SYMVER(pthread_cond_init_232, pthread_cond_init@@)
++#else
++SYMVER(pthread_cond_init_232, pthread_cond_init@@GLIBC_2.3.2)
++#endif
++#endif /* __ANDROID__ */
+ int pthread_cond_init_232(pthread_cond_t *restrict cond, const pthread_condattr_t *restrict attr)
+ {
+ clockid_t clock_id;
+@@ -5012,6 +5026,13 @@ int pthread_cond_init_232(pthread_cond_t *restrict cond, const pthread_condattr_
+ return result;
+ }
+
++#ifndef __ANDROID__
++#if defined __ARM_ARCH || defined FORCE_PTHREAD_NONVER
++SYMVER(pthread_cond_destroy_232, pthread_cond_destroy@@)
++#else
++SYMVER(pthread_cond_destroy_232, pthread_cond_destroy@@GLIBC_2.3.2)
++#endif
++#endif /* __ANDROID__ */
+ int pthread_cond_destroy_232(pthread_cond_t *cond)
+ {
+ struct pthread_cond_monotonic* e;
+@@ -5216,11 +5237,21 @@ int pthread_cond_timedwait_common(pthread_cond_t *cond, pthread_mutex_t *mutex,
+ return result;
+ }
+
++#ifndef __ANDROID__
++SYMVER(pthread_cond_timedwait_225, pthread_cond_timedwait@GLIBC_2.2.5)
++#endif
+ int pthread_cond_timedwait_225(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
+ {
+ return pthread_cond_timedwait_common(cond, mutex, abstime, FT_COMPAT_GLIBC_2_2_5);
+ }
+
++#ifndef __ANDROID__
++#if defined __ARM_ARCH || defined FORCE_PTHREAD_NONVER
++SYMVER(pthread_cond_timedwait_232, pthread_cond_timedwait@@)
++#else
++SYMVER(pthread_cond_timedwait_232, pthread_cond_timedwait@@GLIBC_2.3.2)
++#endif
++#endif /* __ANDROID__ */
+ int pthread_cond_timedwait_232(pthread_cond_t *cond, pthread_mutex_t *mutex, const struct timespec *abstime)
+ {
+ return pthread_cond_timedwait_common(cond, mutex, abstime, FT_COMPAT_GLIBC_2_3_2);
+@@ -5231,17 +5262,6 @@ int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex, const s
+ {
+ return pthread_cond_timedwait_common(cond, mutex, abstime, FT_COMPAT_GLIBC_2_3_2);
+ }
+-#else
+-__asm__(".symver pthread_cond_timedwait_225, pthread_cond_timedwait@GLIBC_2.2.5");
+-#if defined __ARM_ARCH || defined FORCE_PTHREAD_NONVER
+-__asm__(".symver pthread_cond_timedwait_232, pthread_cond_timedwait@@");
+-__asm__(".symver pthread_cond_init_232, pthread_cond_init@@");
+-__asm__(".symver pthread_cond_destroy_232, pthread_cond_destroy@@");
+-#else
+-__asm__(".symver pthread_cond_timedwait_232, pthread_cond_timedwait@@GLIBC_2.3.2");
+-__asm__(".symver pthread_cond_init_232, pthread_cond_init@@GLIBC_2.3.2");
+-__asm__(".symver pthread_cond_destroy_232, pthread_cond_destroy@@GLIBC_2.3.2");
+-#endif
+ #endif /* __ANDROID__ */
+
+ #endif
+--
+2.55.0
+
diff --git a/libfaketime.spec b/libfaketime.spec
index 0b5aaa0..e5eb060 100644
--- a/libfaketime.spec
+++ b/libfaketime.spec
@@ -1,5 +1,3 @@
-%define _lto_cflags %{nil}
-
Name: libfaketime
Version: 0.9.13
Release: %autorelease
@@ -27,6 +25,9 @@ Patch0: libfaketime-0.9.12-Dynamic-libraries-are-expected-to-be-executable-o
# Remove tests which pass NULL to syscalls and are surprised with a segfault,
# in upstream after 0.9.13, <https://github.com/wolfcw/libfaketime/issues/554>
Patch1: libfaketime-0.9.13-Remove-tests-passing-NULL-to-sem_timedwait-and-clock.patch
+# Enable LTO, in upstream after 0.9.13,
+# <https://github.com/wolfcw/libfaketime/pull/557>
+Patch2: libfaketime-0.9.13-Adapt-symbol-versioning-to-LTO.patch
BuildRequires: coreutils
BuildRequires: gcc
BuildRequires: make
reply other threads:[~2026-09-07 10:03 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=178877541973.1.340929927112267671.rpms-libfaketime-30b589987141@fedoraproject.org \
--to=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox