[PATCH] ruby: update to ruby 2.5.1

14 views
Skip to first unread message

KANATSU Minoru

unread,
May 28, 2019, 10:00:03 AM5/28/19
to osv...@googlegroups.com, KANATSU Minoru
Signed-off-by: KANATSU Minoru <icc.pot...@gmail.com>
---
ruby/Makefile | 23 ++++++++-------
ruby/disable-fstat.patch | 16 -----------
ruby/no-ipv6.patch | 45 ------------------------------
ruby/no-use-sleepy-thread-timer-ruby.patch | 12 --------
4 files changed, 11 insertions(+), 85 deletions(-)
delete mode 100644 ruby/disable-fstat.patch
delete mode 100644 ruby/no-ipv6.patch
delete mode 100644 ruby/no-use-sleepy-thread-timer-ruby.patch

diff --git a/ruby/Makefile b/ruby/Makefile
index 5439367..5c937ef 100644
--- a/ruby/Makefile
+++ b/ruby/Makefile
@@ -3,7 +3,9 @@ module: usr.manifest

CFLAGS=-fPIC -Wall -shared

-RUBY_VER=2.2.4
+RUBY_VER_MAJOR=2.5
+RUBY_VER_MINOR=1
+RUBY_VER=${RUBY_VER_MAJOR}.${RUBY_VER_MINOR}

RUBY_LDFLAGS=-lm -lcrypt -ldl -lpthread -lruby
LIBS=-Lupstream/ruby
@@ -20,9 +22,6 @@ version_check:
upstream/ruby: version_check
mkdir -p upstream
cd upstream && git clone --depth 1 -b v$(subst .,_,${RUBY_VER}) https://github.com/ruby/ruby.git
- cd upstream/ruby && patch -p1 < ../../no-use-sleepy-thread-timer-ruby.patch
- cd upstream/ruby && patch -p1 < ../../no-ipv6.patch
- cd upstream/ruby && patch -p1 < ../../disable-fstat.patch
cd upstream/ruby && autoconf
cd upstream/ruby && ./configure --libdir=/usr/lib --enable-pic --enable-shared --disable-install-doc --disable-install-rdoc --disable-ipv6

@@ -56,7 +55,7 @@ usr.manifest: ruby.so upstream/bundler upstream/cert.pem
cp -a ./upstream/bundler/lib/* ./upstream/ruby/lib/
echo '/ruby.so: $${MODULE_DIR}/ruby.so' > usr.manifest
echo '/**: $${MODULE_DIR}/upstream/ruby/bin/**' >> usr.manifest
- echo '/libruby.so.2.2: $${MODULE_DIR}/upstream/ruby/libruby.so' >> usr.manifest
+ echo '/libruby.so.${RUBY_VER_MAJOR}: $${MODULE_DIR}/upstream/ruby/libruby.so' >> usr.manifest
echo '/usr/share/ruby/**: $${MODULE_DIR}/upstream/ruby/lib/**' >> usr.manifest
echo '/usr/lib64/ruby/rbconfig.rb: $${MODULE_DIR}/upstream/ruby/rbconfig.rb' >> usr.manifest
echo '/usr/lib64/ruby/**: $${MODULE_DIR}/upstream/ruby/.ext/x86_64-linux/**' >> usr.manifest
@@ -68,15 +67,15 @@ usr.manifest: ruby.so upstream/bundler upstream/cert.pem
: > bootfs.manifest

ROOTFS: module
- mkdir -p ./ROOTFS/usr/lib/ruby/2.2.0/x86_64-linux
- cp -a ./upstream/ruby/.ext/common/* ./ROOTFS/usr/lib/ruby/2.2.0
- cp -a ./upstream/bundler/lib/* ./ROOTFS/usr/lib/ruby/2.2.0
+ mkdir -p ./ROOTFS/usr/lib/ruby/${RUBY_VER_MAJOR}.0/x86_64-linux
+ cp -a ./upstream/ruby/.ext/common/* ./ROOTFS/usr/lib/ruby/${RUBY_VER_MAJOR}.0
+ cp -a ./upstream/bundler/lib/* ./ROOTFS/usr/lib/ruby/${RUBY_VER_MAJOR}.0
cp ruby.so ./ROOTFS/
cp -a ./upstream/ruby/bin/* ./ROOTFS/
- cp ./upstream/ruby/libruby.so ./ROOTFS/libruby.so.2.2
- cp -a ./upstream/ruby/lib/* ./ROOTFS/usr/lib/ruby/2.2.0
- cp ./upstream/ruby/rbconfig.rb ./ROOTFS/usr/lib/ruby/2.2.0/x86_64-linux/rbconfig.rb
- cp -a ./upstream/ruby/.ext/x86_64-linux/* ./ROOTFS/usr/lib/ruby/2.2.0/x86_64-linux/
+ cp ./upstream/ruby/libruby.so ./ROOTFS/libruby.so.${RUBY_VER_MAJOR}
+ cp -a ./upstream/ruby/lib/* ./ROOTFS/usr/lib/ruby/${RUBY_VER_MAJOR}.0
+ cp ./upstream/ruby/rbconfig.rb ./ROOTFS/usr/lib/ruby/${RUBY_VER_MAJOR}.0/x86_64-linux/rbconfig.rb
+ cp -a ./upstream/ruby/.ext/x86_64-linux/* ./ROOTFS/usr/lib/ruby/${RUBY_VER_MAJOR}.0/x86_64-linux/
mkdir -p ./ROOTFS/usr/local/ssl
cp ./upstream/cert.pem ./ROOTFS/usr/local/ssl/cert.pem
find upstream/ruby/.ext/x86_64-linux/ -name '*.so' -exec ldd {} \;|awk '{print "cp",$$3,"./ROOTFS/"}'|grep "/lib"|grep -v "ld-linux"|grep -v "libc.so"|grep -v "libpthread.so"|grep -v "libdl.so"|grep -v "libm.so"|grep -v "libruby.so"|sort|uniq > tmp.sh
diff --git a/ruby/disable-fstat.patch b/ruby/disable-fstat.patch
deleted file mode 100644
index cebd7d3..0000000
--- a/ruby/disable-fstat.patch
+++ /dev/null
@@ -1,16 +0,0 @@
-diff --git a/io.c b/io.c
-index 9522990..3610b39 100644
---- a/io.c
-+++ b/io.c
-@@ -185,9 +185,11 @@ rb_update_max_fd(int fd)
- struct stat buf;
- rb_atomic_t afd = (rb_atomic_t)fd;
-
-+#if 0
- if (fstat(fd, &buf) != 0 && errno == EBADF) {
- rb_bug("rb_update_max_fd: invalid fd (%d) given.", fd);
- }
-+#endif
-
- while (max_file_descriptor < afd) {
- ATOMIC_CAS(max_file_descriptor, max_file_descriptor, afd);
diff --git a/ruby/no-ipv6.patch b/ruby/no-ipv6.patch
deleted file mode 100644
index 1f6835a..0000000
--- a/ruby/no-ipv6.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-diff --git a/ext/socket/getaddrinfo.c b/ext/socket/getaddrinfo.c
-index a17d12b..0279577 100644
---- a/ext/socket/getaddrinfo.c
-+++ b/ext/socket/getaddrinfo.c
-@@ -49,8 +49,10 @@
- # include <net/socket.h>
- #else
- # include <sys/socket.h>
-+#undef AF_INET6
- #endif
- #include <netinet/in.h>
-+#undef IPPROTO_IPV6
- #if defined(HAVE_ARPA_INET_H)
- #include <arpa/inet.h>
- #endif
-diff --git a/ext/socket/getnameinfo.c b/ext/socket/getnameinfo.c
-index 4da9680..a574f5a 100644
---- a/ext/socket/getnameinfo.c
-+++ b/ext/socket/getnameinfo.c
-@@ -45,8 +45,10 @@
- # include <net/socket.h>
- #else
- # include <sys/socket.h>
-+#undef AF_INET6
- #endif
- #include <netinet/in.h>
-+#undef IPPROTO_IPV6
- #if defined(HAVE_ARPA_INET_H)
- #include <arpa/inet.h>
- #endif
-diff --git a/ext/socket/rubysocket.h b/ext/socket/rubysocket.h
-index a4893d9..7325f64 100644
---- a/ext/socket/rubysocket.h
-+++ b/ext/socket/rubysocket.h
-@@ -31,8 +31,10 @@
- # include <net/socket.h>
- # else
- # include <sys/socket.h>
-+#undef AF_INET6
- # endif
- # include <netinet/in.h>
-+#undef IPPROTO_IPV6
- # ifdef HAVE_NETINET_IN_SYSTM_H
- # include <netinet/in_systm.h>
- # endif
diff --git a/ruby/no-use-sleepy-thread-timer-ruby.patch b/ruby/no-use-sleepy-thread-timer-ruby.patch
deleted file mode 100644
index 8b9952b..0000000
--- a/ruby/no-use-sleepy-thread-timer-ruby.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Nur ruby.orig/thread_pthread.c ruby/thread_pthread.c
---- ruby.orig/thread_pthread.c 2014-06-20 07:44:27.131259578 +0900
-+++ ruby/thread_pthread.c 2014-06-20 07:44:43.612250114 +0900
-@@ -59,7 +59,7 @@
-
- #if defined(HAVE_POLL) && defined(HAVE_FCNTL) && defined(F_GETFL) && defined(F_SETFL) && defined(O_NONBLOCK) && !defined(__native_client__)
- /* The timer thread sleeps while only one Ruby thread is running. */
--# define USE_SLEEPY_TIMER_THREAD 1
-+# define USE_SLEEPY_TIMER_THREAD 0
- #else
- # define USE_SLEEPY_TIMER_THREAD 0
- #endif
--
2.14.5

Waldek Kozaczuk

unread,
Jun 5, 2019, 11:45:28 PM6/5/19
to OSv Development
Hi,

Thanks for the patch and sorry for the delay reviewing it. I had to test it using ruby 2.5.5 so I changed minor version in the makefile from 1 to 5.

The app definitively builds on both Ubuntu 19.04 and Fedora 29 and runs irb however there are couple of problems I have found:
  •  it builds 1st time but then subsequently when I do ./scripts/build image=ruby I get an error: 
    cd upstream && git clone --depth 1 -b v2_5_5 https://github.com/ruby/ruby.git
    fatal: destination path 'ruby' already exists and is not an empty directory.
    make: *** [Makefile:24: upstream/ruby] Error 128 
  • on Fedora I see duplicate entry of libruby.so - the first from the app upstream directory and the other from the host:
    libruby.so.2.5: /lib64/libruby.so.2.5
The minor issue is that the delete button does not work - the terminal needs to be set?

I also noticed this patch deletes number of patches. I am not familiar with C Ruby code but I presume you have verified/tested they are not needed with new Ruby, correct?. For example I saw that this fstat related issue about special files is still open - https://github.com/cloudius-systems/osv/issues/519. So maybe new ruby does not use fstat this way anymore.

It would be also nice to minimize things we have to build. For example the biggest artifact libruby.so.2.5 could be directly taken from host. I think the only thing we need to build is the main - ruby.so. Please take a look at python2x and python3x for a good example.

Finally if we can avoid any building and take everything as is from host that would be best. We have a brand new script ./scripts/manifest_from_host.sh that can be used for that (please see this commit for explanation - https://github.com/cloudius-systems/osv/commit/83128b2b10b641ab09892954eb2bdeffaea5e869). Obviously for that we would have to bring on obstack implementation. I think we can come up with some minimal implementation based on this tiny example - https://git.busybox.net/uClibc/tree/libc/misc/gnu/obprintf.c.

Regards,
Waldek

On Tuesday, May 28, 2019 at 10:00:03 AM UTC-4, KANATSU Minoru wrote:
Signed-off-by: KANATSU Minoru <icc.po...@gmail.com>
Reply all
Reply to author
Forward
0 new messages