ocaml-wasm / wasm_of_ocaml

Other
232 stars 8 forks source link

[BUG] Build seems to fail with OCaml 4.11.1 #14

Closed JasonGross closed 6 months ago

JasonGross commented 9 months ago

Describe the bug

#=== ERROR while compiling js_of_ocaml-compiler.5.4.0 =========================#
# context     2.1.5 | linux/x86_64 | ocaml-base-compiler.4.11.1 | pinned(git+https://github.com/ocaml-wasm/wasm_of_ocaml.git#d09d81e2ae6654cacb0d0f04845d8d9ce5316439)
# path        ~/work/test/test/_opam/.opam-switch/build/js_of_ocaml-compiler.5.4.0
# command     ~/.opam/opam-init/hooks/sandbox.sh build dune build -p js_of_ocaml-compiler -j 4 @install
# exit-code   1
# env-file    ~/.opam/log/js_of_ocaml-compiler-10504-b4a0f1.env
# output-file ~/.opam/log/js_of_ocaml-compiler-10504-b4a0f1.out
### output ###
# (cd _build/default && /home/runner/work/test/test/_opam/bin/ocamlc.opt -w -40 -w -7-37 -safe-string -g -bin-annot -I compiler/lib/.js_of_ocaml_compiler.objs/byte -I /home/runner/work/test/test/_opam/lib/gen -I /home/runner/work/test/test/_opam/lib/menhirLib -I /home/runner/work/test/test/_opam/lib/ocaml/compiler-libs -I /home/runner/work/test/test/_opam/lib/sedlex -I /home/runner/work/test/test/_opam/lib/seq -I /home/runner/work/test/test/_opam/lib/yojson -intf-suffix .ml -no-alias-deps -open Js_of_ocaml_compiler -o compiler/lib/.js_of_ocaml_compiler.objs/byte/js_of_ocaml_compiler__Ocaml_compiler.cmo -c -impl compiler/lib/ocaml_compiler.pp.ml)
# File "compiler/lib/ocaml_compiler.ml", lines 48-51, characters 6-54:
# 48 | ......Int
# 49 |         (match target with
# 50 |         | `JavaScript -> Int32.of_int_warning_on_overflow i
# 51 |         | `Wasm -> Int31.of_int_warning_on_overflow i)
# Error: The constructor Int expects 2 argument(s),
#        but is applied here to 1 argument(s)
# (cd _build/default && /home/runner/work/test/test/_opam/bin/ocamlopt.opt -w -40 -w -7-37 -safe-string -g -I compiler/lib/.js_of_ocaml_compiler.objs/byte -I compiler/lib/.js_of_ocaml_compiler.objs/native -I /home/runner/work/test/test/_opam/lib/gen -I /home/runner/work/test/test/_opam/lib/menhirLib -I /home/runner/work/test/test/_opam/lib/ocaml/compiler-libs -I /home/runner/work/test/test/_opam/lib/sedlex -I /home/runner/work/test/test/_opam/lib/seq -I /home/runner/work/test/test/_opam/lib/yojson -intf-suffix .ml -no-alias-deps -open Js_of_ocaml_compiler -o compiler/lib/.js_of_ocaml_compiler.objs/native/js_of_ocaml_compiler__Ocaml_compiler.cmx -c -impl compiler/lib/ocaml_compiler.pp.ml)
# File "compiler/lib/ocaml_compiler.ml", lines 48-51, characters 6-54:
# 48 | ......Int
# 49 |         (match target with
# 50 |         | `JavaScript -> Int32.of_int_warning_on_overflow i
# 51 |         | `Wasm -> Int31.of_int_warning_on_overflow i)
# Error: The constructor Int expects 2 argument(s),
#        but is applied here to 1 argument(s)
# (cd _build/default && /home/runner/work/test/test/_opam/bin/ocamlc.opt -w -40 -w -7-37 -safe-string -g -bin-annot -I compiler/lib/.js_of_ocaml_compiler.objs/byte -I /home/runner/work/test/test/_opam/lib/gen -I /home/runner/work/test/test/_opam/lib/menhirLib -I /home/runner/work/test/test/_opam/lib/ocaml/compiler-libs -I /home/runner/work/test/test/_opam/lib/sedlex -I /home/runner/work/test/test/_opam/lib/seq -I /home/runner/work/test/test/_opam/lib/yojson -intf-suffix .ml -no-alias-deps -open Js_of_ocaml_compiler -o compiler/lib/.js_of_ocaml_compiler.objs/byte/js_of_ocaml_compiler__Wa_gc_target.cmo -c -impl compiler/lib/wasm/wa_gc_target.pp.ml)
# File "compiler/lib/wasm/wa_gc_target.ml", line 863, characters 12-29:
# 863 |             String.fold_right
#                   ^^^^^^^^^^^^^^^^^
# Error: Unbound value String.fold_right

https://github.com/JasonGross/test/actions/runs/6976358757/job/18984699373#step:4:3064

There's a chance this is a red herring from me passing --best-effort to opam pin add

jmid commented 9 months ago

Indeed! man String reveals

       val fold_right : (char -> 'acc -> 'acc) -> string -> 'acc -> 'acc

       fold_right f s x computes f s.[0] (f s.[1] ( ... (f s.[n-1] x) ...))  ,
       where n is the length of the string s .

       Since 4.13

so this can be fixed by adding a lower bound.

hhugo commented 9 months ago

There is a Stdlib overlay (compiler/lib/stdlib.ml) where such function can be added.