From f5d6088c5a42af6035e98ab814de7f50bfaa55c8 Mon Sep 17 00:00:00 2001 From: Sam James Date: Thu, 23 Apr 2026 03:28:07 +0100 Subject: [PATCH] dev-lang/ruby: avoid UB with coroutines for 4.0.x Define RB_THREAD_CURRENT_EC_NOINLINE to always make a function call to get the coroutine execution context. Without it, GCC 16's x86 CSE pass will (with TLS descriptors at least) cache the value. 971174054a26be0a4becbe7c67a7cc980158abf2 added the convenient macro in 4.0.0, so for older releases, we'll have to patch instead. Bug: https://bugs.ruby-lang.org/issues/20243 Bug: https://gcc.gnu.org/PR124995 Closes: https://bugs.gentoo.org/972696 Signed-off-by: Sam James --- dev-lang/ruby/{ruby-4.0.3.ebuild => ruby-4.0.3-r1.ebuild} | 2 ++ dev-lang/ruby/ruby-4.0.9999.ebuild | 2 ++ 2 files changed, 4 insertions(+) rename dev-lang/ruby/{ruby-4.0.3.ebuild => ruby-4.0.3-r1.ebuild} (99%) diff --git a/dev-lang/ruby/ruby-4.0.3.ebuild b/dev-lang/ruby/ruby-4.0.3-r1.ebuild similarity index 99% rename from dev-lang/ruby/ruby-4.0.3.ebuild rename to dev-lang/ruby/ruby-4.0.3-r1.ebuild index c7a940bd060f7..3adfb863e1d17 100644 --- a/dev-lang/ruby/ruby-4.0.3.ebuild +++ b/dev-lang/ruby/ruby-4.0.3-r1.ebuild @@ -209,6 +209,8 @@ src_configure() { append-flags -fno-strict-aliasing # Fails to link (gcc PR124865, gcc PR50676) filter-flags -flto-partition=cache + # bug #972696 + append-cppflags -DRB_THREAD_CURRENT_EC_NOINLINE # Workaround for bug #938302 if use systemtap && has_version "dev-debug/systemtap[-dtrace-symlink(+)]" ; then diff --git a/dev-lang/ruby/ruby-4.0.9999.ebuild b/dev-lang/ruby/ruby-4.0.9999.ebuild index c7a940bd060f7..3adfb863e1d17 100644 --- a/dev-lang/ruby/ruby-4.0.9999.ebuild +++ b/dev-lang/ruby/ruby-4.0.9999.ebuild @@ -209,6 +209,8 @@ src_configure() { append-flags -fno-strict-aliasing # Fails to link (gcc PR124865, gcc PR50676) filter-flags -flto-partition=cache + # bug #972696 + append-cppflags -DRB_THREAD_CURRENT_EC_NOINLINE # Workaround for bug #938302 if use systemtap && has_version "dev-debug/systemtap[-dtrace-symlink(+)]" ; then