From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@sympa.inria.fr Delivered-To: caml-list@sympa.inria.fr Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by sympa.inria.fr (Postfix) with ESMTPS id 22E0B7F7AF for ; Fri, 9 Oct 2015 14:27:58 +0200 (CEST) IronPort-PHdr: 9a23:ZRZkHRWtRcnGpQjMW7v5KGLWwGXV8LGtZVwlr6E/grcLSJyIuqrYZhOPt8tkgFKBZ4jH8fUM07OQ6PC8HzFYqb+681k8M7V0HycfjssXmwFySOWkMmbcaMDQUiohAc5ZX0Vk9XzoeWJcGcL5ekGA6ibqtW1aJBzzOEJPK/jvHcaK1oLsh7z0psWbSj4LrQT+SIs6FA+xowTVu5teqqpZAYF19CH0pGBVcf9d32JiKAHbtR/94sCt4MwrqHwI6LoXzNNbSajxY4g/SLVZCnxmbzF0t4XXskzsQBGDrkAAVWEOlxNOBUCR7Rf0Wb/+vzH28/Fh3y2COMTwS/Y4VGLxwb1sTUrTlCoJPjhx0GzTjsFqiatdplr1vAByzYfSSJ2VOaB7d7jBcMkBA2ZMCJUCHxddC5+xOtNcR9EKOvxV+tWsqg== Authentication-Results: mail3-smtp-sop.national.inria.fr; spf=None smtp.pra=stefan@the2masters.de; spf=Pass smtp.mailfrom=stefan@the2masters.de; spf=None smtp.helo=postmaster@mail-io0-f174.google.com Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of stefan@the2masters.de) identity=pra; client-ip=209.85.223.174; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="stefan@the2masters.de"; x-sender="stefan@the2masters.de"; x-conformance=sidf_compatible Received-SPF: Pass (mail3-smtp-sop.national.inria.fr: domain of stefan@the2masters.de designates 209.85.223.174 as permitted sender) identity=mailfrom; client-ip=209.85.223.174; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="stefan@the2masters.de"; x-sender="stefan@the2masters.de"; x-conformance=sidf_compatible; x-record-type="v=spf1" Received-SPF: None (mail3-smtp-sop.national.inria.fr: no sender authenticity information available from domain of postmaster@mail-io0-f174.google.com) identity=helo; client-ip=209.85.223.174; receiver=mail3-smtp-sop.national.inria.fr; envelope-from="stefan@the2masters.de"; x-sender="postmaster@mail-io0-f174.google.com"; x-conformance=sidf_compatible X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0AKAQDdsRdWm67fVdFEGhaDZG4GrCyIEYsGFwEJgnKCCn8CgUIHOxEBAQEBAQEBARABAQEBAQYLCwkhLoIfggcBAQEDARIRHQEBExkLAQQLCQILAwoNHQICIhIBBQEKEgYTCQkJB4d3AwoIBAk7kSKPTYExPjGKWHGEZQEFiXsDhS4BAQEBAQEBAwEBAQEBAQEVBgqKYYEGhGciBAeCLjsUgTGGCAyBLY5WhRmGEIFxWn5Ig3KOL4NPgiMSI4EXESaCMA0WB4FWbwGGY4EGAQEB X-IPAS-Result: A0AKAQDdsRdWm67fVdFEGhaDZG4GrCyIEYsGFwEJgnKCCn8CgUIHOxEBAQEBAQEBARABAQEBAQYLCwkhLoIfggcBAQEDARIRHQEBExkLAQQLCQILAwoNHQICIhIBBQEKEgYTCQkJB4d3AwoIBAk7kSKPTYExPjGKWHGEZQEFiXsDhS4BAQEBAQEBAwEBAQEBAQEVBgqKYYEGhGciBAeCLjsUgTGGCAyBLY5WhRmGEIFxWn5Ig3KOL4NPgiMSI4EXESaCMA0WB4FWbwGGY4EGAQEB X-IronPort-AV: E=Sophos;i="5.17,657,1437429600"; d="scan'208";a="150082406" Received: from mail-io0-f174.google.com ([209.85.223.174]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/AES128-GCM-SHA256; 09 Oct 2015 14:27:56 +0200 Received: by iofh134 with SMTP id h134so89271165iof.0 for ; Fri, 09 Oct 2015 05:27:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=the2masters.de; s=mail; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=YA5T9Z1/2AJZYkY/EhmCORXaDqDeOoN26UoIa3kSlOM=; b=d4I6vPrsNWyVbH3xnGb5wzjz8P+g5LynGVaMXVnIkIvGxw/WPG9QfmxhuVVSeZXUWk zDWP6c4FlKqFBNw1PRMus5cwmRfips/L1o9JcxOsm2rKhcdTQzWLMgDsBYsMVelFXxRP GxdZqfbyuKq2PC04V3sGZ4QhRB7qkiCyQ5i/M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc:content-type; bh=YA5T9Z1/2AJZYkY/EhmCORXaDqDeOoN26UoIa3kSlOM=; b=lh79Mlj3LeW4ooGw7lXouPhf6Io/0IxdABphAP6wpmfTRWXTmXkU9sFjm692Yeob/7 uthpyHcOzfvxGpF6QxMjYMkMCic7CRcnEAt8tmUn3MT9WwolTFAgQ7hMkVZLE1GcrZPm CYvkfvyYiBi3Zaus6/hCY8uL+0GuDUTzlwhPsosKODLNkwkTnbI5ZRL0UpLJgkl8Bl8K +jYmYbQNNrnW0Kiy5pEDhs2QnqhwY7rptL2APhLZt3BCuDGPtOXfaxIWKuKgwUgYzERE I6dy7dlWkZ2Fqcq8TCFz+il/jTcU2bBOsXfEJhOKmFNG6Ln/U09kIzsC0+ooeOPxw/xc MZsg== X-Gm-Message-State: ALoCoQkd9IsWZ0rghKCLnjbj28g86hWdSnRahlAsVXekUTOLeoTl3xmRfYC8lkrTAUzwVuqN0E0I X-Received: by 10.107.46.158 with SMTP id u30mr16545252iou.56.1444393674851; Fri, 09 Oct 2015 05:27:54 -0700 (PDT) MIME-Version: 1.0 Received: by 10.36.210.85 with HTTP; Fri, 9 Oct 2015 05:27:35 -0700 (PDT) X-Originating-IP: [87.159.75.210] In-Reply-To: References: From: Stefan Hellermann Date: Fri, 9 Oct 2015 14:27:35 +0200 Message-ID: To: Gerd Stolpmann Cc: Nicolas Ojeda Bar , caml-list@inria.fr Content-Type: multipart/alternative; boundary=001a113ac342e7e2a40521ab1b6e Subject: Re: [Caml-list] Broken 32 bit cross-compiler on 64bit host --001a113ac342e7e2a40521ab1b6e Content-Type: text/plain; charset=UTF-8 So I think I have to build a 32 bit and a 64 bit host OCaml and select the right one when building a cross-compiler. I sent a patch series which changes the way the configure script checks for pointer sizes and endianess. Is this okay? It should work for all native and cross compilation cases. Can you test and comment on them? These are the only patches I need against OCaml to make it usable on openwrt. Stefan 2015-10-08 18:42 GMT+02:00 Gerd Stolpmann : > Correct, it's unsupported. Unfortunately, there is no check in the > configure script whether the word sizes match (it only checks for the > OCaml version). > > It's not only the value marshaller that can fail, but I've also seen > illegal assembler code. The core of the problem is that the generic parts > of the native-code backend use nativeint for integer calculations, and the > code emitters for 32 bit platforms then just assume nativeint has only 32 > bits. I guess the solution would be to introduce a new integer type > targetint into the compiler that is either int32 or int64, depending on > what the cross-compile target is. > > Gerd > > > > 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 > >> > >> > >> > > > > -- > > Caml-list mailing list. Subscription management and archives: > > https://sympa.inria.fr/sympa/arc/caml-list > > Beginner's list: http://groups.yahoo.com/group/ocaml_beginners > > Bug reports: http://caml.inria.fr/bin/caml-bugs > > > -- > ------------------------------------------------------------ > Gerd Stolpmann, Darmstadt, Germany gerd@gerd-stolpmann.de > My OCaml site: http://www.camlcity.org > Contact details: http://www.camlcity.org/contact.html > Company homepage: http://www.gerd-stolpmann.de > ------------------------------------------------------------ > > > --001a113ac342e7e2a40521ab1b6e Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable
So I think I have to build a 32 bit and a 64 bit= host OCaml and select the right one when building a cross-compiler.
I sent a patch series which changes the way the configure script che= cks for pointer sizes and endianess. Is this okay? It should work for all n= ative and cross compilation cases. Can you test and comment on them? These = are the only patches I need against OCaml to make it usable on openwrt.
Stefan

2015-10-08 18:42 GMT+02:00 Gerd Stolpmann <<= a href=3D"mailto:info@gerd-stolpmann.de" target=3D"_blank">info@gerd-stolpm= ann.de>:
Correct, it's = unsupported. Unfortunately, there is no check in the
configure script whether the word sizes match (it only checks for the
OCaml version).

It's not only the value marshaller that can fail, but I've also see= n
illegal assembler code. The core of the problem is that the generic parts of the native-code backend use nativeint for integer calculations, and the<= br> code emitters for 32 bit platforms then just assume nativeint has only 32 bits. I guess the solution would be to introduce a new integer type
targetint into the compiler that is either int32 or int64, depending on
what the cross-compile target is.

Gerd


> 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 distri= bution [1]
>> [2]. This would mean you could run your favorite OCaml application= s 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 ha= ve 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-pt= hread
>> -no-shared-libs -no-debugger -no-ocamldoc -no-graph -no-cfi -big-e= ndian
>>
>>
>> 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 larg= e")
>>
>>
>> This is similar to OCaml Bug #5977 [4]
>>
>> There is a workaround:
>> Build the host OCaml as 32 bit OCaml, then build the cross compile= r 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 w= here
>> no
>> 32 bit development tools are installed. It only catches the case w= hen
>> building on x86_64 hosts, it will break when building on say power= pc64
>> or
>> 64 bit arm. It's also problematic for openwrt, as only the cro= ss
>> 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 configu= re 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<= br> >> 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. withou= t any
>> visible difference. Running the test-prog divmod.c on a few target= s
>> always
>> returns 0.
>>
>> [1] https://openwrt.org/
>> [2] https://patchwork.ozlabs.org/patch/518982/
>> [3]
https://www.cis.upenn.edu/~bcpierce/unison/<= /a>
>> [4]
http://caml.inria.fr/mantis/view.php?id= =3D5977
>>
>>
>>
>
> --
> Caml-list mailing list.=C2=A0 Subscription management and archives:
> https://sympa.inria.fr/sympa/arc/caml-list
> Beginner's list: http://groups.yahoo.com/group= /ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs


--
------------------------------------------------------------
Gerd Stolpmann, Darmstadt, Germany=C2=A0 =C2=A0 gerd@gerd-stolpmann.de
My OCaml site:=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 http://www.camlcity.org<= br> Contact details:=C2=A0 =C2=A0 =C2=A0 =C2=A0 http://www.camlcity.= org/contact.html
Company homepage:=C2=A0 =C2=A0 =C2=A0 =C2=A0http://www.gerd-stolpmann.de=
------------------------------------------------------------



--001a113ac342e7e2a40521ab1b6e--