#335 √ resolved
kwatch

[BUG] Building rubinius failed due to '_STRUCT_MCONTEXT' on MacOS X

Reported by kwatch | February 18th, 2008 @ 08:59 PM | in 1.0 preview

Building rubinius failed due to '_STRUCT_MCONTEXT' on MacOS X 10.4 Tiger.

$ rake build
(in /usr/local/tmp/rubinius.code)
make vm
cd shotgun; make rubinius
cd lib; make library; 
CC archive.o
In file included from ../../shotgun/lib/state.h:175,
                 from ../../shotgun/lib/shotgun.h:19,
                 from archive.c:4:
../../shotgun/lib/machine.h:29: error: parse error before '_STRUCT_MCONTEXT'
../../shotgun/lib/machine.h:29: warning: no semicolon at end of struct or union
../../shotgun/lib/machine.h:35: error: parse error before '}' token
make[2]: *** [archive.o] Error 1
make[1]: *** [lib/librubinius-0.8.0.dylib] Error 2
make: *** [vm] Error 2
rake aborted!
Command failed with status (2): [make vm...]
/usr/local/tmp/rubinius.code/rakefile:98
(See full trace by running task with --trace)

Here is the shotgun/lib/machine.h around line 29.

 26   ucontext_t g_firesuit;
 27   /* work around a bug in 10.5's libc versus header files */
 28 #if __DARWIN_UNIX03
 29   _STRUCT_MCONTEXT __system_mc;
 30 #endif
 31   int g_use_firesuit;
 32   int g_access_violation;
 33   int g_firesuit_arg;
 34   char *g_firesuit_message;
 35 };

_STRUCT_MCONTEXT seems not to be defined in any file.

$ find . -type f | xargs grep _STRUCT_MCONTEXT
./shotgun/lib/machine.h:  _STRUCT_MCONTEXT __system_mc;
./shotgun/lib/subtend/nmc.h:  _STRUCT_MCONTEXT __system_mc;
./shotgun/lib/subtend/nmc.h:  _STRUCT_MCONTEXT __cont_mc;

