Issue #16384 has been updated by ko1 (Koichi Sasada).

Status changed from Assigned to Closed

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

----------------------------------------
Bug #16384: Cannot cross-compile 2.7: undefined method `each_builtin' for RubyVM:Class (NoMethodError)
https://bugs.ruby-lang.org/issues/16384#change-83204

* Author: qnighy (Masaki Hara)
* Status: Closed
* Priority: Normal
* Assignee: ko1 (Koichi Sasada)
* Target version: 
* ruby -v: ruby 2.7.0preview3 (2019-11-23 master b563439274) [x86_64-linux]
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN
----------------------------------------
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`](https://github.com/rake-compiler/rake-compiler/pull/161):

```
$ 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](https://github.com/ruby/ruby/blob/v2_7_0_preview3/configure.ac#L3031-L3043), so I suppose this is the bug on Ruby's side, not rake-compiler's.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>