From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.4 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id 13DAEBC37 for ; Sat, 2 May 2009 02:07:28 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AooCAL8r+0lKfVwbkGdsb2JhbACWJz8BAQEBCQkMBxEDpiyBCI9jAQMBA4N6BQ X-IronPort-AV: E=Sophos;i="4.40,281,1238968800"; d="scan'208";a="25494548" Received: from qw-out-2122.google.com ([74.125.92.27]) by mail2-smtp-roc.national.inria.fr with ESMTP; 02 May 2009 02:07:27 +0200 Received: by qw-out-2122.google.com with SMTP id 8so2052619qwh.33 for ; Fri, 01 May 2009 17:07:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=l6i2DAVWcNrktAu6t2Fhz/h9VaIckTnH41WZlHPFaMM=; b=ZBItQgfapw+u0x+zSMbO7lZtQePhlhGJXMCAKu58g8JuDBr+sIE8MKxf4oAbW9gmo7 RBIJ1GqGuiXA3AHJ86yd9WqNB8SFx3iogyMhC3DQxLL7uRRHBY8u1IaTfcJwrClO9yWV CUbMsgdEVcMreO5OAaMAQJZ1IHWFf4I3USLGQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=HPwi9q9nFcdnbB7Ulpf6Bpz/uQMDjmce4hpC45Qq4U9vbhtmrzyFmOmUYkQtFtFJry Tp0ncaWt5VXtazD5dYY3twikvE5MW8WO5IHkZneT3Dd4ZNas+oTqq2q0p0Ny/pcdZUn6 EwiZXXRcGGk8MXfLdVH97yIGuXkk6myNAynTc= MIME-Version: 1.0 Received: by 10.229.95.16 with SMTP id b16mr2574738qcn.33.1241222845813; Fri, 01 May 2009 17:07:25 -0700 (PDT) In-Reply-To: References: <170624B9-E8DE-4E94-BAA5-2CAF928CE54B@gmail.com> <49F9E7F7.7060705@glondu.net> Date: Fri, 1 May 2009 17:07:25 -0700 Message-ID: Subject: Re: [Caml-list] Re: arm backend From: Nathaniel Gray To: Jeffrey Scofield Cc: caml-list@inria.fr Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; ocaml:01 compiler:01 ocaml:01 gdb:01 appending:01 unboxed:01 2009:98 cocoa:98 cocoa:98 nathan:98 threads:01 wrote:01 compile:01 caml-list:01 functions:01 On Fri, May 1, 2009 at 3:12 PM, Jeffrey Scofield wrote= : > Nathaniel Gray 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? =C2=A0It's probably too late for my current project but in >> the future I'd love to use ocaml for my iPhone projects. =C2=A0I 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. =C2=A0I don't know enough about the AR= M >> 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. =C2=A0Presumably > 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. =C2=A0arm.S uses r10 as a scratch register, but it is not a scratch > =C2=A0 =C2=A0register on iPhone. =C2=A0It has to be saved/restored when p= assing > =C2=A0 =C2=A0between OCaml and the native iPhone code (I think of it as > =C2=A0 =C2=A0ObjC code). =C2=A0Note, by the way, that gdb shows r10 by th= e > =C2=A0 alternate name of sl. =C2=A0This is confusing at first. > > 2. arm.S assumes r9 can be used as a general purpose register, > =C2=A0 =C2=A0but it is used on the iPhone to hold a global thread context= . > =C2=A0 Again, it has to be saved/restored (or at least that's what we > =C2=A0 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. =C2=A0(Multiple threads will almost certainly > require more careful handling of r9.) =C2=A0It 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 OCam= l? > We also made a small fix to the ARM code generator > (beyond the patches from Toshiyuki Maeda). =C2=A0In essence, > it fixes up the handling of unboxed floating return > values of external functions. =C2=A0Things 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=3D4782 --=20 Nathan Gray http://www.n8gray.org/