This is the mail archive of the
java-patches@gcc.gnu.org
mailing list for the Java project.
Re: 4.1/4.2/4.3 PATCH: Switch boehm-gc to pthreads on Solaris (boehm-gc/21940, boehm-gc/21942)
Andreas Tobler writes:
> I tried this patch on solaris8 sparc and I saw an improvement in the
> libgcj test (32 and 64 bit). But I hang in the gctest. I might debug
> next week.
After manually working around the hang with the alternate thread library in
/usr/lib/lwp, I've now a clean patch which uses it. One can easily use gcc
-print-multi-os-directory to detect the /usr/lib/lwp subdir corresponding
to the current multilib.
Here's the revised patch, tested with
make configure-target-boehm-gc
make check
on Solaris 8 for both multilibs. I have to explicitly link with -lthread,
otherwise the default version in /usr/lib is used: libpthread is a filter
library, and its dependencies are only searched in LD_LIBRARY_PATH and the
RPATH/RUNPATH encoded in the affected library (libpthread, i.e. none).
This is confirmed on threads(3THR), which specifies
cc -mt ... -lpthread ... -R/usr/lib/lwp
where -mt expands to -lthread.
The other change is to use THREADLIBS instead of THREADDLLIBS in
gctest_LDADD so the proper flags are passed to the gctest link. This is
probably a merge error from upstream, where the variable is called
THREADDLLIBS in gc6.8.
I suppose this modified patch is still ok for 4.1/4.2/4.3?
Regards.
Rainer
-----------------------------------------------------------------------------
Rainer Orth, Faculty of Technology, Bielefeld University
Mon Jun 18 19:26:10 2007 Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
PR boehm-gc/21940
PR boehm-gc/21942
* configure.ac (GC_SOLARIS_THREADS): Don't define on *-*-solaris*.
Use alternate thread library in /usr/lib/lwp.
* configure: Regenerate.
* dyn_load.c: Use GC_SOLARIS_PTHREADS.
* include/gc_config_macros.h (GC_SOLARIS_THREADS): Don't define.
* include/private/gcconfig.h: Handle 64-bit Solaris 2/x86.
(GC_SOLARIS_THREADS): Don't define.
* include/private/solaris_threads.h: Remove.
* pthread_support.c (GC_thr_init) [GC_SOLARIS_PTHREADS]: Determine
GC_nprocs via sysconf().
* Makefile.am (libgcjgc_la_SOURCES): Remove solaris_pthreads.c and
solaris_threads.c.
(gctest_LDADD): Use THREADLIBS instead of THREADDLLIBS.
* Makefile.in: Regenerate.
* solaris_pthreads.c: Remove.
* solaris_threads.c: Remove.
Index: boehm-gc/configure.ac
===================================================================
--- boehm-gc/configure.ac (revision 125822)
+++ boehm-gc/configure.ac (working copy)
@@ -173,8 +173,12 @@ case "$THREADS" in
THREADLIBS=-pthread
;;
*-*-solaris*)
- AC_DEFINE(GC_SOLARIS_THREADS,1,[support for Solaris (thr_) threads])
AC_DEFINE(GC_SOLARIS_PTHREADS,1,[support for Solaris pthreads])
+ # 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"
;;
*-*-irix*)
AC_DEFINE(GC_IRIX_THREADS,1,[support for Irix pthreads])
Index: boehm-gc/include/gc_config_macros.h
===================================================================
--- boehm-gc/include/gc_config_macros.h (revision 125822)
+++ boehm-gc/include/gc_config_macros.h (working copy)
@@ -72,10 +72,6 @@
# define GC_WIN32_THREADS
#endif
-#if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
-# define GC_SOLARIS_THREADS
-#endif
-
# define __GC
# ifndef _WIN32_WCE
# include <stddef.h>
Index: boehm-gc/include/private/gcconfig.h
===================================================================
--- boehm-gc/include/private/gcconfig.h (revision 125822)
+++ boehm-gc/include/private/gcconfig.h (working copy)
@@ -153,6 +153,11 @@
# define SUNOS5
# define mach_type_known
# endif
+# if defined(sun) && defined(__amd64)
+# define X86_64
+# define SUNOS5
+# define mach_type_known
+# endif
# if (defined(__OS2__) || defined(__EMX__)) && defined(__32BIT__)
# define I386
# define OS2
@@ -2041,6 +2046,36 @@
extern char etext[];
# define SEARCH_FOR_DATA_START
# endif
+# ifdef SUNOS5
+# define ELF_CLASS ELFCLASS64
+# define OS_TYPE "SUNOS5"
+ extern int _etext[], _end[];
+ extern ptr_t GC_SysVGetDataStart();
+# define DATASTART GC_SysVGetDataStart(0x1000, _etext)
+# define DATAEND (_end)
+/* # define STACKBOTTOM ((ptr_t)(_start)) worked through 2.7, */
+/* but reportedly breaks under 2.8. It appears that the stack */
+/* base is a property of the executable, so this should not break */
+/* old executables. */
+/* HEURISTIC2 probably works, but this appears to be preferable. */
+/* # include <sys/vm.h> */
+/* # define STACKBOTTOM USRSTACK */
+# define HEURISTIC2
+# define PROC_VDB
+# define DYNAMIC_LOADING
+# if !defined(USE_MMAP) && defined(REDIRECT_MALLOC)
+# define USE_MMAP
+ /* Otherwise we now use calloc. Mmap may result in the */
+ /* heap interleaved with thread stacks, which can result in */
+ /* excessive blacklisting. Sbrk is unusable since it */
+ /* doesn't interact correctly with the system malloc. */
+# endif
+# ifdef USE_MMAP
+# define HEAP_START (ptr_t)0x40000000
+# else
+# define HEAP_START DATAEND
+# endif
+# endif
# endif
#if defined(LINUX) && defined(USE_MMAP)
@@ -2186,11 +2221,6 @@
((word*)x)[1] = 0;
# endif /* CLEAR_DOUBLE */
- /* Internally we use GC_SOLARIS_THREADS to test for either old or pthreads. */
-# if defined(GC_SOLARIS_PTHREADS) && !defined(GC_SOLARIS_THREADS)
-# define GC_SOLARIS_THREADS
-# endif
-
# if defined(GC_IRIX_THREADS) && !defined(IRIX5)
--> inconsistent configuration
# endif
Index: boehm-gc/pthread_support.c
===================================================================
--- boehm-gc/pthread_support.c (revision 125822)
+++ boehm-gc/pthread_support.c (working copy)
@@ -883,7 +883,8 @@ void GC_thr_init()
# if defined(GC_HPUX_THREADS)
GC_nprocs = pthread_num_processors_np();
# endif
-# if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS)
+# if defined(GC_OSF1_THREADS) || defined(GC_AIX_THREADS) \
+ || defined(GC_SOLARIS_PTHREADS)
GC_nprocs = sysconf(_SC_NPROCESSORS_ONLN);
if (GC_nprocs <= 0) GC_nprocs = 1;
# endif
Index: boehm-gc/Makefile.am
===================================================================
--- boehm-gc/Makefile.am (revision 125822)
+++ boehm-gc/Makefile.am (working copy)
@@ -21,7 +21,7 @@ libgcjgc_la_SOURCES = allchblk.c alloc.c
dyn_load.c finalize.c gc_dlopen.c gcj_mlc.c headers.c \
malloc.c mallocx.c mark.c mark_rts.c misc.c new_hblk.c \
obj_map.c os_dep.c pcr_interface.c ptr_chck.c real_malloc.c reclaim.c \
-solaris_pthreads.c solaris_threads.c specific.c stubborn.c typd_mlc.c \
+specific.c stubborn.c typd_mlc.c \
backgraph.c win32_threads.c \
pthread_support.c pthread_stop_world.c darwin_stop_world.c \
$(asm_libgcjgc_sources)
@@ -49,7 +49,7 @@ AM_CFLAGS = @GC_CFLAGS@
check_PROGRAMS = gctest
gctest_SOURCES = tests/test.c
-gctest_LDADD = ./libgcjgc.la $(THREADDLLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS)
+gctest_LDADD = ./libgcjgc.la $(THREADLIBS) $(UNWINDLIBS) $(EXTRA_TEST_LIBS)
gctest_LDFLAGS = -shared-libgcc
TESTS_ENVIRONMENT = LD_LIBRARY_PATH=../../$(MULTIBUILDTOP)gcc
TESTS = gctest
Index: boehm-gc/dyn_load.c
===================================================================
--- boehm-gc/dyn_load.c (revision 125822)
+++ boehm-gc/dyn_load.c (working copy)
@@ -225,7 +225,7 @@ static ptr_t GC_first_common()
# if defined(SUNOS4) || defined(SUNOS5DL)
/* Add dynamic library data sections to the root set. */
-# if !defined(PCR) && !defined(GC_SOLARIS_THREADS) && defined(THREADS)
+# if !defined(PCR) && !defined(GC_SOLARIS_PTHREADS) && defined(THREADS)
# ifndef SRC_M3
--> fix mutual exclusion with dlopen
# endif /* We assume M3 programs don't call dlopen for now */