[Bug boehm-gc/37017] Using --enable-threads=solaris breaks near end of build in boehm-gc configury

rob1weld at aol dot com gcc-bugzilla@gcc.gnu.org
Mon Aug 4 18:45:00 GMT 2008



------- Comment #3 from rob1weld at aol dot com  2008-08-04 18:44 -------
> I wrote:
> It would be nice if the main configure script caught this instead of the build
failing just as it was about to finish.

But then I would not have to try fixing this ...

The boehm-gc directory built correctly and the build continues until we get to
the libjava directory that fails with this error:

...
checking for remove... yes
checking for shmat... yes
checking for IceConnectionNumber in -lICE... yes
checking for garbage collector to use... boehm
checking for thread model used by GCC... solaris
configure: error: thread package solaris not yet supported
gmake[2]: *** [config.status] Error 1
gmake[2]: Leaving directory `/aux0/gcc-4.2.3_build/i386-pc-solaris2.11/libjava'
gmake[1]: *** [all-target-libjava] Error 2
gmake[1]: Leaving directory `/aux0/gcc-4.2.3_build'
gmake: *** [all] Error 2


The _matching_ portions of the "gcc-4.2.3/boehm-gc/configure" and the
"gcc-4.2.3/libjava/configure" can be fixed the same way.


The libjava configure has a few problems:

1. Libjava can be configured to use the Boehm Garbage Collection - so the
configuring should matchup the threading types and options more closely.

2. Another huge bug: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37019

3. Various parts in "libjava/configure" make assumtions that are not true
and are not the same as those made in "boehm-gc/configure":

EG: 

In the "case "$THREADS" in" section (line 5354 in "boehm-gc/configure" and line
9109 in libjava/configure) the boehm configury separates the various Operating
Systems in a more fine-grained manner than is done in the libjava configury.


The libjava configury checks for these thread types (with only ONE case
statement used for "*-*-linux*" and (much later) a few more OS types are
checked):

no | none | single)
posix | posix95 | pthreads)
    case "$host" in
     *-*-linux*)
cat >>confdefs.h <<\_ACEOF
#define LINUX_THREADS 1
_ACEOF
        ;;
    esac
win32)
decosf1 | irix | mach | os2 | solaris | dce | vxworks)
...
case "$THREADS" in
 posix)
    case "$host" in
     *-*-cygwin*)
        # Don't set THREADLIBS here.  Cygwin doesn't have -lpthread.
        ;;
     *-*-freebsd[1234]*)
        # Before FreeBSD 5, it didn't have -lpthread (or any library which
        # merely adds pthread_* functions) but it does have a -pthread switch
        # which is required at link-time to select -lc_r *instead* of -lc.
        THREADLDFLAGS=-pthread
        # Don't set THREADSPEC here as might be expected since -pthread is
        # not processed when found within a spec file, it must come from
        # the command line.  For now, the user must provide the -pthread
        # switch to link code compiled with gcj.  In future, consider adding
        # support for weak references to pthread_* functions ala gthr.h API.
        THREADSPEC='%{!pthread: %{!shared: %eUnder this configuration, the user
must provide -pthread when linking.}}'
        ;;
     *-*-freebsd*)
        # FreeBSD >=5.3 implements a model much closer to other modern UNIX
        # systems which support threads and -lpthread.
        THREADLDFLAGS=-pthread
        THREADSPEC=-lpthread
        ;;
     alpha*-dec-osf* | hppa*-hp-hpux*)
        THREADCXXFLAGS=-pthread
        # boehm-gc needs some functions from librt, so link that too.
        THREADLIBS='-lpthread -lrt'
        THREADSPEC='-lpthread -lrt'
        ;;
     *)
        THREADLIBS=-lpthread
        THREADSPEC=-lpthread
        ;;
    esac
    THREADH=posix-threads.h
    # MIT pthreads doesn't seem to have the mutexattr functions.
    # But for now we don't check for it.  We just assume you aren't
    # using MIT pthreads.
cat >>confdefs.h <<\_ACEOF
#define HAVE_PTHREAD_MUTEXATTR_INIT 1
_ACEOF
    # If we're using the Boehm GC, then we happen to know that it
    # defines _REENTRANT, so we don't bother.  Eww.
    if test "$GC" != boehm; then
cat >>confdefs.h <<\_ACEOF
#define _REENTRANT 1
_ACEOF
    fi
cat >>confdefs.h <<\_ACEOF
#define _POSIX_PTHREAD_SEMANTICS 1
_ACEOF
    ;;
 win32)
    THREADH=win32-threads.h
    THREADCXXFLAGS=-mthreads
    # We need thread-safe exception handling so _CRT_MT should be set to 1.
    # But we do not want the executables created to be dependent on
    # mingwm10.dll which provides a __mingwthr_key_dtor() that cleans up
    # exception handling contexts.  The following kludge achieves this effect
    # and causes a dummy __mingwthr_key_dtor() to be linked in from
    # libmingw32.a.  This causes a memory leak of about 24 bytes per thread.
    # A workaround is to explicitly use -mthreads while linking Java programs.
    # See PR libgcj/28263.
    #
    # FIXME: In Java we are able to detect thread death at the end of
    # Thread.run() so we should be able to clean up the exception handling
    # contexts ourselves.
    THREADSTARTFILESPEC='crtmt%O%s'
    ;;
 none)
    THREADH=no-threads.h
    ;;
esac
          ac_config_links="$ac_config_links
include/java-threads.h:include/$THREADH"



The boehm-gc configury checks for these thread types AND has additional cases
for various OS types to set additional features:

no | none | single)
posix | posix95 | pthreads)
    case "$host" in
     x86-*-linux* | ia64-*-linux* | i586-*-linux* | i686-*-linux* |
x86_64-*-linux* | alpha-*-linux*)
cat >>confdefs.h <<\_ACEOF
#define GC_LINUX_THREADS 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define _REENTRANT 1
_ACEOF
        if test "${enable_parallel_mark}" = yes; then
cat >>confdefs.h <<\_ACEOF
#define PARALLEL_MARK 1
_ACEOF
        fi
cat >>confdefs.h <<\_ACEOF
#define THREAD_LOCAL_ALLOC 1
_ACEOF
        ;;
     *-*-linux*)
        cat >>confdefs.h <<\_ACEOF
#define GC_LINUX_THREADS 1
_ACEOF
        cat >>confdefs.h <<\_ACEOF
#define _REENTRANT 1
_ACEOF
        ;;
     *-*-aix*)
cat >>confdefs.h <<\_ACEOF
#define GC_AIX_THREADS 1
_ACEOF
        cat >>confdefs.h <<\_ACEOF
#define _REENTRANT 1
_ACEOF
        ;;
     *-*-hpux11*)
        { echo "$as_me:$LINENO: WARNING: \"Only HP-UX 11 POSIX threads are
supported.\"" >&5
echo "$as_me: WARNING: \"Only HP-UX 11 POSIX threads are supported.\"" >&2;}
cat >>confdefs.h <<\_ACEOF
#define GC_HPUX_THREADS 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define _POSIX_C_SOURCE 199506L
_ACEOF
        if test "${enable_parallel_mark}" = yes; then
          cat >>confdefs.h <<\_ACEOF
#define PARALLEL_MARK 1
_ACEOF
        fi
        cat >>confdefs.h <<\_ACEOF
#define THREAD_LOCAL_ALLOC 1
_ACEOF
        THREADLIBS="-lpthread -lrt"
        # HPUX needs REENTRANT for the _r calls.
cat >>confdefs.h <<\_ACEOF
#define _REENTRANT 1
_ACEOF
        ;;
     *-*-hpux10*)
        { echo "$as_me:$LINENO: WARNING: \"Only HP-UX 11 POSIX threads are
supported.\"" >&5
echo "$as_me: WARNING: \"Only HP-UX 11 POSIX threads are supported.\"" >&2;}
        ;;
      *-*-kfreebsd*-gnu)
       cat >>confdefs.h <<\_ACEOF
#define GC_FREEBSD_THREADS 1
_ACEOF
       INCLUDES="$INCLUDES -pthread"
       THREADDLLIBS=-pthread
       cat >>confdefs.h <<\_ACEOF
#define _REENTRANT 1
_ACEOF
         if test "${enable_parallel_mark}" = yes; then
         cat >>confdefs.h <<\_ACEOF
#define PARALLEL_MARK 1
_ACEOF
       fi
       cat >>confdefs.h <<\_ACEOF
#define THREAD_LOCAL_ALLOC 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define USE_COMPILER_TLS 1
_ACEOF
               ;;
     *-*-freebsd*)
        { echo "$as_me:$LINENO: WARNING: \"FreeBSD does not yet fully support
threads with Boehm GC.\"" >&5
echo "$as_me: WARNING: \"FreeBSD does not yet fully support threads with Boehm
GC.\"" >&2;}
cat >>confdefs.h <<\_ACEOF
#define GC_FREEBSD_THREADS 1
_ACEOF
        AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
        THREADLIBS=-pthread
        ;;
     *-*-solaris*)
cat >>confdefs.h <<\_ACEOF
#define GC_SOLARIS_PTHREADS 1
_ACEOF
        # Need to use alternate thread library, otherwise gctest hangs
        # on Solaris 8.
        multi_os_directory=`$CC -print-multi-os-directory`
        THREADLIBS="-L/usr/lib/lwp/$multi_os_directory \
                    -R/usr/lib/lwp/$multi_os_directory -lpthread -lthread -lrt"
        if test "${enable_parallel_mark}" = yes; then
cat >>confdefs.h <<\_ACEOF
#define PARALLEL_MARK 1
_ACEOF
        fi
        ;;
     *-*-irix*)
cat >>confdefs.h <<\_ACEOF
#define GC_IRIX_THREADS 1
_ACEOF
        ;;
     *-*-cygwin*)
cat >>confdefs.h <<\_ACEOF
#define GC_WIN32_THREADS 1
_ACEOF
        ;;
     *-*-darwin*)
cat >>confdefs.h <<\_ACEOF
#define GC_DARWIN_THREADS 1
_ACEOF
        cat >>confdefs.h <<\_ACEOF
#define THREAD_LOCAL_ALLOC 1
_ACEOF
        if test "${enable_parallel_mark}" = yes; then
          cat >>confdefs.h <<\_ACEOF
#define PARALLEL_MARK 1
_ACEOF
        fi
        ;;
     *-*-osf*)
cat >>confdefs.h <<\_ACEOF
#define GC_OSF1_THREADS 1
_ACEOF
        if test "${enable_parallel_mark}" = yes; then
          cat >>confdefs.h <<\_ACEOF
#define PARALLEL_MARK 1
_ACEOF
          cat >>confdefs.h <<\_ACEOF
#define THREAD_LOCAL_ALLOC 1
_ACEOF
          # May want to enable it in other cases, too.
          # Measurements havent yet been done.
        fi
        AM_CPPFLAGS="$AM_CPPFLAGS -pthread"
        THREADLIBS="-lpthread -lrt"
        ;;
    esac
    ;;
 win32)
    cat >>confdefs.h <<\_ACEOF
#define GC_WIN32_THREADS 1
_ACEOF
            ;;
 dgux386)
    THREADS=dgux386
echo "$as_me:$LINENO: result: $THREADLIBS" >&5
echo "${ECHO_T}$THREADLIBS" >&6
    # Use pthread GCC  switch
    THREADLIBS=-pthread
    if test "${enable_parallel_mark}" = yes; then
        cat >>confdefs.h <<\_ACEOF
#define PARALLEL_MARK 1
_ACEOF
    fi
    cat >>confdefs.h <<\_ACEOF
#define THREAD_LOCAL_ALLOC 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define GC_DGUX386_THREADS 1
_ACEOF
cat >>confdefs.h <<\_ACEOF
#define DGUX_THREADS 1
_ACEOF
    # Enable _POSIX4A_DRAFT10_SOURCE with flag -pthread
    AM_CPPFLAGS="-pthread $AM_CPPFLAGS"
    ;;
 aix)
    THREADS=posix
    THREADLIBS=-lpthread
    cat >>confdefs.h <<\_ACEOF
#define GC_AIX_THREADS 1
_ACEOF
    cat >>confdefs.h <<\_ACEOF
#define _REENTRANT 1
_ACEOF
    ;;
 decosf1 | irix | mach | os2 | dce | vxworks)
...


I see that what threading types are checked for, which OSes they are used on,
and what features are implemented is not consistent between boehm-gc and
libjava even though libjava can use the boehm-gc library.

---

Further on in the libjava/configure file it says this:

      LIBS="$LIBS $THREADLIBS"
      # Some POSIX thread systems don't have pthread_mutexattr_settype.
      # E.g., Solaris.

But this page:
http://docs.sun.com/app/docs/doc/816-5137/sthreads-96692?l=en&a=view says that
it is called "pthread_mutex_attr_settype()" (and
"pthread_mutex_attr_gettype()").

---

Further on in the libjava/configure file it says this:

      # Look for sched_yield.  Up to Solaris 2.6, it is in libposix4, since
      # Solaris 7 the name librt is preferred.

so it seems to be trying to use threading in Solaris but only if posix threads
are chosen (but choosing "solaris" threads would give us "sched_yield" (and the
Solaris version "thr_yield" also)).



> Andrew Pinski  2008-08-03 23:08 wrote:
> I really don't think using solaris threads is that well supported anymore.

The "support" is there, it is just broken in a few spots and needs a once-over
by someone more familiar with Solaris than me (but I'll give it a go). 

There are inconsistencies between the various library's thread options that
would need to be addressed (even _IF_ you plan to remove the
"--enable-threads=solaris" option) to ensure that the Posix options are
consistent.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=37017



More information about the Gcc-bugs mailing list