This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [v3] patch for Missing explicit instantiations in libstdc++
On Fri, Dec 07, 2001 at 08:59:10AM -0800, Benjamin Kosnik wrote:
> > /usr/ccs/bin/ld: Unsatisfied symbols:
> > std::_Swap_lock_struct<0>::_S_swap_lock (data)
>
> Huh.
>
> see src/globalc.cc:
>
> #if __GTHREADS
> #ifdef __GTHREAD_MUTEX_INIT
> // Need to provide explicit instantiations of static data for
> // systems with broken weak linkage support.
> template __gthread_mutex_t _Swap_lock_struct<0>::_S_swap_lock;
> #elif defined(__GTHREAD_MUTEX_INIT_FUNCTION)
Er. Um.
When Loren and I cleaned out the thread code paths, we observed that the
__GTHREADS case was the only case that libstdc++-v3 needed to support;
gthr-*.h already does all the wrapping we need. So we removed all the
non-GTHREADS code and -- the point I'm slowly making -- removed the
"#define __GTHREADS" in c++config.
My theory is that this whole block of globals.cc got elided during
preprocessing. Easy enough to check; just 'nm' the library and see which
of the paths got taken: GTHREAD_MUTEX_INIT or GTHREAD_MUTEX_INIT_FUNCTION.
I'll bet you a cold cup of coffee that neither of them did.
Perhaps something like the following. (Untested.)
Index: src/globals.cc
===================================================================
RCS file: /home/pme/Repositories/GCC/gcc/libstdc++-v3/src/globals.cc,v
retrieving revision 1.5
diff -u -3 -p -r1.5 globals.cc
--- src/globals.cc 4 Dec 2001 20:13:40 -0000 1.5
+++ src/globals.cc 7 Dec 2001 18:27:45 -0000
@@ -91,7 +91,6 @@ namespace std
// Globals for once-only runtime initialization of mutex objects. This
// allows static initialization of these objects on systems that need a
// function call to initialize a mutex. For example, see stl_threads.h.
-#if __GTHREADS
#ifdef __GTHREAD_MUTEX_INIT
// Need to provide explicit instantiations of static data for
// systems with broken weak linkage support.
@@ -111,5 +110,4 @@ namespace std
_GLIBCPP_mutex_address_init ()
{ __GTHREAD_MUTEX_INIT_FUNCTION (_GLIBCPP_mutex_address); }
#endif
-#endif // __GTHREADS
}