[Pkg-openmpi-maintainers] Bug#608901: link failure with ld --as-needed

Ralf Wildenhues Ralf.Wildenhues at gmx.de
Sat Jan 8 08:50:39 UTC 2011


* Matthias Klose wrote on Thu, Jan 06, 2011 at 10:59:12PM CET:
> On 06.01.2011 22:40, Ralf Wildenhues wrote:
> >
> >>  /usr/lib/gcc/x86_64-linux-gnu/4.5.2/collect2 --build-id --no-add-needed --eh-frame-hdr -m elf_x86_64 --hash-style=both -dynamic-linker /lib64/ld-linux-x86-64.so.2 /usr/lib/gcc/x86_64-linux-gnu/4.5.2/../../../../lib/crt1.o /usr/lib/gcc/x86_64-linux-gnu/4.5.2/../../../../lib/crti.o /usr/lib/gcc/x86_64-linux-gnu/4.5.2/crtbegin.o -L/usr/lib/openmpi/lib -L/usr/lib/gcc/i686-linux-gnu/4.5.2 -L/usr/lib/openmpi/lib -L/usr/lib/gcc/x86_64-linux-gnu/4.5.2 -L/usr/lib/gcc/x86_64-linux-gnu/4.5.2/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/x86_64-linux-gnu/4.5.2/../../.. /tmp/ccqYKv1H.o --as-needed -ldl -lmpi -lopen-rte -lopen-pal -lnsl -lutil -lgcc_s -lpthread -ldl -lmpi_f90 -lmpi_f77 -lmpi -lopen-rte -lopen-pal -ldl --export-dynamic -lnsl -lutil -lgfortran -lm -ldl -lgfortran -lm -lgcc_s -lgcc -lpthread -lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.5.2/crtend.o /usr/lib/gcc/x86_64-linux-gnu/4.5.2/../../../../lib/crtn.o
> >>/usr/bin/ld: /tmp/ccqYKv1H.o(.debug_info+0x48d): unresolvable R_X86_64_64 relocation against symbol `mpi_fortran_argv_null_'
> >>/usr/bin/ld: /tmp/ccqYKv1H.o(.debug_info+0x4a7): unresolvable R_X86_64_64 relocation against symbol `mpi_fortran_argv_null_'
> >>/usr/bin/ld: /tmp/ccqYKv1H.o(.debug_info+0x511): unresolvable R_X86_64_64 relocation against symbol `mpi_fortran_errcodes_ignore_'
> >>/usr/bin/ld: /tmp/ccqYKv1H.o(.debug_info+0x52b): unresolvable R_X86_64_64 relocation against symbol `mpi_fortran_errcodes_ignore_'
> >
> >Thanks.  libmpi_f90 should provide these symbols.  libmpi_f77 references
> >them on my system, but doesn't have a DT_NEEDED entry on libmpi_f90.so.0.
> >
> >Can you wrap -lmpi_f90 in '-Wl,--no-as-needed ... -Wl,--as-needed' when
> >running commands manually, to see whether that fixes it?
> 
> yes, this works as expected.

> $ nm test.o
[...]
> 0000000000000001 C mpi_fortran_argv_null_
> 0000000000000008 C mpi_fortran_argvs_null_
> 0000000000000004 C mpi_fortran_bottom_
> 0000000000000004 C mpi_fortran_errcodes_ignore_
[...]

Well, so test.o already provides common definitions for them.
I don't think --as-needed is then supposed to trigger inclusion
for libmpi_f90, but I also don't think the link should fail then.

> $ objdump -T /usr/lib/libmpi_f90.so|grep argv
> 0000000000202c80 g    DO .bss   0000000000000008              mpi_fortran_argv_null_
> 0000000000202c60 g    DO .bss   0000000000000008  Base
> mpi_fortran_argvs_null_
> 
> $ nm -D /usr/lib/libmpi_f90.so|grep argv
> 0000000000202c80 B mpi_fortran_argv_null_
> 0000000000202c60 B mpi_fortran_argvs_null_
> 
> objdump doesn't show `Base' for this symbol.

I don't think symbol versions are relevant here though.

Can you reproduce it with something like this?

cat >liba.c <<\END
extern int foo;

int a ()
{
  return foo;
}
END

cat >libb.c <<\END
int foo;

int b ()
{
  return foo;
}
END

cat >main.c <<\END
int foo;
extern int b ();

int main ()
{
  return b ();
}
END

gcc -fPIC -c liba.c
gcc -fPIC -c libb.c
gcc -c main.c
gcc -shared -o liba.so liba.o
gcc -shared -o libb.so libb.o
gcc -o main main.o -L. -Wl,--as-needed -la -lb


If not, then can you modify it so it reproduces (maybe several variables
are needed)?  If yes, then I suggest (possibly after further
simplification, e.g., omitting liba) you file a bug with binutils.
And can you find out whether you can avoid the bug by, say force-pulling
in libmpi_f90 aka libb (by referencing an unrelated symbol in that
library).

And, I guess, upstream OpenMPI should be notified about this.

Thanks,
Ralf






More information about the Pkg-openmpi-maintainers mailing list