public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [Darwin] Patch c++/15428
@ 2004-05-20  1:49 Matt Austern
  2004-05-20 18:13 ` Jason Merrill
  0 siblings, 1 reply; 17+ messages in thread
From: Matt Austern @ 2004-05-20  1:49 UTC (permalink / raw)
  To: gcc-patches

This patch fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15428 by 
changing the compiler so that, on Darwin, vtables are not always 
emitted as weak.  This is Darwin-only because it is a violation of the 
Itanium C++ ABI.  It is necessary on Darwin because of a linker quirk.  
(The documentation part of the patch explains the necessity.)

OK to commit to mainline?
				--Matt



? gcc/.gdb_history
Index: gcc/defaults.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/defaults.h,v
retrieving revision 1.138
diff -p -r1.138 defaults.h
*** gcc/defaults.h	13 May 2004 06:39:37 -0000	1.138
--- gcc/defaults.h	19 May 2004 23:28:25 -0000
*************** do { fputs (integer_asm_op (POINTER_SIZE
*** 238,248 ****
   #endif
   #endif

! /* Determines whether explicit template instantiations should
!    be given link-once semantics. The C++ ABI requires this
!    macro to be nonzero; see the documentation. */
! #ifndef TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
! # define TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY 1
   #endif

   /* This determines whether or not we need linkonce unwind information 
*/
--- 238,250 ----
   #endif
   #endif

! /* This determines whether weak symbols must be left out of a static
!    archive's table of contents.  Defining this macro to be nonzero has
!    the consequence that certain symbols will not be made weak that
!    otherwise would be.  The C++ ABI requires this macro to be zero;
!    see the documentation. */
! #ifndef TARGET_WEAK_NOT_IN_ARCHIVE_TOC
! #define TARGET_WEAK_NOT_IN_ARCHIVE_TOC 0
   #endif

   /* This determines whether or not we need linkonce unwind information 
*/
Index: gcc/config/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.h,v
retrieving revision 1.80
diff -p -r1.80 darwin.h
*** gcc/config/darwin.h	19 May 2004 02:11:42 -0000	1.80
--- gcc/config/darwin.h	19 May 2004 23:28:25 -0000
*************** do { text_section ();							\
*** 358,368 ****
   #undef USE_COMMON_FOR_ONE_ONLY
   #define USE_COMMON_FOR_ONE_ONLY 0

! /* The Darwin linker doesn't like explicit template instantiations to 
be
!    coalesced, because it doesn't want coalesced symbols to appear in
      a static archive's table of contents. */
! #undef TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
! #define TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY 0

   /* We make exception information linkonce. */
   #undef TARGET_USES_WEAK_UNWIND_INFO
--- 358,367 ----
   #undef USE_COMMON_FOR_ONE_ONLY
   #define USE_COMMON_FOR_ONE_ONLY 0

! /* The Darwin linker doesn't want coalesced symbols to appear in
      a static archive's table of contents. */
! #undef TARGET_WEAK_NOT_IN_ARCHIVE_TOC
! #define TARGET_WEAK_NOT_IN_ARCHIVE_TOC 1

   /* We make exception information linkonce. */
   #undef TARGET_USES_WEAK_UNWIND_INFO
Index: gcc/cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.708
diff -p -r1.708 decl2.c
*** gcc/cp/decl2.c	19 May 2004 01:28:56 -0000	1.708
--- gcc/cp/decl2.c	19 May 2004 23:28:25 -0000
*************** maybe_make_one_only (tree decl)
*** 1440,1446 ****
        to for variables so that cp_finish_decl will update their 
linkage,
        because their DECL_INITIAL may not have been set properly yet.  
*/

!   if (TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
         || (! DECL_EXPLICIT_INSTANTIATION (decl)
   	  && ! DECL_TEMPLATE_SPECIALIZATION (decl)))
       {
--- 1440,1446 ----
        to for variables so that cp_finish_decl will update their 
linkage,
        because their DECL_INITIAL may not have been set properly yet.  
*/

!   if (!TARGET_WEAK_NOT_IN_ARCHIVE_TOC
         || (! DECL_EXPLICIT_INSTANTIATION (decl)
   	  && ! DECL_TEMPLATE_SPECIALIZATION (decl)))
       {
*************** maybe_emit_vtables (tree ctype)
*** 1581,1586 ****
--- 1581,1587 ----
     tree vtbl;
     tree primary_vtbl;
     bool needed = false;
+   bool weaken_vtables;

     /* If the vtables for this class have already been emitted there is
        nothing more to do.  */
*************** maybe_emit_vtables (tree ctype)
*** 1611,1616 ****
--- 1612,1640 ----
     else if (TREE_PUBLIC (vtbl) && !DECL_COMDAT (vtbl))
       needed = true;

+   /* Determine whether to make vtables weak.  The ABI requires that we
+       do so.  There are two cases in which we have to violate the ABI
+       specification: targets where we don't have weak symbols
+       (obviously), and targets where weak symbols don't appear in
+       static archives' tables of contents.  On such targets, avoiding
+       undefined symbol link errors requires that we only make a symbol
+       weak if we know that it will be emitted everywhere it's needed.
+       So on such targets we don't make vtables weak in the common case
+       where we're emitting a vtable of a nontemplate class in the
+       translation unit containing the definition of a noninline key
+       method. */
+   if (flag_weak && !TARGET_WEAK_NOT_IN_ARCHIVE_TOC)
+     weaken_vtables = true;
+   else if (flag_weak)
+     {
+       if (CLASSTYPE_USE_TEMPLATE (ctype))
+  	weaken_vtables = CLASSTYPE_IMPLICIT_INSTANTIATION (ctype);
+       else
+  	weaken_vtables = !CLASSTYPE_KEY_METHOD (ctype)
+  	  || DECL_DECLARED_INLINE_P (CLASSTYPE_KEY_METHOD (ctype));
+     }
+   else
+     weaken_vtables = false;

     /* The ABI requires that we emit all of the vtables if we emit any
        of them.  */
*************** maybe_emit_vtables (tree ctype)
*** 1657,1664 ****
   	  DECL_IGNORED_P (vtbl) = 1;
   	}

!       /* Always make vtables weak.  */
!       if (flag_weak)
   	comdat_linkage (vtbl);

         rest_of_decl_compilation (vtbl, NULL, 1, 1);
--- 1681,1688 ----
   	  DECL_IGNORED_P (vtbl) = 1;
   	}

!       /* Always make vtables weak.  Or at least almost always; see 
above. */
!       if (weaken_vtables)
   	comdat_linkage (vtbl);

         rest_of_decl_compilation (vtbl, NULL, 1, 1);
Index: gcc/cp/pt.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/pt.c,v
retrieving revision 1.851
diff -p -r1.851 pt.c
*** gcc/cp/pt.c	13 May 2004 06:40:21 -0000	1.851
--- gcc/cp/pt.c	19 May 2004 23:28:25 -0000
*************** do_type_instantiation (tree t, tree stor
*** 10789,10795 ****
          get unresolved symbols at link time. */

       explicitly_instantiate_members =
!       TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
         && previous_instantiation_extern_p && ! extern_p
         && ! TYPE_FOR_JAVA (t);

--- 10789,10795 ----
          get unresolved symbols at link time. */

       explicitly_instantiate_members =
!       !TARGET_WEAK_NOT_IN_ARCHIVE_TOC
         && previous_instantiation_extern_p && ! extern_p
         && ! TYPE_FOR_JAVA (t);

Index: gcc/doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.325
diff -p -r1.325 tm.texi
*** gcc/doc/tm.texi	19 May 2004 13:54:15 -0000	1.325
--- gcc/doc/tm.texi	19 May 2004 23:28:28 -0000
*************** commands that will make the symbol(s) as
*** 6759,6771 ****
   hidden, protected or internal visibility as specified by 
@var{visibility}.
   @end deftypefn

! @defmac TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
   A C expression that evaluates to true if the target's linker expects
! explicit template specializations, as well as implicit, to be given
! linkonce semantics.  The default is @code{1}.  The C++ ABI requires
! this macro to be nonzero.  Define this macro for targets where full
! C++ ABI compliance is impossible and where explicit and implicit
! template specialization must be treated differently.
   @end defmac

   @defmac TARGET_SUPPORTS_HIDDEN
--- 6759,6781 ----
   hidden, protected or internal visibility as specified by 
@var{visibility}.
   @end deftypefn

! @defmac TARGET_WEAK_NOT_IN_ARCHIVE_TOC
   A C expression that evaluates to true if the target's linker expects
! that weak symbols do not appear in a static archive's table of 
contents.
! The default is @code{0}.
!
! Leaving weak symbols out of an archive's table of contents means that,
! if a symbol will only have a definition in one translation unit and
! will have undefined references from other translation units, that
! symbol should not be weak.  Defining this macro to be nonzero will
! thus have the effect that certain symbols that would normally be weak
! (explicit template instantiations, and vtables for polymorphic classes
! with noninline key methods) will instead be nonweak.
!
! The C++ ABI requires this macro to be zero.  Define this macro for
! targets where full C++ ABI compliance is impossible and where linker
! restrictions require weak symbols to be left out of a static archive's
! table of contents.
   @end defmac

   @defmac TARGET_SUPPORTS_HIDDEN

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

* Re: [Darwin] Patch c++/15428
  2004-05-20  1:49 [Darwin] Patch c++/15428 Matt Austern
@ 2004-05-20 18:13 ` Jason Merrill
  2004-05-20 20:28   ` Matt Austern
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Merrill @ 2004-05-20 18:13 UTC (permalink / raw)
  To: Matt Austern; +Cc: gcc-patches

On Wed, 19 May 2004 16:54:11 -0700, Matt Austern <austern@apple.com> wrote:

> *************** do_type_instantiation (tree t, tree stor
> *** 10789,10795 ****
>           get unresolved symbols at link time. */
>
>        explicitly_instantiate_members =
> !       TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
>          && previous_instantiation_extern_p && ! extern_p
>          && ! TYPE_FOR_JAVA (t);
>
> --- 10789,10795 ----
>           get unresolved symbols at link time. */
>
>        explicitly_instantiate_members =
> !       !TARGET_WEAK_NOT_IN_ARCHIVE_TOC
>          && previous_instantiation_extern_p && ! extern_p
>          && ! TYPE_FOR_JAVA (t);

Why are/were you checking the macro here?

Jason

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

* Re: [Darwin] Patch c++/15428
  2004-05-20 18:13 ` Jason Merrill
