caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Adrien Nader <adrien@notk.org>
To: whitequark <whitequark@whitequark.org>
Cc: "Soegtrop, Michael" <michael.soegtrop@intel.com>, caml-list@inria.fr
Subject: Re: [Caml-list] [ANN] opam-cross-windows
Date: Tue, 15 Mar 2016 10:18:05 +0100	[thread overview]
Message-ID: <20160315091805.GA835@notk.org> (raw)
In-Reply-To: <921db39a51df11567295fcbbb1e6b394@whitequark.org>

On Tue, Mar 15, 2016, whitequark wrote:
> On 2016-03-15 11:26, Soegtrop, Michael wrote:
> >Dear Whitequark,
> >
> >>I've released opam-cross-windows[1], a 4.02.3 OCaml toolchain in
> >>the spirit
> >>of opam-cross-android[2] (ex opam-android).
> >
> >Do you think there are good chances that this also works for cross
> >compiling for MinGW on cygwin.
> >Or asked in another way: are there known reasons why this
> >shouldn't work?
> 
> opam-cross-windows builds OCaml to run on top of bare Win32 i.e. it uses
> win32unix and otherwise embeds such assumptions in the compiler
> configuration.
> Since Cygwin is striving to present a Unix-like environment, those
> assumptions would not hold. So I don't think opam-cross-windows will
> work on Cygwin, sorry.

My understanding of the question was to build the cross-compiler from
Cygwin rather than from Linux. As far as I'm concerned, I see no reason
for this not to work besides small implementation.

> >I made some scripts to compile things like GTK, pango, cairo, ocaml,
> >menhir, Coq, CoqIDE, ... for MinGW on cygwin and also to setup cygwin
> >with the required packages automatically in a reproducible way. A
> >MinGW cross Opam for cygwin would be the logical next step. Together
> >with my scripts this might be a reproducible and maintainable way to
> >compile and setup ocaml and required libraries on Windows.
> 
> Perhaps. I find Cygwin annoying to deal with so I don't care for it
> much.
> Feel free to fork opam-cross-windows and reuse my technique to solve
> your problem. It can be adapted with minimal changes to almost any
> set of host and target systems, given that the OCaml buildsystem
> supports it.

At that point I should point out win-builds.org which has the C packages
buildable in a portable and reproducible manner. Not the OCaml ones
because I hadn't been confident enough in its cross-compiler until now
(seeing toplevel expressions not being evaluated sometimes has been a
really cold shower). Unfotunately I need to finish a set of large
changes before I can push a large update to win-builds that simplifies
setup a lot.

> >One more question: on Windows there is (or was) a circular dependency
> >between flexdll and Ocaml. One of the two needs to be installed in
> >binary form. Did you also run into this issue? If so, how did you
> >solve it?
> 
> Inherent deficiencies in the current OCaml buildsystem mean that
> any cross-compiler build requires an OCaml compiler targeting the build
> system, with exactly matching version and bitness. Similarly, since
> opam-cross-windows does not provide a compiler switch, an OCaml compiler
> is inherently present (and it is required anyway to compile packages
> which invoke build system components such as ppx, camlp4, cppo, etc).
> So, the need to build flexdll does not present a problem.

I saw mentions of flexdll being embedded in the compiler sources now too
so that it is possible to break that loop. Haven't had time to try it
though. In any case, as whitequark points out, there is no such loop for
cross-compilers.

> >Btw: I also experimented with MSys, MSys2 instead of cygwin, but found
> >that cross compiling mayn packages for for MinGW under cygwin is
> >easier than under MSys, MSys2.
> 
> Note that opam-cross-windows uses a toolchain that targets plain Win32
> API without using any kind of POSIX emulation such as MSYS or Cygwin.

It is important to note that Msys was never meant for people to compile
and link against but only as a posix environment to run applications in.

MSYS2 updates it against a much more recent cygwin and builds many many
more things against it. However noone wants their application to link
against any msys*.

The difference between cygwin and msys is that with cygwin you do
cross-compile while with msys* you light a candle, pray to $deity and
hope that whatever you're building will not notice it is building in a
posix-ish environment that automatically translates paths that go to and
come from win32 applications depending on a set of heuristics.

It is possible to do cross-compilation under msys* too but I've found it
to be less reliable, especially with msys2 because it does weird things
and changes every other day. In particular, issues when building an
ocaml cross-compiler seemed impossible to understand.

-- 
Adrien Nader

  parent reply	other threads:[~2016-03-15  9:18 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-13  9:02 whitequark
2016-03-14 19:55 ` Martin DeMello
2016-03-14 20:14   ` Adrien Nader
2016-03-14 20:26     ` Martin DeMello
2016-03-14 20:39       ` Adrien Nader
2016-03-14 21:10         ` Martin DeMello
2016-03-15  8:37       ` whitequark
2016-03-15  8:26 ` Soegtrop, Michael
2016-03-15  8:36   ` whitequark
2016-03-15  8:53     ` Soegtrop, Michael
2016-03-15  8:56       ` whitequark
2016-03-15 11:29         ` Soegtrop, Michael
2016-03-16 14:27       ` Andreas Hauptmann
2016-03-15  9:18     ` Adrien Nader [this message]
2016-03-15  9:12   ` David Allsopp
2016-05-20 18:38 ` Boutillier, Pierre
2016-05-20 18:45   ` whitequark
2016-05-23  8:24     ` Soegtrop, Michael
2016-05-24  6:57       ` whitequark
2016-05-24 12:35         ` Adrien Nader
2016-05-23  9:53   ` Mauricio Fernández

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160315091805.GA835@notk.org \
    --to=adrien@notk.org \
    --cc=caml-list@inria.fr \
    --cc=michael.soegtrop@intel.com \
    --cc=whitequark@whitequark.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).