1From e47c6f751a7ef87640c61316ada774e8e9cc6b07 Mon Sep 17 00:00:00 2001
2From: Eugene Gershnik <gershnik@users.noreply.github.com>
3Date: Mon, 6 May 2024 09:29:39 -0700
4Subject: [PATCH] libuuid: fix uuid_time on macOS without attribute((alias))
5
6Weak aliases are not supported by clang on Darwin.
7Instead this fix uses inline asm to make `_uuid_time` an alias to
8`___uuid_time`
9
10It appears that on macOS the time API is purely 32 or 64 bit depending
11on the build type. There is no ABI issue on that platform and `uuid_time`
12can be unconditionally aliased to `_uuid_time`. This is all conjectural,
13however, since I have no ability to make 32-bit builds for macOS - the
14Apple toolchain doesn't support this since 2019.
15
16Fixes util-linux/util-linux#2873
17---
18 libuuid/src/uuid_time.c | 4 ++++
19 1 file changed, 4 insertions(+)
20
21diff --git a/libuuid/src/uuid_time.c b/libuuid/src/uuid_time.c
22index 9b415b3ee73..df0478e1909 100644
23--- a/libuuid/src/uuid_time.c
24+++ b/libuuid/src/uuid_time.c
25@@ -85,6 +85,10 @@ time_t __uuid_time(const uuid_t uu, struct timeval *ret_tv)
26 }
27 #if defined(__USE_TIME_BITS64) && defined(__GLIBC__)
28 extern time_t uuid_time64(const uuid_t uu, struct timeval *ret_tv) __attribute__((weak, alias("__uuid_time")));
29+#elif defined(__clang__) && defined(__APPLE__)
30+__asm__(".globl _uuid_time");
31+__asm__(".set _uuid_time, ___uuid_time");
32+extern time_t uuid_time(const uuid_t uu, struct timeval *ret_tv);
33 #else
34 extern time_t uuid_time(const uuid_t uu, struct timeval *ret_tv) __attribute__((weak, alias("__uuid_time")));
35 #endif