@ 2004-05-20 20:28   ` Matt Austern
  2004-05-20 21:02     ` Jason Merrill
  0 siblings, 1 reply; 17+ messages in thread
From: Matt Austern @ 2004-05-20 20:28 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches


On May 20, 2004, at 10:34 AM, Jason Merrill wrote:

> On Wed, 19 May 2004 16:54:11 -0700, Matt Austern <austern@apple.com> 
> wrote:
>
>> *************** do_type_instantiation (tree t, tree stor
>> *** 10789,10795 ****
>>           get unresolved symbols at link time. */
>>
>>        explicitly_instantiate_members =
>> !       TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
>>          && previous_instantiation_extern_p && ! extern_p
>>          && ! TYPE_FOR_JAVA (t);
>>
>> --- 10789,10795 ----
>>           get unresolved symbols at link time. */
>>
>>        explicitly_instantiate_members =
>> !       !TARGET_WEAK_NOT_IN_ARCHIVE_TOC
>>          && previous_instantiation_extern_p && ! extern_p
>>          && ! TYPE_FOR_JAVA (t);
>
> Why are/were you checking the macro here?

It's the general rule: on Darwin, you should never make something weak 
unless you know that it will be emitted in every translation unit where 
it will be used.  If something is weak, but is only emitted in one 
translation unit, then in the presence of static archives you'll get 
unresolved symbols.

The case where this matters: you've got an explicit instantiation of an 
extern template.  Remember, extern templates are a GNU extension that 
syntactically looks like a template instantiation.  It tells the 
compiler: don't do this particular instantiation implicitly, even if 
you think you need to, because I promise I'll have an explicit 
instantiation somewhere else.

OK, so here' s a specific code example.  Suppose we have a header file 
x.h with the following declarations:
   template <typename T> struct X { void foo(); };
   template <typename T> void X<T>::foo() { };
   extern template struct X<int>;

Now we include that header file into two source files, a.cc and b.cc.  
In a.cc we use X<int>::foo(), but we don't have an explicit 
instantiation.  In b.cc we do have an explicit instantiation.  a.o will 
have an unresolved reference to _ZN1XIiE3fooEv, which is expected to be 
defined elsewhere.  b.o will have a definition.

The point is that we need to make sure that the definition of 
_ZN1XIiE3fooEv in b.o isn't weak.  So we do two things.  First, we do 
explicit instantiations, not implicit, for member functions of 
explicitly instantiated class templates.  (Arguably that's what the 
standard calls for anyway; as you may have noticed from the reflector 
thread, John Spicer thinks so.)  Second, we make explicit 
instantiations ordinary symbols, not weak.  This is acceptable, because 
you only need weak symbols when you might have more than one 
definition, and the standard says that you may not have more than one 
explicit instantiation in a program.  It mean that gcc on Darwin 
violates the Itanium C++ ABI specification, but that's OK too.  There 
are lot of platforms where we have to make ABI compromises.

I actually mentioned this in the comment just above the code fragment 
that you quoted.  I'm not quite sure how I could modify the comment to 
be clearer without getting too verbose.  Any suggestions?

			--Matt

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

* Re: [Darwin] Patch c++/15428
  2004-05-20 20:28   ` Matt Austern
@ 2004-05-20 21:02     ` Jason Merrill
  2004-05-20 22:08       ` Matt Austern
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Merrill @ 2004-05-20 21:02 UTC (permalink / raw)
  To: Matt Austern; +Cc: gcc-patches

On Thu, 20 May 2004 11:38:11 -0700, Matt Austern <austern@apple.com> wrote:

>>>        explicitly_instantiate_members =
>>> !       !TARGET_WEAK_NOT_IN_ARCHIVE_TOC
>>>          && previous_instantiation_extern_p && ! extern_p
>>>          && ! TYPE_FOR_JAVA (t);

> OK, so here' s a specific code example.  Suppose we have a header file x.h
> with the following declarations:
>    template <typename T> struct X { void foo(); };
>    template <typename T> void X<T>::foo() { };
>    extern template struct X<int>;
>
> Now we include that header file into two source files, a.cc and b.cc.  In
> a.cc we use X<int>::foo(), but we don't have an explicit instantiation.
> In b.cc we do have an explicit instantiation.  a.o will have an
> unresolved reference to _ZN1XIiE3fooEv, which is expected to be defined
> elsewhere.  b.o will have a definition.  The point is that we need to
> make sure that the definition of _ZN1XIiE3fooEv in b.o isn't weak.  So we
> do two things.  First, we do explicit instantiations, not implicit, for
> member functions of explicitly instantiated class templates.

My issue is twofold:

1) It seems to me that the above code would accomplish this for your
   testcase without checking TARGET_WEAK_IN_ARCHIVE_TOC; since the previous
   instantiation was "extern", this one will be explicit.

2) It looks like the test of TARGET_WEAK_IN_ARCHIVE_TOC is backwards, and
   will force the member instantiations to always be *implicit* on Darwin.

Jason

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

* Re: [Darwin] Patch c++/15428
  2004-05-20 21:02     ` Jason Merrill
@ 2004-05-20 22:08       ` Matt Austern
  2004-05-20 22:16         ` Jason Merrill
  0 siblings, 1 reply; 17+ messages in thread
From: Matt Austern @ 2004-05-20 22:08 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

On May 20, 2004, at 11:57 AM, Jason Merrill wrote:

> On Thu, 20 May 2004 11:38:11 -0700, Matt Austern <austern@apple.com> 
> wrote:
>
>>>>        explicitly_instantiate_members =
>>>> !       !TARGET_WEAK_NOT_IN_ARCHIVE_TOC
>>>>          && previous_instantiation_extern_p && ! extern_p
>>>>          && ! TYPE_FOR_JAVA (t);
>
>> OK, so here' s a specific code example.  Suppose we have a header 
>> file x.h
>> with the following declarations:
>>    template <typename T> struct X { void foo(); };
>>    template <typename T> void X<T>::foo() { };
>>    extern template struct X<int>;
>>
>> Now we include that header file into two source files, a.cc and b.cc. 
>>  In
>> a.cc we use X<int>::foo(), but we don't have an explicit 
>> instantiation.
>> In b.cc we do have an explicit instantiation.  a.o will have an
>> unresolved reference to _ZN1XIiE3fooEv, which is expected to be 
>> defined
>> elsewhere.  b.o will have a definition.  The point is that we need to
>> make sure that the definition of _ZN1XIiE3fooEv in b.o isn't weak.  
>> So we
>> do two things.  First, we do explicit instantiations, not implicit, 
>> for
>> member functions of explicitly instantiated class templates.
>
> My issue is twofold:
>
> 1) It seems to me that the above code would accomplish this for your
>    testcase without checking TARGET_WEAK_IN_ARCHIVE_TOC; since the 
> previous
>    instantiation was "extern", this one will be explicit.

I believe the check for the macro is necessary.  We know that the 
instantiation of this class template is explicit, but we still have to 
decide whether that means that the members should be instantiated 
explicitly or implicitly.  On most targets we deliberately decided to 
do the latter.  On Darwin we need to do the former.  The only way we 
could give up checking for this macro is if we decided that explicit 
instantiation of a class template should imply explicit instantiation 
of its member on all targets.  I didn't want to slip in a change to a 
deliberate decision in the guise of fixing one target.

>
> 2) It looks like the test of TARGET_WEAK_IN_ARCHIVE_TOC is backwards, 
> and
>    will force the member instantiations to always be *implicit* on 
> Darwin.

You're right.  This looks like a goof from when I changed the sense of 
the macro.  Thanks for catching it! I'll submit a new patch with the 
fix.

			--Matt

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

* Re: [Darwin] Patch c++/15428
  2004-05-20 22:08       ` Matt Austern
@ 2004-05-20 22:16         ` Jason Merrill
  2004-05-22  8:54           ` Matt Austern
  2004-05-24 12:57           ` [Darwin] Patch c++/15428 Matt Austern
  0 siblings, 2 replies; 17+ messages in thread
From: Jason Merrill @ 2004-05-20 22:16 UTC (permalink / raw)
  To: Matt Austern; +Cc: gcc-patches

On Thu, 20 May 2004 14:00:32 -0700, Matt Austern <austern@apple.com> wrote:

> On May 20, 2004, at 11:57 AM, Jason Merrill wrote:
>
>> On Thu, 20 May 2004 11:38:11 -0700, Matt Austern <austern@apple.com>
>> wrote:
>>
>>>>>        explicitly_instantiate_members =
>>>>> !       !TARGET_WEAK_NOT_IN_ARCHIVE_TOC
>>>>>          && previous_instantiation_extern_p && ! extern_p
>>>>>          && ! TYPE_FOR_JAVA (t);
>>
>>> OK, so here' s a specific code example.  Suppose we have a header file
>>> x.h
>>> with the following declarations:
>>>    template <typename T> struct X { void foo(); };
>>>    template <typename T> void X<T>::foo() { };
>>>    extern template struct X<int>;
>>>
>>> Now we include that header file into two source files, a.cc and b.cc.  In
>>> a.cc we use X<int>::foo(), but we don't have an explicit instantiation.
>>> In b.cc we do have an explicit instantiation.  a.o will have an
>>> unresolved reference to _ZN1XIiE3fooEv, which is expected to be defined
>>> elsewhere.  b.o will have a definition.  The point is that we need to
>>> make sure that the definition of _ZN1XIiE3fooEv in b.o isn't weak.  So we
>>> do two things.  First, we do explicit instantiations, not implicit, for
>>> member functions of explicitly instantiated class templates.
>>
>> My issue is twofold:
>>
>> 1) It seems to me that the above code would accomplish this for your
>> testcase without checking TARGET_WEAK_IN_ARCHIVE_TOC; since the previous
>> instantiation was "extern", this one will be explicit.
>
> I believe the check for the macro is necessary.  We know that the
> instantiation of this class template is explicit, but we still have to
> decide whether that means that the members should be instantiated
> explicitly or implicitly.

Yes.

> On most targets we deliberately decided to do the latter.

Yes.

> On Darwin we need to do the former.

I still don't see why.  You explained above why this is necessary if
there's a previous extern instantiation, but in that case we already do
explicit instantiations on all targets.

Jason

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

* Re: [Darwin] Patch c++/15428
  2004-05-20 22:16         ` Jason Merrill
@ 2004-05-22  8:54           ` Matt Austern
  2004-05-22 12:25             ` Jason Merrill
  2004-06-03 22:10             ` [Darwin] Patch c++/15428 (revised) Matt Austern
  2004-05-24 12:57           ` [Darwin] Patch c++/15428 Matt Austern
  1 sibling, 2 replies; 17+ messages in thread
From: Matt Austern @ 2004-05-22  8:54 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

On May 20, 2004, at 2:04 PM, Jason Merrill wrote:

> I still don't see why.  You explained above why this is necessary if
> there's a previous extern instantiation, but in that case we already do
> explicit instantiations on all targets.

If so, then I missed something!  (Always possible.)  When I did my 
original linkonce work for Darwin, I didn't find any logic that treated 
this case specially.  Here's what we had in 3.4, for example:

  /*       The explicit instantiation of a class template specialization
	 implies the instantiation of all of its members not
	 previously explicitly specialized in the translation unit
	 containing the explicit instantiation.

        Of course, we can't instantiate member template classes, since
        we don't have any arguments for them.  Note that the standard
        is unclear on whether the instantiation of the members are
        *explicit* instantiations or not.  We choose to be generous,
        and not set DECL_EXPLICIT_INSTANTIATION.  Therefore, we allow
        the explicit instantiation of a class where some of the members
        have no definition in the current translation unit.  */

     if (! static_p)
       for (tmp = TYPE_METHODS (t); tmp; tmp = TREE_CHAIN (tmp))
	if (TREE_CODE (tmp) == FUNCTION_DECL
	    && DECL_TEMPLATE_INSTANTIATION (tmp))
	  {
	    mark_decl_instantiated (tmp, extern_p);
	    repo_template_instantiated (tmp, extern_p);
	    if (! extern_p)
	      instantiate_decl (tmp, /*defer_ok=*/1);

In mainline, in do_type_instantiation, we have the 
explicitly_instantiate_members test.  But that's something that I added 
for Darwin, and what we're discussing now is whether I got it right.  I 
think what I'm hearing you say is that some other part of the compiler 
does the same test, so all that logic in  do_type_instantiation never 
had to go in in the first place, and it can be removed, not fixed.  Can 
you point me to that other place that does the same test?

			--Matt

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

* Re: [Darwin] Patch c++/15428
  2004-05-22  8:54           ` Matt Austern
