caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Nicolas Ojeda Bar <n.oje.bar@gmail.com>
To: Stefan Hellermann <stefan@the2masters.de>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Broken 32 bit cross-compiler on 64bit host
Date: Thu, 8 Oct 2015 11:52:58 +0200	[thread overview]
Message-ID: <CAPunWhAvvm9Y3E0SW8pQBFZr6rrueeF+4cR9vv5mQYaASZJFcw@mail.gmail.com> (raw)
In-Reply-To: <CAANYUdA9yg3TNJ4WriWhDo_FnsSmB7bOf+cWviBBcux8txUueg@mail.gmail.com>

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

Dear Stefan,

I believe it is currently impossible to build a working cross-compiler
between different word sizes, as the compiler does not differentiate
between the host and the target's native integers.

Best wishes,
Nicolas


On Thu, Oct 8, 2015 at 11:43 AM, Stefan Hellermann <stefan@the2masters.de>
wrote:

> Hello,
>
> currently I'm trying to add OCaml to the openwrt router distribution [1]
> [2]. This would mean you could run your favorite OCaml applications on your
> router. I would like to run unison [3] on my router.
>
> So I first build native OCaml 4.02.3 on my x86_64 linux host, and then
> build a OCaml cross-compiler for the 32 bit target, e.g.
> mips-openwrt-linux. Building OCaml went fine after adding a small patch to
> manually set Endianness and Bitness in configure script, please have a look
> at attached patch.
>
> host OCaml configure line:
> ./configure -prefix somepath -no-pthread -no-debugger -no-ocamldoc
> -no-graph -no-cfi
> cross OCaml configure line:
> ./configure -prefix someotherpath -target-bindir /usr/bin -host
> x86_64-unknown-linux-gnu -target mips-openwrt-linux-musl -cc
> "mips-openwrt-linux-musl-gcc some target cflags" -as
> "mips-openwrt-linux-musl-as some target as flags" -no-pthread
> -no-shared-libs -no-debugger -no-ocamldoc -no-graph -no-cfi -big-endian
>
>
> Now the bug: When running OCaml applicantions (build with -custom), they
> crash on startup on the target:
>
> Fatal error: exception Failure("input_value: integer too large")
>
>
> This is similar to OCaml Bug #5977 [4]
>
> There is a workaround:
> Build the host OCaml as 32 bit OCaml, then build the cross compiler with
> this 32 bit host OCaml. The resulting binaries work on the target.
> This is what I did for openwrt [2], but it fails on 64 bit hosts where no
> 32 bit development tools are installed. It only catches the case when
> building on x86_64 hosts, it will break when building on say powerpc64 or
> 64 bit arm. It's also problematic for openwrt, as only the cross compiler
> but not the host tools are recompiled if the target arch changes, e.g. from
> 64 bit arm to 32 bit mips.
>
> Now my questions:
> - Is building a 32 bit cross compiler on a 64 bit host supposed to work?
> - Is my patch to configure ok, or is there a better way to configure the
> cross-compiler?
> - Should I run some test suite on the target and post the results?
>
> [WARNING] Something went wrong while checking native division and modulus
> please report it at http://http://caml.inria.fr/mantis/
> Do I have to care?
> I tried defining and undefining NONSTANDARD_DIV_MOD in m.h. without any
> visible difference. Running the test-prog divmod.c on a few targets always
> returns 0.
>
> [1] https://openwrt.org/
> [2] https://patchwork.ozlabs.org/patch/518982/
> [3] https://www.cis.upenn.edu/~bcpierce/unison/
> [4] http://caml.inria.fr/mantis/view.php?id=5977
>
>
>

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

  reply	other threads:[~2015-10-08  9:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-10-08  9:43 Stefan Hellermann
2015-10-08  9:52 ` Nicolas Ojeda Bar [this message]
2015-10-08 16:42   ` Gerd Stolpmann
2015-10-09 12:27     ` Stefan Hellermann
2015-10-13 16:22       ` Adrien Nader

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=CAPunWhAvvm9Y3E0SW8pQBFZr6rrueeF+4cR9vv5mQYaASZJFcw@mail.gmail.com \
    --to=n.oje.bar@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=stefan@the2masters.de \
    /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).