[PATCH] Fix PR libitm/55693

Jack Howarth howarth@bromo.med.uc.edu
Wed Feb 6 17:21:00 GMT 2013


On Wed, Feb 06, 2013 at 05:37:12PM +0100, Patrick Marlier wrote:
> Hi Jack,
> 
> Thanks for having a look at this.
> 
> However I don't understand why you need this:
> 
> Index: gcc/config/i386/darwin.h
> ===================================================================
> --- gcc/config/i386/darwin.h (revision 195764)
> +++ gcc/config/i386/darwin.h (working copy)
> @@ -131,8 +131,7 @@ extern int darwin_emit_branch_islands;
>    "%{Ofast|ffast-math|funsafe-math-optimizations:crtfastmath.o%s} \
>     %{mpc32:crtprec32.o%s} \
>     %{mpc64:crtprec64.o%s} \
> -   %{mpc80:crtprec80.o%s} \
> -   %{fgnu-tm: -lcrttme.o}"
> +   %{mpc80:crtprec80.o%s}" TM_DESTRUCTOR
> 
>  #undef SUBTARGET_EXTRA_SPECS
>  #define SUBTARGET_EXTRA_SPECS                                   \
> Index: gcc/config/darwin.h
> ===================================================================
> --- gcc/config/darwin.h (revision 195764)
> +++ gcc/config/darwin.h (working copy)
> @@ -363,7 +363,8 @@ extern GTY(()) int darwin_ms_struct;
>    %{shared-libgcc:%:version-compare(< 10.5 mmacosx-version-min= crt3.o%s)}"
> 
>  /* We want a destructor last in the list.  */
> -#define ENDFILE_SPEC "%{fgnu-tm: -lcrttme.o}"
> +#define TM_DESTRUCTOR "%{fgnu-tm: -lcrttme.o}"
> +#define ENDFILE_SPEC TM_DESTRUCTOR
> 
>  #define DARWIN_EXTRA_SPECS \
>    { "darwin_crt1", DARWIN_CRT1_SPEC }, \
> 
> 
> It seems you just add a macro TM_DESTRUCTOR which is the same as
> ENDFILE_SPEC. Maybe I missed something (I am updating my svn)...

Patrick,
   This was the patch Iain proposed off-list and I just cleaned up the comments.
I believe that he added the additional definition of TM_DESTRUCTOR so that 
it could be used to replace the explicit instance of %{fgnu-tm: -lcrttme.o}
in the definition of ENDFILE_SPEC in gcc/config/i386/darwin.h.

> 
> Also why HAVE_ELF_STYLE_WEAKREF is not defined for MacOS version where
> weak ref works? It could be better to define function to dummy only if
> HAVE_ELF_STYLE_WEAKREF is not set (and not testing the MacOS version).

I assume you are referring to the change...

 /* Provide dummy functions to satisfy linkage for versions of the Darwin 
    tool-chain that that can't handle undefined weak refs at the link stage.
-   ??? Define these dummy functions only when !HAVE_ELF_STYLE_WEAKREF. */
+   Don't define for 10.6 or later with faster weak-symbol coalescing. */

As far as I can tell that was only a TODO type note in the comments and
was never implemented. Using !HAVE_ELF_STYLE_WEAKREF as the conditional
to avoid defining the dummy functions won't help at all. The problem here
has nothing to do with HAVE_ELF_STYLE_WEAKREF but is the fact that 
the introduction of faster c++ weak-symbol coalescing prevents dyld from
looking in libstdc++ for the __cxa* symbols if weak symbols for them
exist in linked libgcc/config/darwin-crt-tm.o. This problem also exists
for Xcode 3.2.6 which doesn't HAVE_ELF_STYLE_WEAKREF. So the correct fix
is what Iain proposed of defining the dummy functions only when the
__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 10.6.

> 
> If we want to remove support for Xcode 4.2 (buggy linker), I think you
> should also have a look at the old commit to undo it (I remember a
> change in libitm which add a #ifdef MACH).

I don't see the point. The libitm.c++/eh-1.C execution test case is broken
current gcc trunk on Xcode 4.2 up to 4.4. With the patch, it remains broken (as you 
there are some linker bugs you just can hack around).
             Jack

> 
> Thanks.
> 
> --
> Patrick



More information about the Gcc-patches mailing list