@ 2004-05-22 12:25             ` Jason Merrill
  2004-05-22 13:14               ` Matt Austern
  2004-06-03 22:10             ` [Darwin] Patch c++/15428 (revised) Matt Austern
  1 sibling, 1 reply; 17+ messages in thread
From: Jason Merrill @ 2004-05-22 12:25 UTC (permalink / raw)
  To: Matt Austern; +Cc: gcc-patches

On Fri, 21 May 2004 18:19:22 -0700, Matt Austern <austern@apple.com> wrote:

> On May 20, 2004, at 2:04 PM, Jason Merrill wrote:
>
>> I still don't see why.  You explained above why this is necessary if
>> there's a previous extern instantiation, but in that case we already do
>> explicit instantiations on all targets.
>
> If so, then I missed something!  (Always possible.)  When I did my original
> linkonce work for Darwin, I didn't find any logic that treated this case
> specially.

Ah, I see, I was thinking that the explicitly_instantiate_members variable
was preexisting, and you had only added a reference to the macro.  It all
makes sense to me now.

Jason

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

* Re: [Darwin] Patch c++/15428
  2004-05-22 12:25             ` Jason Merrill
@ 2004-05-22 13:14               ` Matt Austern
  0 siblings, 0 replies; 17+ messages in thread
From: Matt Austern @ 2004-05-22 13:14 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

On May 21, 2004, at 7:30 PM, Jason Merrill wrote:

> On Fri, 21 May 2004 18:19:22 -0700, Matt Austern <austern@apple.com> 
> wrote:
>
>> On May 20, 2004, at 2:04 PM, Jason Merrill wrote:
>>
>>> I still don't see why.  You explained above why this is necessary if
>>> there's a previous extern instantiation, but in that case we already 
>>> do
>>> explicit instantiations on all targets.
>>
>> If so, then I missed something!  (Always possible.)  When I did my 
>> original
>> linkonce work for Darwin, I didn't find any logic that treated this 
>> case
>> specially.
>
> Ah, I see, I was thinking that the explicitly_instantiate_members 
> variable
> was preexisting, and you had only added a reference to the macro.  It 
> all
> makes sense to me now.

Of course, the other part of this is that we might be changing this 
part of the code anyway.  John Spicer thinks it's obvious from 14.7.2 
that explicit instantiation of a class template always means that its 
members get explicitly instantiated too, and he found it surprising 
that anyone might imagine it would be an implicit instantiation.  That 
isn't what we currently do.  Depending on what the committee decides, 
we might eventually want to change this.

			--Matt

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

* Re: [Darwin] Patch c++/15428
  2004-05-20 22:16         ` Jason Merrill
  2004-05-22  8:54           ` Matt Austern
@ 2004-05-24 12:57           ` Matt Austern
  2004-05-24 21:57             ` Jason Merrill
  1 sibling, 1 reply; 17+ messages in thread
From: Matt Austern @ 2004-05-24 12:57 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

On May 20, 2004, at 2:04 PM, Jason Merrill wrote:

> I still don't see why.  You explained above why this is necessary if
> there's a previous extern instantiation, but in that case we already do
> explicit instantiations on all targets.

I poked into this a bit more.  Oddly enough, what you said was right
under my original interpretation, for a reason neither of us noticed.
That is: the whole explicitly_instantiate_members stuff in
do_type_instantiation is unnecessary.  If you set it unconditionally
to 0, then, on all targets, what you'll get is still that an explicit
instantiation of a class template that has previously been marked
extern will result in all of its members getting explicitly
instantiated.  (But explicit instantiation of a class template that
hasn't been marked extern will result in implicit instantiation of
its members)

*However*: I think it's still probably a good idea to keep the
explicitly_instantiate_members stuff.  Without it, we're relying
on something that's a bit subtle and that I'm not convinced is
intentional.  It's there for another reason, and I think it gives
this behavior just by accident.  I don't want to count on it.

What's going on: the comments in do_type_instantiation say that
we're doing an implicit instantiation of the members.  So the
first thing we do is call mark_decl_instantiated(tmp, extern_p)
for each member.  Now take a look at mark_decl_instantiated.
If extern_p is true, it calls SET_DECL_EXPLICIT_INSTANTIATION.
(The comments say that it's there to prevent implicit
instantiation of an extern template.)  The explicit bit gets
set when we mark the template as extern.  The next time
through, when we do the real explicit instantiation, nobody has
cleared the extern bit, so we get explicit instantiations of
all the members.

Like I said, I think this is probably an accident.  I think the
extern bit was set just to prevent implicit instantiations, and
nobody thought about what it implied for the case of an extern
template that's later instantiated explicitly.

I'm inclined to keep the explicitly_instantiate_members code,
because it makes it clear what's going on.  But I could be
persuaded to get rid of it, and just put in a comment documenting
what's going on and asserting that it's intentional.

Thoughts?

			--Matt

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

* Re: [Darwin] Patch c++/15428
  2004-05-24 12:57           ` [Darwin] Patch c++/15428 Matt Austern
@ 2004-05-24 21:57             ` Jason Merrill
  2004-05-24 22:12               ` Matt Austern
  0 siblings, 1 reply; 17+ messages in thread
From: Jason Merrill @ 2004-05-24 21:57 UTC (permalink / raw)
  To: Matt Austern; +Cc: gcc-patches

The whole business about not setting the explicit bit is a kludge to allow
explicit instantiations of a class when not all of the members have been
defined.  It would probably be better to handle that directly in
do_type_instantiation, and just always set the explicit bit.

Jason

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

* Re: [Darwin] Patch c++/15428
  2004-05-24 21:57             ` Jason Merrill
@ 2004-05-24 22:12               ` Matt Austern
  2004-05-25  2:29                 ` Matt Austern
  0 siblings, 1 reply; 17+ messages in thread
From: Matt Austern @ 2004-05-24 22:12 UTC (permalink / raw)
  To: Jason Merrill; +Cc: gcc-patches

On May 24, 2004, at 12:03 PM, Jason Merrill wrote:

> The whole business about not setting the explicit bit is a kludge to 
> allow
> explicit instantiations of a class when not all of the members have 
> been
> defined.  It would probably be better to handle that directly in
> do_type_instantiation, and just always set the explicit bit.

I agree that that would  be cleaner.  It would also be consistent with
the direction that I think the standards committee is moving in.

I'll make sure that doesn't break the build (i.e. that nothing in 
libstdc++
or libjava depends on the old behavior), and, if it looks OK, I'll 
submit a
patch to make that change.

			--Matt

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

* Re: [Darwin] Patch c++/15428
  2004-05-24 22:12               ` Matt Austern
