Discussion:
[MLton] Linker errors when building ADATE with amd64
Lars Magnusson
2010-10-21 10:56:45 UTC
Permalink
Hi

I'm currently working on porting the ADATE system to x86_64. I get
some linker errors when building that I'm having a hard time figuring
out.

The mlton output (with the compile SML output discarded):

Compile and Assemble starting
gcc -std=gnu99 -c -I/usr/lib/mlton/targets/self/include \
-I/usr/lib/mlton/include -O1 -fno-common -fno-strict-aliasing \
-fomit-frame-pointer -w -m64 -o /tmp/fileeFQzBJ.o /tmp/filePR2V5Q.5.c
gcc -c -m64 -o /tmp/fileCXMKcs.o /tmp/file08JvNj.4.s
gcc -c -m64 -o /tmp/fileNKJ89G.o /tmp/filekicUjH.3.s
gcc -c -m64 -o /tmp/fileSG5tLs.o /tmp/fileSzumK1.2.s
gcc -c -m64 -o /tmp/filelBmNve.o /tmp/fileX2z7aA.1.s
gcc -c -m64 -o /tmp/filew8NCvz.o /tmp/filevZ0aQ8.0.s
gcc -std=gnu99 -c -I/usr/lib/mlton/targets/self/include \
-I/usr/lib/mlton/include -O1 -fno-common -fno-strict-aliasing \
-fomit-frame-pointer -w -m64 -o /tmp/fileHL1K7s.o ./execute.c
gcc -std=gnu99 -c -I/usr/lib/mlton/targets/self/include \
-I/usr/lib/mlton/include -O1 -fno-common -fno-strict-aliasing \
-fomit-frame-pointer -w -m64 -o /tmp/fileUoLkXN.o \
./ampi_interface_mlton.c
gcc -std=gnu99 -c -I/usr/lib/mlton/targets/self/include \
-I/usr/lib/mlton/include -O1 -fno-common -fno-strict-aliasing \
-fomit-frame-pointer -w -m64 -o /tmp/fileZS2MEL.o ./svd_lin_solve.c
Compile and Assemble finished in 0.76 + 0.00 (0% GC)
Link starting
gcc -o makespec /tmp/fileeFQzBJ.o /tmp/fileCXMKcs.o /tmp/fileNKJ89G.o \
/tmp/fileSG5tLs.o /tmp/filelBmNve.o /tmp/filew8NCvz.o \
/tmp/fileHL1K7s.o /tmp/fileUoLkXN.o /tmp/fileZS2MEL.o \
-L/usr/lib/mlton/targets/self -lmlton -lgdtoa -lm -lgmp -m64 \
-mmodel=medium -fPIC -static
/tmp/fileUoLkXN.o: In function `ampi_init_client':
ampi_interface_mlton.c:(.text+0x1085): warning: Using 'gethostbyname'
in statically linked applications requires at runtime the shared
libraries from the glibc version used for linking
/tmp/filew8NCvz.o: In function `L_5':
(.text+0x4fa2): relocation truncated to fit: R_X86_64_PC32 against
symbol `CommandLine_argv' defined in .bss section in
/usr/lib/mlton/targets/self/libmlton.a(CommandLine.o)
/tmp/filew8NCvz.o: In function `L_5':
(.text+0x4fa9): relocation truncated to fit: R_X86_64_PC32 against
symbol `CommandLine_argc' defined in .bss section in
/usr/lib/mlton/targets/self/libmlton.a(CommandLine.o)
/tmp/filew8NCvz.o: In function `L_5':
(.text+0x4fb0): relocation truncated to fit: R_X86_64_PC32 against
symbol `CommandLine_commandName' defined in .bss section in
/usr/lib/mlton/targets/self/libmlton.a(CommandLine.o)
/tmp/fileUoLkXN.o: In function `ampi_comm_size':
ampi_interface_mlton.c:(.text+0x2): relocation truncated to fit:
R_X86_64_PC32 against `.bss'
/tmp/fileUoLkXN.o: In function `ampi_comm_rank':
ampi_interface_mlton.c:(.text+0x9): relocation truncated to fit:
R_X86_64_PC32 against `.bss'
/tmp/fileUoLkXN.o: In function `ampi_get_source':
ampi_interface_mlton.c:(.text+0x11): relocation truncated to fit:
R_X86_64_PC32 against `.bss'
/tmp/fileUoLkXN.o: In function `ampi_get_tag':
ampi_interface_mlton.c:(.text+0x1c): relocation truncated to fit:
R_X86_64_PC32 against `.bss'
/tmp/fileUoLkXN.o: In function `ampi_get_count':
ampi_interface_mlton.c:(.text+0x27): relocation truncated to fit:
R_X86_64_PC32 against `.bss'
/tmp/fileUoLkXN.o: In function `ampi_write_buffer':
ampi_interface_mlton.c:(.text+0x38): relocation truncated to fit:
R_X86_64_PC32 against `.bss'
ampi_interface_mlton.c:(.text+0x60): relocation truncated to fit:
R_X86_64_PC32 against `.bss'
/tmp/fileUoLkXN.o: In function `ampi_read_buffer':
ampi_interface_mlton.c:(.text+0x8d): additional relocation overflows
omitted from the output
collect2: ld returned 1 exit status
Link raised in 0.13 + 0.00 (0% GC)
Link raised: Fail
MLton raised in 10.86 + 4.38 (29% GC)
MLton raised: Fail
call to system failed with exit status 1:
gcc -o makespec /tmp/fileeFQzBJ.o /tmp/fileCXMKcs.o /tmp/fileNKJ89G.o
/tmp/fileSG5tLs.o /tmp/filelBmNve.o /tmp/filew8NCvz.o
/tmp/fileHL1K7s.o /tmp/fileUoLkXN.o /tmp/fileZS2MEL.o
-L/usr/lib/mlton/targets/self -lmlton -lgdtoa -lm -lgmp -m64
-mmodel=medium -fPIC -static


The mlton command line I'm using is:

mlton @MLton fixed-heap 800m -- -link-opt '-mmodel=medium -fPIC
-static' -verbose 1 -codegen amd64 -const 'Exn.keepHistory true'
-runtime 'ram-slop 1.0' -default-ann 'allowFFI true' makespec.sml
./execute.c ./ampi_interface_mlton.c ./svd_lin_solve.c

I've played around with the link-opt's but haven't been able to change
the outcome.

Can someone tell me what I can do to fix this?

- Lars Magnusson
Florian Weimer
2010-10-21 12:52:02 UTC
Permalink
Post by Lars Magnusson
I've played around with the link-opt's but haven't been able to change
the outcome.
Could you send the error message with the -link-opt flag?
Wesley W. Terpstra
2010-10-22 08:06:26 UTC
Permalink
Post by Lars Magnusson
-static' -verbose 1 -codegen amd64 -const 'Exn.keepHistory true'
-runtime 'ram-slop 1.0' -default-ann 'allowFFI true' makespec.sml
./execute.c ./ampi_interface_mlton.c ./svd_lin_solve.c
Lose the '-static'.
Lars Magnusson
2010-10-22 08:20:05 UTC
Permalink
Thanks for the reply.

I've tried losing the static (among other flags) but the same linker
errors remain.

The problem is introduced when I include the execute.c file. But this
file compiles and links just fine when compiled separately with the
same flags used by mlton.

-Lars Magnusson
Post by Wesley W. Terpstra
Post by Lars Magnusson
-static' -verbose 1 -codegen amd64 -const 'Exn.keepHistory true'
-runtime 'ram-slop 1.0' -default-ann 'allowFFI true' makespec.sml
./execute.c ./ampi_interface_mlton.c ./svd_lin_solve.c
Lose the '-static'.
Florian Weimer
2010-10-22 09:10:51 UTC
Permalink
Post by Lars Magnusson
I've tried losing the static (among other flags) but the same linker
errors remain.
If the messages remain exactly the same, you're still linking
statically for some reason.
Lars Magnusson
2010-10-22 10:03:50 UTC
Permalink
I figured it out.. sort of..

We allocate a huge array of words (uint64_t[400000000]). Why this
makes the linker fail I'm not sure, but I thought it was best to let
you guys know.

-Lars Magnusson
Post by Lars Magnusson
Thanks for the reply.
I've tried losing the static (among other flags) but the same linker
errors remain.
The problem is introduced when I include the execute.c file. But this
file compiles and links just fine when compiled separately with the
same flags used by mlton.
-Lars Magnusson
Post by Wesley W. Terpstra
Post by Lars Magnusson
-static' -verbose 1 -codegen amd64 -const 'Exn.keepHistory true'
-runtime 'ram-slop 1.0' -default-ann 'allowFFI true' makespec.sml
./execute.c ./ampi_interface_mlton.c ./svd_lin_solve.c
Lose the '-static'.
Florian Weimer
2010-10-22 11:08:07 UTC
Permalink
Post by Lars Magnusson
We allocate a huge array of words (uint64_t[400000000]). Why this
makes the linker fail I'm not sure, but I thought it was best to let
you guys know.
amd64 uses 32-bit relocations by default. If you have such a large
value in your data segment, parts of it will not be reachable by the
program.

I don't think there is a full 64 bit ABI for GNU/Linux.

Loading...