Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0007608OCamlback end (clambda to assembly)public2017-08-18 13:232017-10-14 12:09
ReporterSP 
Assigned Toxleroy 
PrioritynormalSeverityminorReproducibilityalways
StatusassignedResolutionopen 
PlatformARMOSArchlinuxOS Version
Product Version 
Target Version4.07.0+devFixed in Version 
Summary0007608: OCaml-uri doesn't compile on ARM with assembler error
DescriptionI have the following compilation error with another ARM chip.

A key part seems to be this:
```
/tmp/camlasm480e0c.s: Assembler messages:
/tmp/camlasm480e0c.s:52: Error: value of 68249 too large for field of 2 bytes at 30
/tmp/camlasm480e0c.s:73426: Error: value of 68255 too large for field of 2 bytes at 204542
```

Log file cropped to relevant section:


```
File "lib/uri.ml", line 306, characters 33-50:
Warning 52: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (See manual section 8.5)
File "lib/uri.ml", line 321, characters 27-44:
Warning 52: Code should not depend on the actual values of
this constructor's arguments. They are only for information
and may change in future versions. (See manual section 8.5)
File "lib/uri.ml", line 568, characters 17-33:
Warning 3: deprecated: String.lowercase
Use String.lowercase_ascii instead.
    ocamlopt lib/uri_top.{cmx,o}
File "_none_", line 1:
Warning 58: no cmx file was found in path for module Toploop, and its interface was not compiled with -opaque
    ocamlopt etc/uri_services.{cmx,o}
    ocamlopt lib/uri.{a,cmxa}
    ocamlopt lib/uri_top.{a,cmxa}
    ocamlopt etc/uri_services.{a,cmxa}
    ocamlopt lib/uri.cmxs
    ocamlopt lib/uri_top.cmxs
    ocamlopt etc/uri_services.cmxs
      ocamlc etc/uri_services_full.{cmo,cmt}
      ocamlc etc/uri_services_full.cma
    ocamlopt etc/uri_services_full.{cmx,o} (exit 2)
(cd _build/default && /usr/bin/ocamlopt.opt -w -40 -g -I /home/fox/.opam/system/lib/bytes -I /home/fox/.opam/system/lib/re -I /home/fox/.opam/system/lib/sexplib -I /home/fox/.opam/system/lib/sexplib/0 -I /home/fox/.opam/system/lib/stringext -I /usr/lib/ocaml -I lib -no-alias-deps -I etc -o etc/uri_services_full.cmx -c -impl etc/uri_services_full.ml)
/tmp/camlasm480e0c.s: Assembler messages:
/tmp/camlasm480e0c.s:52: Error: value of 68249 too large for field of 2 bytes at 30
/tmp/camlasm480e0c.s:73426: Error: value of 68255 too large for field of 2 bytes at 204542
/tmp/camlasm480e0c.s:148307: Error: offset out of range
/tmp/camlasm480e0c.s:188181: Error: offset out of range
/tmp/camlasm480e0c.s:148267: Error: offset out of range
/tmp/camlasm480e0c.s:148274: Error: offset out of range
/tmp/camlasm480e0c.s:148295: Error: offset out of range
/tmp/camlasm480e0c.s:148299: Error: offset out of range
/tmp/camlasm480e0c.s:148303: Error: offset out of range
/tmp/camlasm480e0c.s:148320: Error: offset out of range
/tmp/camlasm480e0c.s:188141: Error: offset out of range
/tmp/camlasm480e0c.s:188148: Error: offset out of range
/tmp/camlasm480e0c.s:188169: Error: offset out of range
/tmp/camlasm480e0c.s:188173: Error: offset out of range
/tmp/camlasm480e0c.s:188177: Error: offset out of range
/tmp/camlasm480e0c.s:188194: Error: offset out of range
File "etc/uri_services_full.ml", line 1:
Error: Assembler error, input left in file /tmp/camlasm480e0c.s
```

Related issue on ocaml-uri: https://github.com/mirage/ocaml-uri/issues/106 [^]
Steps To ReproduceBuild ocaml-uri on ARM.
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0018187)
gasche (developer)
2017-08-18 15:52

There have been several fixes to ARM code generation in trunk (4.06.0+dev). Would it be reasonable to make sure that ocaml-uri and its various dependencies compile under the trunk to check if the problem goes away?

I know it is work (I expect the ocaml-uri people or its users to do it), but it will have to be done before the 4.06 release anyway so it will not be lost.
(0018430)
SP (reporter)
2017-09-30 21:18
edited on: 2017-10-16 23:30

Tried installing `uri` on 4.06.0+trunk, but there are too many dependencies which require ocaml < 4.06. Any suggestions about this?

(0018431)
gasche (developer)
2017-09-30 22:45

We are going to make a beta release of 4.06.0 very soon. That will be a very good time to kindly ask the maintainers of uri's dependencies to test their build under 4.06 and release working versions, so that you can test yourself. If you manage to test uri before the release, and it is still broken (I believe it should now work), we can add the issue to the list of things to fix before the release.
(0018552)
dbuenzli (reporter)
2017-10-12 17:37

It seems the error persists in 4.06.0

See https://github.com/mirage/ocaml-uri/issues/106#issuecomment-336175195 [^]
(0018554)
gasche (developer)
2017-10-12 18:09

(I'm including here the information reported by github user 'alrev' in the downstream issue report.)

The error was reproduced on Raspberry 2 and 3, and a Cubietruck machine. (armv7l-unknown-linux-gnueabihf).

From the switch 4.06.0+beta1+default-unsafe-string, the failure can be reproduced by installing the development version of the dependencies:

  opam pin add ppx_core --dev-repo
  opam pin add ppx_sexp_conv --dev-repo

and then compiling the source of the project (this is the hash of the current master):

  https://github.com/mirage/ocaml-uri/archive/a0846a1def8abdade6578719f7236aae9445f2d4.tar.gz [^]
(0018557)
xleroy (administrator)
2017-10-12 19:50

Any chance to have a self-contained repro case? Or just a copy of the problematic .s file?
(0018558)
xleroy (administrator)
2017-10-13 15:03
edited on: 2017-10-13 15:05

At last we got a copy of the bad .s file: https://github.com/mirage/ocaml-uri/files/1381922/camlasmbaf612.s_plus_err_and_env.zip [^]

Two overflows remain, on lines 52 and 73429, and correspond to `tbh` instructions (branch through table) where the branch destinations are far away and overflow the 16-bit displacements used by the `tbh` instruction. In turn, this comes from two huge pattern-matchings in the source code, autogenerated from a large data table.

The other "offset out of range" overflows do not occur on this version of the .s file. I think these overflows were fixed by commit 07b28ed in 4.06.

The fix I'll propose soon is to stop using the Thumb-2 `tbh` instruction and fall back to the classic ARM implementation of jump through table.

(0018565)
xleroy (administrator)
2017-10-14 12:08

The fix I had in mind needs significant preliminary work:
* Switch the ARM code emitter to "unified" syntax instead of the "legacy" syntax used today. (The fix needs the "b.w" opcode to denote a 32-bit-encoded Thumb2 unconditional branch, and this opcode is not supported by GNU as in "legacy" syntax.)
* Add a "destroyed_at_switch" architectural parameter for all architectures. (Because a temporary register is needed for the Thumb version of the fix.)

I'm pushing this issue after release 4.06. In the meantime, the one package that has problems can be compiled with "ocamlopt -fno-thumb", or rewritten to avoid such huge functions.

- Issue History
Date Modified Username Field Change
2017-08-18 13:23 SP New Issue
2017-08-18 15:52 gasche Note Added: 0018187
2017-08-18 15:52 gasche Status new => feedback
2017-08-29 17:51 underscore Note Added: 0018203
2017-08-29 17:57 underscore Note Deleted: 0018203
2017-09-30 21:18 SP Note Added: 0018430
2017-09-30 21:18 SP Status feedback => new
2017-09-30 22:45 gasche Note Added: 0018431
2017-10-02 13:41 gasche Assigned To => gasche
2017-10-02 13:41 gasche Status new => feedback
2017-10-02 13:41 gasche Severity minor => major
2017-10-02 13:41 gasche Target Version => 4.06.0 +dev/beta1/beta2/rc1
2017-10-12 17:37 dbuenzli Note Added: 0018552
2017-10-12 17:39 gasche Assigned To gasche =>
2017-10-12 17:39 gasche Status feedback => acknowledged
2017-10-12 18:09 gasche Note Added: 0018554
2017-10-12 19:50 xleroy Note Added: 0018557
2017-10-13 15:03 xleroy Note Added: 0018558
2017-10-13 15:03 xleroy Assigned To => xleroy
2017-10-13 15:03 xleroy Status acknowledged => assigned
2017-10-13 15:05 xleroy Note Edited: 0018558 View Revisions
2017-10-13 21:07 frisch Category tools (ocaml{lex,yacc,dep,debug,...}) => back end (clambda to assembly)
2017-10-14 12:08 xleroy Note Added: 0018565
2017-10-14 12:09 xleroy Target Version 4.06.0 +dev/beta1/beta2/rc1 => 4.07.0+dev
2017-10-14 12:09 xleroy Severity major => minor
2017-10-16 23:30 SP Note Edited: 0018430 View Revisions


Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker