Navigation Menu

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

OCaml fails to build in 32 bits mode in a 64 bit system. #7679

Closed
vicuna opened this issue Nov 28, 2017 · 9 comments
Closed

OCaml fails to build in 32 bits mode in a 64 bit system. #7679

vicuna opened this issue Nov 28, 2017 · 9 comments

Comments

@vicuna
Copy link

vicuna commented Nov 28, 2017

Original bug ID: 7679
Reporter: @ejgallego
Assigned to: @gasche
Status: resolved (set by @gasche on 2017-11-28T17:23:49Z)
Resolution: not a bug
Priority: normal
Severity: major
Platform: Linux
OS: Ubuntu
OS Version: 17.04
Version: 4.06.0
Category: configure and build/install
Monitored by: @gasche

Bug description

Dear Ocaml devs,

trying to compile 4.06.0 in 32bit mode [so it can be used by js_of_ocaml] I hit this compilation problem:

./configure -with-debug-runtime -cc "gcc -m32" -as "as --32" -aspp "gcc -m32 -c" -host "i386-linux" -partialld "ld -r -melf_i386"

....

boot/ocamlrun ./ocamlopt -g -nostdlib -I stdlib -I otherlibs/dynlink -o ocamlc.opt compilerlibs/ocamlcommon.cmxa compilerlibs/ocamlbytecomp.cmxa driver/main.cmx -cclib "-lm -ldl -lpthread "
stdlib/libasmrun.a(i386.o): In function caml_system__code_begin': (.text+0x0): multiple definition of caml_system__code_begin'
stdlib/libasmrun.a(amd64.o):(.text+0x0): first defined here
....
/usr/bin/ld: i386:x86-64 architecture of input file `stdlib/libasmrun.a(amd64.o)' is incompatible with i386 output
collect2: error: ld returned 1 exit status
File "caml_startup", line 1:
Error: Error during linking
Makefile:883: recipe for target 'ocamlc.opt' failed

It could be well the case that I am doing something wrong, as I am using the configure line that worked for 4.05.0. 4.05.0 in 32 bits mode works ok in my system.

Steps to reproduce

  • clone 4.06 branch
  • ./configure -with-debug-runtime -cc "gcc -m32" -as "as --32" -aspp "gcc -m32 -c" -host "i386-linux" -partialld "ld -r -melf_i386"
  • make world
  • make world.opt => fail
@vicuna
Copy link
Author

vicuna commented Nov 28, 2017

Comment author: @dra27

For OCaml's Travis build, we just use -host i686-pc-linux-gnu, but that doesn't necessarily mean that there isn't a regression in the configure system

@vicuna
Copy link
Author

vicuna commented Nov 28, 2017

Comment author: vlaviron

I have a git worktree configured with exactly the same options, that I use for testing, and could compile 4.06 without errors. However, looking at the Makefiles and the doc for the ar command, it looks like you may have launched the compilation while a libasmrun.a from a 64-bit compilation was still present, which would be consistent with the error you get (the command used to create libasmrun.a adds and replaces objects, but does not remove the ones not replaced).
If this is the case, make clean && make world.opt should fix your problem.

@vicuna
Copy link
Author

vicuna commented Nov 28, 2017

Comment author: @ejgallego

I'm gonna try again, thanks. But I originally found this error when creating an OPAM switch so the compilation state should have been clean.

@dra, in fact I had looked at what travis does and I tried with -host i686-pc-linux-gnu, but that didn't seem to do what I needed. Will report back too.

@vicuna
Copy link
Author

vicuna commented Nov 28, 2017

Comment author: @ejgallego

Waaah, so for some reason my OPAM used some stale compiler information :embarrased: in fact the original build seems to work now. Sorry for the noise, closing the issue.

WRT to -host i686-pc-linux-gnu I do indeed get this:

with ./configure -host i686-pc-linux-gnu :
[...]
gcc -c -DSYS_linux_elf -I../byterun -DMODEL_default -o i386.o i386.S ||
{ echo "If your assembler produced syntax errors, it is probably";
echo "unhappy with the preprocessor. Check your assembler, or";
echo "try producing i386.o by hand.";
exit 2; }
i386.S: Assembler messages:
i386.S:148: Error: invalid instruction suffix for `push'
[...]
If your assembler produced syntax errors, it is probably
unhappy with the preprocessor. Check your assembler, or
try producing i386.o by hand.
Makefile:153: recipe for target 'i386.o' failed
make[3]: *** [i386.o] Error 2

@vicuna
Copy link
Author

vicuna commented Nov 28, 2017

Comment author: @ejgallego

Ummm, I can't modify the issue status it seems. Please, resolve as INVALID.

@vicuna vicuna closed this as completed Nov 28, 2017
@vicuna
Copy link
Author

vicuna commented Nov 28, 2017

Comment author: @xavierleroy

Indeed, leftover files from an earlier (64-bit) compile explains the error.

Still, we should erase ".a" files before reconstructing them with "ar rc". I'll look into this.

Concerning "./configure -host i686-pc-linux-gnu", I'm pretty sure this is not enough to build a 32-bit version on a 64-bit host. Maybe it should be enough, but in the meantime please stick to the incantation given in INSTALL.adoc.

@vicuna
Copy link
Author

vicuna commented Nov 28, 2017

Comment author: @dra27

Indeed - Travis replaces all the compiler packages with their 32-bit counterparts, which is why it works there.

@vicuna
Copy link
Author

vicuna commented Nov 28, 2017

Comment author: @xavierleroy

Pull request here: #1494

@vicuna
Copy link
Author

vicuna commented Nov 30, 2017

Comment author: @xavierleroy

Pull request merged, will be in 4.07

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants