Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0006266OCamlOCaml generalpublic2013-12-12 11:252015-01-23 12:45
Assigned To 
PlatformOSOS Version
Product Version 
Target VersionFixed 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 [^]).

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.
Attached Filespatch file icon camlrun.patch [^] (36,483 bytes) 2014-12-28 23:34 [Show Content]

- Relationships
related to 0005887confirmed 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
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 [^] I've also heard about iOS applications implemented in OCaml, see [^] for example.
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 ( [^]), 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.
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.
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 [^]
    opam install ocaml-android
    ocamlfind -toolchain android ocamlopt

I will follow up these patches with ones that properly detect the target environment features without running target binaries.
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.
strobegen (reporter)
2014-10-17 09:29

I will try to test when it be ready
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).
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'.
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.

- 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

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker