commit:     e5c1b4e29ac0ff3d1cde32159f7926b9827d4dbf
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  6 08:22:24 2026 +0000
Commit:     Sam James <sam <AT> gentoo <DOT> org>
CommitDate: Tue Jan  6 08:22:24 2026 +0000
URL:        https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=e5c1b4e2

dev-lang/ruby: rebase musl patch for 4.0.0

Closes: https://bugs.gentoo.org/968203
Signed-off-by: Sam James <sam <AT> gentoo.org>

 dev-lang/ruby/files/4.0/901-musl-stacksize.patch | 49 +++++++++++++++---------
 1 file changed, 30 insertions(+), 19 deletions(-)

diff --git a/dev-lang/ruby/files/4.0/901-musl-stacksize.patch 
b/dev-lang/ruby/files/4.0/901-musl-stacksize.patch
index f18aa271ea65..ab9308d0e7b6 100644
--- a/dev-lang/ruby/files/4.0/901-musl-stacksize.patch
+++ b/dev-lang/ruby/files/4.0/901-musl-stacksize.patch
@@ -1,20 +1,31 @@
---- a/thread_pthread.c 2023-02-08 05:02:20.000000000 +0100
-+++ b/thread_pthread.c 2023-03-10 17:46:25.694739053 +0100
-@@ -1033,7 +1033,7 @@
- {
-     native_main_thread.id = pthread_self();
+https://github.com/ruby/ruby/pull/10633
+
+From 605f55ebd7e94d56c3ef86635b413f30cfc33b46 Mon Sep 17 00:00:00 2001
+From: Nobuyoshi Nakada <[email protected]>
+Date: Thu, 25 Apr 2024 21:00:37 +0900
+Subject: [PATCH] [Bug #20452] Take main thread address/size with rlimit if
+ musl libc
+
+Musl libc defines `pthread_getattr_np` but it can not get the correct
+value of the main thread.
+---
+ thread_pthread.c | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/thread_pthread.c b/thread_pthread.c
+index 493350b52055af..9199edc3543e59 100644
+--- a/thread_pthread.c
++++ b/thread_pthread.c
+@@ -1791,6 +1791,11 @@ native_thread_destroy(struct rb_native_thread *nt)
  
--#if MAINSTACKADDR_AVAILABLE
-+#if MAINSTACKADDR_AVAILABLE && !(defined(__linux__) && !defined(__GLIBC__))
-     if (native_main_thread.stack_maxsize) return;
-     {
-         void* stackaddr;
-@@ -2090,7 +2090,7 @@
- 
- #ifdef STACKADDR_AVAILABLE
-     if (get_stack(&base, &size) == 0) {
--# ifdef __APPLE__
-+# if defined(__APPLE__) || (defined(__linux__) && !defined(__GLIBC__))
-         if (pthread_equal(th->nt->thread_id, native_main_thread.id)) {
-             struct rlimit rlim;
-             if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur > size) {
+ #if defined HAVE_PTHREAD_GETATTR_NP || defined HAVE_PTHREAD_ATTR_GET_NP
+ #define STACKADDR_AVAILABLE 1
++# if defined(__linux__) && !defined __GLIBC__
++    /* Musl libc defines `pthread_getattr_np` but it can not get the
++     * correct value of the main thread. */
++#   define MAINSTACKADDR_AVAILABLE 0
++# endif
+ #elif defined HAVE_PTHREAD_GET_STACKADDR_NP && defined 
HAVE_PTHREAD_GET_STACKSIZE_NP
+ #define STACKADDR_AVAILABLE 1
+ #undef MAINSTACKADDR_AVAILABLE
+

Reply via email to