This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: AIX xlc and gcc/g++ Question
- To: Fang-Pin Chang <fchang at qualcomm dot com>
- Subject: Re: AIX xlc and gcc/g++ Question
- From: David Edelsohn <dje at watson dot ibm dot com>
- Date: Wed, 26 Apr 2000 14:41:34 -0400
- cc: gcc at gcc dot gnu dot org
gcc (not just g++) automatically generates calls to invoke the
static constructors produced by G++ that it finds at link time. The list
of constructors is generated at link time by collect2, so it is not easy
to manually have your program perform the same functionality when linked
by XLC.
Is it possible to perform the final link with gcc (or g++) instead
of XLC although you compile the C code with XLC?
The next release should allow you to create a shared library of
the G++ code more easily and that will use the AIX runtime initialization
functionality, but that primarily is intended for AIX 4.3 and not
available with gcc-2.8.1 (or gcc-2.95.2).
If you really need this to work with XLC as linker and do not need
the C++ statically constructed objects before the application gets
control, I think that you could generate the list of constructors manually
and call them first-thing at the beginning of main().
If you perform a link phase using G++ and enable debugging in
collect2, the extra files generated will be printed on the screen as well
as preserved in /tmp (use "g++ -Wl,-debug ..." which passed the
commandline option "-debug" to collect2 front-end of the linker). An
extra C file is generated and compiled containing a function which is
invoked by __main() in libgcc.a called before main(). The detail with
which you need to reproduce all of those steps depends on whether you need
static destructors, etc. You might be able to run the list of
constructors directly.
David
P.S. I would suggest that you use gcc-2.95.2 as well.
===============================================================================
David Edelsohn T.J. Watson Research Center
dje@watson.ibm.com P.O. Box 218
+1 914 945 4364 (TL 862) Yorktown Heights, NY 10598