Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

"rake cross compile" doesn't choose correct g++ executable #12

Open
lylejohnson opened this Issue Oct 27, 2009 · 10 comments

Comments

Projects
None yet
4 participants

I'm working with the latest rake-compiler (post-0.6.0) from GitHub and it seems that while the "rake cross compile" task does correct set the C compiler (to "i586-mingw32msvc-cc" on my machine) it doesn't get the C++ compiler right (it chooses plain old "g++" instead of "i586-mingw32msvc-g++"). I'm looking into this and will provide a patch if I figure it out; just wanted to get it recorded somewhere.

Contributor

luislavena commented Oct 27, 2009

Thank you Lyle

This is actually not a rake-compiler issue, but the lack of rbconfig to setup CXX.

rake-compiler uses rbconfig in combination with mkmf. rbconfig was generated by miniruby during the build process, and lacks that information.

The only place rake-compiler defines the compiler itself is here:

http://github.com/luislavena/rake-compiler/blob/master/lib/rake/extensioncompiler.rb

And the only purpose is to help determine the platform and the executable for manual execution.

But this is not used by mkmf or the cross compile process at all.

I advice you setup an environment variable or a extconf parameter that let you assign the CXX properly.

I advice against using ExtensionCompiler to define that in extconf (since the gem will not be available in that particular version of the cross-compiled ruby).

OK, I understand. Trying now with:

rake cross compile CXX=/usr/bin/i586-mingw32msvc-g++

and that seems to be working a little better (so far!)

Contributor

luislavena commented Oct 27, 2009

Good news.

Feel free to create a patch then that extend ExtensionCompiler to define the g ++ executable for the mingw host.

This did not resolve my issue, on Fedora 13. I get this error:
[root@li137-46 tenderlove-nokogiri-0e2a3d9]# rake-compiler
/usr/lib/ruby/gems/1.8/gems/rake-compiler-0.7.0/lib/rake/extensioncompiler.rb:28:in mingw_host': No MinGW tools or unknown setup platform? (RuntimeError) from /usr/lib/ruby/gems/1.8/gems/rake-compiler-0.7.0/bin/../tasks/bin/cross-ruby.rake:40 from /usr/lib/ruby/gems/1.8/gems/rake-compiler-0.7.0/bin/rake-compiler:21:inload'
from /usr/lib/ruby/gems/1.8/gems/rake-compiler-0.7.0/bin/rake-compiler:21

Contributor

luislavena commented Jun 24, 2010

Did you tried setting CXX before invoking rake compiler?

Do you have cross compiling toolset installed in that machine?

passing it as a flag did not work, but setting the env variable did. Thanks for your help.

tmm1 commented Nov 25, 2010

I ran into this as well, and used the following in EM:

task :cross_cxx do
  require 'rake/extensioncompiler'
  ENV['CXX'] = "#{Rake::ExtensionCompiler.mingw_host}-g++"
end

if Rake::Task.task_defined?(:cross)
  task :cross => :cross_cxx
end
Contributor

luislavena commented Nov 25, 2010

I'm keeping this open as documentation thread.

Do you guys think this should be covered/set by rake-compiler in the cross task?

tmm1 commented Nov 25, 2010

Yes, I would prefer if this was default behavior inside rake-compiler..

I don't think there's any downside of adding an ENV['CXX'] ||= so there is a default value set?

Contributor

luislavena commented Nov 25, 2010

@tmm1

Yeah, that can work, but that will make ExtensionTask depend on ExtensionCompiler

Since I'm planning a huge internal change of rake-compiler, will table this until then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment