Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libuv-devel: update to 1.50.0 #27671

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 18 additions & 13 deletions devel/libuv/Portfile
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,13 @@ subport libuv-devel {
legacysupport.newest_darwin_requires_legacy 15

github.setup \
libuv libuv 1.47.0 v
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
libuv libuv 1.50.0 v
github.tarball_from archive
revision 0

checksums rmd160 6510cd246bb2062874a5cb37e92a1c727a7d2655 \
sha256 72a187104662b47f2a2b204da39d2acb05cf22a4fcb13ceaebe3b0ed0c0e2e43 \
size 1654769
checksums rmd160 c8e0059ab5028b19ae7459e9f33b8f17f77dc9e1 \
sha256 c42c51d4e630f95dcefcafff95bf003ea52939e312d5e6584e7d9e102ead3e9e \
size 1686246
}

set domain libuv.org
Expand All @@ -48,17 +47,21 @@ long_description \
${name} is a multi-platform support library with a focus on \
cross-platform asynchronous I/O.

patchfiles-append \
patch-libuv-unix-core-close-nocancel.diff

if {${subport} eq ${name}} {
# RELEASE
patchfiles-append patch-libuv-legacy.diff
patchfiles-append \
patch-libuv-unix-core-close-nocancel.diff \
patch-libuv-legacy.diff

conflicts libuv-devel
} else {
# DEVEL
patchfiles-append patch-libuv-legacy-devel.diff
patch.pre_args-replace \
-p0 -p1
patchfiles-append \
0001-swap-mach_continuous_time-for-clock_gettime_nsec_np.patch \
0002-prevent-pragmas-causing-issues-on-older-gcc-versions.patch \
0003-support-legacy-macos-pre-v11.patch

conflicts libuv

Expand All @@ -75,8 +78,10 @@ configure.args --disable-silent-rules

platform darwin {
if { ${os.major} == 8 } {
# Tiger has no libutil
patchfiles-append patch-no-libutil-on-Tiger.diff
post-patch {
# Tiger has no libutil
reinplace -E "s|(.*DARWIN_TRUE.*-lutil.*)|# \\1|" Makefile.in
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@barracuda156 Do you know if this is sufficient as compared with the patch? The patch originally commented out DragonFlyBSD's, FreeBSD's, etc as well which seemed unnecessary for Tiger to work.

If it is necessary then the regex could instead be:

Suggested change
reinplace -E "s|(.*DARWIN_TRUE.*-lutil.*)|# \\1|" Makefile.in
reinplace -E "s|(.*-lutil.*)|# \\1|" Makefile.in

which would yield a similar result to the patch.

(Extra context: I changed this to be a reinplace instead because this file is dynamically created by automake so will more likely apply in the future)

}

configure.cppflags-append -D__DARWIN_UNIX03
# prevent conflicting opentransport header from being pulled in
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
From 304a518853ff6400fbd661a2461e38f47f7be656 Mon Sep 17 00:00:00 2001
From: Fred Wright <[email protected]>
Date: Wed, 19 Feb 2025 23:47:55 +0000
Subject: [PATCH 1/3] swap mach_continuous_time for clock_gettime_nsec_np

See: https://github.com/macports/macports-ports/pull/27671#issuecomment-2664257623
See: https://github.com/macports/macports-ports/pull/27671#issuecomment-2670030330
---
src/unix/darwin.c | 14 +++-----------
1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/src/unix/darwin.c b/src/unix/darwin.c
index 009efbef..e9f86490 100644
--- a/src/unix/darwin.c
+++ b/src/unix/darwin.c
@@ -25,15 +25,13 @@
#include <stdint.h>
#include <errno.h>

-#include <mach/mach.h>
-#include <mach/mach_time.h>
+#include <time.h>
#include <mach-o/dyld.h> /* _NSGetExecutablePath */
#include <sys/resource.h>
#include <sys/sysctl.h>
#include <unistd.h> /* sysconf */

static uv_once_t once = UV_ONCE_INIT;
-static mach_timebase_info_data_t timebase;


int uv__platform_loop_init(uv_loop_t* loop) {
@@ -51,15 +49,9 @@ void uv__platform_loop_delete(uv_loop_t* loop) {
}


-static void uv__hrtime_init_once(void) {
- if (KERN_SUCCESS != mach_timebase_info(&timebase))
- abort();
-}
-
-
uint64_t uv__hrtime(uv_clocktype_t type) {
- uv_once(&once, uv__hrtime_init_once);
- return mach_continuous_time() * timebase.numer / timebase.denom;
+ (void) type;
+ return clock_gettime_nsec_np(CLOCK_MONOTONIC_RAW);
}


--
2.48.0

Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
From 9d6c5364932ae7fef006d4b9113d34d922f88716 Mon Sep 17 00:00:00 2001
From: Ken Cunningham <[email protected]>
Date: Tue, 21 May 2019 21:00:49 -0700
Subject: [PATCH 2/3] prevent pragmas causing issues on older gcc versions

See: https://github.com/macports/macports-ports/pull/4433

Co-authored-by: Michael Dickens <[email protected]>
---
src/unix/core.c | 27 ++++++++++++++++++++-------
1 file changed, 20 insertions(+), 7 deletions(-)

diff --git a/src/unix/core.c b/src/unix/core.c
index 61cbc0d0..0b22a395 100644
--- a/src/unix/core.c
+++ b/src/unix/core.c
@@ -597,18 +597,31 @@ int uv__accept(int sockfd) {
* will unwind the thread when it's in the cancel state. Work around that
* by making the system call directly. Musl libc is unaffected.
*/
+
+#if defined(__GNUC__)
+# define GCC_VERSION \
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)
+#endif
+#if defined(__clang__) || (defined(GCC_VERSION) && (GCC_VERSION >= 40500))
+/* gcc diagnostic pragmas available */
+# define GCC_DIAGNOSTIC_AVAILABLE
+#endif
int uv__close_nocancel(int fd) {
-#if defined(__APPLE__)
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
-#if defined(__LP64__) || TARGET_OS_IPHONE
+#if defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1050)
+# if defined(GCC_DIAGNOSTIC_AVAILABLE)
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wdollar-in-identifier-extension"
+# endif
+# if defined(__LP64__) || __LP64__ || (defined(TARGET_OS_IPHONE) && (TARGET_OS_IPHONE > 0))
extern int close$NOCANCEL(int);
return close$NOCANCEL(fd);
-#else
+# else
extern int close$NOCANCEL$UNIX2003(int);
return close$NOCANCEL$UNIX2003(fd);
-#endif
-#pragma GCC diagnostic pop
+# endif
+# if defined(GCC_DIAGNOSTIC_AVAILABLE)
+# pragma GCC diagnostic pop
+# endif
#elif defined(__linux__) && defined(__SANITIZE_THREAD__) && defined(__clang__)
long rc;
__sanitizer_syscall_pre_close(fd);
--
2.48.0

204 changes: 204 additions & 0 deletions devel/libuv/files/0003-support-legacy-macos-pre-v11.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
From 142c42613441cd61ef911c794d39f6a06911f505 Mon Sep 17 00:00:00 2001
From: Ken Cunningham <[email protected]>
Date: Mon, 12 Nov 2018 14:40:24 -0800
Subject: [PATCH 3/3] support legacy macos (pre v11)

See: https://github.com/libuv/libuv/blob/v1.x/SUPPORTED_PLATFORMS.md

Co-authored-by: Michael Dickens <[email protected]>
Co-authored-by: Sergey Fedorov <[email protected]>
Co-authored-by: Evan Miller <[email protected]>
---
src/unix/fs.c | 4 ++--
src/unix/internal.h | 2 +-
src/unix/process.c | 8 ++++++--
src/unix/tty.c | 2 +-
src/unix/udp.c | 14 ++++++++------
test/test-fs.c | 4 ++--
6 files changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/unix/fs.c b/src/unix/fs.c
index 239ecda1..424729e3 100644
--- a/src/unix/fs.c
+++ b/src/unix/fs.c
@@ -1079,7 +1079,7 @@ static ssize_t uv__fs_sendfile(uv_fs_t* req) {
return -1;
}
/* sendfile() on iOS(arm64) will throw SIGSYS signal cause crash. */
-#elif (defined(__APPLE__) && !TARGET_OS_IPHONE) \
+#elif (defined(__APPLE__) && (!TARGET_OS_IPHONE || (MAC_OS_X_VERSION_MAX_ALLOWED >= 1050))) \
|| defined(__DragonFly__) \
|| defined(__FreeBSD__)
{
@@ -1458,7 +1458,7 @@ static void uv__to_stat(struct stat* src, uv_stat_t* dst) {
dst->st_blksize = src->st_blksize;
dst->st_blocks = src->st_blocks;

-#if defined(__APPLE__)
+#if defined(__APPLE__) && (MAC_OS_X_VERSION_MAX_ALLOWED >= 1050)
dst->st_atim.tv_sec = src->st_atimespec.tv_sec;
dst->st_atim.tv_nsec = src->st_atimespec.tv_nsec;
dst->st_mtim.tv_sec = src->st_mtimespec.tv_sec;
diff --git a/src/unix/internal.h b/src/unix/internal.h
index b1d2b217..83fa32d8 100644
--- a/src/unix/internal.h
+++ b/src/unix/internal.h
@@ -75,7 +75,7 @@
# include <poll.h>
#endif /* _AIX */

-#if defined(__APPLE__)
+#if (defined(__APPLE__) && MAC_OS_X_VERSION_MIN_REQUIRED >= 101000)
# include "darwin-syscalls.h"
# if !TARGET_OS_IPHONE
# include <AvailabilityMacros.h>
diff --git a/src/unix/process.c b/src/unix/process.c
index f2038f2c..a3f885d4 100644
--- a/src/unix/process.c
+++ b/src/unix/process.c
@@ -36,7 +36,9 @@
#include <poll.h>

#if defined(__APPLE__)
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
# include <spawn.h>
+#endif
# include <paths.h>
# include <sys/kauth.h>
# include <sys/types.h>
@@ -404,7 +406,7 @@ static void uv__process_child_init(const uv_process_options_t* options,
}


-#if defined(__APPLE__)
+#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
typedef struct uv__posix_spawn_fncs_tag {
struct {
int (*addchdir_np)(const posix_spawn_file_actions_t *, const char *);
@@ -605,9 +607,11 @@ static int uv__spawn_set_posix_spawn_file_actions(
}
}

+#if MAC_OS_X_VERSION_MIN_REQUIRED >= 1070
if (fd == use_fd)
err = posix_spawn_file_actions_addinherit_np(actions, fd);
else
+#endif
err = posix_spawn_file_actions_adddup2(actions, use_fd, fd);
assert(err != ENOSYS);
if (err != 0)
@@ -856,7 +860,7 @@ static int uv__spawn_and_init_child(
int exec_errorno;
ssize_t r;

-#if defined(__APPLE__)
+#if defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1050)
uv_once(&posix_spawn_init_once, uv__spawn_init_posix_spawn);

/* Special child process spawn case for macOS Big Sur (11.0) onwards
diff --git a/src/unix/tty.c b/src/unix/tty.c
index 793054ba..228b543d 100644
--- a/src/unix/tty.c
+++ b/src/unix/tty.c
@@ -85,7 +85,7 @@ static int uv__tty_is_slave(const int fd) {
int dummy;

result = ioctl(fd, TIOCGPTN, &dummy) != 0;
-#elif defined(__APPLE__)
+#elif defined(__APPLE__) && MAC_OS_X_VERSION_MAX_ALLOWED >= 1050
char dummy[256];

result = ioctl(fd, TIOCPTYGNAME, &dummy) != 0;
diff --git a/src/unix/udp.c b/src/unix/udp.c
index 67c01f7d..8417178f 100644
--- a/src/unix/udp.c
+++ b/src/unix/udp.c
@@ -152,7 +152,7 @@ static void uv__udp_io(uv_loop_t* loop, uv__io_t* w, unsigned int revents) {
}

static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) {
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__FreeBSD__) || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 101000))
struct sockaddr_in6 peers[20];
struct iovec iov[ARRAY_SIZE(peers)];
struct mmsghdr msgs[ARRAY_SIZE(peers)];
@@ -215,9 +215,9 @@ static int uv__udp_recvmmsg(uv_udp_t* handle, uv_buf_t* buf) {
handle->recv_cb(handle, 0, buf, NULL, UV_UDP_MMSG_FREE);
}
return nread;
-#else /* __linux__ || ____FreeBSD__ || __APPLE__ */
+#else /* __linux__ || __FreeBSD__ || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 101000)) */
return UV_ENOSYS;
-#endif /* __linux__ || ____FreeBSD__ || __APPLE__ */
+#endif /* __linux__ || __FreeBSD__ || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 101000)) */
}

static void uv__udp_recvmsg(uv_udp_t* handle) {
@@ -754,6 +754,7 @@ static int uv__udp_set_membership6(uv_udp_t* handle,
!defined(__ANDROID__) && \
!defined(__DragonFly__) && \
!defined(__QNX__) && \
+ (!defined(__APPLE__) || (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)) && \
!defined(__GNU__)
static int uv__udp_set_source_membership4(uv_udp_t* handle,
const struct sockaddr_in* multicast_addr,
@@ -877,7 +878,7 @@ int uv__udp_init_ex(uv_loop_t* loop,


int uv_udp_using_recvmmsg(const uv_udp_t* handle) {
-#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__FreeBSD__) || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 1070))
if (handle->flags & UV_HANDLE_UDP_RECVMMSG)
return 1;
#endif
@@ -945,6 +946,7 @@ int uv_udp_set_source_membership(uv_udp_t* handle,
!defined(__ANDROID__) && \
!defined(__DragonFly__) && \
!defined(__QNX__) && \
+ (!defined(__APPLE__) || (MAC_OS_X_VERSION_MAX_ALLOWED >= 1070)) && \
!defined(__GNU__)
int err;
union uv__sockaddr mcast_addr;
@@ -1298,7 +1300,7 @@ static int uv__udp_sendmsgv(int fd,
r = 0;
nsent = 0;

-#if defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__)
+#if defined(__linux__) || defined(__FreeBSD__) || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 101000))
if (count > 1) {
for (i = 0; i < count; /*empty*/) {
struct mmsghdr m[20];
@@ -1325,7 +1327,7 @@ static int uv__udp_sendmsgv(int fd,

goto exit;
}
-#endif /* defined(__linux__) || defined(__FreeBSD__) || defined(__APPLE__) */
+#endif /* defined(__linux__) || defined(__FreeBSD__) || (defined(__APPLE__) && (MAC_OS_X_VERSION_MIN_REQUIRED >= 101000)) */

for (i = 0; i < count; i++, nsent++)
if ((r = uv__udp_sendmsg1(fd, bufs[i], nbufs[i], addrs[i])))
diff --git a/test/test-fs.c b/test/test-fs.c
index 423d72dd..36bb2df0 100644
--- a/test/test-fs.c
+++ b/test/test-fs.c
@@ -1477,7 +1477,7 @@ TEST_IMPL(fs_fstat) {
ASSERT_OK(uv_fs_fstat(NULL, &req, file, NULL));
ASSERT_OK(req.result);
s = req.ptr;
-# if defined(__APPLE__)
+# if defined(__APPLE__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050)
ASSERT_EQ(s->st_birthtim.tv_sec, t.st_birthtimespec.tv_sec);
ASSERT_EQ(s->st_birthtim.tv_nsec, t.st_birthtimespec.tv_nsec);
# elif defined(__linux__)
@@ -1518,7 +1518,7 @@ TEST_IMPL(fs_fstat) {
ASSERT_EQ(s->st_size, (uint64_t) t.st_size);
ASSERT_EQ(s->st_blksize, (uint64_t) t.st_blksize);
ASSERT_EQ(s->st_blocks, (uint64_t) t.st_blocks);
-#if defined(__APPLE__)
+# if defined(__APPLE__) && (__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1050)
ASSERT_EQ(s->st_atim.tv_sec, t.st_atimespec.tv_sec);
ASSERT_EQ(s->st_atim.tv_nsec, t.st_atimespec.tv_nsec);
ASSERT_EQ(s->st_mtim.tv_sec, t.st_mtimespec.tv_sec);
--
2.48.0

Loading