Comments and changes to this ticket

  • kwatch

    kwatch February 21st, 2008 @ 10:03 AM

    I commented out the above three lines which contains _STRUCT_MCONTEXT and tried to compile rubinius but got the following error.

    • cpu_instructions.c:1493: warning: implicit declaration of function 'getcontext'
    • machine.c:139: warning: implicit declaration of function 'setcontext'
    • subtend/nmc.c:271: warning: implicit declaration of function 'setcontext'
    • subtend/nmc.c:298: warning: implicit declaration of function 'getcontext'
    • subtend/nmc.c:336: warning: implicit declaration of function 'makecontext'
    • subtend/ruby.c:185: warning: implicit declaration of function 'getcontext'
    • subtend/ruby.c:188: warning: implicit declaration of function 'setcontext'

    detail:

    $ rake build
    (in /usr/local/tmp/rubinius.code)
    make vm
    cd shotgun; make rubinius
    cd lib; make library; 
    ruby genheader.rb > auto.c
    ruby primitives.rb > system_primitives.gen
    ruby instructions.rb > instructions.gen
    ruby node_types.rb
    DEP var_table.c
    DEP tuple.c
    DEP symbol.c
    DEP subtend/setup.c
    DEP subtend/ruby.c
    DEP subtend/nmethod.c
    DEP subtend/nmc.c
    DEP subtend/library.c
    DEP subtend/handle.c
    DEP subtend/ffi_x86.c
    DEP subtend/ffi_amd64.c
    DEP subtend/ffi.c
    DEP subtend/PortableUContext.c
    DEP strlcpy.c
    DEP strlcat.c
    DEP string.c
    DEP state.c
    DEP sha1.c
    DEP sendsite.c
    DEP selector.c
    DEP rubinius.c
    DEP regexp.c
    DEP object_memory.c
    DEP object.c
    DEP numeric.c
    DEP node_types.c
    DEP module.c
    DEP methtbl.c
    DEP methctx.c
    DEP metaclass.c
    DEP marksweep.c
    DEP machine.c
    DEP log.c
    DEP list.c
    DEP io.c
    DEP instruction_names.c
    DEP heap.c
    DEP hash.c
    DEP grammar_runtime.c
    bison -o grammar.c grammar.y
    DEP grammar.c
    DEP float.c
    DEP ffi_util.c
    DEP environment.c
    DEP cpu_task.c
    DEP cpu_sample.c
    DEP cpu_primitives.c
    DEP cpu_marshal.c
    DEP cpu_instructions.c
    DEP cpu_event.c
    DEP cpu_cache.c
    DEP cpu.c
    DEP config_hash.c
    DEP compress.c
    DEP class.c
    DEP bytearray.c
    DEP bootstrap.c
    DEP bignum.c
    DEP baker.c
    DEP auto.c
    DEP array.c
    DEP archive.c
    CC archive.o
    CC array.o
    CC auto.o
    CC baker.o
    CC bignum.o
    CC bootstrap.o
    CC bytearray.o
    CC class.o
    CC compress.o
    CC config_hash.o
    CC cpu.o
    CC cpu_cache.o
    CC cpu_event.o
    CC cpu_instructions.o
    cpu_instructions.c: In function 'cpu_run':
    cpu_instructions.c:1493: warning: implicit declaration of function 'getcontext'
    CC cpu_marshal.o
    CC cpu_primitives.o
    CC cpu_sample.o
    CC cpu_task.o
    CC environment.o
    CC ffi_util.o
    CC float.o
    CC grammar.o
    CC grammar_runtime.o
    CC hash.o
    CC heap.o
    CC instruction_names.o
    CC io.o
    CC list.o
    CC log.o
    CC machine.o
    machine.c: In function '_machine_error_reporter':
    machine.c:139: warning: implicit declaration of function 'setcontext'
    CC marksweep.o
    CC metaclass.o
    CC methctx.o
    CC methtbl.o
    CC module.o
    CC node_types.o
    CC numeric.o
    CC object.o
    CC object_memory.o
    CC regexp.o
    CC rubinius.o
    CC selector.o
    CC sendsite.o
    CC sha1.o
    CC state.o
    CC string.o
    CC strlcat.o
    CC strlcpy.o
    CC subtend/PortableUContext.o
    CC subtend/ffi.o
    CC subtend/ffi_amd64.o
    CC subtend/ffi_x86.o
    CC subtend/handle.o
    CC subtend/library.o
    CC subtend/nmc.o
    CC subtend/setup.o
    CC symbol.o
    CC tuple.o
    CC var_table.o
    CC subtend/PortableUContext_asm.o
    LINK librubinius-0.8.0.dylib
    CC main.o
    CC rubinius.bin
    /usr/bin/ld: Undefined symbols:
    _getcontext
    _setcontext
    _makecontext
    collect2: ld returned 1 exit status
    make[1]: *** [rubinius.bin] Error 1
    make: *** [vm] Error 2
    rake aborted!
    Command failed with status (2): [make vm...]
    /usr/local/tmp/rubinius.code/rakefile:98
    (See full trace by running task with --trace)
    
  • seydar

    seydar February 21st, 2008 @ 11:12 AM

    I found this same bug, too (just yesterday!) and followed the same steps you did. same error. I'm running Mac OS 10.4.11, gcc 4.0.1. Did you have to comment anything in nmc.h? I found that I did

  • seydar

    seydar February 22nd, 2008 @ 05:12 PM

    Here's my file produced by git; I can't seem to get the format-patch and email bit working:

    commit a009d219ac53f8b8a44cbc8d6c7c6ec517eca942Author: Ari Brown

    Date: Fri Feb 22 16:33:23 2008 -0500

    Enabled rubinius to be built on Pre-Leopard Macs

    • fixed an #if in machine.h and nmc.h

    diff --git a/shotgun/lib/machine.h b/shotgun/lib/machine.h

    index 8b934d1..78212fd 100644

    --- a/shotgun/lib/machine.h

    +++ b/shotgun/lib/machine.h

    @@ -25,7 +25,7 @@ struct rubinius_machine {

    int show_config;

    ucontext_t g_firesuit;

    /* work around a bug in 10.5's libc versus header files */

    -#if __DARWIN_UNIX03

    +#if defined(__APPLE__) && defined(HAS_UCONTEXT) /* patch for tiger */

    _STRUCT_MCONTEXT __system_mc;

    #endif

    int g_use_firesuit;

    diff --git a/shotgun/lib/subtend/nmc.h b/shotgun/lib/subtend/nmc.h

    index 5f3ff66..76ed977 100644

    --- a/shotgun/lib/subtend/nmc.h

    +++ b/shotgun/lib/subtend/nmc.h

    @@ -18,11 +18,11 @@ struct rni_nmc {

    int jump_val;

    ucontext_t system;

    /* work around a bug in 10.5's libc versus header files */

    -#if __DARWIN_UNIX03

    +#if defined(__APPLE__) && defined(HAS_UCONTEXT)

    _STRUCT_MCONTEXT __system_mc;

    #endif

    ucontext_t cont;

    -#if __DARWIN_UNIX03

    +#if defined(__APPLE__) && defined(HAS_UCONTEXT)

    _STRUCT_MCONTEXT __cont_mc;

    #endif

  • kwatch

    kwatch February 22nd, 2008 @ 06:34 PM

    Hi seydar,

    I tried your patch and found that it seems to work correctly.

    And I have a question: is it possible to replace '#if defined(__APPLE__) && defined(HAS_UCONTEXT)' to '#if defined(_STRUCT_MCONTEXT)'?

    /*if defined(__APPLE__) && defined(HAS_UCONTEXT)*/
    #if defined(_STRUCT_MCONTEXT)
    

    Or:

    #if defined(__APPLE__) && defined(HAS_UCONTEXT)
    #define HAS_STRUCT_MCONTEXT 1
    #else
    #define HAS_STRUCT_MCONTEXT 0
    #endif
    
    #if HAS_STRUCT_MCONTEXT
    ...
    #endif
    

    I appreciate you that rubinius is compiled in my macbook.

  • seydar

    seydar February 22nd, 2008 @ 07:18 PM

    No, unfortunately, because it's needed as a workaround for Leopard and could break other systems. It would work fine on Tiger, but not Leopard.

  • seydar

    seydar February 22nd, 2008 @ 07:28 PM

    No, unfortunately, because it's needed as a workaround for Leopard and could break other systems. It would work fine on Tiger, but not Leopard.

  • kwatch

    kwatch February 23rd, 2008 @ 09:41 PM

    thank you, seydar.

    I hope your patch will be included in Rubinius repository soon.

  • Wilson Bilkovich

    Wilson Bilkovich February 25th, 2008 @ 04:45 PM

      • → State changed from “new” to “resolved”
      • → Assigned user changed from “” to “Wilson Bilkovich”

    Applied to the main repository at 21:42 UTC 2008-12-25.

    Thanks!

  • kwatch

    kwatch February 25th, 2008 @ 10:34 PM

    I confirmed that Rubinius can be compiled on Tiger.

    Thank you very much.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Tags