Compilation in OCaml 4.04.1
maroneze opened this issue · 1 comments
I tried compiling landmarks on the freshly-released OCaml 4.04.1, but I got the following error when trying opam install landmarks
(I made a local opam repository using the extracted contents of the OCaml release archive):
[ERROR] The compilation of landmarks failed at "make".
Processing 1/1: [landmarks: ocamlfind remove]
#=== ERROR while installing landmarks.1.1 =====================================#
# opam-version 1.2.2
# os linux
# command make
# path /home/andr/.opam/4.04.1+local-git-/build/landmarks.1.1
# compiler 4.04.1+local-git-
# exit-code 2
# env-file /home/andr/.opam/4.04.1+local-git-/build/landmarks.1.1/landmarks-21719-5f1023.env
# stdout-file /home/andr/.opam/4.04.1+local-git-/build/landmarks.1.1/landmarks-21719-5f1023.out
# stderr-file /home/andr/.opam/4.04.1+local-git-/build/landmarks.1.1/landmarks-21719-5f1023.err
### stdout ###
# ocamldep -I . *.mli *.ml > .depend
# ocamlopt -c clock.c
# ocamlc -w +A-30-42-41-48-40-4 -safe-string -strict-sequence -bin-annot -g -c landmark_misc.ml
# ocamlc -w +A-30-42-41-48-40-4 -safe-string -strict-sequence -bin-annot -g -c landmark_graph.mli
# ocamlc -w +A-30-42-41-48-40-4 -safe-string -strict-sequence -bin-annot -g -c landmark_graph.ml
# ocamlc -w +A-30-42-41-48-40-4 -safe-string -strict-sequence -bin-annot -g -c landmark.mli
# ocamlc -w +A-30-42-41-48-40-4 -safe-string -strict-sequence -bin-annot -g -c landmark.ml
# ocamlmklib -o landmarks clock.o landmark_misc.cmo landmark_graph.cmo landmark.cmo
### stderr ###
# /usr/bin/ld: clock.o: relocation R_X86_64_PC32 against undefined symbol `caml_copy_int64' can not be used when making a shared object; recompile with -fPIC
# /usr/bin/ld: final link failed: Bad value
# collect2: error: ld returned 1 exit status
# make[1]: *** [Makefile:38: landmarks.cma] Error 2
# make: *** [Makefile:15: landmarks] Error 2
I don't have the time right now to try adding the suggested flag, but I'll do later. In any case, I wanted to notify about it.
I am using a Fedora 26-alpha with GCC 7, so it is not impossible that it is an issue due to this somewhat bleeding-edge configuration. However, I am able to compile landmarks on OCaml 4.04.0 without issues.
Ok, I finally had a look at it and the problem was that my GCC was suffixed with the version number (gcc-7
), so the Makefile didn't include the -fPIC
flag. Renaming it to gcc
avoids the issue.
To make it work in such cases, instead of firstword
, the Makefile
would have to include something as findstring
, but then it could have false positives. So, in the end, I think it's not worth changing anything.
In the unlikely event someone might have a similar issue, they will probably end up finding this, and finding out about the solution.