public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* why debian uses --use-cxa-atexit
@ 2002-06-01 16:21 Jack Howarth
  2002-06-01 22:15 ` Jakub Jelinek
  0 siblings, 1 reply; 3+ messages in thread
From: Jack Howarth @ 2002-06-01 16:21 UTC (permalink / raw)
  To: gcc

   I've gone back through the debian-gcc mailing list and found
the origin of debian using --use-cxa-atexit in their gcc 3.x
compiler builds. It is in the thread starting with...

http://lists.debian.org/debian-gcc/2001/debian-gcc-200106/msg00126.html

which basically says that they are using --use-cxa-atexit because
global destructors are not run in the correct order. They got this
from http://gcc.gnu.org/bugs.html#known which has...

Global destructors are not run in the correct order.

Global destructors should be run in the reverse order of their constructors completing. In most cases this is the same as the reverse order of constructors starting, but sometimes it is different, and that is important. You need to compile and link your programs with --use-cxa-atexit. We have not turned this switch on by default, as it requires a cxa aware runtime library (libc, glibc, or equivalent).

Is this information still accurate for gcc 3.1? It would seem this is the 
only reason debian is using --use-cxa-atexit. Thanks for any clarifications.
                      Jack

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

* Re: why debian uses --use-cxa-atexit
  2002-06-01 16:21 why debian uses --use-cxa-atexit Jack Howarth
@ 2002-06-01 22:15 ` Jakub Jelinek
  2002-06-02 10:50   ` Nathan Sidwell
  0 siblings, 1 reply; 3+ messages in thread
From: Jakub Jelinek @ 2002-06-01 22:15 UTC (permalink / raw)
  To: Jack Howarth; +Cc: gcc

On Sat, Jun 01, 2002 at 07:21:20PM -0400, Jack Howarth wrote:
>    I've gone back through the debian-gcc mailing list and found
> the origin of debian using --use-cxa-atexit in their gcc 3.x
> compiler builds. It is in the thread starting with...
> 
> http://lists.debian.org/debian-gcc/2001/debian-gcc-200106/msg00126.html
> 
> which basically says that they are using --use-cxa-atexit because
> global destructors are not run in the correct order. They got this
> from http://gcc.gnu.org/bugs.html#known which has...
> 
> Global destructors are not run in the correct order.
> 
> Global destructors should be run in the reverse order of their
> constructors completing. In most cases this is the same as the reverse
> order of constructors starting, but sometimes it is different, and that
> is important. You need to compile and link your programs
> with --use-cxa-atexit. We have not turned this switch on by default, as
> it requires a cxa aware runtime library (libc, glibc, or equivalent).
> 
> Is this information still accurate for gcc 3.1? It would seem this is the 
> only reason debian is using --use-cxa-atexit. Thanks for any clarifications.

It is not about being or not being accurate for gcc 3.1, it is about glibc
2001-02-26 or later having:

/* This is defined by newer gcc version unique for each module.  */
extern void *__dso_handle __attribute__ ((__weak__));

/* Register FUNC to be executed by `exit'.  */
int
atexit (void (*func) (void))
{
  return __cxa_atexit ((void (*) (void *)) func, NULL,
                       &__dso_handle == NULL ? NULL : __dso_handle);
}

/* Hide the symbol so that no definition but the one locally in the
   executable or DSO is used.  */
#ifdef HAVE_DOT_HIDDEN
asm (".hidden\tatexit");
#endif

in /usr/lib/libc_nonshared.a (and exporting atexit from libc.so only
as compatibility symbol version, so nothing newly linked can use it).

	Jakub

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

* Re: why debian uses --use-cxa-atexit
  2002-06-01 22:15 ` Jakub Jelinek
@ 2002-06-02 10:50   ` Nathan Sidwell
  0 siblings, 0 replies; 3+ messages in thread
From: Nathan Sidwell @ 2002-06-02 10:50 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Jack Howarth, gcc

Jakub Jelinek wrote:
> 
> It is not about being or not being accurate for gcc 3.1, it is about glibc
> 2001-02-26 or later having:
> 
> /* This is defined by newer gcc version unique for each module.  */
> extern void *__dso_handle __attribute__ ((__weak__));
> 
> /* Register FUNC to be executed by `exit'.  */
> int
> atexit (void (*func) (void))
> {
>   return __cxa_atexit ((void (*) (void *)) func, NULL,
>                        &__dso_handle == NULL ? NULL : __dso_handle);
> }
it is the address of  __dso_handle which is needed. We'd misinterpreted
the spec until Mark applied
2002-04-15  Mark Mitchell  <mark@codesourcery.com>

        * decl.c (register_dtor_fn): Pass the address of dso_handle, not
        dso_handle itself, to __cxa_atexit.

so that call should really be
  return __cxa_atextit ((void (*) (void *)) func, NULL, &__dso_handle);

(previously __dso_handle was inited to its own address, so your
code would work for g++ produced objects, but not necessarily for others.)

nathan
nathan
-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org

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

end of thread, other threads:[~2002-06-02 17:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-06-01 16:21 why debian uses --use-cxa-atexit Jack Howarth
2002-06-01 22:15 ` Jakub Jelinek
2002-06-02 10:50   ` Nathan Sidwell

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).