Commit 5ed0f177 authored by TBK's avatar TBK Committed by Leo

main/ruby: switch to ucontext

parent 9d2c2ffd
......@@ -38,13 +38,13 @@
pkgname=ruby
pkgver=2.7.2
_abiver="${pkgver%.*}.0"
pkgrel=0
pkgrel=1
pkgdesc="An object-oriented language for quick and easy programming"
url="https://www.ruby-lang.org/"
arch="all"
license="Ruby BSD-2-Clause"
license="Ruby AND BSD-2-Clause AND MIT"
depends="ca-certificates"
depends_dev="$pkgname=$pkgver-r$pkgrel gmp-dev"
depends_dev="$pkgname=$pkgver-r$pkgrel gmp-dev libucontext-dev"
makedepends="$depends_dev zlib-dev openssl-dev gdbm-dev readline-dev
libffi-dev coreutils yaml-dev linux-headers autoconf"
install="$pkgname.post-upgrade"
......@@ -72,7 +72,6 @@ source="https://cache.ruby-lang.org/pub/ruby/${pkgver%.*}/ruby-$pkgver.tar.gz
rubygems-avoid-platform-specific-gems.patch
test_insns-lower-recursion-depth.patch
fix-get_main_stack.patch
arm-coroutines.patch
"
replaces="ruby-gems"
......@@ -85,14 +84,6 @@ case "$CARCH" in
*) _arch="$CARCH";;
esac
# s390x/mips require libucontext
case "$CARCH" in
s390x|mips*)
depends_dev="$depends_dev libucontext-dev"
makedepends="$makedepends libucontext-dev"
;;
esac
case "$CARCH" in
x86|x86_64|s390x) options="$options !check" ;; # Tests deadlock under musl>=1.2.0-r0
esac
......@@ -107,14 +98,14 @@ done
prepare() {
default_prepare
# XXX: Fix broken symlinks pointing to nowhere.
rm tool/config.sub tool/config.guess
touch tool/config.sub tool/config.guess
update_config_sub
update_config_guess
autoconf
# v2.7.1 - Of all the bootstraptest only test_fiber fails on s390x:
# test_fiber.rb bootstraptest.tmp.rb:8: [BUG] vm_call_cfunc: cfp consistency error (0x000003ffb63fefb0, 0x000003ffb42f5f58)
case "$CARCH" in
s390x)
rm bootstraptest/test_fiber.rb ;;
esac
}
build() {
......@@ -124,17 +115,15 @@ build() {
export CFLAGS="$CFLAGS -fno-omit-frame-pointer -fno-strict-aliasing"
export CPPFLAGS="$CPPFLAGS -fno-omit-frame-pointer -fno-strict-aliasing"
# Needed for coroutine stuff
export LIBS="-lucontext"
# ruby saves path to install. we want use $PATH
export INSTALL=install
# the configure script does not detect isnan/isinf as macros
export ac_cv_func_isnan=yes
export ac_cv_func_isinf=yes
case "$CARCH" in
s390x|mips*)
export LIBS="-lucontext"
;;
esac
./configure \
--build=$CBUILD \
......@@ -143,7 +132,7 @@ build() {
--sysconfdir=/etc \
--mandir=/usr/share/man \
--infodir=/usr/share/info \
--with-sitedir='/usr/local/lib/site_ruby' \
--with-sitedir=/usr/local/lib/site_ruby \
--with-search-path="/usr/lib/site_ruby/\$(ruby_ver)/$_arch-linux" \
--enable-pthread \
--disable-rpath \
......@@ -353,8 +342,8 @@ _mvgem() {
done
}
sha512sums="e80dc16b60149d0d6fedf0ba7b556ae460ff328ee63e9d9e41f5021f67addcc98159cb27bddccaebd6e4b1cddf29266f1c01c32d9ec8bb665aed63c0a2295f2f ruby-2.7.2.tar.gz
cfdc5ea3b2e2ea69c51f38e8e2180cb1dc27008ca55cc6301f142ebafdbab31c3379b3b6bba9ff543153876dd98ed2ad194df3255b7ea77a62e931c935f80538 rubygems-avoid-platform-specific-gems.patch
814fe6359505b70d8ff680adf22f20a74b4dbd3fecc9a63a6c2456ee9824257815929917b6df5394ed069a6869511b8c6dce5b95b4acbbb7867c1f3a975a0150 test_insns-lower-recursion-depth.patch
8d730f02f76e53799f1c220eb23e3d2305940bb31216a7ab1e42d3256149c0721c7d173cdbfe505023b1af2f5cb3faa233dcc1b5d560fa8f980c17c2d29a9d81 fix-get_main_stack.patch
0300bd6f596db73603e9bf1b1ccbc09da27dc2082aa00ef6cecef474809bb91248739375c405e43819e86b0c8cee8dedefdad102478082eba011bdc795e657c7 arm-coroutines.patch"
a142199140fa711a64717429e9069fd2082319abaf4b129f561db374b3bc16e2a90cc4c849b5d28334505d1c71fed242aef3c44d983da3513d239dcb778673a5 rubygems-avoid-platform-specific-gems.patch
43c1fc80f0dcb4f24d891478889808583da90dc9e0df74c3b1cf41253c13a0d416d2b7ae17e7d53ac1238340a845b088f0fe20324a79905cc6b950b3dcfa4ac6 test_insns-lower-recursion-depth.patch
3ffc034c01110ee5531265333ca5ee8d61d08131843fe3004c5b34c88c9c1b32cb4ed89574f393177c8bd526e9c15da61ab344f93adf07b9148c561ee19e2eb5 fix-get_main_stack.patch"
Upstream: https://github.com/ruby/ruby/pull/2995
From 9ce598b91e6ec8a146eec57c751d18dbebd2db60 Mon Sep 17 00:00:00 2001
From: Paul Jordan <paullj1@gmail.com>
Date: Wed, 1 Apr 2020 02:13:49 +0100
Subject: [PATCH 1/3] ucontext doesn't exist in a musl-libc env; use native
assembly
---
configure.ac | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/configure.ac b/configure.ac
index 5bc93800efd1..a054d163b316 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2353,8 +2353,8 @@ AS_CASE([$rb_cv_coroutine], [yes|''], [
[*86-mingw32], [
rb_cv_coroutine=win32
],
- [armv7*-linux*], [
- rb_cv_coroutine=ucontext
+ [arm*-linux*], [
+ rb_cv_coroutine=arm32
],
[aarch64-linux*], [
rb_cv_coroutine=arm64
From e2f04a9a9684ea3575546cc317dd16dba54ecbaf Mon Sep 17 00:00:00 2001
From: Paul Jordan <paullj1@gmail.com>
Date: Wed, 1 Apr 2020 02:15:20 +0100
Subject: [PATCH 2/3] Patch assembly so that it aligns properly
---
coroutine/arm32/Context.S | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/test/fiddle/helper.rb b/test/fiddle/helper.rb
index 348131e4480f..f5c7bd2ca6c7 100644
--- a/test/fiddle/helper.rb
+++ b/test/fiddle/helper.rb
@@ -32,7 +32,11 @@
# libc.so and libm.so are installed to /lib/arm-linux-gnu*.
# It's not installed to /lib32.
dirs = Dir.glob('/lib/arm-linux-gnu*')
- libdir = dirs[0] if dirs && File.directory?(dirs[0])
+ if dirs.length > 0
+ libdir = dirs[0] if dirs && File.directory?(dirs[0])
+ else # handle alpine environment
+ libdir = '/lib' if File.directory? '/lib'
+ end
else
libdir = '/lib32' if File.directory? '/lib32'
end
@@ -40,8 +44,17 @@
# 64-bit ruby
libdir = '/lib64' if File.directory? '/lib64'
end
- libc_so = File.join(libdir, "libc.so.6")
- libm_so = File.join(libdir, "libm.so.6")
+
+ # Handle musl libc
+ libc = Dir.glob(File.join(libdir, "libc.musl*.so*"))
+ if libc && libc.length > 0
+ libc_so = libc[0]
+ libm_so = libc[0]
+ else
+ # glibc
+ libc_so = File.join(libdir, "libc.so.6")
+ libm_so = File.join(libdir, "libm.so.6")
+ end
when /mingw/, /mswin/
require "rbconfig"
crtname = RbConfig::CONFIG["RUBY_SO_NAME"][/msvc\w+/] || 'ucrtbase'
......@@ -2,7 +2,7 @@ diff --git a/thread_pthread.c b/thread_pthread.c
index 951885ffa0..cf90321d1d 100644
--- a/thread_pthread.c
+++ b/thread_pthread.c
@@ -530,9 +530,6 @@ hpux_attr_getstackaddr(const pthread_attr_t *attr, void **addr)
@@ -656,9 +656,6 @@ hpux_attr_getstackaddr(const pthread_attr_t *attr, void **addr)
# define MAINSTACKADDR_AVAILABLE 0
# endif
#endif
......@@ -12,7 +12,7 @@ index 951885ffa0..cf90321d1d 100644
#ifdef STACKADDR_AVAILABLE
/*
@@ -614,6 +611,55 @@ get_stack(void **addr, size_t *size)
@@ -740,6 +737,55 @@ get_stack(void **addr, size_t *size)
return 0;
#undef CHECK_ERR
}
......
......@@ -17,7 +17,7 @@ a platform-agnostic (source) gem. Users can override it using
--- a/lib/rubygems.rb
+++ b/lib/rubygems.rb
@@ -743,7 +743,10 @@
@@ -759,7 +759,10 @@
def self.platforms
@platforms ||= []
if @platforms.empty?
......
......@@ -36,7 +36,7 @@ so we hit SystemStackError sooner than on other platforms.
--- a/bootstraptest/test_insns.rb
+++ b/bootstraptest/test_insns.rb
@@ -248,7 +248,7 @@
@@ -276,7 +276,7 @@
end
}/ox
end
......@@ -44,4 +44,4 @@ so we hit SystemStackError sooner than on other platforms.
+ x = once(32); x = once(7); x = once(16);
x =~ "true" && $~
},
[ 'once', <<~'},', ], # {
[ 'once', <<-'},', ], # {
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment