caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* OCaml 3.11.0+beta1 cross-compiler
@ 2008-11-14 12:57 Richard Jones
  2008-11-15 19:02 ` ANNOUNCE: Windows cross-compiler (was: Re: [Caml-list] OCaml 3.11.0+beta1 cross-compiler) Richard Jones
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Jones @ 2008-11-14 12:57 UTC (permalink / raw)
  To: caml-list


Despite bug 4303 (http://caml.inria.fr/mantis/view.php?id=4303) having
lead to some changes in the compiler, I'm still extremely perplexed
about how to build a cross-compiler.

I want an 'ocamlopt' to be a Linux native binary[1] that generates
Windows executables.

We have a cross-assembler and cross-linker (i686-pc-mingw32-as and
i686-pc-mingw32-gcc respectively).  We also have a cross-compiler
version of flexdll.

My best attempt so far has been to generate config/{m,s}.h from
prepared Windows versions, and then build using the Unix Makefiles.
This gets some way, but produces an ocamlc which searches for files
using \ as a path separator, which is wrong and causes it to fail
looking for pervasives.cmi.

Anyone done this, or care to share any more hints?

Rich.

[1] Running stuff under Wine isn't acceptable and nor is installing
binaries.

-- 
Richard Jones
Red Hat


^ permalink raw reply	[flat|nested] 3+ messages in thread

* ANNOUNCE: Windows cross-compiler (was: Re: [Caml-list] OCaml 3.11.0+beta1 cross-compiler)
  2008-11-14 12:57 OCaml 3.11.0+beta1 cross-compiler Richard Jones
@ 2008-11-15 19:02 ` Richard Jones
  2008-11-16  4:20   ` Romain Beauxis
  0 siblings, 1 reply; 3+ messages in thread
From: Richard Jones @ 2008-11-15 19:02 UTC (permalink / raw)
  To: caml-list

[Oh well, the overwhelming rush of answers seems to indicate we are
entering into new territory here ...]

Here is a Linux -> Win32 OCaml cross-compiler, developed and sponsored
by Red Hat's Fedora MinGW project[1].  Red Hat are sponsoring this
project so that we can build our OCaml virt tools for Windows without
the hassle of using Windows.

  http://hg.et.redhat.com/misc/fedora-mingw--devel/
  (There is no direct link - to get the latest version you have
  to click "manifest" then "ocaml").

If you're not familiar with RPM builds, then start with the .spec file
and the patches.  Pay close attention to the 'BuildRequires' which are
the parts of the MinGW project you will need to build it - in
particular, we use a version of FlexDLL which we have modified for
cross-compilation.

It's probably best to say what does work, because the list of what
_doesn't_ work is quite long.  But with this you get:

  i686-pc-mingw32-ocamlopt
       The cross-compiler replacement for ocamlopt
          (bytecode so you need a corresponding
           ocamlrun interpreter to use it)

  *.cmx, *.cmxa
       The usual OCaml stdlib libraries, eg. nums, dynlink, unix, threads
          (only lightly tested)

eg:

  $ cat /tmp/test.ml
  
  open Printf
  
  let () =
    printf "reported os_type = %S\n" Sys.os_type;
    printf "ok\n"

  $ boot/ocamlrun i686-pc-mingw32-ocamlopt -verbose -I stdlib /tmp/test.ml \
    -o /tmp/test.exe
  + i686-pc-mingw32-as -o '/tmp/test.o' '/tmp/camlasm56b36c.s'
  + i686-pc-mingw32-as -o '/tmp/camlstartup4b26a5.o' '/tmp/camlstartup76cf6d.s'
  + flexlink -chain mingw -exe -o '/tmp/test.exe'  -I'/usr/lib64/i686-pc-mingw32-ocaml' '-Lstdlib' '-L/usr/lib64/i686-pc-mingw32-ocaml' '/tmp/camlstartup4b26a5.o' 'stdlib/std_exit.o' '/tmp/test.o' 'stdlib/stdlib.a' 'stdlib/libasmrun.a'  

  $ file /tmp/test.exe 
  /tmp/test.exe: PE32 executable for MS Windows (console) Intel 80386 32-bit

  $ wine /tmp/test.exe
  reported os_type = "Win32"
  ok

There are about a million things to fix, but this should be enough to
get people started.

Rich.

[1] https://fedoraproject.org/wiki/MinGW

-- 
Richard Jones
Red Hat


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ANNOUNCE: Windows cross-compiler (was: Re: [Caml-list] OCaml 3.11.0+beta1 cross-compiler)
  2008-11-15 19:02 ` ANNOUNCE: Windows cross-compiler (was: Re: [Caml-list] OCaml 3.11.0+beta1 cross-compiler) Richard Jones
@ 2008-11-16  4:20   ` Romain Beauxis
  0 siblings, 0 replies; 3+ messages in thread
From: Romain Beauxis @ 2008-11-16  4:20 UTC (permalink / raw)
  To: caml-list

Le Saturday 15 November 2008 20:02:51 Richard Jones, vous avez écrit :
> There are about a million things to fix, but this should be enough to
> get people started.

Thanks for this work, that seems an awsome achievement !


Romain


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-11-16  4:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-14 12:57 OCaml 3.11.0+beta1 cross-compiler Richard Jones
2008-11-15 19:02 ` ANNOUNCE: Windows cross-compiler (was: Re: [Caml-list] OCaml 3.11.0+beta1 cross-compiler) Richard Jones
2008-11-16  4:20   ` Romain Beauxis

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).