@ 2004-05-25  2:29                 ` Matt Austern
  2004-05-25 21:43                   ` Jason Merrill
  0 siblings, 1 reply; 17+ messages in thread
From: Matt Austern @ 2004-05-25  2:29 UTC (permalink / raw)
  To: Matt Austern; +Cc: gcc-patches, Jason Merrill

On May 24, 2004, at 12:09 PM, Matt Austern wrote:

> On May 24, 2004, at 12:03 PM, Jason Merrill wrote:
>
>> The whole business about not setting the explicit bit is a kludge to  
>> allow
>> explicit instantiations of a class when not all of the members have  
>> been
>> defined.  It would probably be better to handle that directly in
>> do_type_instantiation, and just always set the explicit bit.
>
> I agree that that would  be cleaner.  It would also be consistent with
> the direction that I think the standards committee is moving in.
>
> I'll make sure that doesn't break the build (i.e. that nothing in  
> libstdc++
> or libjava depends on the old behavior), and, if it looks OK, I'll  
> submit a
> patch to make that change.

However, it turns out that this is *not* OK.  This change breaks  
libstdc++.

			--Matt


/work/obj.expl/gcc/xgcc -shared-libgcc -B/work/obj.expl/gcc/  
-nostdinc++ -L/work/obj.expl/powerpc-apple-darwin7.3.0/libstdc++-v3/src  
-L/work/obj.expl/powerpc-apple-darwin7.3.0/libstdc++-v3/src/.libs  
-B/work/root.expl/powerpc-apple-darwin7.3.0/bin/  
-B/work/root.expl/powerpc-apple-darwin7.3.0/lib/ -isystem  
/work/root.expl/powerpc-apple-darwin7.3.0/include -isystem  
/work/root.expl/powerpc-apple-darwin7.3.0/sys-include  
-I/work/obj.expl/powerpc-apple-darwin7.3.0/libstdc++-v3/include/ 
powerpc-apple-darwin7.3.0  
-I/work/obj.expl/powerpc-apple-darwin7.3.0/libstdc++-v3/include  
-I/work/fsf-mainline.expl/libstdc++-v3/libsupc++ -O2 -g -O2 -g -O2  
-fno-implicit-templates -Wall -Wextra -Wwrite-strings -Wcast-qual  
-fdiagnostics-show-location=once -c  
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc   
-fno-common -DPIC -o .libs/locale-inst.o
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = false]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = false]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT, _Intl>&  
std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>& std::__moneypunct_cache<_CharT,  
_Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with  
_CharT = char, bool _Intl = true]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:48:  
error: explicit instantiation of `std::__moneypunct_cache<_CharT,  
_Intl>::__moneypunct_cache(conststd::__moneypunct_cache<_CharT,  
_Intl>&) [with _CharT = char, bool _Intl = true]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of `std::__numpunct_cache<_CharT>&  
std::__numpunct_cache<_CharT>::operator=(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:79:  
error: explicit instantiation of  
`std::__numpunct_cache<_CharT>::__numpunct_cache(conststd:: 
__numpunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `void  
std::__timepunct_cache<_CharT>::_M_cache(conststd::locale&) [with  
_CharT = char]' but no definition available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of `std::__timepunct_cache<_CharT>&  
std::__timepunct_cache<_CharT>::operator=(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In  
instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:    
instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:167:  
error: explicit instantiation of  
`std::__timepunct_cache<_CharT>::__timepunct_cache(conststd:: 
__timepunct_cache<_CharT>&) [with _CharT = char]' but no definition  
available
make[4]: *** [locale-inst.lo] Error 1
make[3]: *** [all-recursive] Error 1
make[2]: *** [all] Error 2
make[1]: *** [all-target-libstdc++-v3] Error 2
make: *** [bootstrap] Error 2
[isolde:obj.expl]$

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

* Re: [Darwin] Patch c++/15428
  2004-05-25  2:29                 ` Matt Austern
@ 2004-05-25 21:43                   ` Jason Merrill
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Merrill @ 2004-05-25 21:43 UTC (permalink / raw)
  To: Matt Austern; +Cc: gcc-patches

On Mon, 24 May 2004 14:10:30 -0700, Matt Austern <austern@apple.com> wrote:

> On May 24, 2004, at 12:09 PM, Matt Austern wrote:
>
>> On May 24, 2004, at 12:03 PM, Jason Merrill wrote:
>>
>>> The whole business about not setting the explicit bit is a kludge to
>>> allow explicit instantiations of a class when not all of the members
>>> have been defined.  It would probably be better to handle that directly
>>> in do_type_instantiation, and just always set the explicit bit.
>>
>> I agree that that would  be cleaner.  It would also be consistent with
>> the direction that I think the standards committee is moving in.
>>
>> I'll make sure that doesn't break the build (i.e. that nothing in
>> libstdc++ or libjava depends on the old behavior), and, if it looks OK,
>> I'll submit a patch to make that change.
>
> However, it turns out that this is *not* OK.  This change breaks  libstdc++.

Which change, exactly?  I was proposing that do_type_instantiation not try
to explicitly instantiate a member with no definition available.

Jason

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

* [Darwin] Patch c++/15428 (revised)
  2004-05-22  8:54           ` Matt Austern
  2004-05-22 12:25             ` Jason Merrill
@ 2004-06-03 22:10             ` Matt Austern
  2004-06-03 22:43               ` Jason Merrill
  1 sibling, 1 reply; 17+ messages in thread
From: Matt Austern @ 2004-06-03 22:10 UTC (permalink / raw)
  To: gcc-patches

This patch fixes http://gcc.gnu.org/bugzilla/show_bug.cgi?id=15428 by 
changing the compiler so that, on Darwin, vtables are not always 
emitted as weak.  This is Darwin-only because it is a violation of the 
Itanium C++ ABI.  It is necessary on Darwin because of a linker quirk.  
(The documentation part of the patch explains the necessity.)

What has changed since the previous version of this patch: this version 
is slightly simpler.  The earlier version touched the logic that 
determined whether members of an explicitly instantiated class template 
should be instantiated implicitly or explicitly.  That's now 
unnecessary, because that logic no longer exists.

OK to commit to mainline?

				--Matt


? gcc/.gdb_history
Index: gcc/defaults.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/defaults.h,v
retrieving revision 1.139
diff -p -r1.139 defaults.h
*** gcc/defaults.h	30 May 2004 18:32:24 -0000	1.139
--- gcc/defaults.h	3 Jun 2004 21:40:58 -0000
*************** do { fputs (integer_asm_op (POINTER_SIZE
*** 238,248 ****
   #endif
   #endif

! /* Determines whether explicit template instantiations should
!    be given link-once semantics. The C++ ABI requires this
!    macro to be nonzero; see the documentation.  */
! #ifndef TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
! # define TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY 1
   #endif

   /* This determines whether or not we need linkonce unwind information 
*/
--- 238,250 ----
   #endif
   #endif

! /* This determines whether weak symbols must be left out of a static
!    archive's table of contents.  Defining this macro to be nonzero has
!    the consequence that certain symbols will not be made weak that
!    otherwise would be.  The C++ ABI requires this macro to be zero;
!    see the documentation. */
! #ifndef TARGET_WEAK_NOT_IN_ARCHIVE_TOC
! #define TARGET_WEAK_NOT_IN_ARCHIVE_TOC 0
   #endif

   /* This determines whether or not we need linkonce unwind information 
*/
Index: gcc/config/darwin.h
===================================================================
RCS file: /cvs/gcc/gcc/gcc/config/darwin.h,v
retrieving revision 1.80
diff -p -r1.80 darwin.h
*** gcc/config/darwin.h	19 May 2004 02:11:42 -0000	1.80
--- gcc/config/darwin.h	3 Jun 2004 21:40:58 -0000
*************** do { text_section ();							\
*** 358,368 ****
   #undef USE_COMMON_FOR_ONE_ONLY
   #define USE_COMMON_FOR_ONE_ONLY 0

! /* The Darwin linker doesn't like explicit template instantiations to 
be
!    coalesced, because it doesn't want coalesced symbols to appear in
      a static archive's table of contents. */
! #undef TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
! #define TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY 0

   /* We make exception information linkonce. */
   #undef TARGET_USES_WEAK_UNWIND_INFO
--- 358,367 ----
   #undef USE_COMMON_FOR_ONE_ONLY
   #define USE_COMMON_FOR_ONE_ONLY 0

! /* The Darwin linker doesn't want coalesced symbols to appear in
      a static archive's table of contents. */
! #undef TARGET_WEAK_NOT_IN_ARCHIVE_TOC
! #define TARGET_WEAK_NOT_IN_ARCHIVE_TOC 1

   /* We make exception information linkonce. */
   #undef TARGET_USES_WEAK_UNWIND_INFO
Index: gcc/cp/decl2.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl2.c,v
retrieving revision 1.712
diff -p -r1.712 decl2.c
*** gcc/cp/decl2.c	2 Jun 2004 21:12:52 -0000	1.712
--- gcc/cp/decl2.c	3 Jun 2004 21:40:59 -0000
*************** maybe_make_one_only (tree decl)
*** 1441,1447 ****
        to for variables so that cp_finish_decl will update their 
linkage,
        because their DECL_INITIAL may not have been set properly yet.  
*/

!   if (TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
         || (! DECL_EXPLICIT_INSTANTIATION (decl)
   	  && ! DECL_TEMPLATE_SPECIALIZATION (decl)))
       {
--- 1441,1447 ----
        to for variables so that cp_finish_decl will update their 
linkage,
        because their DECL_INITIAL may not have been set properly yet.  
*/

!   if (!TARGET_WEAK_NOT_IN_ARCHIVE_TOC
         || (! DECL_EXPLICIT_INSTANTIATION (decl)
   	  && ! DECL_TEMPLATE_SPECIALIZATION (decl)))
       {
*************** maybe_emit_vtables (tree ctype)
*** 1582,1587 ****
--- 1582,1588 ----
     tree vtbl;
     tree primary_vtbl;
     bool needed = false;
+   bool weaken_vtables;

     /* If the vtables for this class have already been emitted there is
        nothing more to do.  */
*************** maybe_emit_vtables (tree ctype)
*** 1612,1617 ****
--- 1613,1641 ----
     else if (TREE_PUBLIC (vtbl) && !DECL_COMDAT (vtbl))
       needed = true;

+   /* Determine whether to make vtables weak.  The ABI requires that we
+       do so.  There are two cases in which we have to violate the ABI
+       specification: targets where we don't have weak symbols
+       (obviously), and targets where weak symbols don't appear in
+       static archives' tables of contents.  On such targets, avoiding
+       undefined symbol link errors requires that we only make a symbol
+       weak if we know that it will be emitted everywhere it's needed.
+       So on such targets we don't make vtables weak in the common case
+       where we're emitting a vtable of a nontemplate class in the
+       translation unit containing the definition of a noninline key
+       method. */
+   if (flag_weak && !TARGET_WEAK_NOT_IN_ARCHIVE_TOC)
+     weaken_vtables = true;
+   else if (flag_weak)
+     {
+       if (CLASSTYPE_USE_TEMPLATE (ctype))
+  	weaken_vtables = CLASSTYPE_IMPLICIT_INSTANTIATION (ctype);
+       else
+  	weaken_vtables = !CLASSTYPE_KEY_METHOD (ctype)
+  	  || DECL_DECLARED_INLINE_P (CLASSTYPE_KEY_METHOD (ctype));
+     }
+   else
+     weaken_vtables = false;

     /* The ABI requires that we emit all of the vtables if we emit any
        of them.  */
*************** maybe_emit_vtables (tree ctype)
*** 1658,1665 ****
   	  DECL_IGNORED_P (vtbl) = 1;
   	}

!       /* Always make vtables weak.  */
!       if (flag_weak)
   	comdat_linkage (vtbl);

         rest_of_decl_compilation (vtbl, NULL, 1, 1);
--- 1682,1689 ----
   	  DECL_IGNORED_P (vtbl) = 1;
   	}

!       /* Always make vtables weak.  Or at least almost always; see 
above. */
!       if (weaken_vtables)
   	comdat_linkage (vtbl);

         rest_of_decl_compilation (vtbl, NULL, 1, 1);
Index: gcc/doc/tm.texi
===================================================================
RCS file: /cvs/gcc/gcc/gcc/doc/tm.texi,v
retrieving revision 1.326
diff -p -r1.326 tm.texi
*** gcc/doc/tm.texi	21 May 2004 01:03:20 -0000	1.326
--- gcc/doc/tm.texi	3 Jun 2004 21:41:03 -0000
*************** commands that will make the symbol(s) as
*** 6753,6765 ****
   hidden, protected or internal visibility as specified by 
@var{visibility}.
   @end deftypefn

! @defmac TARGET_EXPLICIT_INSTANTIATIONS_ONE_ONLY
   A C expression that evaluates to true if the target's linker expects
! explicit template specializations, as well as implicit, to be given
! linkonce semantics.  The default is @code{1}.  The C++ ABI requires
! this macro to be nonzero.  Define this macro for targets where full
! C++ ABI compliance is impossible and where explicit and implicit
! template specialization must be treated differently.
   @end defmac

   @defmac TARGET_SUPPORTS_HIDDEN
--- 6753,6775 ----
   hidden, protected or internal visibility as specified by 
@var{visibility}.
   @end deftypefn

! @defmac TARGET_WEAK_NOT_IN_ARCHIVE_TOC
   A C expression that evaluates to true if the target's linker expects
! that weak symbols do not appear in a static archive's table of 
contents.
! The default is @code{0}.
!
! Leaving weak symbols out of an archive's table of contents means that,
! if a symbol will only have a definition in one translation unit and
! will have undefined references from other translation units, that
! symbol should not be weak.  Defining this macro to be nonzero will
! thus have the effect that certain symbols that would normally be weak
! (explicit template instantiations, and vtables for polymorphic classes
! with noninline key methods) will instead be nonweak.
!
! The C++ ABI requires this macro to be zero.  Define this macro for
! targets where full C++ ABI compliance is impossible and where linker
! restrictions require weak symbols to be left out of a static archive's
! table of contents.
   @end defmac

   @defmac TARGET_SUPPORTS_HIDDEN

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

* Re: [Darwin] Patch c++/15428 (revised)
  2004-06-03 22:10             ` [Darwin] Patch c++/15428 (revised) Matt Austern
@ 2004-06-03 22:43               ` Jason Merrill
  0 siblings, 0 replies; 17+ messages in thread
From: Jason Merrill @ 2004-06-03 22:43 UTC (permalink / raw)
  To: Matt Austern; +Cc: gcc-patches

OK, but please include a ChangeLog entry with future patches.

Jason

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

* Re: [Darwin] Patch c++/15428
@ 2004-05-25  2:40 Benjamin Kosnik
  0 siblings, 0 replies; 17+ messages in thread
From: Benjamin Kosnik @ 2004-05-25  2:40 UTC (permalink / raw)
  To: gcc-patches; +Cc: austern, jason


../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc: In instantiation of `std::__moneypunct_cache<_CharT, _Intl>& std::__moneypunct_cache<_CharT, _Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with _CharT = char, bool _Intl = false]':
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47: instantiated from here
../../../../fsf-mainline.expl/libstdc++-v3/src/locale-inst.cc:47: error: explicit instantiation of `std::__moneypunct_cache<_CharT, _Intl>& std::__moneypunct_cache<_CharT, _Intl>::operator=(conststd::__moneypunct_cache<_CharT, _Intl>&) [with _CharT = char, bool _Intl = false]' but no definition available


Matt, I too think what you are trying to do makes a great deal of sense.
It doesn't make sense to have explicit instantiations of a class when
not all of the members have been defined.

So, it's weak that libstdc++ can't deal with this, especially since I
just added these declarations to work around -Weffc++. Grrr. 

You should just add in the default definitions for these copy
constructors and assignment operators. All the locale caches will have
these.

-benjamin

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

end of thread, other threads:[~2004-06-03 22:10 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-05-20  1:49 [Darwin] Patch c++/15428 Matt Austern
2004-05-20 18:13 ` Jason Merrill
2004-05-20 20:28   ` Matt Austern
2004-05-20 21:02     ` Jason Merrill
2004-05-20 22:08       ` Matt Austern
2004-05-20 22:16         ` Jason Merrill
2004-05-22  8:54           ` Matt Austern
2004-05-22 12:25             ` Jason Merrill
2004-05-22 13:14               ` Matt Austern
2004-06-03 22:10             ` [Darwin] Patch c++/15428 (revised) Matt Austern
2004-06-03 22:43               ` Jason Merrill
2004-05-24 12:57           ` [Darwin] Patch c++/15428 Matt Austern
2004-05-24 21:57             ` Jason Merrill
2004-05-24 22:12               ` Matt Austern
2004-05-25  2:29                 ` Matt Austern
2004-05-25 21:43                   ` Jason Merrill
2004-05-25  2:40 Benjamin Kosnik

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