Running on OSX

Feb 27, 2015 at 10:26 AM
Edited Feb 27, 2015 at 10:26 AM
Hello,
I tried to run on OSX (i'd like to use C#Native on iOS, and OSX seems an easier first step):
  • I used Mono 3.12.0 to run Il2Bc.exe and generate the .ll files (worked like a charm)
  • When trying to compile the .ll files (my test and corelib) I got an error because clock_gettime is not defined on OSX (it's used in corelib by getTicks())
I tried two workarounds (manually modifyng the .ll file) in order to be able to compile:
  • I replaced clock_gettime with clock_get_time, it crashed: no surprise here, different parameters, etc. I just wanted to see if it ran)
  • I replaced the whole getTicks() method body with
    ret i32 0
    or
    ret i32 12345
    In the first case it crashes with some stack error, in the latter it crashes with a segmentation fault.
    I'm not that familiar with LLVM, so I don't know how to generate a more meaningful stack trace, and actually I don't know where the problem lies (C#Native? corelib? OSX interfacing?)
Thanks (and congratulations for your work)

m.
Coordinator
Feb 27, 2015 at 3:16 PM
Thx for your experiments, I didn't have a chance to try it on OSX.

and seems you need to change CoreLib for OSX, have a look into DateTime class to see how to call C functions.

then you need to compile it in debug (put /debug in command line for il2bc) to compile the app and CoreLib

then you need to run the app in GDB (or LLDB)

before running the app in GDB, type command "catch throw", when you hit the segment fault type "bt" to see call stack.


PS. Segment fault usually means memory access issue, common issues: size of returning data, wrong type etc. On Android segment fault usually caused by wrong align or throwing exceptions which are not caught
Coordinator
Feb 27, 2015 at 3:23 PM
and in generated .LL file check if you providing correct TARGET and DATA LAYOUT settings (first 2 lines of the file)
Feb 27, 2015 at 3:26 PM
AlexDev wrote:
and in generated .LL file check if you providing correct TARGET and DATA LAYOUT settings (first 2 lines of the file)
Yes, I forgot to write it, but I used the correct target

Thanks again