cannot define two `Rake::ExtensionTask`s with separate cross_compiling blocks #36

tmm1 opened this Issue Mar 1, 2011 · 9 comments

3 participants


eventmachine defines two extension tasks:

each one uses its own cross_compiling block to add a .rb fat-binary wrapper to spec.files, but the second extension gets rubyeventmachine.rb added to it instead of fastfilereader.rb

with this patch:

diff --git a/tasks/package.rake b/tasks/package.rake
index 84e317e..73a5c6f 100644
--- a/tasks/package.rake
+++ b/tasks/package.rake
@@ -16,7 +16,9 @@ else
       ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']

       # inject 1.8/1.9 pure-ruby entry point
+      p [:outside, ext.object_id,]
       ext.cross_compiling do |spec|
+        p [:inside, ext.object_id,]
         spec.files += ["lib/#{}.rb"]

you can see the first block is getting called twice:

[:outside, 2159882380, "rubyeventmachine"]
[:outside, 2159788460, "fastfilereaderext"]
[:inside, 2159882380, "rubyeventmachine"]
[:inside, 2159882380, "rubyeventmachine"]


Rake ExtensionTask defines a single cross task and that is invoked. Multiple files been added will generate duplicate spec entries.

A workaround will be always place the ruby entry point inside the gem.

The whole cross task approach needs to be changed, so will left this open until I decide how to tackle it.

Thank you for the report.


Are there any workarounds for this? See eventmachine/eventmachine#222

@luislavena luislavena was assigned Oct 5, 2011

Will see what can be done, sorry for the delay.


@tmm1: can you try this on EventMachine?

  def setup_cross_compilation(ext)
    unless RUBY_PLATFORM =~ /mswin|mingw/
      ext.cross_compile = true
      ext.cross_platform = ['x86-mingw32', 'x86-mswin32-60']

      # inject 1.8/1.9 pure-ruby entry point
      # HACK: add these dependencies to the task instead of using cross_compiling
      ext.cross_platform.each do |platf|
        Rake::Task["native:#{}:#{platf}"].prerequisites.unshift "lib/#{}.rb"

@tmm1, ping? did the above code help you out? please let me know.


No luck:

Don't know how to build task 'native:eventmachine:x86-mingw32'
/Users/test/.rvm/gems/ruby-1.8.7-p330/gems/rake-0.9.2/lib/rake/task_manager.rb:49:in `[]'
/Users/test/.rvm/gems/ruby-1.8.7-p330/gems/rake-0.9.2/lib/rake/task.rb:298:in `[]'
/Users/test/code/em/tasks/package.rake:31:in `setup_cross_compilation'
/Users/test/code/em/tasks/package.rake:30:in `each'
/Users/test/code/em/tasks/package.rake:30:in `setup_cross_compilation'
/Users/test/.rvm/gems/ruby-1.8.7-p330/gems/rake-compiler-0.7.9/lib/rake/baseextensiontask.rb:34:in `initialize'
/Users/test/code/em/tasks/package.rake:36:in `new'

@tmm1, can you try this weird-and-shameful-hack-that-I-m-not-proud-of?


How about packaging fastfilereader in its own gem? Wouldn't this provide the needed separation?

@tmm1 tmm1 added a commit to eventmachine/eventmachine that referenced this issue Mar 8, 2013
@tmm1 tmm1 use hack from rake-compiler/rake-compiler#36 to work around rake-comp…
…iler bug (fixes #222)

The rakefile hack works. I've merged into EM 1.0.2 to work around this bug until it is resolved. Thanks @luislavena

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