caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nathaniel Gray <n8gray@gmail.com>
To: Jeffrey Scofield <dynasticon@mac.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Re: arm backend
Date: Fri, 1 May 2009 17:07:25 -0700	[thread overview]
Message-ID: <aee06c9e0905011707ybc280cey2735cec6416cee86@mail.gmail.com> (raw)
In-Reply-To: <m2eiv8tqvc.fsf@mac.com>

On Fri, May 1, 2009 at 3:12 PM, Jeffrey Scofield <dynasticon@mac.com> wrote:
> Nathaniel Gray <n8gray@gmail.com> writes:
>
>> Speaking of which, has anybody built an ocaml cross compiler for the
>> iphone that can work with native cocoa touch apps built with the
>> official SDK?  It's probably too late for my current project but in
>> the future I'd love to use ocaml for my iPhone projects.  I tried
>> following the instructions here[1] with some necessary
>> modifications[2] to get the assembler to work but my test app crashed
>> as soon as it entered ocaml code.  I don't know enough about the ARM
>> platform to say why.
>
> Yes, we have OCaml 3.10.2 cross compiling for iPhone OS 2.2.

Great!

> There are at least two more problems, however.  Presumably
> this is due to differences between the iPhone ABI and the one that
> the ARM port (the old one I guess you could say) is targeted for.
>
> 1.  arm.S uses r10 as a scratch register, but it is not a scratch
>    register on iPhone.  It has to be saved/restored when passing
>    between OCaml and the native iPhone code (I think of it as
>    ObjC code).  Note, by the way, that gdb shows r10 by the
>   alternate name of sl.  This is confusing at first.
>
> 2. arm.S assumes r9 can be used as a general purpose register,
>    but it is used on the iPhone to hold a global thread context.
>   Again, it has to be saved/restored (or at least that's what we
>   decided to do).
>
> We saw crashes caused by both of these problems.

Ok, I'm glad I left this to people who are familiar with ARM assembly
programming.  :-)

> I'm appending a new version of arm.S that works for us with
> one OCaml thread.  (Multiple threads will almost certainly
> require more careful handling of r9.)  It has the patches
> from Toshiyuki Maeda mentioned above and a few of our
> own to fix these two problems.

Awesome, but now I'm confused because the arm.S you included has lots
of .global pseudo-ops.  Do you not compile it with Apple's as?

> We have an application that has been working well for
> a couple months, so there's some evidence that these
> changes are sufficient.

What's your app?  How are you managing the interface between Cocoa and OCaml?

> We also made a small fix to the ARM code generator
> (beyond the patches from Toshiyuki Maeda).  In essence,
> it fixes up the handling of unboxed floating return
> values of external functions.  Things mostly work without
> this change; I'll save a description for a later post (if
> anybody is interested).

I am very interested in any and all information needed to get a
correct OCaml port suitable for use in App Store applications.  Please
share!

BTW, I've added an issue in mantis[1] now that I know this is more
than a configuration problem.

Thanks,
-n8

[1] http://caml.inria.fr/mantis/view.php?id=4782

-- 
Nathan Gray
http://www.n8gray.org/


  reply	other threads:[~2009-05-02  0:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-30 12:14 Joel Reymont
2009-04-30 13:28 ` Sylvain Le Gall
2009-04-30 18:03   ` [Caml-list] " Stéphane Glondu
2009-04-30 19:19     ` Nathaniel Gray
2009-05-01 12:02       ` Mattias Engdegård
2009-05-01 18:27         ` Nathaniel Gray
2009-05-01 19:24           ` Mattias Engdegård
2009-05-01 22:12       ` Jeffrey Scofield
2009-05-02  0:07         ` Nathaniel Gray [this message]
2009-05-02 23:15           ` OCaml on iPhone (was: arm backend) Jeffrey Scofield
2009-05-03 12:34             ` [Caml-list] " Robert Muller
2009-05-05  4:59               ` OCaml on iPhone Jeffrey Scofield
2009-05-05  9:43 ` [Caml-list] arm backend Xavier Leroy
2009-05-05 18:21   ` Nathaniel Gray
2009-05-06  3:56   ` Jeffrey Scofield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aee06c9e0905011707ybc280cey2735cec6416cee86@mail.gmail.com \
    --to=n8gray@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=dynasticon@mac.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).