https://gcc.gnu.org/bugzilla/show_bug.cgi?id=127366

            Bug ID: 127366
           Summary: Avoid empty atexit call in mingw __gcc_register_frame
                    / crtbegin.o
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgcc
          Assignee: unassigned at gcc dot gnu.org
          Reporter: pali at kernel dot org
  Target Milestone: ---

Created attachment 65577
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=65577&action=edit
mingw avoid empty atexit() call in crtbegin.o

Function __gcc_register_frame inside cygming-crtbegin.c is calling
atexit(__gcc_deregister_frame) for condition #if DEFAULT_USE_CXA_ATEXIT.
The whole content of __gcc_deregister_frame function is already guarded by the
#if DWARF2_UNWIND_INFO. Therefore it is not needed to call atexit() for case
when DWARF2_UNWIND_INFO is 0.

The atexit implementation when building mingw-w64 DLL libraries is not small
and has to be statically linked into every DLL library. Therefore for gcc it
would make sense to avoid atexit call when it is not needed (to decrease size
of final DLL library and not to link larger static code).

In the attachment is a patch which puts the atexit() call inside the same guard
#if DWARF2_UNWIND_INFO, which will avoid generating of atexit() call when it
would do nothing.

Reply via email to