macosgccmacruby

How to set custom gcc options when compiling with MacRuby?


I'm trying to compile a simple ruby script to an executable with MacRuby. The issue I'm having is that the executable compiled on Mac OS 10.8.3 doesn't work on 10.7.x (I get an Illegal instruction: 4 error). It seems that I have to pass an option to gcc, -mmacosx-version-min=10.6 in order for the executable to be compatible with older systems, but I can't figure out how to do so. Any help is appreciated.


Solution

  • macrubyc doesn't have a good way to pass options through to gcc. But, you can see the commands that macrubyc is using, modify them, and run them yourself. If you want to pass -mmacosx-version-min=10.6 to gcc, here is a manual method to do it.

    $ macrubyc script.rb -V
    

    macrubyc will AOT compile "script.rb". The -V option will print every command executed by macrubyc. This printed output basically shows generating the bit code, then compiling, assembling, and linking.

    The 3rd command (in my experience) is where gcc compiles the native assembly file generated from the bit code. In this command is where you would inject the -mmacosx-version-min=10.6 option.