Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006266OCamlOCaml generalpublic2013-12-12 11:252015-02-27 16:50
Reporterstrobegen 
Assigned To 
PrioritynormalSeverityfeatureReproducibilityN/A
StatusconfirmedResolutionopen 
PlatformOSOS Version
Product Version 
Target Version4.02.2+devFixed in Version 
Summary0006266: Cross compilation for iOs, Android etc
DescriptionI guess that out of box compiling support for mobile platforms like iOs and Android might be a significant stimulus for popularization of language.
Currently mobile market is huge in stlll growing (for instance http://www.asymco.com/2012/01/17/the-rise-and-fall-of-personal-computing/ [^]).

I think that creating lot of bindings for native platforms APIs (like Xamarian did for mono, for instance) is not so important - that is really necessary that:
* cross compilation
* out of box ways to easily build library binary which can be linked to native application code with original platform tools/IDEs.
Tagspatch
Attached Filespatch file icon camlrun-4.02.patch [^] (34,937 bytes) 2015-02-12 04:50 [Show Content]
patch file icon camlrun-trunk.patch [^] (33,154 bytes) 2015-02-12 04:50 [Show Content]

- Relationships
related to 0005887assignedgasche Name clash with memory.h header file with the Android NDK 
related to 0006613resolved armv5te code generation bug: shift expression expected -- `subs r0,r3,#4294967296' 

-  Notes
(0010704)
gasche (developer)
2013-12-12 14:22

I know nothing at all about cross-compilation, but I think that cross-compilation to android is already possible today, as explained by Jonathan Protzenko in http://gallium.inria.fr/blog/ocaml-on-a-nexus-7/. [^] I've also heard about iOS applications implemented in OCaml, see http://psellos.com/ocaml/ [^] for example.
(0010706)
strobegen (reporter)
2013-12-13 15:48

Yes it all possible now, I also know examples of few games written on Ocaml in iOs App Store (I guess, I was read some time ago article about small team which shipped few game titles to AppStore (not psellos)) but this functionally doesn't included to default compiler, currently only short way to build this kinds of apps for iOs is OCamlXARM (http://psellos.com/ocaml/compile-to-iphone.html [^]), I'm not sure but I guess that OCamlXARM contain few patches to original Ocaml distribution related to ARM assembler (& crosscompiling) parts. Therefore my opinion that it will be very useful for Ocaml community if this functionally will be available in default distribution and officially supported:
on OSX: cross compiling to iOs: ARM, ARM64 & Android: ARM.
on Windows: cross compiling to Android ARM,
on Linux: cross compiling to Android ARM.
(0012386)
whitequark (developer)
2014-10-17 06:11

I have started working on proper cross-compilation to Android, and shortly after that I will probably switch to iOS. My goal is to produce small, self-contained patches that can be merged one by one; I will post a patchset shortly. In fact, the amount of work required is not as large as one would expect.
(0012387)
whitequark (developer)
2014-10-17 07:45

I have uploaded three small patches, which allow Android cross-compilation to proceed (both world and world.opt), given that config/{Makefile,m.h,s.h} are provided.

This can be easily tested using:

    opam repo add android https://github.com/whitequark/opam-android [^]
    opam install ocaml-android
    ocamlfind -toolchain android ocamlopt helloworld.ml

I will follow up these patches with ones that properly detect the target environment features without running target binaries.
(0012388)
whitequark (developer)
2014-10-17 08:01

Actually, maybe not. I have just realized that my approach is fundamentally flawed while writing out some detailed instructions. Please wait for an updated patchset.
(0012389)
strobegen (reporter)
2014-10-17 09:29

I will try to test when it be ready
(0012926)
whitequark (developer)
2014-12-21 23:12

Reminder sent to: gasche

@gasche, I've attached a patch that brings cross-builds one step closer. Specifically this patch ensures that the variable CAMLRUN, which is already set by the configure script, is actually used when running boot/ binaries, freshly built binaries, and is also embedded in the shebang line in all the built tools.

It also replaces some usage of gcc with $(CC).
(0012989)
gasche (developer)
2014-12-27 08:50

Applying the patch makes "make world.opt" fail on my machine at the following point:

make ocamlc.opt
make[2]: Entering directory `/home/gasche/Prog/ocaml/github-trunk'
/home/gasche/Prog/ocaml/github-trunk/boot/ocamlrun ./ocamlopt -nostdlib -I stdlib -I otherlibs/dynlink -use-runtime /home/gasche/Prog/ocaml/github-trunk/boot/ocamlrun -ccopt "-Wl,-E" -o ocamlc.opt \
  compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlbytecomp.cmxa \
  driver/main.cmx -cclib "-lm -ldl -lcurses -lpthread"
./ocamlopt: unknown option '-use-runtime'.
(0012995)
whitequark (developer)
2014-12-28 23:35
edited on: 2014-12-28 23:36

I've updated the patch. Notable changes:

  * All tools and all Makefile.nt files are also updated. (Some were missing in original patch.)
  * ocamlyacc, being the only other native component except ocamlrun, is also detected with ./configure and required to be present on host for cross-builds.
  * ocamlbuild/Makefile.noboot is removed, as it was never referenced and also ocamlbuild/Makefile does not require ocamlbuild anymore.

make world world.opt now passes.

(0013252)
gasche (developer)
2015-02-08 11:12

The patch seems okay in principle and I was about to merge it, but:

- the patch conflicts with Damien's change to use $(CC) more consistently in trunk@15784
  https://github.com/ocaml/ocaml/commit/66af6470a62e688c1197639d3b1bd945a90efd0a [^]
- Damien only patched trunk, but we may want to apply this one change to 4.02 as well

whitequark, would you mind preparing two versions of the patch, one that applies cleanly to trunk and the other for 4.02. I feel sorry to ask for such tedious work, I could do it but I'll rather try to merge the other patches on my list during my weekend time window.

Damien, could you give your opinion on whether the present change and trunk@15784 are eligible for 4.02+dev?
(0013262)
doligez (administrator)
2015-02-09 17:54

@whitequark if you don't want to bother with two versions of the patch, let's go for 4.02 and I'll deal with the conflicts when I merge it into trunk (after the 4.02.2 release). Or split it into two patches, one for CAMLRUN and one for CC.

I'm a bit nervous with the use of -use-runtime because it precludes using libraries that have C object files, but I guess it's OK for building the compiler.

There is a small problem with the patch: as far as I can tell, it gives the -use-runtime option twice to the compiler (but only in Makefile, not in Makefile.nt). You have to decide whether to add it to OCAMLC or to give it on the command line.

I'm OK for integrating this and trunk@15784 into 4.02.2.
(0013272)
whitequark (developer)
2015-02-12 04:51

I've attached diffs for 4.02 and trunk.

I've fixed the double -use-runtime problem.
(0013290)
gasche (developer)
2015-02-15 22:02

Damien, I just tried to cherry-pick trunk@15784 in 4.02, but:
- it will also conflict (slightly) with PR#5887 so I'd rather wait for PR#5887 to be tested and hopefully picked as well
- I don't understand the interaction between this change and 4.02@15762 ( https://github.com/ocaml/ocaml/commit/ca53e9558ea358d7f3919a6298838d23abb16686 [^] ); why is -DPROFILING not used in trunk, only in 4.02? Why does byterun/Makefile not use it as well?

My guess would be that -DPROFILING is the right thing to do both in trunk and in byterun/. I can make the change but I'd rather double-check it.
(0013357)
whitequark (developer)
2015-02-27 16:50

Ping?

- Issue History
Date Modified Username Field Change
2013-12-12 11:25 strobegen New Issue
2013-12-12 14:22 gasche Note Added: 0010704
2013-12-13 15:48 strobegen Note Added: 0010706
2014-07-16 14:48 doligez Status new => confirmed
2014-10-16 09:34 xleroy Relationship added related to 0006613
2014-10-17 06:11 whitequark Note Added: 0012386
2014-10-17 06:11 whitequark Relationship added related to 0005887
2014-10-17 07:37 whitequark File Added: 0002-Detect-host-ocamlyacc-alongside-host-ocamlrun-in-con.patch
2014-10-17 07:37 whitequark File Added: 0003-Update-every-invocation-of-ocamlrun-or-ocamlyacc-to-.patch
2014-10-17 07:38 whitequark File Added: 0004-Add-a-CROSS_COMPILING-Makefile.config-flag.patch
2014-10-17 07:45 whitequark Note Added: 0012387
2014-10-17 08:01 whitequark Note Added: 0012388
2014-10-17 08:05 whitequark File Deleted: 0002-Detect-host-ocamlyacc-alongside-host-ocamlrun-in-con.patch
2014-10-17 08:05 whitequark File Deleted: 0003-Update-every-invocation-of-ocamlrun-or-ocamlyacc-to-.patch
2014-10-17 08:05 whitequark File Deleted: 0004-Add-a-CROSS_COMPILING-Makefile.config-flag.patch
2014-10-17 09:29 strobegen Note Added: 0012389
2014-12-21 23:08 whitequark File Added: camlrun.patch
2014-12-21 23:12 whitequark Note Added: 0012926
2014-12-27 08:50 gasche Note Added: 0012989
2014-12-28 23:34 whitequark File Deleted: camlrun.patch
2014-12-28 23:34 whitequark File Added: camlrun.patch
2014-12-28 23:35 whitequark Note Added: 0012995
2014-12-28 23:36 whitequark Note Edited: 0012995 View Revisions
2015-01-23 12:45 whitequark Tag Attached: patch
2015-02-08 11:12 gasche Note Added: 0013252
2015-02-09 17:54 doligez Note Added: 0013262
2015-02-09 17:54 doligez Target Version => 4.02.2+dev
2015-02-12 04:50 whitequark File Deleted: camlrun.patch
2015-02-12 04:50 whitequark File Added: camlrun-4.02.patch
2015-02-12 04:50 whitequark File Added: camlrun-trunk.patch
2015-02-12 04:51 whitequark Note Added: 0013272
2015-02-15 22:02 gasche Note Added: 0013290
2015-02-27 16:50 whitequark Note Added: 0013357


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker