This is the mail archive of the gcc@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]

Re: AIX xlc and gcc/g++ Question


David,

Thank you for an excellent and insightful reply.  For my program, I need to
link with the xlc linker.  However, as a workaround, I am employing a
first-use rule on initializing global objects.  That is, I am turning these
global objects into pointers, initializing them to null when they are
declared.  This seems to work.  Then, just before they are first
referenced/used, I am adding code to let the progarm allocate memory for
them.  Of course I am then relying on the OS to release the application
heap when the program exits.  This should be all right so long as the
destructors fo these objects don't do much, which they currently do not.

I will look into your suggestion about generating the list of constructors
manually as well as gcc 2.95.2.  As for deploying the code using the next
release of gcc under AIX 4.3, that will probably happen later this year.  I
will revisit this issue then.

Thanks again!

--

At 02:41 PM 4/26/00 -0400, David Edelsohn wrote:
>	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


--
Fang-Pin Chang
Qualcomm Incorporated
http://www.qualcomm.com

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