Note: This is a public test instance of Red Hat Bugzilla. The data contained within is a snapshot of the live data so any changes you make will not be reflected in the production Bugzilla. Email is disabled so feel free to test any aspect of the site that you want. File any problems you find or give feedback at bugzilla.redhat.com.

Bug 1224815

Summary: OCaml aarch64 backend generates invalid asm: conditional branch out of range
Product: [Fedora] Fedora Reporter: Peter Robinson <pbrobinson>
Component: ocamlAssignee: Richard W.M. Jones <rjones>
Status: CLOSED RAWHIDE QA Contact: Fedora Extras Quality Assurance <extras-qa>
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: rawhideCC: c.david86, loganjerry, rjones
Target Milestone: ---   
Target Release: ---   
Hardware: aarch64   
OS: Unspecified   
URL: http://caml.inria.fr/mantis/view.php?id=6878
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2015-06-09 11:47:42 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 922257    
Attachments:
Description Flags
camlasm50dee1.s none

Description Peter Robinson 2015-05-25 22:13:09 UTC
ocaml-menhir-20141215-1.fc22 http://arm.koji.fedoraproject.org/koji/taskinfo?taskID=3006942
ocaml-menhir-20141215-1.fc23 http://arm.koji.fedoraproject.org/koji/taskinfo?taskID=3006940


/usr/bin/ocamldep.opt -modules parser.mli > parser.mli.depends
/usr/bin/ocamlc.opt -c -g -safe-string -w @1..49-4-9-33-41-44 -o parser.cmi parser.mli
/usr/bin/ocamlc.opt -c -g -safe-string -g -w @1..49-4-9-33-41-44 -o lexer.cmo lexer.ml
/usr/bin/ocamldep.opt -modules parser.ml > parser.ml.depends
/usr/bin/ocamlopt.opt -c -g -safe-string -g -inline 1000 -w @1..49-4-9-33-41-44 -o misc.cmx misc.ml
/usr/bin/ocamldep.opt -modules parserAux.ml > parserAux.ml.depends
/usr/bin/ocamlopt.opt -c -g -safe-string -g -inline 1000 -w @1..49-4-9-33-41-44 -o parameters.cmx parameters.ml
/usr/bin/ocamlopt.opt -c -g -safe-string -g -inline 1000 -w @1..49-4-9-33-41-44 -o parserAux.cmx parserAux.ml
/usr/bin/ocamlopt.opt -c -g -safe-string -g -inline 1000 -w @1..49-4-9-33-41-44 -o parser.cmx parser.ml
+ /usr/bin/ocamlopt.opt -c -g -safe-string -g -inline 1000 -w @1..49-4-9-33-41-44 -o parser.cmx parser.ml
/tmp/camlasm8a39a8.s: Assembler messages:
/tmp/camlasm8a39a8.s:3024: Error: conditional branch out of range
/tmp/camlasm8a39a8.s:87479: Error: conditional branch out of range
File "parser.ml", line 1:
Error: Assembler error, input left in file /tmp/camlasm8a39a8.s
Command exited with code 2.
Makefile:66: recipe for target 'stage2' failed
make[1]: Leaving directory '/builddir/build/BUILD/menhir-20141215/src'
make[1]: *** [stage2] Error 10
Makefile:78: recipe for target 'all' failed

Comment 1 Jerry James 2015-05-26 03:17:20 UTC
Hmmm, Richard is there anything I can do about this?  I'm at a loss how to solve this by patching menhir.

Comment 2 Richard W.M. Jones 2015-05-26 08:55:47 UTC
Created attachment 1029813 [details]
camlasm50dee1.s

This looks superficially like a proper bug in the OCaml compiler (ie.
nothing to do with Menhir).  I am able to reproduce it on my aarch64
machine too, so it's not a peculiarity of Koji.

We did see a similar bug before (bug 1099153) but that bug was fixed
or fixed itself for some other reason.

The error for me is:

+ /usr/bin/ocamlopt.opt -c -g -safe-string -g -inline 1000 -w @1..49-4-9-33-41-44 -o parser.cmx parser.ml
/tmp/camlasm50dee1.s: Assembler messages:
/tmp/camlasm50dee1.s:3024: Error: conditional branch out of range
/tmp/camlasm50dee1.s:87479: Error: conditional branch out of range
File "parser.ml", line 1:
Error: Assembler error, input left in file /tmp/camlasm50dee1.s
Command exited with code 2.

The failing .s file is attached.

Comment 3 Richard W.M. Jones 2015-05-26 09:01:21 UTC
Upstream bug report:
http://caml.inria.fr/mantis/view.php?id=6878

Comment 4 Richard W.M. Jones 2015-06-09 09:31:35 UTC
I've had a lot of conversations with Mark Shinwell who is fixing
this, and he's come up with a final patch.  I'm going to add this
to the OCaml compiler in Fedora.  It's quite a large change, since
it aims to add extra machinery to handle branch relaxation generically
across backends.

Comment 5 Richard W.M. Jones 2015-06-09 10:00:22 UTC
Bleah git.  Unfortunately the "patch" is a maze of twisty commits
and diamond-shaped merges and I cannot get it to apply to our tree.
I'm going to wait until the final patch is posted to the upstream
4.02 branch which should be soon.

Comment 6 Richard W.M. Jones 2015-06-09 11:46:39 UTC
OK got it patched.  This is the x86 build:

http://koji.fedoraproject.org/koji/taskinfo?taskID=9995092

Comment 7 Richard W.M. Jones 2015-06-09 11:51:01 UTC
A few notes:

- ocaml-menhir builds OK for me with the new OCaml package

- a "mass rebuild" does not seem to be necessary, since if any packages
  were hitting this bug before, they would have failed to build, they
  wouldn't have built incorrect code silently

Comment 8 Peter Robinson 2015-06-10 15:53:07 UTC
Confirmed this is now fixed in aarch64 rawhide:

http://arm.koji.fedoraproject.org/koji/taskinfo?taskID=3031250

Comment 9 Jerry James 2015-06-11 03:37:04 UTC
Thanks for working with upstream to get this fixed, Richard.