Ok, here's the solution: remove --as-needed option out of compiler's
internal linker invocation command line. Steps to do this:

1) Dump compiler specs: $ gcc -dumpspecs > specs
2) Open specs file for edit and remove --as-needed from the line

*link:
%{!r:--build-id} --no-add-needed --as-needed %{!static:--eh-frame-hdr}
%{!m32:-m elf_x86_64} %{m32:-m elf_i386} --hash-style=gnu
%{shared:-shared}   %{!shared:     %{!static:
%{rdynamic:-export-dynamic}       %{m32:-dynamic-linker
%{muclibc:/lib/ld-uClibc.so.0;:%{mbionic:/system/bin/linker;:/lib/ld-linux.so.2}}}
      %{!m32:-dynamic-linker
%{muclibc:/lib/ld64-uClibc.so.0;:%{mbionic:/system/bin/linker64;:/lib64/ld-linux-x86-64.so.2}}}}
    %{static:-static}}

resulting into

*link:
%{!r:--build-id} --no-add-needed %{!static:--eh-frame-hdr} %{!m32:-m
elf_x86_64} %{m32:-m elf_i386} --hash-style=gnu   %{shared:-shared}
%{!shared:     %{!static:       %{rdynamic:-export-dynamic}
%{m32:-dynamic-linker
%{muclibc:/lib/ld-uClibc.so.0;:%{mbionic:/system/bin/linker;:/lib/ld-linux.so.2}}}
      %{!m32:-dynamic-linker
%{muclibc:/lib/ld64-uClibc.so.0;:%{mbionic:/system/bin/linker64;:/lib64/ld-linux-x86-64.so.2}}}}
    %{static:-static}}

3) Save specs file into compiler's folder
/usr/lib/gcc/<target>/<version>/ For example, in case of Ubuntu 10.10
with gcc 4.6.1 it's /usr/lib/gcc/x86_64-linux-gnu/4.6.1/

With this change no unresolvable relocations anymore!

- D.

