Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zarith compilation fails in 32bit OCaml switches on a 64bit host. #38

Closed
ejgallego opened this issue Oct 17, 2018 · 3 comments
Closed

Comments

@ejgallego
Copy link

Ubuntu 18.04, opam 2.0, switch is 4.07.0+32bit:

./configure 
binary ocaml: found in /home/egallego/.opam/4.07.0+32bit/bin
binary ocamlc: found in /home/egallego/.opam/4.07.0+32bit/bin
binary ocamldep: found in /home/egallego/.opam/4.07.0+32bit/bin
binary ocamlmklib: found in /home/egallego/.opam/4.07.0+32bit/bin
binary ocamldoc: found in /home/egallego/.opam/4.07.0+32bit/bin
binary ar: found in /usr/bin
binary perl: found in /usr/bin
binary gcc: found in /usr/bin
binary ocamlopt: found in /home/egallego/.opam/4.07.0+32bit/bin
checking compilation with gcc -O3 -Wall -Wextra : working
include caml/mlvalues.h: found
library dynlink.cmxa: found
binary ocamlfind: found in /home/egallego/.opam/4.07.0+32bit/bin
OCaml's word size is 32
binary uname: found in /bin
include gmp.h: found
library gmp: found
OCaml extended comparison supported
OCaml new hash functions available
OCaml supports -bin-annot to produce documentation

detected configuration:

  native-code:          yes
  dynamic linking:      yes
  asm path:             x86_64
  defines:              -DZ_OCAML_HASH -DZ_OCAML_COMPARE_EXT -DHAS_GMP -DZ_ELF -DZ_DOT_LABEL_PREFIX 
  libraries:             -lgmp
  C options:            -O3 -Wall -Wextra 
  asm options           
  installation path:    /home/egallego/.opam/4.07.0+32bit/lib
  installation method   findlib
$ make
project.mak:151: depend: No existe el archivo o el directorio
./z_pp.pl x86_64
Name "main::extra" used only once: possible typo at ./z_pp.pl line 29.
found assembly file caml_z_x86_64.S
  found abs
  found add
  found div
  found divexact
  found logand
  found lognot
  found logor
  found logxor
  found mul
  found neg
  found pred
  found rem
  found shift_left
  found shift_right
  found sub
  found succ
ocamldep -native  z.ml q.ml big_int_Z.ml z.mli q.mli big_int_Z.mli > depend
ocamlc -I +compiler-libs -bin-annot  -c z.mli
ocamlc -I +compiler-libs -bin-annot  -c z.ml
ocamlc -I +compiler-libs -bin-annot  -c q.mli
ocamlc -I +compiler-libs -bin-annot  -c q.ml
ocamlc -I +compiler-libs -bin-annot  -c big_int_Z.mli
ocamlc -I +compiler-libs -bin-annot  -c big_int_Z.ml
ocamlmklib -failsafe -o zarith z.cmo q.cmo big_int_Z.cmo -lgmp
gcc -DZ_OCAML_HASH -DZ_OCAML_COMPARE_EXT -DHAS_GMP -DZ_ELF -DZ_DOT_LABEL_PREFIX     -c -o caml_z_x86_64.o caml_z_x86_64.S
ocamlc -ccopt "-I/home/egallego/.opam/4.07.0+32bit/lib/ocaml  -DZ_OCAML_HASH -DZ_OCAML_COMPARE_EXT -DHAS_GMP -DZ_ELF -DZ_DOT_LABEL_PREFIX  -O3 -Wall -Wextra " -c caml_z.c
ocamlmklib -failsafe -o zarith caml_z_x86_64.o caml_z.o -lgmp
/usr/bin/ld: la arquitectura i386:x86-64 del fichero de entrada `caml_z_x86_64.o' es incompatible con la salida i386
collect2: error: ld returned 1 exit status
ocamlc -I +compiler-libs -bin-annot  -c zarith_top.ml
ocamlc -o zarith_top.cma -a zarith_top.cmo
ocamlopt -I +compiler-libs  -c z.ml
ocamlopt -I +compiler-libs  -c q.ml
ocamlopt -I +compiler-libs  -c big_int_Z.ml
ocamlmklib -failsafe -o zarith z.cmx q.cmx big_int_Z.cmx -lgmp
ocamlopt -shared -o zarith.cmxs -I . zarith.cmxa -linkall
/usr/bin/ld: se salta el ./libzarith.a incompatible mientras se busca -lzarith
/usr/bin/ld: no se puede encontrar -lzarith
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking
project.mak:79: recipe for target 'zarith.cmxs' failed
make: *** [zarith.cmxs] Error 2
@ejgallego
Copy link
Author

./configure -host i686-linux-gnu && make CC='gcc -m32' makes the build work.

I wonder how this should be detected under the 32bit OPAM.

@ejgallego
Copy link
Author

I see that a similar https://forge.ocamlcore.org/tracker/?func=detail&atid=1095&aid=1539&group_id=243 report was closed.

Indeed, it may make sense for Zarith not to have to care about incorrect host settings; I have little clue on cross-compilation but then I wonder what the 4.07.0+32bit switch is doing.

Does it make sense to have a 32bit OCaml and not set arch to i686?

@antoinemine
Copy link
Collaborator

OK. PR #56 changes slightly the configure to detect this situation (based on the host and actual size of OCaml words).

antoinemine added a commit that referenced this issue Aug 22, 2019
Fix for #38: configure detects 32bit OCaml switch on 64bit host
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants