[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: ocaml crosscompiler ?



Le mardi 5 janvier 2010 15:35:32, Stefano Zacchiroli a écrit :
> >  * The cross-compiler packaging should benefit from the main compiler's 
> > packaging. It may even be very similar.
> 
> Well, to that end, I believe that the current packaging of ocaml in Git
> can be very useful: I can easily imagine a cross compiler ocaml package
> having as "upstream" the main ocaml packaging hence gaining the ability
> to push/pull changes and ever cherry-pick specific patches. We already
> have the technology to handle that, from there on is a matter of
> technical choices of the first/main maintainer of the cross compiler.

Yes, I was thinking about this too.

> >  * We need to discuss a policy for such a cross compiler: 
> >    o Where to install it ?
> >    o What name to give it ?
> 
> I'm not an expert on cross compilation (used that only once in a while,
> never packaged a cross compiler), but the first thing we should look for
> is some sort of common way of doing things. Given that you seem
> knowledgeable on the subject, can you please report to all of us which
> naming/path choices other cross compilers available in Debian have done?
> 
> Once those are clear we can easily come to a reasoned decision for an
> OCaml cross compiler ...

So, some facts. 

The cross-compiler for windows used for compiling the 
ocaml cross-compiler is contained in the package mingw32.

This package installs its files in /usr/lib/gcc[exec]/i586-mingw32msvc for 
gcc-related files, and the binaries are named /usr/bin/i586-mingw32msvc-*, 
where i586-mingw32msvc is the target host.

In fedora's mingw32, the target host is i686-pc-mingw32.

The compilation of the ocaml cross-compiler is pretty straight forward. 
It works on intel 32bit arch (i386 and amd64 in 32 bit mode). After patching, 
it needs:
 * A boostrap compilation giving a native 32-bit ocamlc including a patch about 
   file seperator in win32.
 * A full compilation using a shipped makefile

Also, the compilation needs a binary of the flexdll utility used to load dynamic 
binary objects in widows. This may be a seperate package or compiled in the 
main package.

Then, the package installs the arch-specific binaries with a "mingw32-" prefix to 
/usr/bin, and the libs to /usr/lib/mingw32-ocaml.

The setup uses ocamlfind to switch from /usr/lib/ocaml to /usr/lib/mingw32-ocaml. 

A module compilation is almost the same, usually adding --target=i586-mingw32msvc, 
and pointing to the ocaml cross-compiler, although the names ocamlop, ocamlc, etc.. 
are often hardcoded in the build scripts.

> >  * We eventually need to decide what we want to do about cross-compiled 
> > modules. For native modules, it should not be difficult, and I believe
> > that we  may be able to compile a cross-compiled module only by changing
> > the default ocamlc and etc.. For modules which link to binary objects,
> > such as bindings, this might be a little bit more difficult since we also
> > need a cross-compiled version of the corresponding library..
> 
> I've voiced a humble opinion on this already. I believe we should
> refrain from packaging cross-compiled modules unless they are proven to
> be needed and useful to at least some users, given that they come at a
> price (if only the need of multiplying the places that must be fixed
> upon security flaws). Once more, this kind of problems do not seem
> specific to OCaml though, what does the gcc-mingw32 people do for their
> libraries?

Yes, I agree that building 32-bit modules is not relevant. However, a 
custom version of ocamlfind should be interesting. It is also very easy 
since it only involves a set of conf files if I remember well... It may be in a main 
mingw32-ocaml package, then...


Romain

PS: some links:
The main git repository for the build system:
  http://git.annexia.org/?p=fedora-mingw.git;a=tree;f=ocaml;h=c735be9b0f072449402289b6c23e57cd5667b02a;hb=HEAD
Ocaml-specific files:
  http://git.annexia.org/?p=fedora-mingw.git;a=tree;f=ocaml;h=c735be9b0f072449402289b6c23e57cd5667b02a;hb=HEAD
The build script for ocaml:
  http://git.annexia.org/?p=fedora-mingw.git;a=blob_plain;f=ocaml/mingw32-ocaml.spec;hb=HEAD
The flexdll files:
  http://git.annexia.org/?p=fedora-mingw.git;a=blob_plain;f=ocaml/mingw32-ocaml.spec;hb=HEAD

Romain


Reply to: