Project

General

Profile

Actions

Bug #16384

closed

Cannot cross-compile 2.7: undefined method `each_builtin' for RubyVM:Class (NoMethodError)

Added by qnighy (Masaki Hara) over 4 years ago. Updated over 4 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]
[ruby-core:96034]

Description

Due to each_builtin existing only in miniruby, Ruby 2.7 cannot be built when configured for cross-compilation.

Environment

$ ruby -v
ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 18.04.3 LTS
Release:	18.04
Codename:	bionic
$ uname -a
Linux qnighy-michelle 4.15.0-66-generic #75-Ubuntu SMP Tue Oct 1 05:24:09 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux

Reproduction

Prepare Ruby 2.7.0-preview3

$ rbenv install 2.7.0-preview3
$ rbenv shell 2.7.0-preview3

Download a patched version of rake-compiler:

$ git clone https://github.com/rake-compiler/rake-compiler.git
$ cd rake-compiler
$ git checkout 6822686f0c45e752974de02a980365515e843267

Try generating rake-compiler toolchain:

$ rake -f bin/rake-compiler cross-ruby VERSION=2.7.0-preview3 HOST=x86_64-linux

I got the following output:

(...snip...)

compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/enc/trans/newline.c
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/missing/memcmp.c
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/missing/setproctitle.c
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/missing/strlcat.c
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/missing/strlcpy.c
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/addr2line.c
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/dmyenc.c
linking miniruby
generating x86_64-linux-gnu-fake.rb
x86_64-linux-gnu-fake.rb updated
generating encdb.h
encdb.h updated
/home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/tool/ifchange "--timestamp=.rbconfig.time" rbconfig.rb rbconfig.tmp
rbconfig.rb updated
generating enc.mk
making srcs under enc
make[1]: ディレクトリ '/home/qnighy/.rake-compiler/builds/x86_64-linux/ruby-2.7.0-preview3' に入ります
make[1]: 'srcs' に対して行うべき事はありません.
make[1]: ディレクトリ '/home/qnighy/.rake-compiler/builds/x86_64-linux/ruby-2.7.0-preview3' から出ます
generating transdb.h
transdb.h updated
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/dln.c
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/localeinit.c
creating verconf.h
verconf.h updated
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/loadpath.c
compiling /home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/prelude.c
Traceback (most recent call last):
/home/qnighy/.rake-compiler/sources/ruby-2.7.0-preview3/tool/mk_builtin_binary.rb:15:in `<main>': undefined method `each_builtin' for RubyVM:Class (NoMethodError)
uncommon.mk:1125: recipe for target 'builtin_binary.inc' failed
make: *** [builtin_binary.inc] Error 1
rake-compiler aborted!
Command failed with status (2): [make...]
/home/qnighy/workdir/rake-compiler/tasks/bin/cross-ruby.rake:161:in `block (2 levels) in <top (required)>'
/home/qnighy/workdir/rake-compiler/tasks/bin/cross-ruby.rake:160:in `block in <top (required)>'
/home/qnighy/workdir/rake-compiler/bin/rake-compiler:24:in `<top (required)>'
Tasks: TOP => cross-ruby => install => /home/qnighy/.rake-compiler/ruby/x86_64-linux/ruby-2.7.0-preview3/bin/ruby.exe => /home/qnighy/.rake-compiler/builds/x86_64-linux/ruby-2.7.0-preview3/ruby.exe
(See full trace by running task with --trace)

Expected behavior

The build command should succeed.

The problem seems to be that RubyVM::each_builtin is available only in ./miniruby. Ruby's configure script explicitly sets MINIRUBY as BASERUBY if configured for cross-compilation, so I suppose this is the bug on Ruby's side, not rake-compiler's.

Updated by hsbt (Hiroshi SHIBATA) over 4 years ago

  • Assignee set to ko1 (Koichi Sasada)
  • Status changed from Open to Assigned

Updated by qnighy (Masaki Hara) over 4 years ago

  • Description updated (diff)

Updated the description to refer to rake-compiler/rake-compiler instead of qnighy/rake-compiler. The necessary change to reproduce the problem has landed to upstream.

Updated by ko1 (Koichi Sasada) over 4 years ago

  • Status changed from Assigned to Closed

could you try on current master? It was fixed.
40026a408d

Updated by qnighy (Masaki Hara) over 4 years ago

I confirmed that the problem was fixed in cf948a3d3f and 2.7.0-rc1. Thank you for the fix!

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0