This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: AW: AIX link error with g++ 4.4.0


I played a little with it on AIX 5.3 TL 9, including trying Dave's
patch.

When compiling a hello-world one-liner, I get warnings on multiple
defines with g++ (or gcc -shared-libgcc):

$ g++ -o hw hw.cpp
ld: 0711-224 WARNING: Duplicate symbol: .__divti3
ld: 0711-224 WARNING: Duplicate symbol: .__modti3
ld: 0711-224 WARNING: Duplicate symbol: .__udivti3
ld: 0711-224 WARNING: Duplicate symbol: .__umodti3
ld: 0711-224 WARNING: Duplicate symbol: .__udivmodti4
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.

They are defined in libgcc_s and libgcc, and both are on the link line.

Now, g++ -static-libgcc and -static works with Dave's patch. However,
compiling with g++ -static gives the unresolved externals:

$ g++ -o hw  -static hw.cpp
ld: 0711-317 ERROR: Undefined symbol: encrypted_pw_passlen
ld: 0711-317 ERROR: Undefined symbol: crypt_r
ld: 0711-317 ERROR: Undefined symbol: max_history_size
ld: 0711-317 ERROR: Undefined symbol: getpass_auto
ld: 0711-317 ERROR: Undefined symbol: max_pw_passlen
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more information.
collect2: ld returned 8 exit status

This can be worked around by adding -lcrypt. Now, the g++ hello-world
links w/o errors, but it hangs (consuming cpu time) when trying to
execute. The program reads:

[hw.cpp]
#include <iostream>

int main ()
{
    std::cout << "hello, world!\n";

    return 0;
}

Invoking gdb on the hung hello-world from another terminal yields the
call stack:

$ gdb hw 1196058
GNU gdb 6.8
Copyright (C) 2008 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "powerpc-ibm-aix5.3.0.0"...
Attaching to program: /home/ntnu/joern/src/hw, process 1196058
0x1016656c in std::__timepunct<char>::__timepunct ()
(gdb) where
#0  0x1016656c in std::__timepunct<char>::__timepunct ()
#1  0x10160890 in std::locale::_Impl::_Impl (this=<incomplete type>,
    __refs=<incomplete type>) at  _start_ :404
#2  0x1016038c in std::locale::_S_initialize_once () at  _start_ :251
#3  0x1015e4e4 in std::locale::locale (this=<incomplete type>) at  _start_ :210
#4  0x1014da54 in std::ios_base::Init::Init (this=<incomplete type>)
    at  _start_ :519
#5  0x1014d38c in __static_initialization_and_destruction_0 (__initialize_p=1,
    __priority=65535)
    at /opt/freeware/lib/gcc/powerpc-ibm-aix5.3.0.0/4.4.1/include/c++/iostream:72
#6  0x1014d43c in global constructors keyed to 65535_0_main () at hw.cpp:8
#7  0x1016d4c8 in _GLOBAL__FI_hw ()
#8  0x10000a20 in mod_init1 ()
#9  0x100008c8 in __modinit ()
#10 0x100001fc in __start ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
(gdb)

I don't know if this is of any practical importance, especially as I
recon attempting xlC -bstatic on hw.cpp gives lots of unresolved
externals. GNU g++ seems to work well with default linker options.

Best Regards --Jørn Amundsen



On Tue, 16 Jun 2009, David Edelsohn wrote:

"Fehringer Franz" <Franz.Fehringer@fja.com> writes:

I have exactly the same error like described in
http://gcc.gnu.org/ml/gcc-help/2009-05/msg00323.html
namely
collect2: library libstdc++ -lsupc++ not found

The bug is in the way that gcc/gpg++spec.c uses LIBSTDCXX_STATIC, or
possibly in the way that macro is defined in gcc/config/rs6000/aix.h. ?I
don't see a simple fix.

I have applied a fix to GCC mainline that uses LIBSTDCXX_STATIC as an additional library argument when linking statically, solving this problem. I may backport this to GCC 4.4 if it proves safe.

While this solves the error about libstdc++ -lsupc++, I still receive
other errors on AIX 5.3 when linking statically because ld tried to
resolve all symbols in libc.a.  AIX 5.3 libc.a contains some
references to functions that are not defined elsewhere.  I needed to
use -Wl,-berok to generate a working executable.

David

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]