Projects

Ticket #579 (closed defect: fixed)

Opened 6 months ago

Last modified 6 months ago

i386 compilation doesn't work

Reported by: carlo@… Owned by: martinlagardette@…
Priority: major Milestone: MacRuby 0.6
Component: MacRuby Keywords:
Cc: darrin@…

Description

This bug report references MR0.5b2 as well as its standard MacRuby application template.

Trying to build self-contained compiled i386 apps (embedded MR) works fine, but the apps won't run. i86_64 builds are showing no problems and work as expected, but i386 versions exit right away, logging the following error message:

core:in `each': no such file to load -- bootstrap (LoadError)
from [project path]/build/Release/MyApp.app/Contents/Resources/rb_main.rb:in `<main>'

"bootstrap" being whatever *.rbo file is to be loaded first. $LOAD_PATH looks okay, i.e. it's identical when running i386 or x86_64 code. The behaviour is the same on both single-arch builds and 32/64bit "combo" builds.

Not compiling the the application yields an app which works a-okay on both architectures.

Tried on a 2006 2GHz Core Duo MacBook as well as a late 2009 C2D iMac, both running XCode 3.2.1 on 10.6.2. (Both being *my* machines makes it possible I've somehow managed to misconfigure them in the same way, of course.)

Change History

Changed 6 months ago by carlo@…

My bad, forgot to include more information about my settings.

ARCHS: i386 x86_64 SDKROOT: macosx10.5 ONLY_ACTIVE_ARCH: no VALID_ARCHS: i386 x86_64

Rest of the settings is standard MR Xcode project settings.

Changed 6 months ago by carlo@…

Still doesn't work in 0.5 (final). Any ideas what else I could check?

Changed 6 months ago by lsansonetti@…

Looks like the AOT compiler is broken for 32-bit targets.

$ cd /tmp
$ echo 'p 42' > t.rb
$ macrubyc --arch i386 --arch x86_64 -C t.rb -o t.rbo
$ file t.rbo
t.rbo: Mach-O universal binary with 2 architectures
t.rbo (for architecture i386):	Mach-O bundle i386
t.rbo (for architecture x86_64):	Mach-O 64-bit bundle x86_64
$ macruby -r ./t.rbo -e ''
42
$ arch -i386 macruby -r ./t.rbo -e ''
no such file to load -- ./t.rbo (LoadError)

Changed 6 months ago by darrin@…

  • cc darrin@… added

Cc Me!

Changed 6 months ago by martinlagardette@…

Hi Carlo!

This should be fixed with r3456. Could you please check? Thanks a lot!

Changed 6 months ago by carlo@…

Thanks! I'll take a look as soon as I have a bit more free time (lots of client work at the moment)… I'll report back.

Changed 6 months ago by carlo@…

I've downloaded the latest nightly (macruby_nightly-2010-02-11-1236.pkg), compile my app against it. It runs fine on 64bit, but 32bit results in this:

*buildpath*/Ephemera.app/Contents/Resources/rb_main.rb:34:in `block': 
    dlopen(*buildpath*/Ephemera.app/Contents/Resources/bootstrap.rbo, 9): no suitable image found.  Did find:
*buildpath*/Ephemera.app/Contents/Resources/bootstrap.rbo:
    mach-o, but wrong architecture - *buildpath*/Ephemera.app/Contents/Resources/bootstrap.rbo (LoadError)
*buildpath*/Ephemera.app/Contents/Resources/rb_main.rb:9:in `<main>'

I figured said nightly should contain the proposed fix — am I mistaken?

Changed 6 months ago by lsansonetti@…

  • owner changed from lsansonetti@… to martinlagardette@…
  • milestone changed from MacRuby 0.5 to MacRuby 0.6

I believe this is because macruby_deploy spawns macrubyc processes that only build for the current architecture.

      if !File.exist?(obj) or File.mtime(source) > File.mtime(obj)
        die "Can't compile \"#{source}\"" unless system("macrubyc -C \"#{source}\" -o \"#{obj}\"")
        FileUtils.rm_f(source)
      end

macruby_deploy should be smarter and retrieve the architecture from the Xcode environment variables and appropriately pass the right flags to macrubyc. Thibault, do you want to look at this?

Changed 6 months ago by martinlagardette@…

  • status changed from new to closed
  • resolution set to fixed

Fixed with r3527.
As discussed with Carlo, the script uses the Xcode ARCHS env var, so it should properly be set to i386 and x86_64 in the targets build info. Adding PPC will work but have not effect, since it will be intersected with rubyc VALID_ARCHS, containing only i386 and x86_64

Note: See TracTickets for help on using tickets.