caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] Trying out the arm64 compiler
@ 2013-12-23 15:00 Richard W.M. Jones
  2013-12-23 15:07 ` Richard W.M. Jones
  0 siblings, 1 reply; 7+ messages in thread
From: Richard W.M. Jones @ 2013-12-23 15:00 UTC (permalink / raw)
  To: caml-list; +Cc: benedikt.meurer

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

I'm trying to compile OCaml for arm64/aarch64.  I'm currently
trying the trunk branch from:

https://github.com/ocaml/ocaml

which should be identical to SVN.  It requires a trivial patch which
is attached.

I'm using qemu as an arm64 userspace emulator, with Fedora Rawhide:

http://rwmj.wordpress.com/2013/12/22/how-to-run-aarch64-binaries-on-an-x86-64-host-using-qemu-userspace-emulation/#content

Anyway, it hangs, consistently as soon as it tries to run any
ocamlopt-compiled program.  During the compile, the first hang is
here:

../../ocamlcomp.sh -c -w +33..39 -warn-error A -g -nolabels unix.mli

[which runs the just-compiled ocamlc.opt], but even a trivial test
program hangs:

$ echo 'print_endline "hello, world"' > test.ml
$ ./boot/ocamlrun ./ocamlopt -I stdlib stdlib.cmxa test.ml -o test
$ ./test
[hangs here]

Disassembly shows this really is an aarch64 native binary.

Unfortunately because of the technique I'm using (qemu-arm64) I cannot
use gdb or strace to look at where it is hanging, although I am
reasonably sure that it's not hanging *because* of qemu -- at least,
I've been able to compile and run masses of software using gcc under
the same conditions.

Has anyone seen this or have any other ideas?

Am I using the right branch for arm64 work?

Rich.

-- 
Richard Jones
Red Hat

[-- Attachment #2: 0001-Minor-compile-fix-for-arm64.patch --]
[-- Type: text/x-diff, Size: 819 bytes --]

From de5c2f3809771981976d4afd50b701b3f005eedc Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Mon, 23 Dec 2013 09:51:55 -0500
Subject: [PATCH] Minor compile fix for arm64.

---
 asmcomp/arm64/emit.mlp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/asmcomp/arm64/emit.mlp b/asmcomp/arm64/emit.mlp
index bc03c5d..1b298da 100644
--- a/asmcomp/arm64/emit.mlp
+++ b/asmcomp/arm64/emit.mlp
@@ -604,7 +604,7 @@ let emit_instr i =
         `	ldr	{emit_reg reg_trap_ptr}, [sp], 16\n`;
         cfi_adjust_cfa_offset (-16);
         stack_offset := !stack_offset - 16
-    | Lraise ->
+    | Lraise k ->
         begin match !Clflags.debug, k with
         | true, (Lambda.Raise_regular | Lambda.Raise_reraise) ->
           `	bl	{emit_symbol "caml_raise_exn"}\n`;
-- 
1.8.3.1


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

* Re: [Caml-list] Trying out the arm64 compiler
  2013-12-23 15:00 [Caml-list] Trying out the arm64 compiler Richard W.M. Jones
@ 2013-12-23 15:07 ` Richard W.M. Jones
  2013-12-23 15:32   ` Richard W.M. Jones
  0 siblings, 1 reply; 7+ messages in thread
From: Richard W.M. Jones @ 2013-12-23 15:07 UTC (permalink / raw)
  To: caml-list; +Cc: benedikt.meurer

On Mon, Dec 23, 2013 at 03:00:27PM +0000, Richard W.M. Jones wrote:
> $ ./test
> [hangs here]

FWIW:

$ OCAMLRUNPARAM=v=0x1ff ./test
Initial minor heap size: 2048k bytes
Initial major heap size: 992k bytes
Initial space overhead: 80%
Initial max overhead: 500%
Initial heap increment: 992k bytes
Initial allocation policy: 0
[hangs here, using 100% CPU]

Rich.

-- 
Richard Jones
Red Hat

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

* Re: [Caml-list] Trying out the arm64 compiler
  2013-12-23 15:07 ` Richard W.M. Jones
@ 2013-12-23 15:32   ` Richard W.M. Jones
  2013-12-23 17:16     ` Richard W.M. Jones
  0 siblings, 1 reply; 7+ messages in thread
From: Richard W.M. Jones @ 2013-12-23 15:32 UTC (permalink / raw)
  To: caml-list; +Cc: benedikt.meurer

I worked out how to get qemu to give me a call trace.  The trace:

http://oirase.annexia.org/tmp/arm64-call-trace.txt

prints a log containing registers and current PC before each
translated block runs ("translated block" meaning each block of code
that qemu translates to native code).

Here's the code disassembly:

http://oirase.annexia.org/tmp/arm64-disassembly.txt

Rich.

-- 
Richard Jones
Red Hat

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

* Re: [Caml-list] Trying out the arm64 compiler
  2013-12-23 15:32   ` Richard W.M. Jones
@ 2013-12-23 17:16     ` Richard W.M. Jones
  2013-12-23 18:32       ` Richard W.M. Jones
  0 siblings, 1 reply; 7+ messages in thread
From: Richard W.M. Jones @ 2013-12-23 17:16 UTC (permalink / raw)
  To: caml-list; +Cc: benedikt.meurer


An update on this:

The error also occurs with 055d5c0379e42b4f561cb1fc5159659d8e9a7b6f /
trunk@13909 which is the arm64 merge commit.

I've asked if we can run the test binary on real aarch64 hardware
(which I don't have direct access to, but I know people who do) to see
if it behaves the same way as on qemu.

Rich.

-- 
Richard Jones
Red Hat

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

* Re: [Caml-list] Trying out the arm64 compiler
  2013-12-23 17:16     ` Richard W.M. Jones
@ 2013-12-23 18:32       ` Richard W.M. Jones
  2013-12-23 19:00         ` Anil Madhavapeddy
  2013-12-23 22:03         ` Richard W.M. Jones
  0 siblings, 2 replies; 7+ messages in thread
From: Richard W.M. Jones @ 2013-12-23 18:32 UTC (permalink / raw)
  To: caml-list; +Cc: benedikt.meurer

On Mon, Dec 23, 2013 at 05:16:41PM +0000, Richard W.M. Jones wrote:
> 
> An update on this:
> 
> The error also occurs with 055d5c0379e42b4f561cb1fc5159659d8e9a7b6f /
> trunk@13909 which is the arm64 merge commit.
> 
> I've asked if we can run the test binary on real aarch64 hardware
> (which I don't have direct access to, but I know people who do) to see
> if it behaves the same way as on qemu.

It turns out to be a *qemu* issue, as the same binary works
fine on the actual hardware.  A surprise for me.

Rich.

-- 
Richard Jones
Red Hat

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

* Re: [Caml-list] Trying out the arm64 compiler
  2013-12-23 18:32       ` Richard W.M. Jones
@ 2013-12-23 19:00         ` Anil Madhavapeddy
  2013-12-23 22:03         ` Richard W.M. Jones
  1 sibling, 0 replies; 7+ messages in thread
From: Anil Madhavapeddy @ 2013-12-23 19:00 UTC (permalink / raw)
  To: Richard W.M. Jones; +Cc: Ocaml Mailing List, benedikt.meurer

On 23 Dec 2013, at 18:32, Richard W.M. Jones <rich@annexia.org> wrote:

> On Mon, Dec 23, 2013 at 05:16:41PM +0000, Richard W.M. Jones wrote:
>> 
>> An update on this:
>> 
>> The error also occurs with 055d5c0379e42b4f561cb1fc5159659d8e9a7b6f /
>> trunk@13909 which is the arm64 merge commit.
>> 
>> I've asked if we can run the test binary on real aarch64 hardware
>> (which I don't have direct access to, but I know people who do) to see
>> if it behaves the same way as on qemu.
> 
> It turns out to be a *qemu* issue, as the same binary works
> fine on the actual hardware.  A surprise for me.

Thanks, that's a useful warning as I was about to take the same
approach.  Sadly with the recent shutdown of Calxeda, I'm not sure
where to buy any ARM64 hardware from anymore.  Tips welcome...

-anil

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

* Re: [Caml-list] Trying out the arm64 compiler
  2013-12-23 18:32       ` Richard W.M. Jones
  2013-12-23 19:00         ` Anil Madhavapeddy
@ 2013-12-23 22:03         ` Richard W.M. Jones
  1 sibling, 0 replies; 7+ messages in thread
From: Richard W.M. Jones @ 2013-12-23 22:03 UTC (permalink / raw)
  To: caml-list; +Cc: benedikt.meurer


To close the loop, this was a bug in the qemu emulator.  It didn't
emulate the "ret xM" form of the instruction (only the default which
uses x30).

Bug report and fix is here:

https://bugs.launchpad.net/qemu/+bug/1263747

Rich.

-- 
Richard Jones
Red Hat

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

end of thread, other threads:[~2013-12-23 22:03 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-12-23 15:00 [Caml-list] Trying out the arm64 compiler Richard W.M. Jones
2013-12-23 15:07 ` Richard W.M. Jones
2013-12-23 15:32   ` Richard W.M. Jones
2013-12-23 17:16     ` Richard W.M. Jones
2013-12-23 18:32       ` Richard W.M. Jones
2013-12-23 19:00         ` Anil Madhavapeddy
2013-12-23 22:03         ` Richard W.M. Jones

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).