ocaml-cross / opam-cross-android

An OCaml cross-toolchain for Android and several useful libraries
105 stars 15 forks source link

Support for several ABIs #2

Closed vouillon closed 8 years ago

vouillon commented 10 years ago

The toolchain is currently configured to target the ARMv5TE architecture.

It should be possible to generate ARMv7 code as well, as it is supported by most Android devices, uses hard floating points, and is more compact (OCaml will generate Thumb-2 instructions by default). You can have a look at how https://github.com/vouillon/ocaml-android does it. I think the selection should be done through an environment variable as with ANDROID_LEVEL.

The x86 architecture should be supported as well.

A concern is that the Android NDK is going to be duplicated for each all compiler. Maybe one can just extract the relevant platform and toolchain?

whitequark commented 10 years ago

Why would NDK be duplicated?

whitequark commented 10 years ago

Ah, you mean if I do the --alias-of thing with OPAM. I think I have a solution for both issues.

I'll add a conf-android-abi package that gathers and saves the parameters of the environment, including NDK path, ABI, architecture, and so on. Then, packages could use variables to fetch that information back.

vouillon commented 10 years ago

This is what I had in mind, indeed.

whitequark commented 10 years ago

By the way, if you like my approach to Android port better (I hope you do--I embarked on this with an explicit intent to make it simpler and more clear), I could add you as a collaborator.

vouillon commented 9 years ago

The ports should converge at some point. So, yes, I'm interested in being a collaborator. But I don't have the time to work on this at the moment.

lingz commented 8 years ago

Amy news on how to compile for x86 at current? Is it only possible with @vouillion 's package and not this one?

whitequark commented 8 years ago

@lingz you should be able to build for x86 by creating a separate switch and installing the compiler with ANDROID_ARCH set correctly. I don't recall offhand what the right value is but something like x86 might work?

lingz commented 8 years ago

For creating a separate switch do you mean to fork the opam-android32 package and modify the files there to add a case for arch=x86?

whitequark commented 8 years ago

Ah sorry. I forgot that I haven't pushed the changes yet that make switching platforms simple. I should do it within a week or so.

lingz commented 8 years ago

Ah that would be great. Thanks and look forward to it.

whitequark commented 8 years ago

Done (both hard-float ABI support and x86 support); please see README to see how would this be used.