[cext] updating CC override

Tim,

Overriding CC via the environment before the process starts seems to
work fine so far, but it has a usage side effect. On windows (using the
DevKit to provide gcc, g++, and make capabilities) it’s now a two-step
process to install a native gem:

set CC=gcc
gem install rdiscount --platform=ruby

I’d like to get rid of the first step.

“Solving” this by having the DevKit install (actual paths determined at
install time) an operating_system.rb into JRuby similar to the following
will likely not work if the mkmf-generated Makefile already defines CC
and CXX (and IIRC rubygems can’t call ‘make’ with
–environment-overrides):

FILE:

<JRUBY_ROOT>/lib/ruby/site_ruby/1.8/rubygems/defaults/operating_system.rb

:DK-BEG: override ‘gem install’ to enable RubyInstaller DevKit usage

Gem.pre_install do |gem_installer|
unless gem_installer.spec.extensions.empty?
unless ENV[‘PATH’].include?(‘C:\DevKit\mingw\bin’) then
puts ‘Temporarily enhancing PATH to include DevKit…’
ENV[‘PATH’] = ‘C:\DevKit\bin;C:\DevKit\mingw\bin;’ +
ENV[‘PATH’]
ENV[‘CC’] = ‘gcc’
ENV[‘CXX’] = ‘g++’
end
end
end

:DK-END:

So I suggest we look at following two areas:

  1. Tap into JRuby’s ENV rather than Java’s System.getenv to see how
    overrides after the Java process has started work.

  2. Investigate mkmf mods as I suspect the only solid way to do this is
    to have operating_system.rb do something like:

require ‘rbconfig’

RbConfig::MAKEFILE_CONFIG[‘CC’] = ‘gcc’
RbConfig::MAKEFILE_CONFIG[‘CXX’] = ‘g++’

Do you see any showstoppers with either idea? Other ideas?

I’m not yet familiar with the JRuby source so if you’ll save me some
time by pointing me to the source for creating/managing ENV, I’ll find
time to experiment and work up a patch for your review.

Jon


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

Overriding CC via the environment before the process starts seems to work fine so far, but it has a usage side effect. On windows (using the DevKit to provide gcc, g++, and make capabilities) it’s now a two-step process to install a native gem:

set CC=gcc
gem install rdiscount --platform=ruby

I’d like to get rid of the first step.

With rdiscount, this naive patch appears to get rid of the first step
when I use

FILE:

<JRUBY_ROOT>/lib/ruby/site_ruby/1.8/rubygems/defaults/operating_system.rb

:DK-BEG: override ‘gem install’ to enable RubyInstaller DevKit usage

Gem.pre_install do |gem_installer|
unless gem_installer.spec.extensions.empty?
unless ENV[‘PATH’].include?(‘C:\DevKit\mingw\bin’) then
puts ‘Temporarily enhancing PATH to include DevKit…’
ENV[‘PATH’] = ‘C:\DevKit\bin;C:\DevKit\mingw\bin;’ +
ENV[‘PATH’]
end
ENV[‘CC’] = ‘gcc’
end
end

:DK-END:

Jon

The patch is applied, thanks!
What was your problem with eventmachine? And what else can I do to
enable you to ship JRuby support with the devkit and installer?

On Sep 11, 2010, at 10:49 PM, Jon wrote:

:DK-BEG: override ‘gem install’ to enable RubyInstaller DevKit usage

Jon
<0001-get-build-env-vars-from-runtime.patch>---------------------------------------------------------------------
To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email

What was your problem with eventmachine? And what else can I do to enable you to ship JRuby support with the devkit and installer?

re: DevKit + JRuby support, I’d want it finalized for the next DevKit
release. I’m currently testing with mods [0] for 4.5.1. If you’ve got
a clone of our repo and would like to to build an “edge” DevKit, copy my
override into “<REPO_ROOT>/override/build_config.rb” and do a “rake
devkit sfx=1 override=1” from the repo root.

Would like any DevKit usage feedback you may have as well a review of:

a) JRuby Windows installer to advertise itself via a registry key so I
can automagically install DevKit support [1]. Tom’s authored
http://jira.codehaus.org/browse/JRUBY-5069

b) Is [2] a valid check to determine whether to inject DevKit assets
into an installed JRuby?

re: eventmachine, I haven’t looked into em’s Java support [3] so I’m not
convinced there’s a real issue. I’m biased as I believe a Java
extension is a “better” solution than trying to integrate the native
libraries via cext; a gut feel without any performance or usage data.

Em fails to compile the first .cpp file, likely due to em’s extconf.rb
doing work [4] [5] [6] with mkmf not comprehending Java + cext as a
target. I haven’t had time to mod JRuby’s mkmf.rb or tweak em’s
extconf.rb to see if the problem is a coordination problem (via CONFIG)
between the two in combo with some missing C++ specifics in the
generated Makefile. Maybe you can give it another set of eyes.

Regardless, even if the eventmachine Java extension code gets the same
level of support as the C++ code, we should double check the following
cext issues to ensure cext handles C++ extensions properly:

  1. RbConfigLibrary.java needs the following:
  • CXX = g++
  • CXXFLAGS = $(CFLAGS) $(cxxflags)
  • LDSHARED = $(CC) -shared $(if $(filter-out -g
    -g0,$(debugflags)),-s)
  • LDSHAREDXX = $(CXX) -shared $(if $(filter-out -g
    -g0,$(debugflags)),-s)
  1. RbConfigLibrary.java probably needs the followin:
  • DESTDIR
  • CPPFLAGS = $(DEFS) $(cppflags)
  • dldflags = $(DEFFILE)
  • create a $(DEFFILE) target
  • update $(DLLIB) target to be $(DLLIB): $(DEFFILE) $(OBJS) Makefile

[0] RubyInstaller build overrides · GitHub
[1]
http://github.com/oneclick/rubyinstaller/blob/master/resources/devkit/dk.rb#L11
[2]
http://github.com/oneclick/rubyinstaller/blob/master/resources/devkit/dk.rb#L301

[3] eventmachine/java at master · eventmachine/eventmachine · GitHub
[4]
eventmachine/ext/extconf.rb at master · eventmachine/eventmachine · GitHub
[5]
eventmachine/ext/extconf.rb at master · eventmachine/eventmachine · GitHub
[6]
eventmachine/ext/extconf.rb at master · eventmachine/eventmachine · GitHub


To unsubscribe from this list, please visit:

http://xircles.codehaus.org/manage_email