Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: "Soegtrop, Michael" <michael.soegtrop@intel.com>,
	"caml-list@inria.fr" <caml-list@inria.fr>
Subject: RE: [Caml-list] flexdll circular dependency on ocamlc: Impossible to built ocaml for mingw without using some prebuilt binaries?
Date: Sat, 24 Oct 2015 11:33:00 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9E9FB68CF@Remus.metastack.local> (raw)
In-Reply-To: <0F7D3B1B3C4B894D824F5B822E3E5A172CE331EE@IRSMSX102.ger.corp.intel.com>

[-- Attachment #1: Type: text/plain, Size: 3950 bytes --]

This is indeed a strange effect - bluntly, flexlink should be bootstrapped with the OCaml sources (i.e. a bytecode image of flexlink should be in /boot).

Note that your Cygwin build-route really is missing a step - you're bootstrapping, so the final stage should be recompiling flexlink using your new ocamlopt (the compilers do indeed need flexlink), then the dependency on Cygwin disappears. For my own builds, I extract flexlink.exe from Alain's binary distribution, build the FlexDLL objects from sources, compile OCaml and then recompile flexlink.exe using the that fresh compiler and replace the earlier binary copy. See, for example, https://github.com/dra27/OCaml-Windows-Build/blob/master/build.cmd#L527-L570

At some point, I was going to alter things so that FlexDLL is the only requirement for pre-installation (as that can be built from source) and have the ocaml process use boot/flexlink if a binary flexlink isn't available... but as that's only to satisfy a religious fervour to remove the circular dependency, it's right down at the bottom of my personal task list, especially as I doubt it would be merged :o)

Regarding the reason for FlexDLL, the solution for tricking the linker does also work for gcc - see http://edll.sourceforge.net/#def_a (which is referenced from FlexDLL's webpage). I expect Alain's motivation for FlexDLL is that the "side-effects" referred to in http://alain.frisch.fr/flexdll.html#examples were known about beforehand which the .def/.a solution doesn't solve, especially as it makes the build process more complicated.


David


From: caml-list-request@inria.fr [mailto:caml-list-request@inria.fr] On Behalf Of Soegtrop, Michael
Sent: 24 October 2015 10:51
To: caml-list@inria.fr
Subject: [Caml-list] flexdll circular dependency on ocamlc: Impossible to built ocaml for mingw without using some prebuilt binaries?

Dear Ocaml Users,

building Ocaml for Mingw on Cygwin I came across a strange effect: flexdll (or flexlink) depends on the Ocaml compiler and the Ocaml compiler depends on flexdll. I wonder how one is supposed to build Ocaml for Mingw from scratch? One either needs prebuilt flexdll/flexlink or Ocaml. What does work is to first build a native Cygwin Ocaml, then flexlink using this one and then the MingW Ocaml, but then flexlink depends on the Cygwin dlls. I am not sure how bad this is but I think ocamlc needs flexlink later as well when linking MingW apps. Also the effort of this is rather high. So I used a prebuilt flexlink/flexdll but I don't really like this.

Also I wonder why flexdll/flexlink is required. The documentation of flexdll states:

Windows DLL cannot refer to symbols defined in the main application or in previously loaded DLLs.

In my experience this is not true. At least when using MSVC one can declare functions in the main executable as DLL-export. Then when linking the main executable an import library is created in the same way as when building a DLL by the linker. The DLL can then link to this import library and can access the functions  in the main executable. The same is true for any other dlls already loaded. I don't do this every day but I did this more than once. I am not sure if this also works on old Windows OSes. I think the oldest one on which I tested this is Windows 7. Also I don't know if gcc does support creating an import library when linking an executable.

If this is of interest, I could provide a small demo for this and also test it with gcc for mingw and, if someone thinks this is useful, also on XP and Vista.

Best regards,

Michael


Intel Deutschland GmbH
Registered Address: Am Campeon 10-12, 85579 Neubiberg, Germany
Tel: +49 89 99 8853-0, www.intel.de<http://www.intel.de>
Managing Directors: Christin Eisenschmid, Prof. Dr. Hermann Eul
Chairperson of the Supervisory Board: Tiffany Doon Silva
Registered Office: Munich
Commercial Register: Amtsgericht Muenchen HRB 186928

[-- Attachment #2: Type: text/html, Size: 8449 bytes --]

  reply	other threads:[~2015-10-24 11:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-24  9:50 Soegtrop, Michael
2015-10-24 11:33 ` David Allsopp [this message]
2015-10-26  8:54   ` Soegtrop, Michael
2015-10-24 12:13 ` Alain Frisch
2015-10-24 12:51   ` David Allsopp
2015-10-26  9:41     ` Alain Frisch
2015-10-26 11:13       ` David Allsopp
2015-10-26  9:13   ` Soegtrop, Michael
2015-10-26  9:28     ` Alain Frisch
2015-10-26 12:46       ` Soegtrop, Michael

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=E51C5B015DBD1348A1D85763337FB6D9E9FB68CF@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    --cc=michael.soegtrop@intel.com \
    /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