public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Link Problems with gcc/g++ 3.1.1 on AIX 4.3.3
@ 2002-07-30  2:50 Frank.Seehase
  2002-08-03 20:55 ` David Edelsohn
  0 siblings, 1 reply; 2+ messages in thread
From: Frank.Seehase @ 2002-07-30  2:50 UTC (permalink / raw)
  To: gcc-help, gcc-bugs


Hi, I have got a problem:

When linking an executable, not referenced objects 
from libraries are pulled in, maybe due to static 
objects initialization code, even if there is no C++ code.

The garbarge collection of the AIX Linker seem to fail.

If the code is compiled as .c (not .cc) files with gcc (not g++) 
there is no problem. I am using the AIX system assembler 
and linker as recommended.

AIX 4.3.3 ML 10

/tools/pkg/gcc/3.1.1/bin/g++ -v
Reading specs from
/tools/pkg/gcc/3.1.1/lib/gcc-lib/powerpc-ibm-aix4.3.3.0/3.1.1/specs
Configured with: ../configure --prefix=/tools/pkg/gcc/3.1.1
--with-as=/bin/as --with-ld=/bin/ld
Thread model: aix
gcc version 3.1.1


/tools/pkg/binutils/2.12.1/bin/ar -V
GNU ar 2.12.1



An example follows.

The symbol fct3 is missing even fct2 is unused.

/tools/pkg/gcc/3.1.1/bin/g++ -o fkt1.o -c fkt1.cc
/tools/pkg/gcc/3.1.1/bin/g++ -o fkt2.o -c fkt2.cc
ar -rv libTst.a fkt1.o fkt2.o
ar: Creating an archive file libTst.a.
a - fkt1.o
a - fkt2.o
/tools/pkg/gcc/3.1.1/bin/g++ -o main.o -c main.cc
/tools/pkg/gcc/3.1.1/bin/g++ -o main main.o libTst.a
ld: 0711-317 ERROR: Undefined symbol: .fkt3(int)
ld: 0711-345 Use the -bloadmap or -bnoquiet option to obtain more
information.
collect2: ld returned 8 exit status


The sources:

/* ---------------------------------- */
/* --- fct2.cc --- */

void fct3( void );

void fct2( void )
{
  fct3( );
}


/* --- fct1.cc --- */
void fct1( void )
{
}


/* --- main.cc --- */
void fct1( void );
int main( void )
{
  fct1( );
  return 0;
}
/* ---------------------------------- */

I have got the same problem with gcc versions 3.0.4 and 3.1
 
Whats wrong?
Any idea?

Thanks, Frank

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Link Problems with gcc/g++ 3.1.1 on AIX 4.3.3
  2002-07-30  2:50 Link Problems with gcc/g++ 3.1.1 on AIX 4.3.3 Frank.Seehase
@ 2002-08-03 20:55 ` David Edelsohn
  0 siblings, 0 replies; 2+ messages in thread
From: David Edelsohn @ 2002-08-03 20:55 UTC (permalink / raw)
  To: Frank.Seehase; +Cc: gcc-help

>>>>> Frank writes:

Frank> When linking an executable, not referenced objects 
Frank> from libraries are pulled in, maybe due to static 
Frank> objects initialization code, even if there is no C++ code.

	That's how GCC work on AIX because otherwise the AIX linker may
garbage collect functions used by static initializers.  Do not place
unreferenced C++ functions in an archive on AIX.

David

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-08-04  3:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-07-30  2:50 Link Problems with gcc/g++ 3.1.1 on AIX 4.3.3 Frank.Seehase
2002-08-03 20:55 ` David Edelsohn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).