Compiling gem for i386-mingw32 / Ruby 2.2.1 using RubyInstaller version

203 views
Skip to first unread message

Anthony Bargnesi

unread,
Mar 13, 2015, 12:01:14 PM3/13/15
to rubyin...@googlegroups.com
Hey folks,

First post here for me. Thank you for all the hard work making this possible.

Apologies if this is not the proper channel, but I did not want to create a github issue.

-----

I am building a gem and cross compiling using rake-compiler / mingw. I hit an error (terminal video showing problem) using "rake-compiler cross-ruby VERSION=2.2.1" related to win32ole.

My thoughts then were to just download the i386-mingw32 build from RubyInstaller and configure it within ~/.rake-compiler/config.yml:

~/rake-compiler/config.yml
---
rbconfig-i386-mingw32-2.2.1: "/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/lib/ruby/2.2.0/i386-mingw32/rbconfig.rb"
rbconfig-x64-mingw32-2.2.1: "/home/tony/.rake-compiler/ruby/x64-mingw32/ruby-2.2.1-x64-mingw32/lib/ruby/2.2.0/x64-mingw32/rbconfig.rb"

I updated the CONFIG["prefix"] within rbconfig.rb to reflect the ruby prefix (i.e. /home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32). Then I ran "rake cross compile" and received the following errors when including ruby.h:

video showing this error
-----

In file included from /home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/ruby.h:24:0,
                 from /home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby.h:33,
                 from ../../../../ext/mri/libbel.c:1:
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/i386-mingw32/ruby/config.h:161:15: error: two or more data types in declaration specifiers
 #define gid_t int
               ^
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/i386-mingw32/ruby/config.h:160:15: error: two or more data types in declaration specifiers
 #define uid_t int
               ^
In file included from /home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby.h:33:0,
                 from ../../../../ext/mri/libbel.c:1:
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/ruby.h:107:14: error: size of array ‘ruby_check_sizeof_long’ is negative
 typedef char ruby_check_sizeof_long[SIZEOF_LONG == sizeof(long) ? 1 : -1];
              ^
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/ruby.h:111:14: error: size of array ‘ruby_check_sizeof_voidp’ is negative
 typedef char ruby_check_sizeof_voidp[SIZEOF_VOIDP == sizeof(void*) ? 1 : -1];
              ^
In file included from /home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby.h:33:0,
                 from ../../../../ext/mri/libbel.c:1:
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/ruby.h: In function ‘rb_int2num_inline’:
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/ruby.h:1303:5: warning: comparison is always true due to limited range of data type [-Wtype-limits]
     if (FIXABLE(v))
     ^
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/ruby.h:1303:5: warning: comparison is always true due to limited range of data type [-Wtype-limits]
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/ruby.h: In function ‘rb_uint2num_inline’:
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/ruby.h:1313:5: warning: comparison is always true due to limited range of data type [-Wtype-limits]
     if (POSFIXABLE(v))
     ^
In file included from /home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/intern.h:35:0,
                 from /home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/ruby.h:1710,
                 from /home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby.h:33,
                 from ../../../../ext/mri/libbel.c:1:
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/st.h: At top level:
/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/include/ruby-2.2.0/ruby/st.h:52:14: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
 typedef char st_check_for_sizeof_st_index_t[SIZEOF_VOIDP == (int)sizeof(st_index_t) ? 1 : -1];
              ^
-----

Does anyone successfully cross compiled ruby 2.2.1 to MinGW using 64-bit linux? I'm using Ubuntu 14.04 64 bit.

Or maybe pointers on how to use the cross compiled RubyInstaller builds in rake-compiler?

Thanks! Great work!

Anthony Bargnesi

Justin Baker

unread,
Mar 13, 2015, 10:16:55 PM3/13/15
to rubyin...@googlegroups.com
Hey!

On Fri, Mar 13, 2015 at 10:45 AM, Anthony Bargnesi <abar...@gmail.com> wrote:
Hey folks,

First post here for me. Thank you for all the hard work making this possible.

Apologies if this is not the proper channel, but I did not want to create a github issue.

-----

I am building a gem and cross compiling using rake-compiler / mingw. I hit an error (terminal video showing problem) using "rake-compiler cross-ruby VERSION=2.2.1" related to win32ole.

We were having a problem with win32ole and Ruby 2.2.0, but we are actually able to compile 2.2.1.
So, I don't know what could cause it to compile here but not there since it is the same compiler.

My thoughts then were to just download the i386-mingw32 build from RubyInstaller and configure it within ~/.rake-compiler/config.yml:

~/rake-compiler/config.yml
---
rbconfig-i386-mingw32-2.2.1: "/home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32/lib/ruby/2.2.0/i386-mingw32/rbconfig.rb"
rbconfig-x64-mingw32-2.2.1: "/home/tony/.rake-compiler/ruby/x64-mingw32/ruby-2.2.1-x64-mingw32/lib/ruby/2.2.0/x64-mingw32/rbconfig.rb"

I updated the CONFIG["prefix"] within rbconfig.rb to reflect the ruby prefix (i.e. /home/tony/.rake-compiler/ruby/i386-mingw32/ruby-2.2.1-i386-mingw32). Then I ran "rake cross compile" and received the following errors when including ruby.h:

video showing this error

I actually have no idea how rake-compiler works. =/

Luis used to maintain it and could have answered that, but he isn't anymore.
I do kinda want to know, so give me the weekend to poke around and I'll let you know.
 

Does anyone successfully cross compiled ruby 2.2.1 to MinGW using 64-bit linux? I'm using Ubuntu 14.04 64 bit.

Or maybe pointers on how to use the cross compiled RubyInstaller builds in rake-compiler?

Thanks! Great work!

I actually have no idea if that would even work.
Again sorry about my ignorance.

Justin

Anthony Bargnesi

unread,
Mar 14, 2015, 3:21:40 PM3/14/15
to rubyin...@googlegroups.com
Justin,

Thanks! I will try to dig deeper as well.

I was able to cross compile Ruby 1.9.3 and published a multi-platform pre-release gem (bel 0.3.0.beta1).

When I tried installing into RubyInstaller 2.0.0 I think I ran up on the ABI compatibility issue from 1.9.3 to 2.0.0.

I will let you know as well if I discover more.

Tony

Anthony Bargnesi

unread,
Mar 14, 2015, 10:50:30 PM3/14/15
to rubyin...@googlegroups.com
Justin,

I tried cross compiling the latest snapshot for Ruby 2.2.2 and received the same win32ole errors. I copied all of the 2.2.2 snapshot source into the failing build and ran like:

rake-compiler cross-ruby VERSION=2.2.1

-----
make[2]: Leaving directory `/home/tony/.rake-compiler/builds/i586-mingw32msvc/ruby-2.2.1/ext/win32'
make[2]: Entering directory `/home/tony/.rake-compiler/builds/i586-mingw32msvc/ruby-2.2.1/ext/win32ole'
compiling win32ole.c
win32ole.c: In function ‘ole_variant2val’:
win32ole.c:1452: warning: implicit declaration of function ‘V_RECORDINFO’
win32ole.c:1452: error: lvalue required as unary ‘&’ operand
win32ole.c:1460: warning: implicit declaration of function ‘V_RECORD’
win32ole.c:1460: error: lvalue required as unary ‘&’ operand
win32ole.c:1658: warning: initialization makes pointer from integer without a cast
win32ole.c:1659: warning: initialization makes pointer from integer without a cast
win32ole.c: In function ‘ole_invoke’:
win32ole.c:2765: warning: passing argument 2 of ‘olerecord_set_ivar’ makes pointer from integer without a cast
win32ole.c:2765: warning: passing argument 3 of ‘olerecord_set_ivar’ makes pointer from integer without a cast
make[2]: *** [win32ole.o] Error 1
make[2]: Leaving directory `/home/tony/.rake-compiler/builds/i586-mingw32msvc/ruby-2.2.1/ext/win32ole'
make[1]: *** [ext/win32ole/all] Error 2
make[1]: Leaving directory `/home/tony/.rake-compiler/builds/i586-mingw32msvc/ruby-2.2.1'
make: *** [build-ext] Error 2
/home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/file_utils.rb:66:in `block in create_shell_runner': Command failed with status (2): [make...] (RuntimeError)
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/file_utils.rb:57:in `call'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/file_utils.rb:57:in `sh'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/file_utils_ext.rb:37:in `sh'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rake-compiler-0.9.5/tasks/bin/cross-ruby.rake:155:in `block (2 levels) in <top (required)>'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/fileutils.rb:127:in `chdir'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/fileutils.rb:127:in `cd'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/file_utils_ext.rb:37:in `chdir'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/gems/2.2.0/gems/rake-compiler-0.9.5/tasks/bin/cross-ruby.rake:154:in `block in <top (required)>'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/task.rb:238:in `call'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/task.rb:238:in `block in execute'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `each'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/task.rb:235:in `execute'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/task.rb:179:in `block in invoke_with_call_chain'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/monitor.rb:211:in `mon_synchronize'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/task.rb:172:in `invoke_with_call_chain'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/task.rb:201:in `block in invoke_prerequisites'
  from /home/tony/.rbenv/versions/2.2.1/lib/ruby/2.2.0/rake/task.rb:199:in `each'
-----

I also noticed that the rake-compiler-dev-box only includes up to 2.1.x in their cross-compile rubies. It may be that there aren't any breaking ABI changes between 2.1 and 2.2, but I am still curious of the win32ole faliures.

Tony

Justin Baker

unread,
Mar 19, 2015, 8:25:31 PM3/19/15
to rubyin...@googlegroups.com
Hey sorry on my lack of an update.

Ends up there's a bug that is breaking cross-compilation for Ruby 2.2 on other platforms.

Luis, graciously, let me know earlier this week about that and pointed me a bug report in rake-compiler-dev-box.

So, it requires a source change in Ruby itself and Ruby 2.2.1 natively installed.

Hope that helps,
Justin
Reply all
Reply to author
Forward
0 new messages