2011/10/3 Dmitry N. Mikushin <maemar...@gmail.com>:
> Hi,
>
> Here's a reprocase, the same one as mentioned here:
> http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=608901
>
> marcusmae@loveland:~/Programming/mpitest$ cat mpitest.f90
> program main
> include 'mpif.h'
> integer ierr
> call mpi_init(ierr)
> end
>
> marcusmae@loveland:~/Programming/mpitest$ mpif90 -g mpitest.f90
> /usr/bin/ld: /tmp/cc3NLduM.o(.debug_info+0x542): unresolvable
> R_X86_64_64 relocation against symbol `mpi_fortran_argv_null_'
> /usr/bin/ld: /tmp/cc3NLduM.o(.debug_info+0x55c): unresolvable
> R_X86_64_64 relocation against symbol `mpi_fortran_argv_null_'
> /usr/bin/ld: /tmp/cc3NLduM.o(.debug_info+0x5d2): unresolvable
> R_X86_64_64 relocation against symbol `mpi_fortran_errcodes_ignore_'
> /usr/bin/ld: /tmp/cc3NLduM.o(.debug_info+0x5ec): unresolvable
> R_X86_64_64 relocation against symbol `mpi_fortran_errcodes_ignore_'
>
> Remove "-g", and the error will be gone.
>
> marcusmae@loveland:~/Programming/mpitest$ mpif90 --showme -g mpitest.f90
> gfortran -g mpitest.f90 -I/opt/openmpi_gcc-1.5.4/include -pthread
> -I/opt/openmpi_gcc-1.5.4/lib -L/opt/openmpi_gcc-1.5.4/lib -lmpi_f90
> -lmpi_f77 -lmpi -ldl -Wl,--export-dynamic -lnsl -lutil -lm -ldl
>
> marcusmae@loveland:~/Programming/mpitest$ mpif90 -v
> Using built-in specs.
> COLLECT_GCC=/usr/bin/gfortran
> COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.6.1/lto-wrapper
> Target: x86_64-linux-gnu
> Configured with: ../src/configure -v --with-pkgversion='Ubuntu/Linaro
> 4.6.1-9ubuntu3'
> --with-bugurl=file:///usr/share/doc/gcc-4.6/README.Bugs
> --enable-languages=c,c++,fortran,objc,obj-c++,go --prefix=/usr
> --program-suffix=-4.6 --enable-shared --enable-linker-build-id
> --with-system-zlib --libexecdir=/usr/lib --without-included-gettext
> --enable-threads=posix --with-gxx-include-dir=/usr/include/c++/4.6
> --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu
> --enable-libstdcxx-debug --enable-libstdcxx-time=yes --enable-plugin
> --enable-objc-gc --disable-werror --with-arch-32=i686
> --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
> --host=x86_64-linux-gnu --target=x86_64-linux-gnu
> Thread model: posix
> gcc version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
>
> 2011/9/28 Dmitry N. Mikushin <maemar...@gmail.com>:
>> Hi,
>>
>> Interestingly, the errors are gone after I removed "-g" from the app
>> compile options.
>>
>> I tested again on the fresh Ubuntu 11.10 install: both 1.4.3 and 1.5.4
>> compile fine, but with the same error.
>> Also I tried hard to find any 32-bit object or library and failed.
>> They all are 64-bit.
>>
>> - D.
>>
>> 2011/9/24 Jeff Squyres <jsquy...@cisco.com>:
>>> Check the output from when you ran Open MPI's configure and "make all" -- 
>>> did it decide to build the F77 interface?
>>>
>>> Also check that gcc and gfortran output .o files of the same bitness / type.
>>>
>>>
>>> On Sep 24, 2011, at 8:07 AM, Dmitry N. Mikushin wrote:
>>>
>>>> Compile and link - yes, but it turns out there was some unnoticed
>>>> compilation error because
>>>>
>>>> ./hellompi: error while loading shared libraries: libmpi_f77.so.1:
>>>> cannot open shared object file: No such file or directory
>>>>
>>>> and this library does not exist.
>>>>
>>>> Hm.
>>>>
>>>> 2011/9/24 Jeff Squyres <jsquy...@cisco.com>:
>>>>> Can you compile / link simple OMPI applications without this problem?
>>>>>
>>>>> On Sep 24, 2011, at 7:54 AM, Dmitry N. Mikushin wrote:
>>>>>
>>>>>> Hi Jeff,
>>>>>>
>>>>>> Today I've verified this application on the Feroda 15 x86_64, where
>>>>>> I'm usually building OpenMPI from source using the same method.
>>>>>> Result: no link errors there! So, the issue is likely ubuntu-specific.
>>>>>>
>>>>>> Target application is compiled linked with mpif90 pointing to
>>>>>> /opt/openmpi_gcc-1.5.4/bin/mpif90 I built.
>>>>>>
>>>>>> Regarding architectures, everything in target folders and OpenMPI
>>>>>> installation is
>>>>>> ELF 64-bit LSB shared object, x86-64, version 1 (SYSV), dynamically
>>>>>> linked, not stripped
>>>>>>
>>>>>> - D.
>>>>>>
>>>>>> 2011/9/24 Jeff Squyres <jsquy...@cisco.com>:
>>>>>>> How does the target application compile / link itself?
>>>>>>>
>>>>>>> Try running "file" on the Open MPI libraries and/or your target 
>>>>>>> application .o files to see what their bitness is, etc.
>>>>>>>
>>>>>>>
>>>>>>> On Sep 22, 2011, at 3:15 PM, Dmitry N. Mikushin wrote:
>>>>>>>
>>>>>>>> Hi Jeff,
>>>>>>>>
>>>>>>>> You're right because I also tried 1.4.3, and it's the same issue
>>>>>>>> there. But what could be wrong? I'm using the simplest form -
>>>>>>>> ../configure --prefix=/opt/openmpi_gcc-1.4.3/ and only installed
>>>>>>>> compilers are system-default gcc and gfortran 4.6.1. Distro is ubuntu
>>>>>>>> 11.10. There is no any mpi installed from packages, and no -m32
>>>>>>>> options around. What else could be the source?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>> - D.
>>>>>>>>
>>>>>>>> 2011/9/22 Jeff Squyres <jsquy...@cisco.com>:
>>>>>>>>> This usually means that you're mixing compiler/linker flags somehow 
>>>>>>>>> (e.g., built something with 32 bit, built something else with 64 bit, 
>>>>>>>>> try to link them together).
>>>>>>>>>
>>>>>>>>> Can you verify that everything was built with all the same 32/64?
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> On Sep 22, 2011, at 1:21 PM, Dmitry N. Mikushin wrote:
>>>>>>>>>
>>>>>>>>>> Hi,
>>>>>>>>>>
>>>>>>>>>> OpenMPI 1.5.4 compiled with gcc 4.6.1 and linked with target app 
>>>>>>>>>> gives
>>>>>>>>>> a load of linker messages like this one:
>>>>>>>>>>
>>>>>>>>>> /usr/bin/ld: 
>>>>>>>>>> ../../lib/libutil.a(parallel_utilities.o)(.debug_info+0x529d):
>>>>>>>>>> unresolvable R_X86_64_64 relocation against symbol
>>>>>>>>>> `mpi_fortran_argv_null_
>>>>>>>>>>
>>>>>>>>>> There are a lot of similar messages about other mpi_fortran_ symbols.
>>>>>>>>>> Is it a known issue?
>>>>>>>>>>
>>>>>>>>>> Thanks,
>>>>>>>>>> - D.
>>>>>>>>>> _______________________________________________
>>>>>>>>>> users mailing list
>>>>>>>>>> us...@open-mpi.org
>>>>>>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> --
>>>>>>>>> Jeff Squyres
>>>>>>>>> jsquy...@cisco.com
>>>>>>>>> For corporate legal information go to:
>>>>>>>>> http://www.cisco.com/web/about/doing_business/legal/cri/
>>>>>>>>>
>>>>>>>>>
>>>>>>>>> _______________________________________________
>>>>>>>>> users mailing list
>>>>>>>>> us...@open-mpi.org
>>>>>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>>>>>>>>>
>>>>>>>> _______________________________________________
>>>>>>>> users mailing list
>>>>>>>> us...@open-mpi.org
>>>>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>>>>>>>
>>>>>>>
>>>>>>> --
>>>>>>> Jeff Squyres
>>>>>>> jsquy...@cisco.com
>>>>>>> For corporate legal information go to:
>>>>>>> http://www.cisco.com/web/about/doing_business/legal/cri/
>>>>>>>
>>>>>>>
>>>>>>> _______________________________________________
>>>>>>> users mailing list
>>>>>>> us...@open-mpi.org
>>>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>>>>>>>
>>>>>> _______________________________________________
>>>>>> users mailing list
>>>>>> us...@open-mpi.org
>>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>>>>>
>>>>>
>>>>> --
>>>>> Jeff Squyres
>>>>> jsquy...@cisco.com
>>>>> For corporate legal information go to:
>>>>> http://www.cisco.com/web/about/doing_business/legal/cri/
>>>>>
>>>>>
>>>>> _______________________________________________
>>>>> users mailing list
>>>>> us...@open-mpi.org
>>>>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>>>>>
>>>> _______________________________________________
>>>> users mailing list
>>>> us...@open-mpi.org
>>>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>>>
>>>
>>> --
>>> Jeff Squyres
>>> jsquy...@cisco.com
>>> For corporate legal information go to:
>>> http://www.cisco.com/web/about/doing_business/legal/cri/
>>>
>>>
>>> _______________________________________________
>>> users mailing list
>>> us...@open-mpi.org
>>> http://www.open-mpi.org/mailman/listinfo.cgi/users
>>>
>>
>

Reply via email to