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

Ruby 2.5.0 #2143

Merged
merged 2 commits into from
Apr 22, 2018
Merged

Ruby 2.5.0 #2143

merged 2 commits into from
Apr 22, 2018

Conversation

carlhoerberg
Copy link
Contributor

Started to implement ruby 2.5.0. But got some problems. It stops compiling at:

make[1]: Leaving directory '/home/vagrant/.termux-build/ruby/build'
generating makefile exts.mk
exts.mk updated
make[1]: Entering directory '/home/vagrant/.termux-build/ruby/build'
make[2]: Entering directory '/home/vagrant/.termux-build/ruby/build/ext/cgi/escape'
make[2]: Entering directory '/home/vagrant/.termux-build/ruby/build/ext/fiddle'
compiling /home/vagrant/.termux-build/ruby/src/ext/cgi/escape/escape.c
compiling /home/vagrant/.termux-build/ruby/src/ext/fiddle/closure.c
compiling /home/vagrant/.termux-build/ruby/src/ext/fiddle/conversions.c
linking shared-object cgi/escape.so
make[2]: Leaving directory '/home/vagrant/.termux-build/ruby/build/ext/cgi/escape'
make[2]: Entering directory '/home/vagrant/.termux-build/ruby/build/ext/etc'
generating constant definitions
/home/vagrant/.termux-build/ruby/build/rbconfig.rb:13:in `<module:RbConfig>': ruby lib version (2.5.0) doesn't match executable version (2.3.3) (RuntimeError)
        from /home/vagrant/.termux-build/ruby/build/rbconfig.rb:11:in `<top (required)>'
        from /usr/lib/ruby/2.3.0/rubygems.rb:9:in `require'
        from /usr/lib/ruby/2.3.0/rubygems.rb:9:in `<top (required)>'
        from <internal:gem_prelude>:4:in `require'
        from <internal:gem_prelude>:4:in `<internal:gem_prelude>'
Makefile:273: recipe for target 'constdefs.h' failed
make[2]: *** [constdefs.h] Error 1
make[2]: Leaving directory '/home/vagrant/.termux-build/ruby/build/ext/etc'
exts.mk:94: recipe for target 'ext/etc/all' failed
make[1]: *** [ext/etc/all] Error 2
make[1]: *** Waiting for unfinished jobs....
compiling /home/vagrant/.termux-build/ruby/src/ext/fiddle/fiddle.c
compiling /home/vagrant/.termux-build/ruby/src/ext/fiddle/function.c
compiling /home/vagrant/.termux-build/ruby/src/ext/fiddle/handle.c
compiling /home/vagrant/.termux-build/ruby/src/ext/fiddle/pointer.c
linking shared-object fiddle.so
make[2]: Leaving directory '/home/vagrant/.termux-build/ruby/build/ext/fiddle'
make[1]: Leaving directory '/home/vagrant/.termux-build/ruby/build'
uncommon.mk:240: recipe for target 'build-ext' failed
make: *** [build-ext] Error 2

@carlhoerberg
Copy link
Contributor Author

It fails because build/ext/etc/Makefile has

ruby = /usr/bin/ruby -I'$(topdir)'

instead of

ruby = /usr/bin/ruby --disable=gems -I/home/vagrant/.termux-build/ruby/build -raarch64-linux-android-fake  -I'$(topdir)'

build/ext/etc/Makefile is generated by build/ext/etc/exts.mk which is generated by src/template/exts.mk.tmpl, which includes some pretty crazy code, and it's not really clear to me where the ruby = /usr/bin/ruby ... lines comes from..

Continuing digging...

@tomty89
Copy link
Contributor

tomty89 commented Feb 16, 2018

Just tried to build ruby 2.5.0 on Termux, went well with the vanilla source (without any patch) and ./configure --prefix=$PREFIX/local; make; make install

From the error it seems to be caused by the existing ruby installation on the build system? I tested without ruby installed, maybe I should test the other case...

@carlhoerberg
Copy link
Contributor Author

seems to be here it's defined: https://github.com/ruby/ruby/blob/5a06ce9e1fae64b10e3fd599c6a6dbbedf5bf3e5/lib/mkmf.rb#L2003

which in turn is defined here: https://github.com/ruby/ruby/blob/5a06ce9e1fae64b10e3fd599c6a6dbbedf5bf3e5/lib/mkmf.rb#L2621

arg_config("--ruby", ... extracts an arguments that's passed to mkfs.rb (as --ruby ...), but haven't found where yet.

@tomty89
Copy link
Contributor

tomty89 commented Feb 16, 2018

Also builds fine with ruby 2.4.3 installed from Termux repo, with or without --enable-shared:

$ ldd $PREFIX/local/bin/ruby                                                       
libruby.so.2.5
libc.so
libdl.so
libcrypt.so
libm.so
$ LD_PRELOAD=$PREFIX/local/lib/libruby.so $PREFIX/local/bin/ruby
WARNING: linker: /data/data/com.termux/files/usr/local/bin/ruby: unused DT entry: type 0xf arg 0x109
WARNING: linker: /data/data/com.termux/files/usr/local/lib/ruby/2.5.0/aarch64-linux/enc/encdb.so: unused DT entry: type 0xf arg 0x113
WARNING: linker: /data/data/com.termux/files/usr/local/lib/ruby/2.5.0/aarch64-linux/enc/trans/transdb.so: unused DT entry: type 0xf arg 0xb3                          
WARNING: linker: /data/data/com.termux/files/usr/local/lib/ruby/2.5.0/aarch64-linux/stringio.so: unused DT entry: type 0xf arg 0x5ee
^CTraceback (most recent call last):
/data/data/com.termux/files/usr/local/bin/ruby: Interrupt

$

@carlhoerberg
Copy link
Contributor Author

@tomty89 yeah, it's cross compilation from linux that doesn't work with 2.5... which is required for building termux packages.

@tomty89
Copy link
Contributor

tomty89 commented Feb 16, 2018

@carlhoerberg it should not have /usr/bin/ruby at all (we don't need/want the system ruby to build ruby):

$ find ruby-2.5.0-shared/ -name exts.mk -exec grep 'ruby =' {} \; | uniq
ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' \
$ find ruby-2.5.0-shared/ -name Makefile -exec grep 'ruby =' {} \; | uniq
ruby = $(topdir)/miniruby -I'$(topdir)' -I'$(top_srcdir)/lib' -I'$(extout)/$(arch)' -I'$(extout)/common'
$ grep topdir ruby-2.5.0-shared/rbconfig.rb
  CONFIG["topdir"] = File.dirname(__FILE__)
$ ./ruby-2.5.0-shared/miniruby --version
ruby 2.5.0p0 (2017-12-25 revision 61468) [aarch64-linux]
$

@carlhoerberg
Copy link
Contributor Author

carlhoerberg commented Feb 16, 2018 via email

@tomty89
Copy link
Contributor

tomty89 commented Feb 16, 2018

When cross compiling you must.

I guess it make sense. But isn't it supposed to be a requirement that the system ruby is of the same version we are going to build, as the error hinted?

@carlhoerberg
Copy link
Contributor Author

carlhoerberg commented Feb 16, 2018 via email

@carlhoerberg
Copy link
Contributor Author

New clues. Printing out $mflags in ext/extmk.rb line 454, in Ruby 2.4.3:

$mflags=["V=0", "MINIRUBY=/usr/bin/ruby --disable=gems -I/home/vagrant/.termux-build/ruby/build -raarch64-linux-android-fake ", "extout=$(topdir)/.ext", "extout_prefix=$(extout)$(target_prefix)/", "configure"]

In Ruby 2.5.0:

$mflags=["-j", "--jobserver-fds=4,5", "-j", "--jobserver-fds=4,5", "MINIRUBY=/usr/bin/ruby", "--disable=gems", "-I/home/vagrant/.termux-build/ruby/build", "-raarch64-linux-androi
d-fake", "extout=$(topdir)/.ext", "extout_prefix=$(extout)$(target_prefix)/", "configure"]

@carlhoerberg
Copy link
Contributor Author

Found the bug! An argument to a template generator wasn't escaped. Then a second bug where the new capacity argument to String didn't work with old versions of ruby that was used in fileutil, by rbinstall, executed by our local ruby version.

@carlhoerberg carlhoerberg changed the title WIP: Ruby 2.5.0 Ruby 2.5.0 Feb 17, 2018
@tomty89
Copy link
Contributor

tomty89 commented Feb 18, 2018

Then a second bug where the new capacity argument to String didn't work with old versions of ruby that was used in fileutil, by rbinstall, executed by our local ruby version.

That is not a bug? That just mean we should build it with ruby 2.4+ (which might be even the case in @fornwall 's build environment)

@carlhoerberg
Copy link
Contributor Author

carlhoerberg commented Feb 18, 2018 via email

@fornwall
Copy link
Member

Nice work and sorry for the late response! @carlhoerberg Could you update to ruby 2.5.1, after which I will merge it?

@carlhoerberg
Copy link
Contributor Author

done, thanks @fornwall

@fornwall fornwall merged commit e171d66 into termux:master Apr 22, 2018
@fornwall
Copy link
Member

Thanks! The updated package is now available for installation!

Note that I had to build 32-bit variants (arm and i686) with gcc to avoid the following build error with clang:

process.c:function timetick2integer: error: undefined reference to '__mulodi4'

This is the NDK issue android/ndk#294 which should be fixed in NDK r18.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants