1

I'm trying to make install ocaml-wasm 1.

Unfortunately the build is failing with the error-message:

Error: /usr/lib/ocaml/bigarray.cma is not a bytecode object file

Here's a Dockerfile so you may reproduce the error:

FROM base/archlinux

RUN pacman -Sy --noconfirm ocaml ocamlbuild wget unzip make
RUN wget https://github.com/WebAssembly/spec/archive/v1.0.zip
RUN unzip v1.0.zip

CMD cd spec-1.0; make -C interpreter install; bash

You may run it:

docker build -t ocaml-wasm . && docker run --rm -it ocaml-wasm

It should find it to produce the same error as above. Here's the entire output of the make command:

make: Entering directory '/spec-1.0/interpreter'
ls util/*.ml* syntax/*.ml* binary/*.ml* text/*.ml* valid/*.ml* runtime/*.ml* exec/*.ml* script/*.ml* host/*.ml* main/*.ml* \                                                                                      
        | sed 's:\(.*/\)\{0,1\}\(.*\)\.[^\.]*:\2:' \
        | grep -v main \
        | sort | uniq \
        >wasm.mlpack
echo >_tags "true: bin_annot"
echo >>_tags "<{util,syntax,binary,text,valid,runtime,exec,script,host,main}/*.cmx>: for-pack(Wasm)"
ocamlbuild -cflags '-w +a-4-27-42-44-45 -warn-error +a' -I util -I syntax -I binary -I text -I valid -I runtime -I exec -I script -I host -I main -libs bigarray -quiet wasm.cmx                                  
+ /usr/bin/ocamlc.opt -pack bigarray.cma -bin-annot util/lib.cmo binary/utf8.cmo exec/float.cmo exec/f32.cmo exec/f64.cmo exec/numeric_error.cmo exec/int.cmo exec/i32.cmo exec/i64.cmo syntax/types.cmo syntax/values.cmo runtime/memory.cmo util/source.cmo syntax/ast.cmo util/error.cmo binary/encode.cmo exec/i64_convert.cmo syntax/operators.cmo binary/decode.cmo script/script.cmo text/parser.cmo text/lexer.cmo text/parse.cmo util/sexpr.cmo text/arrange.cmo exec/i32_convert.cmo exec/f32_convert.cmo exec/f64_convert.cmo exec/eval_numeric.cmo runtime/func.cmo runtime/global.cmo runtime/table.cmo runtime/instance.cmo exec/eval.cmo host/env.cmo main/flags.cmo script/import.cmo script/js.cmo text/print.cmo valid/valid.cmo script/run.cmo host/spectest.cmo -o wasm.cmo                                                                            
File "_none_", line 1:
Error: /usr/lib/ocaml/bigarray.cma is not a bytecode object file
Command exited with code 2.
make: *** [Makefile:83: _build/wasm.cmx] Error 10
rm wasm.mlpack _tags
make: Leaving directory '/spec-1.0/interpreter'

How do I get ocaml-wasm to compile?

I've seen 2, but the answer doesn't help me. I've not installed any non-standard binaries. Could the ocaml distribution on arch linux be broken?

ambiso
  • 559
  • 3
  • 10
  • That does look like a mistake from Arch indeed. It seems that the wrong lib is installed for your compiler. – PatJ Oct 13 '18 at 13:02
  • @PatJ, likely, however ocamlobjinfo has no problem with /usr/lib/ocaml/bigarray.cma – ambiso Oct 13 '18 at 13:04

1 Answers1

1

I suspect that your ocamlbuild version is 0.13 (see ocamlbuild --version), which is known to have this issue. You should use 0.12 to avoid the problem.

ocamlbuild 0.13 is not package on opam because of this problem (so it's not visible to most users), but I hadn't considered that distribution packagers may decide to package it nonetheless.

gasche
  • 31,259
  • 3
  • 78
  • 100