rake-compiler / rake-compiler-dock

Easy to use and reliable cross compiler environment for building Windows, Linux, Mac and JRuby binary gems.
MIT License
77 stars 30 forks source link

Upgrade MinGW-w64 #4

Closed kou closed 9 years ago

kou commented 9 years ago

MinGW-w64 used in rake-compiler-dock has a bug described in https://bugs.ruby-lang.org/issues/7921 . (Building Ruby 2.0.0 with old MinGW-w64 causes a build error.)

https://bugs.ruby-lang.org/issues/7921#note-16 says that "the latest versions of mingw-w64 packages" (the comment was written at 2013) fix the problem.

Could you upgrade MinGW-w64 in rake-compiler-dock? We may be able to use MinGW-w64 in Ubuntu 15.04.

larskanis commented 9 years ago

The bug described is about gcc-4.5.4. Rake-compiler-dock is using 4.2.1 for ruby-1.8.7 and 1.9.3 and gcc-4.7.2 for ruby-2.0 to 2.2. So in my understanding it is no issue here.

I explicitly did not make use of gcc-4.8 or newer, because these versions changed the default for linking of libgcc. This breaks many cross build setups, because since libgcc is no longer static linked into the extension, the cross build has to explicitly request -static build or has to ship additional DLLs with the gem. Typically one or more of these: libwinpthread-1.dll libgcc_s_dw2-1.dll libgcc_s_sjlj-1.dll libgcc_s_seh-1.dll libstdc++-6.dll This change is mentioned in the Windows section of: https://gcc.gnu.org/gcc-4.8/changes.html

Did you encounter a real issue with the rake-compiler-dock?

kou commented 9 years ago

The bug described is about gcc-4.5.4. Rake-compiler-dock is using 4.2.1 for ruby-1.8.7 and 1.9.3 and gcc-4.7.2 for ruby-2.0 to 2.2. So in my understanding it is no issue here.

Sorry. I commented on only this topic. I'll comment on other topic later.

Did you encounter a real issue with the rake-compiler-dock?

Sorry about I didn't show real issue.

I tried rake-compiler-dock against msgpack gem but it failed:

% git clone -b rake-compiler-dock git@github.com:kou/msgpack-ruby.git
% cd msgpack-ruby
% bundle
% bundle exec rake windows:build

bundle exec rake windows:build (that runs rake-compiler-dock bash -c "bundle && rake cross native gem RUBY_CC_VERSION=2.0.0:2.1.6:2.2.2". See also https://github.com/kou/msgpack-ruby/blob/rake-compiler-dock/Rakefile#L70) failed with the following output:

no configuration section for specified version of Ruby (rbconfig-x86-mingw32-2.1.5)
no configuration section for specified version of Ruby (rbconfig-x64-mingw32-2.1.5)
rake-compiler-dock bash -c "bundle && rake cross native gem RUBY_CC_VERSION=2.0.0:2.1.6:2.2.2"
Fetching gem metadata from https://rubygems.org/...........
Fetching version metadata from https://rubygems.org/..
Resolving dependencies...
Installing rake 0.9.6
Installing highline 1.6.21
Installing myrrha 1.2.2
Installing quickl 0.4.3
Installing alf 0.10.1
Using bundler 1.10.5
Installing diff-lcs 1.2.5
Installing gnuplot 2.3.6
Installing json 1.8.3 with native extensions
Using msgpack 0.6.1 from source at .
Using rake-compiler 0.9.5
Installing rake-compiler-dock 0.4.3
Installing rspec-core 2.99.2
Installing rspec-expectations 2.99.2
Installing rspec-mocks 2.99.4
Installing rspec 2.99.0
Installing viiite 0.2.0
Installing yard 0.8.7.6
Bundle complete! 9 Gemfile dependencies, 18 gems now installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
cd tmp/x86-mingw32/msgpack/2.0.0
make
compiling ../../../../ext/msgpack/buffer_class.c
In file included from /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/defines.h:153:0,
                 from /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/ruby.h:70,
                 from /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby.h:33,
                 from ../../../../ext/msgpack/compat.h:22,
                 from ../../../../ext/msgpack/buffer_class.c:19:
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h: In function 'rb_w32_pow':
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h:801:5: warning: implicit declaration of function '_controlfp' [-Wimplicit-function-declaration]
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h:802:16: error: '_PC_64' undeclared (first use in this function)
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h:802:16: note: each undeclared identifier is reported only once for each function it appears in
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h:802:24: error: '_MCW_PC' undeclared (first use in this function)
make: *** [buffer_class.o] Error 1
rake aborted!
Command failed with status (2): [make...]
/usr/local/rvm/gems/ruby-2.2.2/gems/rake-compiler-0.9.5/lib/rake/extensiontask.rb:155:in `block (2 levels) in define_compile_tasks'
/usr/local/rvm/gems/ruby-2.2.2/gems/rake-compiler-0.9.5/lib/rake/extensiontask.rb:154:in `block in define_compile_tasks'
/usr/local/rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `eval'
/usr/local/rvm/gems/ruby-2.2.2/bin/ruby_executable_hooks:15:in `<main>'
Tasks: TOP => native => native:x86-mingw32 => native:msgpack:x86-mingw32 => tmp/x86-mingw32/stage/lib/msgpack/2.0/msgpack.so => copy:msgpack:x86-mingw32:2.0.0 => tmp/x86-mingw32/msgpack/2.0.0/msgpack.so
(See full trace by running task with --trace)
rake aborted!
Command failed with status (1): [docker run -v /tmp/msgpack-ruby:/tmp/msgpack-ruby -e UID\=1000 -e GID\=1000 -e USER\=kou -e GROUP\=kou -e ftp_proxy\= -e http_proxy\= -e https_proxy\= -e RCD_HOST_RUBY_PLATFORM\=x86_64-linux-gnu -e RCD_HOST_RUBY_VERSION\=2.1.5 -e RCD_IMAGE\=larskanis/rake-compiler-dock:0.4.2 -w /tmp/msgpack-ruby --rm -i -t larskanis/rake-compiler-dock:0.4.2 runas sigfw bash -c bundle\ \&\&\ rake\ cross\ native\ gem\ RUBY_CC_VERSION\=2.0.0:2.1.6:2.2.2]
/var/lib/gems/2.1.0/gems/rake-compiler-dock-0.4.3/lib/rake_compiler_dock/starter.rb:81:in `exec'
/var/lib/gems/2.1.0/gems/rake-compiler-dock-0.4.3/lib/rake_compiler_dock/starter.rb:14:in `sh'
/var/lib/gems/2.1.0/gems/rake-compiler-dock-0.4.3/lib/rake_compiler_dock.rb:29:in `sh'
/tmp/msgpack-ruby/Rakefile:70:in `block (2 levels) in <top (required)>'
Tasks: TOP => windows:build
(See full trace by running task with --trace)

It seems that the following error is similar to https://bugs.ruby-lang.org/issues/7921

compiling ../../../../ext/msgpack/buffer_class.c
In file included from /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/defines.h:153:0,
                 from /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/ruby.h:70,
                 from /usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby.h:33,
                 from ../../../../ext/msgpack/compat.h:22,
                 from ../../../../ext/msgpack/buffer_class.c:19:
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h: In function 'rb_w32_pow':
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h:801:5: warning: implicit declaration of function '_controlfp' [-Wimplicit-function-declaration]
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h:802:16: error: '_PC_64' undeclared (first use in this function)
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h:802:16: note: each undeclared identifier is reported only once for each function it appears in
/usr/local/rake-compiler/ruby/i686-w64-mingw32/ruby-2.0.0-p645/include/ruby-2.0.0/ruby/win32.h:802:24: error: '_MCW_PC' undeclared (first use in this function)
make: *** [buffer_class.o] Error 1
larskanis commented 9 years ago

I started an interactive rake-compiler-dock session and issued rake cross native gem RUBY_CC_VERSION=2.0.0:2.1.6:2.2.2 MAKE="make V=1" . Then I used the same command line options to compile a simple include <ruby.h> and it failed equally. So I tested which option causes this failure - and it is -std=c99 .

Changing the following lines in extconf.rb, makes the build succeed:

unless RUBY_PLATFORM =~ /mswin|mingw/
  $CFLAGS << %[ -I.. -Wall -O3 -g -std=c99]
end

I noticed, that it builds with ruby-1.9.3, too.

kou commented 9 years ago

Thanks for debugging it! Now, I understand that this is a problem of msgpack gem not rake-compiler-dock. Sorry for wasting your time. I close this issue.

larskanis commented 9 years ago

No problem - it was fun (I'm quite experienced in debugging rake-compiler-dock related build issues, by now).

larskanis commented 9 years ago

Will you open a pull request at msgpack for this?

kou commented 9 years ago

I'll not open for now. Because the new version of msgpack drops Ruby 2.0.0 support: https://github.com/msgpack/msgpack-ruby/issues/73#issuecomment-123655596

I'll open a pull request when msgpack tries to re-support Ruby 2.0.0 again.

larskanis commented 9 years ago

@kou So I opened a pull request here .

kou commented 9 years ago

Wow! You're very active!

larskanis commented 9 years ago

I don't think so, looking at your timeline at github.