From a267b06e1e2ef0cd7da0b8d418c348c51b4904e7 Mon Sep 17 00:00:00 2001
From: Maximilian Downey Twiss <creatorsmithmdt@gmail.com>
Date: Fri, 25 Nov 2022 17:05:30 +1100
Subject: [PATCH 56/56] java, libjava: Upgrade from in-tree boehm-gc to
 external boehm-gc 8.3.0.

gcc/java/ChangeLog:

	* boehm.cc (get_boehm_type_descriptor): Remove check for flag_use_boehm_gc.
	(uses_jv_markobj_p): Remove flag_use_boehm_gc assert.
	* jvspec.cc: Remove fuse-boehm-gc.
	* lang.opt: Likewise.

libjava/ChangeLog:

	* boehm.cc (GC_REDIRECT_TO_LOCAL): Include gc/gc.h instead of gc_local_alloc.h.
	(_Jv_SetGCFreeSpaceDivisor): Use GC_get_free_space_divisor to get old_div (before GC_set_free_space_divisor call).
	(_Jv_InitGC): Use GC_set variants of functions.
	(_Jv_GCInitializeFinalizers): Likewise.
	* configure.ac: Replace in-tree check with external checks from libobjc, check that found version is modern enough.
	* gnu/gcj/util/natGCInfo.cc (PACKAGE_NAME): Remove.
	(PACKAGE_STRING): Likewise.
	(PACKAGE_TARNAME): Likewise.
	(PACKAGE_VERSION): Likewise.
	(TRUE): Likewise.
	(FALSE): Likewise.
	(GC_print_debug_callback): Replace GC_n_set_marks with public functions.
	(struct print_hblkfl_s): Add.
	(UNIQUE_THRESHOLD): Remove.
	(HUGE_THRESHOLD): Likewise.
	(FL_COMPRESSION): Likewise.
	(N_HBLK_FLS): Likewise.
	(print_hblkfl_file_item): Add.
	(IS_MAPPED): Remove.
	(GC_print_hblkfreelist_file): Handle lack of HDR macro.
	(GC_print_debug_info_file): Use GC_word instead of word, handle lack of struct hblkhdr.
	(GC_enumerator::enumerate): Use GC_word instead of word.
	(GC_enumerator::enumerate_callback_adaptor): Use GC_word instead of word, handle lack of struct hblkhdr.
	(GC_enumerator::enumerate_callback): Handle lack of HDR macro.
	* include/boehm-gc.h: Include gc/gc.h instead of gc_ext_config.h, adjust comment accordingly.
	* libgcj.spec.in: Remove GCSPEC and JC1GCSPEC.
	* Makefile.in: Reconfigure.
	* configure: Likewise.
	* gcj/Makefile.in: Likewise.
	* include/Makefile.in: Likewise.
	* include/config.h.in: Likewise.
	* testsuite/Makefile.in: Likewise.

Co-authored-by: Ivan Maidanski <ivmai@mail.ru>
---
 gcc/java/boehm.cc                 |   6 -
 gcc/java/jvspec.cc                |   2 +-
 gcc/java/lang.opt                 |   4 -
 libjava/Makefile.in               |   4 -
 libjava/boehm.cc                  |  24 +--
 libjava/configure                 | 309 +++++++++++++++++++++++++-----
 libjava/configure.ac              | 202 +++++++++++++++----
 libjava/gcj/Makefile.in           |   4 -
 libjava/gnu/gcj/util/natGCInfo.cc | 171 +++++------------
 libjava/include/Makefile.in       |   4 -
 libjava/include/boehm-gc.h        |   5 +-
 libjava/include/config.h.in       |   3 +
 libjava/libgcj.spec.in            |   4 +-
 libjava/testsuite/Makefile.in     |   4 -
 14 files changed, 501 insertions(+), 245 deletions(-)

diff --git a/gcc/java/boehm.cc b/gcc/java/boehm.cc
index 38a2131e6f8..5859f038998 100644
--- a/gcc/java/boehm.cc
+++ b/gcc/java/boehm.cc
@@ -136,10 +136,6 @@ get_boehm_type_descriptor (tree type)
   int pointer_after_end = 0;
   tree field, value, value_type;
 
-  /* If the GC wasn't requested, just use a null pointer.  */
-  if (! flag_use_boehm_gc)
-    return null_pointer_node;
-
   value_type = java_type_for_mode (ptr_mode, 1);
   wide_int mask = wi::zero (TYPE_PRECISION (value_type));
 
@@ -223,8 +219,6 @@ bool
 uses_jv_markobj_p (tree dtable)
 {
   tree v;
-  /* FIXME: what do we return if !flag_use_boehm_gc ? */
-  gcc_assert (flag_use_boehm_gc);
   /* FIXME: this is wrong if TARGET_VTABLE_USES_DESCRIPTORS.  However,
      this function is only used with flag_reduced_reflection.  No
      point in asserting unless we hit the bad case.  */
diff --git a/gcc/java/jvspec.cc b/gcc/java/jvspec.cc
index 58142368621..3786926e8d9 100644
--- a/gcc/java/jvspec.cc
+++ b/gcc/java/jvspec.cc
@@ -66,7 +66,7 @@ static const char jvgenmain_spec[] =
 		   %<fassume-compiled* %<fno-assume-compiled*\
 		   %<fcompile-resource* %<fassert %<fno-assert \
 		   %<femit-class-file %<femit-class-files %<fencoding*\
-		   %<fuse-boehm-gc %<fhash-synchronization %<fjni\
+		   %<fhash-synchronization %<fjni\
 		   %<findirect-dispatch\
 		   %<fno-store-check %<foutput-class-dir\
 		   %<fclasspath* %<fbootclasspath*\
diff --git a/gcc/java/lang.opt b/gcc/java/lang.opt
index a6596d55a9c..594866da707 100644
--- a/gcc/java/lang.opt
+++ b/gcc/java/lang.opt
@@ -256,10 +256,6 @@ fstore-check
 Java Var(flag_store_check) Init(1)
 Enable assignability checks for stores into object arrays.
 
-fuse-boehm-gc
-Java Var(flag_use_boehm_gc)
-Generate code for the Boehm GC.
-
 fuse-divide-subroutine
 Java Var(flag_use_divide_subroutine) Init(1)
 Call a library routine to do integer divisions.
diff --git a/libjava/Makefile.in b/libjava/Makefile.in
index e1780d99c16..18ea3fd65da 100644
--- a/libjava/Makefile.in
+++ b/libjava/Makefile.in
@@ -679,7 +679,6 @@ EXCEPTIONSPEC = @EXCEPTIONSPEC@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GCC_FOR_ECJX = @GCC_FOR_ECJX@
-GCDEPS = @GCDEPS@
 GCINCS = @GCINCS@
 GCJ = @GCJ@
 GCJDEPMODE = @GCJDEPMODE@
@@ -689,8 +688,6 @@ GCJVERSION = @GCJVERSION@
 GCJ_BIN_DIR = @GCJ_BIN_DIR@
 GCJ_FOR_ECJX = @GCJ_FOR_ECJX@
 GCLIBS = @GCLIBS@
-GCSPEC = @GCSPEC@
-GCTESTSPEC = @GCTESTSPEC@
 GLIB_CFLAGS = @GLIB_CFLAGS@
 GLIB_LIBS = @GLIB_LIBS@
 GREP = @GREP@
@@ -708,7 +705,6 @@ INTERPRETER = @INTERPRETER@
 JAR = @JAR@
 JAVA_HOME = @JAVA_HOME@
 JAVA_VERSION = @JAVA_VERSION@
-JC1GCSPEC = @JC1GCSPEC@
 JRE_BIN_DIR = @JRE_BIN_DIR@
 JRE_DIR = @JRE_DIR@
 JRE_LIB_DIR = @JRE_LIB_DIR@
diff --git a/libjava/boehm.cc b/libjava/boehm.cc
index 043fd0030ca..da90f6db705 100644
--- a/libjava/boehm.cc
+++ b/libjava/boehm.cc
@@ -40,20 +40,18 @@ details.  */
 
 extern "C"
 {
-#include <gc_config.h>
-
 // Set GC_DEBUG before including gc.h!
 #ifdef LIBGCJ_GC_DEBUG
 # define GC_DEBUG
 #endif
 
-#include <gc_mark.h>
-#include <gc_gcj.h>
-#include <javaxfc.h>  // GC_finalize_all declaration.  
+#include <gc/gc_mark.h>
+#include <gc/gc_gcj.h>
+#include <gc/javaxfc.h>  // GC_finalize_all declaration.
 
 #ifdef THREAD_LOCAL_ALLOC
 # define GC_REDIRECT_TO_LOCAL
-# include <gc_local_alloc.h>
+# include <gc/gc.h>
 #endif
 
   // From boehm's misc.c 
@@ -468,7 +466,9 @@ _Jv_GCSetMaximumHeapSize (size_t size)
 int
 _Jv_SetGCFreeSpaceDivisor (int div)
 {
-  return (int)GC_set_free_space_divisor ((GC_word)div);
+  int old_div = (int)GC_get_free_space_divisor ();
+  GC_set_free_space_divisor ((GC_word)div);
+  return old_div;
 }
 
 void
@@ -523,7 +523,7 @@ _Jv_InitGC (void)
   gc_initialized = 1;
 
   // Ignore pointers that do not point to the start of an object.
-  GC_all_interior_pointers = 0;
+  GC_set_all_interior_pointers(0);
 
 #if defined (HAVE_DLFCN_H) && defined (HAVE_DLADDR)
   // Tell the collector to ask us before scanning DSOs.
@@ -538,9 +538,9 @@ _Jv_InitGC (void)
 
   // Cause an out of memory error to be thrown from the allocators,
   // instead of returning 0.  This is cheaper than checking on allocation.
-  GC_oom_fn = handle_out_of_memory;
+  GC_set_oom_fn(handle_out_of_memory);
 
-  GC_java_finalization = 1;
+  GC_set_java_finalization(1);
 
   // We use a different mark procedure for object arrays. This code 
   // configures a different object `kind' for object array allocation and
@@ -597,8 +597,8 @@ _Jv_AllocTraceTwo (jsize size /* includes vtable slot */)
 void
 _Jv_GCInitializeFinalizers (void (*notifier) (void))
 {
-  GC_finalize_on_demand = 1;
-  GC_finalizer_notifier = notifier;
+  GC_set_finalize_on_demand(1);
+  GC_set_finalizer_notifier(notifier);
 }
 
 void
diff --git a/libjava/configure b/libjava/configure
index 30cffa633c3..966b5154f35 100755
--- a/libjava/configure
+++ b/libjava/configure
@@ -739,10 +739,6 @@ USING_NOGC_FALSE
 USING_NOGC_TRUE
 USING_BOEHMGC_FALSE
 USING_BOEHMGC_TRUE
-GCTESTSPEC
-JC1GCSPEC
-GCSPEC
-GCDEPS
 GCINCS
 GCLIBS
 LIBGCJTESTSPEC
@@ -1023,6 +1019,9 @@ with_ecos
 with_system_zlib
 with_x
 enable_java_gc
+with_target_bdw_gc
+with_target_bdw_gc_include
+with_target_bdw_gc_lib
 enable_rpath
 with_libiconv_prefix
 with_libiconv_type
@@ -1719,7 +1718,8 @@ Optional Features:
   --enable-interpreter    enable interpreter
   --disable-java-net      disable java.net
   --disable-jvmpi         disable JVMPI support
-  --enable-java-gc=TYPE   choose garbage collector (default is boehm)
+  --enable-java-gc[=ARG]  enable the use of the bdw-gc garbage collector with
+                          libjava [ARG={default,yes,no}]
   --disable-rpath         do not hardcode runtime library paths
   --enable-tls            Use thread-local storage [default=yes]
   --disable-symvers       disable symbol versioning for libjava
@@ -1753,6 +1753,16 @@ Optional Packages:
   --with-ecos             enable runtime eCos target support
   --with-system-zlib      use installed libz
   --with-x                use the X Window System
+  --with-target-bdw-gc=PATHLIST
+                          specify prefix directory for installed bdw-gc
+                          package. Equivalent to
+                          --with-target-bdw-gc-include=PATH/include plus
+                          --with-target-bdw-gc-lib=PATH/lib
+  --with-target-bdw-gc-include=PATHLIST
+                          specify directories for installed bdw-gc include
+                          files
+  --with-target-bdw-gc-lib=PATHLIST
+                          specify directories for installed bdw-gc library
   --with-gnu-ld           assume the C compiler uses GNU ld default=no
   --with-libiconv-prefix[=DIR]  search for libiconv in DIR/include and DIR/lib
   --without-libiconv-prefix     don't search for libiconv in includedir and libdir
@@ -13128,7 +13138,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 13131 "configure"
+#line 13141 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13234,7 +13244,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 13237 "configure"
+#line 13247 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21426,55 +21436,264 @@ fi
 
 
 
-# Allow the GC to be disabled.  Can be useful when debugging.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for garbage collector to use" >&5
-$as_echo_n "checking for garbage collector to use... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if garbage collector is enabled" >&5
+$as_echo_n "checking if garbage collector is enabled... " >&6; }
 # Check whether --enable-java-gc was given.
 if test "${enable_java_gc+set}" = set; then :
-  enableval=$enable_java_gc; GC=$enableval
-else
-  GC=boehm
-fi
-
-GCLIBS=
-GCINCS=
-GCDEPS=
-GCSPEC=
-JC1GCSPEC=
-GCTESTSPEC=
-case "$GC" in
- boehm)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: boehm" >&5
-$as_echo "boehm" >&6; }
-    GCLIBS=../boehm-gc/libgcjgc_convenience.la
-    JC1GCSPEC='-fuse-boehm-gc'
-    GCTESTSPEC="-L`${PWDCMD-pwd}`/../boehm-gc/.libs -rpath `${PWDCMD-pwd}`/../boehm-gc/.libs"
-    GCINCS='-I$(top_srcdir)/../boehm-gc/include -I../boehm-gc/include'
-    GCOBJS=boehm.lo
-    GCHDR=boehm-gc.h
-    # The POSIX thread support needs to know this.
+  enableval=$enable_java_gc; USE_GC=$enableval
+else
+  USE_GC=yes
+fi
 
-$as_echo "#define HAVE_BOEHM_GC 1" >>confdefs.h
 
+# Check whether --with-target-bdw-gc was given.
+if test "${with_target_bdw_gc+set}" = set; then :
+  withval=$with_target_bdw_gc;
+fi
+
+
+# Check whether --with-target-bdw-gc-include was given.
+if test "${with_target_bdw_gc_include+set}" = set; then :
+  withval=$with_target_bdw_gc_include;
+fi
+
+
+# Check whether --with-target-bdw-gc-lib was given.
+if test "${with_target_bdw_gc_lib+set}" = set; then :
+  withval=$with_target_bdw_gc_lib;
+fi
+
+
+case "${USE_GC}" in
+no)
+  use_bdw_gc=no
+  ;;
+yes|default)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for bdw garbage collector" >&5
+$as_echo_n "checking for bdw garbage collector... " >&6; }
+  if test "x$with_target_bdw_gc$with_target_bdw_gc_include$with_target_bdw_gc_lib" = x; then
+        BDW_GC_CFLAGS=
+    GCLIBS="-lgc"
+  else
+        if test "x$with_target_bdw_gc_include" = x && test "x$with_target_bdw_gc_lib" != x; then
+      as_fn_error $? "found --with-target-bdw-gc-lib but --with-target-bdw-gc-include missing" "$LINENO" 5
+    elif test "x$with_target_bdw_gc_include" != x && test "x$with_target_bdw_gc_lib" = x; then
+      as_fn_error $? "found --with-target-bdw-gc-include but --with-target-bdw-gc-lib missing" "$LINENO" 5
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: using paths configured with --with-target-bdw-gc options" >&5
+$as_echo "using paths configured with --with-target-bdw-gc options" >&6; }
+    fi
+    mldir=`${CC-gcc} --print-multi-directory 2>/dev/null`
+    bdw_val=
+    if test "x$with_target_bdw_gc" != x; then
+      for i in `echo $with_target_bdw_gc | tr ',' ' '`; do
+        case "$i" in
+          *=*) sd=${i%%=*}; d=${i#*=} ;;
+          *) sd=.; d=$i ;;
+        esac
+        if test "$mldir" = "$sd"; then
+          bdw_val=$d
+        fi
+      done
+      if test "x$bdw_val" = x; then
+        as_fn_error $? "no multilib path ($mldir) found in --with-target-bdw-gc" "$LINENO" 5
+      fi
+      bdw_inc_dir="$bdw_val/include"
+      bdw_lib_dir="$bdw_val/lib"
+    fi
+    bdw_val=
+    if test "x$with_target_bdw_gc_include" != x; then
+      for i in `echo $with_target_bdw_gc_include | tr ',' ' '`; do
+        case "$i" in
+          *=*) sd=${i%%=*}; d=${i#*=} ;;
+          *) sd=.; d=$i; fallback=$i ;;
+        esac
+        if test "$mldir" = "$sd"; then
+          bdw_val=$d
+        fi
+      done
+      if test "x$bdw_val" = x && test "x$bdw_inc_dir" = x && test "x$fallback" != x; then
+        bdw_inc_dir="$fallback"
+      elif test "x$bdw_val" = x; then
+        as_fn_error $? "no multilib path ($mldir) found in --with-target-bdw-gc-include" "$LINENO" 5
+      else
+        bdw_inc_dir="$bdw_val"
+      fi
+    fi
+    bdw_val=
+    if test "x$with_target_bdw_gc_lib" != x; then
+      for i in `echo $with_target_bdw_gc_lib | tr ',' ' '`; do
+        case "$i" in
+          *=*) sd=${i%%=*}; d=${i#*=} ;;
+          *) sd=.; d=$i ;;
+        esac
+        if test "$mldir" = "$sd"; then
+          bdw_val=$d
+        fi
+      done
+      if test "x$bdw_val" = x; then
+        as_fn_error $? "no multilib path ($mldir) found in --with-target-bdw-gc-lib" "$LINENO" 5
+      fi
+      bdw_lib_dir="$bdw_val"
+    fi
+    if test "x$bdw_inc_dir" = x; then
+      as_fn_error $? "no multilib path ($mldir) found in --with-target-bdw-gc-include" "$LINENO" 5
+    fi
+    if test "x$bdw_lib_dir" = x; then
+      as_fn_error $? "no multilib path ($mldir) found in --with-target-bdw-gc-lib" "$LINENO" 5
+    fi
+    BDW_GC_CFLAGS="-I$bdw_inc_dir"
+    if test -f $bdw_lib_dir/libgc.la; then
+      GCLIBS="$bdw_lib_dir/libgc.la"
+    else
+      GCLIBS="-L$bdw_lib_dir -lgc"
+    fi
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
+$as_echo "found" >&6; }
+  fi
+
+  case "$GCLIBS" in
+  *libgc.la)
+    use_bdw_gc=yes
     ;;
- no)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
-$as_echo "none" >&6; }
-    GCHDR=no-gc.h
-    ;;
- *)
-    as_fn_error $? "unrecognized collector \"$GC\"" "$LINENO" 5
-    ;;
+  *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for system boehm-gc" >&5
+$as_echo_n "checking for system boehm-gc... " >&6; }
+    save_CFLAGS=$CFLAGS
+    save_LIBS=$LIBS
+    CFLAGS="$CFLAGS $BDW_GC_CFLAGS"
+    LIBS="$LIBS $GCLIBS"
+            if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <gc/gc.h>
+int
+main ()
+{
+GC_init()
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+        if test "$cross_compiling" = yes; then :
+            system_bdw_gc_found=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+          #include <gc/gc.h>
+          int main() {
+            GC_init();
+            return 0;
+          }
+
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  system_bdw_gc_found=yes
+else
+  system_bdw_gc_found=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+
+else
+  system_bdw_gc_found=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    CFLAGS=$save_CFLAGS
+    LIBS=$save_LIBS
+    if test x$enable_objc_gc = xauto && test x$system_bdw_gc_found = xno; then
+      as_fn_error $? "bdw-gc not found" "$LINENO" 5
+      use_bdw_gc=no
+    elif test x$enable_objc_gc = xyes && test x$system_bdw_gc_found = xno; then
+      as_fn_error $? "bdw-gc not found" "$LINENO" 5
+    else
+      use_bdw_gc=yes
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
+$as_echo "found" >&6; }
+    fi
+  esac
 esac
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for GC_iterate_free_hblks in -lgc" >&5
+$as_echo_n "checking for GC_iterate_free_hblks in -lgc... " >&6; }
+if ${ac_cv_lib_gc_GC_iterate_free_hblks+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgc  $LIBS"
+if test x$gcc_no_link = xyes; then
+  as_fn_error $? "Link tests are not allowed after GCC_NO_EXECUTABLES." "$LINENO" 5
+fi
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char GC_iterate_free_hblks ();
+int
+main ()
+{
+return GC_iterate_free_hblks ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_gc_GC_iterate_free_hblks=yes
+else
+  ac_cv_lib_gc_GC_iterate_free_hblks=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gc_GC_iterate_free_hblks" >&5
+$as_echo "$ac_cv_lib_gc_GC_iterate_free_hblks" >&6; }
+if test "x$ac_cv_lib_gc_GC_iterate_free_hblks" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBGC 1
+_ACEOF
+
+  LIBS="-lgc $LIBS"
+
+else
+  as_fn_error $? "installed boehm-gc is too old" "$LINENO" 5
+fi
+
+
+if test "$use_bdw_gc" = no; then
+  as_fn_error $? "bdw-gc not found" "$LINENO" 5
+  GCLIBS=
+  GCINCS=
+  GCHDR=no-gc.h
+else
+  GCINCS=$BDW_GC_CFLAGS
+  GCLIBS=$GCLIBS
+  GCHDR=boehm-gc.h
+  # The POSIX thread support needs to know this.
 
+$as_echo "#define HAVE_BOEHM_GC 1" >>confdefs.h
+
+fi
 
 
 
 ac_config_links="$ac_config_links include/java-gc.h:include/$GCHDR"
 
- if test "$GC" = boehm; then
+ if test "$USE_GC" = yes; then
   USING_BOEHMGC_TRUE=
   USING_BOEHMGC_FALSE='#'
 else
@@ -21482,7 +21701,7 @@ else
   USING_BOEHMGC_FALSE=
 fi
 
- if test "$GC" = no; then
+ if test "$USE_GC" = no; then
   USING_NOGC_TRUE=
   USING_NOGC_FALSE='#'
 else
@@ -21579,7 +21798,7 @@ $as_echo "#define HAVE_PTHREAD_MUTEXATTR_INIT 1" >>confdefs.h
 
     # 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
+    if test "$USE_GC" = no; then
 
 $as_echo "#define _REENTRANT 1" >>confdefs.h
 
@@ -24148,7 +24367,7 @@ fi
 
    # On Solaris, and maybe other architectures, the Boehm collector
    # requires -ldl.
-   if test "$GC" = boehm; then
+   if test "$USE_GC" != no; then
       case "${host}" in
 	  *-*-darwin*)
 	    ;;
diff --git a/libjava/configure.ac b/libjava/configure.ac
index 4f654099fe3..03cae448e33 100644
--- a/libjava/configure.ac
+++ b/libjava/configure.ac
@@ -930,48 +930,174 @@ AC_SUBST(LIBMATHSPEC)
 
 AC_SUBST(LIBGCJTESTSPEC)
 
-# Allow the GC to be disabled.  Can be useful when debugging.
-AC_MSG_CHECKING([for garbage collector to use])
+AC_MSG_CHECKING([if garbage collector is enabled])
 AC_ARG_ENABLE(java-gc,
-  AS_HELP_STRING([--enable-java-gc=TYPE],
-                 [choose garbage collector (default is boehm)]),
-  [GC=$enableval],
-  [GC=boehm])
-GCLIBS=
-GCINCS=
-GCDEPS=
-GCSPEC=
-JC1GCSPEC=
-GCTESTSPEC=
-case "$GC" in
- boehm)
-    AC_MSG_RESULT(boehm)
-    GCLIBS=../boehm-gc/libgcjgc_convenience.la
-    JC1GCSPEC='-fuse-boehm-gc'
-    GCTESTSPEC="-L`${PWDCMD-pwd}`/../boehm-gc/.libs -rpath `${PWDCMD-pwd}`/../boehm-gc/.libs"
-    GCINCS='-I$(top_srcdir)/../boehm-gc/include -I../boehm-gc/include'
-    GCOBJS=boehm.lo    
-    GCHDR=boehm-gc.h
-    # The POSIX thread support needs to know this.
-    AC_DEFINE(HAVE_BOEHM_GC, 1, [Define if Boehm GC in use.])
-    ;;
- no)
-    AC_MSG_RESULT(none)
-    GCHDR=no-gc.h
-    ;;
- *)
-    AC_MSG_ERROR([unrecognized collector "$GC"])
+[AS_HELP_STRING([[--enable-java-gc[=ARG]]],
+    [enable the use of the bdw-gc garbage collector with libjava @<:@ARG={default,yes,no}@:>@])],
+[USE_GC=$enableval],
+[USE_GC=yes])
+AC_ARG_WITH([target-bdw-gc],
+[AS_HELP_STRING([--with-target-bdw-gc=PATHLIST],
+    [specify prefix directory for installed bdw-gc package.
+     Equivalent to --with-target-bdw-gc-include=PATH/include
+     plus --with-target-bdw-gc-lib=PATH/lib])])
+AC_ARG_WITH([target-bdw-gc-include],
+[AS_HELP_STRING([--with-target-bdw-gc-include=PATHLIST],
+    [specify directories for installed bdw-gc include files])])
+AC_ARG_WITH([target-bdw-gc-lib],
+[AS_HELP_STRING([--with-target-bdw-gc-lib=PATHLIST],
+    [specify directories for installed bdw-gc library])])
+
+case "${USE_GC}" in
+no)
+  use_bdw_gc=no
+  ;;
+yes|default)
+  AC_MSG_CHECKING([for bdw garbage collector])
+  if test "x$with_target_bdw_gc$with_target_bdw_gc_include$with_target_bdw_gc_lib" = x; then
+    dnl no bdw-gw options, assuming bdw-gc in default locations
+    BDW_GC_CFLAGS=
+    GCLIBS="-lgc"
+  else
+    dnl bdw-gw options passed by configure flags
+    if test "x$with_target_bdw_gc_include" = x && test "x$with_target_bdw_gc_lib" != x; then
+      AC_MSG_ERROR([found --with-target-bdw-gc-lib but --with-target-bdw-gc-include missing])
+    elif test "x$with_target_bdw_gc_include" != x && test "x$with_target_bdw_gc_lib" = x; then
+      AC_MSG_ERROR([found --with-target-bdw-gc-include but --with-target-bdw-gc-lib missing])
+    else
+      AC_MSG_RESULT([using paths configured with --with-target-bdw-gc options])
+    fi
+    mldir=`${CC-gcc} --print-multi-directory 2>/dev/null`
+    bdw_val=
+    if test "x$with_target_bdw_gc" != x; then
+      for i in `echo $with_target_bdw_gc | tr ',' ' '`; do
+        case "$i" in
+          *=*) sd=${i%%=*}; d=${i#*=} ;;
+          *) sd=.; d=$i ;;
+        esac
+        if test "$mldir" = "$sd"; then
+          bdw_val=$d
+        fi
+      done
+      if test "x$bdw_val" = x; then
+        AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc])
+      fi
+      bdw_inc_dir="$bdw_val/include"
+      bdw_lib_dir="$bdw_val/lib"
+    fi
+    bdw_val=
+    if test "x$with_target_bdw_gc_include" != x; then
+      for i in `echo $with_target_bdw_gc_include | tr ',' ' '`; do
+        case "$i" in
+          *=*) sd=${i%%=*}; d=${i#*=} ;;
+          *) sd=.; d=$i; fallback=$i ;;
+        esac
+        if test "$mldir" = "$sd"; then
+          bdw_val=$d
+        fi
+      done
+      if test "x$bdw_val" = x && test "x$bdw_inc_dir" = x && test "x$fallback" != x; then
+        bdw_inc_dir="$fallback"
+      elif test "x$bdw_val" = x; then
+        AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-include])
+      else
+        bdw_inc_dir="$bdw_val"
+      fi
+    fi
+    bdw_val=
+    if test "x$with_target_bdw_gc_lib" != x; then
+      for i in `echo $with_target_bdw_gc_lib | tr ',' ' '`; do
+        case "$i" in
+          *=*) sd=${i%%=*}; d=${i#*=} ;;
+          *) sd=.; d=$i ;;
+        esac
+        if test "$mldir" = "$sd"; then
+          bdw_val=$d
+        fi
+      done
+      if test "x$bdw_val" = x; then
+        AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-lib])
+      fi
+      bdw_lib_dir="$bdw_val"
+    fi
+    if test "x$bdw_inc_dir" = x; then
+      AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-include])
+    fi
+    if test "x$bdw_lib_dir" = x; then
+      AC_MSG_ERROR([no multilib path ($mldir) found in --with-target-bdw-gc-lib])
+    fi
+    BDW_GC_CFLAGS="-I$bdw_inc_dir"
+    if test -f $bdw_lib_dir/libgc.la; then
+      GCLIBS="$bdw_lib_dir/libgc.la"
+    else
+      GCLIBS="-L$bdw_lib_dir -lgc"
+    fi
+    AC_MSG_RESULT([found])
+  fi
+
+  case "$GCLIBS" in
+  *libgc.la)
+    use_bdw_gc=yes
     ;;
+  *)
+    AC_MSG_CHECKING([for system boehm-gc])
+    save_CFLAGS=$CFLAGS
+    save_LIBS=$LIBS
+    CFLAGS="$CFLAGS $BDW_GC_CFLAGS"
+    LIBS="$LIBS $GCLIBS"
+    dnl the link test is not good enough for ARM32 multilib detection,
+    dnl first check to link, then to run
+    AC_LINK_IFELSE(
+      [AC_LANG_PROGRAM([#include <gc/gc.h>],[GC_init()])],
+      [
+        AC_RUN_IFELSE([AC_LANG_SOURCE([[
+          #include <gc/gc.h>
+          int main() {
+            GC_init();
+            return 0;
+          }
+          ]])],
+          [system_bdw_gc_found=yes],
+          [system_bdw_gc_found=no],
+          dnl assume no system boehm-gc for cross builds ...
+          [system_bdw_gc_found=no]
+        )
+      ],
+      [system_bdw_gc_found=no])
+    CFLAGS=$save_CFLAGS
+    LIBS=$save_LIBS
+    if test x$enable_objc_gc = xauto && test x$system_bdw_gc_found = xno; then
+      AC_MSG_ERROR([bdw-gc not found])
+      use_bdw_gc=no
+    elif test x$enable_objc_gc = xyes && test x$system_bdw_gc_found = xno; then
+      AC_MSG_ERROR([bdw-gc not found])
+    else
+      use_bdw_gc=yes
+      AC_MSG_RESULT([found])
+    fi
+  esac
 esac
+
+AC_CHECK_LIB([gc], [GC_iterate_free_hblks], [], [AC_MSG_ERROR([installed boehm-gc is too old])])
+
+if test "$use_bdw_gc" = no; then
+  AC_MSG_ERROR([bdw-gc not found])
+  GCLIBS=
+  GCINCS=
+  GCHDR=no-gc.h
+else
+  GCINCS=$BDW_GC_CFLAGS
+  GCLIBS=$GCLIBS
+  GCHDR=boehm-gc.h
+  # The POSIX thread support needs to know this.
+  AC_DEFINE(HAVE_BOEHM_GC, 1, [Define if Boehm GC in use.])
+fi
+
 AC_SUBST(GCLIBS)
 AC_SUBST(GCINCS)
-AC_SUBST(GCDEPS)
-AC_SUBST(GCSPEC)
-AC_SUBST(JC1GCSPEC)
-AC_SUBST(GCTESTSPEC)
 AC_CONFIG_LINKS(include/java-gc.h:include/$GCHDR)
-AM_CONDITIONAL(USING_BOEHMGC, test "$GC" = boehm)
-AM_CONDITIONAL(USING_NOGC, test "$GC" = no)
+AM_CONDITIONAL(USING_BOEHMGC, test "$USE_GC" = yes)
+AM_CONDITIONAL(USING_NOGC, test "$USE_GC" = no)
 
 
 AC_MSG_CHECKING([for thread model used by GCC])
@@ -1055,7 +1181,7 @@ case "$THREADS" in
 
     # 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
+    if test "$USE_GC" = no; then
        AC_DEFINE(_REENTRANT, 1, [Required define if using POSIX threads])
     fi
     AC_DEFINE(_POSIX_PTHREAD_SEMANTICS, 1, [Required define if using POSIX threads])
@@ -1412,7 +1538,7 @@ else
 
    # On Solaris, and maybe other architectures, the Boehm collector
    # requires -ldl.
-   if test "$GC" = boehm; then
+   if test "$USE_GC" != no; then
       case "${host}" in
 	  *-*-darwin*)
 	    ;;
diff --git a/libjava/gcj/Makefile.in b/libjava/gcj/Makefile.in
index e517a43dd1a..83b57288302 100644
--- a/libjava/gcj/Makefile.in
+++ b/libjava/gcj/Makefile.in
@@ -229,7 +229,6 @@ EXCEPTIONSPEC = @EXCEPTIONSPEC@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GCC_FOR_ECJX = @GCC_FOR_ECJX@
-GCDEPS = @GCDEPS@
 GCINCS = @GCINCS@
 GCJ = @GCJ@
 GCJDEPMODE = @GCJDEPMODE@
@@ -239,8 +238,6 @@ GCJVERSION = @GCJVERSION@
 GCJ_BIN_DIR = @GCJ_BIN_DIR@
 GCJ_FOR_ECJX = @GCJ_FOR_ECJX@
 GCLIBS = @GCLIBS@
-GCSPEC = @GCSPEC@
-GCTESTSPEC = @GCTESTSPEC@
 GLIB_CFLAGS = @GLIB_CFLAGS@
 GLIB_LIBS = @GLIB_LIBS@
 GREP = @GREP@
@@ -258,7 +255,6 @@ INTERPRETER = @INTERPRETER@
 JAR = @JAR@
 JAVA_HOME = @JAVA_HOME@
 JAVA_VERSION = @JAVA_VERSION@
-JC1GCSPEC = @JC1GCSPEC@
 JRE_BIN_DIR = @JRE_BIN_DIR@
 JRE_DIR = @JRE_DIR@
 JRE_LIB_DIR = @JRE_LIB_DIR@
diff --git a/libjava/gnu/gcj/util/natGCInfo.cc b/libjava/gnu/gcj/util/natGCInfo.cc
index a5936174da7..144337259ce 100644
--- a/libjava/gnu/gcj/util/natGCInfo.cc
+++ b/libjava/gnu/gcj/util/natGCInfo.cc
@@ -25,44 +25,9 @@
 #include <string.h>
 #include <errno.h>
 
-//
-// Boehm GC includes.
-//
-#ifdef PACKAGE_NAME
-#undef PACKAGE_NAME
-#endif
-
-#ifdef PACKAGE_STRING
-#undef PACKAGE_STRING
-#endif
-
-#ifdef PACKAGE_TARNAME
-#undef PACKAGE_TARNAME
-#endif
-
-#ifdef PACKAGE_VERSION
-#undef PACKAGE_VERSION
-#endif
-
-#ifdef TRUE
-#undef TRUE
-#endif
-
-#ifdef FALSE
-#undef FALSE
-#endif
-
-extern "C" {
-#include "private/dbg_mlc.h"
-  int GC_n_set_marks(hdr* hhdr);
-  ptr_t GC_clear_stack(ptr_t p);
-  extern int GC_gcj_kind;
-  extern int GC_gcj_debug_kind;
-}
-
-#endif
-
-#ifdef HAVE_PROC_SELF_MAPS
+#include "gc/gc.h"
+#include "gc/gc_gcj.h"
+#include "gc/gc_mark.h"
 
 static int gc_ok = 1;
 
@@ -76,88 +41,59 @@ struct gc_debug_info
 };
 
 static void
-GC_print_debug_callback(hblk *h, word user_data)
+GC_print_debug_callback(GC_hblk_s *h, GC_word user_data)
 {
-  hdr *hhdr = HDR(h);
-  size_t bytes = WORDS_TO_BYTES(hhdr -> hb_sz);
+  size_t bytes;
 
   gc_debug_info *pinfo = (gc_debug_info *)user_data;
 
   fprintf(pinfo->fp, "ptr = %#lx, kind = %d, size = %zd, marks = %d\n",
-          (unsigned long)h, hhdr->hb_obj_kind, bytes, GC_n_set_marks(hhdr));
+	  (unsigned long)h, GC_get_kind_and_size(h, &bytes), bytes, GC_count_set_marks_in_hblk(h));
 }
 
-/*
-  this next section of definitions shouldn't really be here.
-  copied from boehmgc/allchblk.c
-*/
+struct print_hblkfl_s {
+  FILE *fp;
+  GC_word total_free;
+  int prev_index;
+};
 
-# define UNIQUE_THRESHOLD 32
-# define HUGE_THRESHOLD 256
-# define FL_COMPRESSION 8
-# define N_HBLK_FLS (HUGE_THRESHOLD - UNIQUE_THRESHOLD)/FL_COMPRESSION \
-                         + UNIQUE_THRESHOLD
-#ifndef USE_MUNMAP
-extern "C" {
-  extern word GC_free_bytes[N_HBLK_FLS+1];
+static void GC_CALLBACK print_hblkfl_file_item(struct GC_hblk_s *h, int i,
+					       GC_word client_data)
+{
+  GC_word sz;
+  print_hblkfl_s *pdata = (print_hblkfl_s *)client_data;
+
+  if (pdata->prev_index != i) {
+    fprintf(pdata->fp, "Free list %d:\n", i);
+    pdata->prev_index = i;
+  }
+
+  sz = GC_size(h);
+  fprintf(pdata->fp, "\t0x%lx size %lu ", (unsigned long)h,
+	   (unsigned long)sz);
+  pdata->total_free += sz;
+
+  if (GC_is_black_listed(h, GC_get_hblk_size()) != 0)
+    fprintf(pdata->fp, "start black listed\n");
+  else if (GC_is_black_listed(h, sz) != 0)
+    fprintf(pdata->fp, "partially black listed\n");
+  else
+    fprintf(pdata->fp, "not black listed\n");
 }
-#endif
-
-# ifdef USE_MUNMAP
-#   define IS_MAPPED(hhdr) (((hhdr) -> hb_flags & WAS_UNMAPPED) == 0)
-# else  /* !USE_MMAP */
-#   define IS_MAPPED(hhdr) 1
-# endif /* USE_MUNMAP */
 
 static void
 GC_print_hblkfreelist_file(FILE *fp)
 {
-  struct hblk * h;
-  word total_free = 0;
-  hdr * hhdr;
-  word sz;
-  int i;
+  print_hblkfl_s data;
+  data.fp = fp;
+  data.total_free = 0;
+  data.prev_index = -1;
     
   fprintf(fp, "---------- Begin free map ----------\n");
-  for (i = 0; i <= N_HBLK_FLS; ++i)
-    {
-      h = GC_hblkfreelist[i];
-#ifdef USE_MUNMAP
-      if (0 != h)
-        fprintf (fp, "Free list %ld:\n", (unsigned long)i);
-#else
-      if (0 != h)
-        fprintf (fp, "Free list %ld (Total size %ld):\n",
-                 (unsigned long)i,
-                 (unsigned long)GC_free_bytes[i]);
-#endif
-      while (h != 0)
-        {
-          hhdr = HDR(h);
-          sz = hhdr -> hb_sz;
-          fprintf (fp, "\t0x%lx size %lu ", (unsigned long)h,
-                   (unsigned long)sz);
-          total_free += sz;
-
-          if (GC_is_black_listed (h, HBLKSIZE) != 0)
-            fprintf (fp, "start black listed\n");
-          else if (GC_is_black_listed(h, hhdr -> hb_sz) != 0)
-            fprintf (fp, "partially black listed\n");
-          else
-            fprintf (fp, "not black listed\n");
-
-          h = hhdr -> hb_next;
-        }
-    }
-#ifndef USE_MUNMAP
-  if (total_free != GC_large_free_bytes)
-    {
-      fprintf (fp, "GC_large_free_bytes = %lu (INCONSISTENT!!)\n",
-               (unsigned long) GC_large_free_bytes);
-    }
-#endif
-  fprintf (fp, "Total of %lu bytes on free list\n", (unsigned long)total_free);
-  fprintf (fp, "---------- End free map ----------\n");
+  GC_iterate_free_hblks(print_hblkfl_file_item, (GC_word)&data);
+  fprintf(fp, "Total of %lu bytes on free list\n",
+	   (unsigned long)data.total_free);
+  fprintf(fp, "---------- End free map ----------\n");
 }
 
 static int GC_dump_count = 1;
@@ -173,7 +109,7 @@ GC_print_debug_info_file(FILE* fp)
   if (gc_ok)
     GC_gcollect();
   fprintf(info.fp, "---------- Begin block map ----------\n");
-  GC_apply_to_all_blocks(GC_print_debug_callback, (word)(void*)(&info));
+  GC_apply_to_all_blocks(GC_print_debug_callback, (GC_word)(void*)(&info));
   //fprintf(fp, "#Total used %d free %d wasted %d\n", info.used, info.free, info.wasted);
   //fprintf(fp, "#Total blocks %d; %dK bytes\n", info.blocks, info.blocks*4);
   fprintf(info.fp, "---------- End block map ----------\n");
@@ -194,8 +130,8 @@ namespace
     int bytes_fd;
 
     void print_address_map();
-    void enumerate_callback(struct hblk *h);
-    static void enumerate_callback_adaptor(struct hblk *h, word dummy);
+    void enumerate_callback(GC_hblk_s *h);
+    static void enumerate_callback_adaptor(GC_hblk_s *h, GC_word dummy);
   };
 }
 
@@ -300,7 +236,7 @@ GC_enumerator::enumerate()
   if (gc_ok)
     GC_gcollect();
   GC_apply_to_all_blocks(enumerate_callback_adaptor, 
-                         (word)(void*)(this));
+			 (GC_word)(void*)(this));
   fprintf(fp, "---------- End object map ----------\n");
   fflush(fp); 
 
@@ -316,25 +252,24 @@ GC_enumerator::enumerate()
 }
 
 void
-GC_enumerator::enumerate_callback_adaptor(struct hblk *h,
-                                          word dummy)
+GC_enumerator::enumerate_callback_adaptor(GC_hblk_s *h,
+					  GC_word dummy)
 {
   GC_enumerator* pinfo = (GC_enumerator*)dummy;
   pinfo->enumerate_callback(h);
 }
 
 void
-GC_enumerator::enumerate_callback(struct hblk *h)
+GC_enumerator::enumerate_callback(GC_hblk_s *h)
 {
-  hdr * hhdr = HDR(h);
-  size_t bytes = WORDS_TO_BYTES(hhdr->hb_sz);
+  size_t bytes;
   int i;
 
-  for (i = 0; i == 0 || (i + bytes <= HBLKSIZE); i += bytes)
+  for (i = 0; i == 0 || (i + bytes <= GC_get_hblk_size()); i += bytes)
     {
-      int inUse = mark_bit_from_hdr(hhdr,BYTES_TO_WORDS(i));  // in use
+      int inUse = GC_is_marked((char*)h+i);                   // in use
       char *ptr = (char*)h+i;                                 // address
-      int kind = hhdr->hb_obj_kind;                           // kind
+      int kind = GC_get_kind_and_size(h, &bytes);             // kind
       void *klass = 0;
       void *data = 0;
       if (kind == GC_gcj_kind
@@ -431,7 +366,7 @@ void
 
   J2A(name, n);
   oomDumpName = n;
-  GC_oom_fn = nomem_handler;
+  GC_set_oom_fn(nomem_handler);
 }
 
 #else  // HAVE_PROC_SELF_MAPS
diff --git a/libjava/include/Makefile.in b/libjava/include/Makefile.in
index d60f77153f7..57add8dc800 100644
--- a/libjava/include/Makefile.in
+++ b/libjava/include/Makefile.in
@@ -230,7 +230,6 @@ EXCEPTIONSPEC = @EXCEPTIONSPEC@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GCC_FOR_ECJX = @GCC_FOR_ECJX@
-GCDEPS = @GCDEPS@
 GCINCS = @GCINCS@
 GCJ = @GCJ@
 GCJDEPMODE = @GCJDEPMODE@
@@ -240,8 +239,6 @@ GCJVERSION = @GCJVERSION@
 GCJ_BIN_DIR = @GCJ_BIN_DIR@
 GCJ_FOR_ECJX = @GCJ_FOR_ECJX@
 GCLIBS = @GCLIBS@
-GCSPEC = @GCSPEC@
-GCTESTSPEC = @GCTESTSPEC@
 GLIB_CFLAGS = @GLIB_CFLAGS@
 GLIB_LIBS = @GLIB_LIBS@
 GREP = @GREP@
@@ -259,7 +256,6 @@ INTERPRETER = @INTERPRETER@
 JAR = @JAR@
 JAVA_HOME = @JAVA_HOME@
 JAVA_VERSION = @JAVA_VERSION@
-JC1GCSPEC = @JC1GCSPEC@
 JRE_BIN_DIR = @JRE_BIN_DIR@
 JRE_DIR = @JRE_DIR@
 JRE_LIB_DIR = @JRE_LIB_DIR@
diff --git a/libjava/include/boehm-gc.h b/libjava/include/boehm-gc.h
index ed8ac6aa2e3..96f45469203 100644
--- a/libjava/include/boehm-gc.h
+++ b/libjava/include/boehm-gc.h
@@ -27,7 +27,7 @@ extern "C"
 #include <java/lang/Class.h>
 #include <string.h>
 
-#include <gc_ext_config.h> // for THREAD_LOCAL_ALLOC
+#include <gc/gc.h> // for THREAD_LOCAL_ALLOC
 
 extern "C" void * GC_gcj_malloc(size_t, void *);
 extern "C" void * GC_malloc_atomic(size_t);
@@ -41,8 +41,7 @@ extern "C" void * GC_local_malloc_atomic(size_t);
 inline void *
 _Jv_AllocObj (jsize size, jclass klass)
 {
-  // This should call GC_GCJ_MALLOC, but that would involve
-  // including gc.h.
+  // FIXME: This should call GC_GCJ_MALLOC
 #ifdef THREAD_LOCAL_ALLOC
   return GC_local_gcj_malloc (size, klass->vtable);
 #else 
diff --git a/libjava/include/config.h.in b/libjava/include/config.h.in
index 52fef3c056b..ec444d6c107 100644
--- a/libjava/include/config.h.in
+++ b/libjava/include/config.h.in
@@ -207,6 +207,9 @@
 /* Define if libdlloader will be built on this platform */
 #undef HAVE_LIBDLLOADER
 
+/* Define to 1 if you have the `gc' library (-lgc). */
+#undef HAVE_LIBGC
+
 /* Define to 1 if you have the `ltdl' library (-lltdl). */
 #undef HAVE_LIBLTDL
 
diff --git a/libjava/libgcj.spec.in b/libjava/libgcj.spec.in
index 22eec3dbc79..bfeed858d44 100644
--- a/libjava/libgcj.spec.in
+++ b/libjava/libgcj.spec.in
@@ -7,6 +7,6 @@
 *startfile: @THREADSTARTFILESPEC@ %(startfileorig)
 
 %rename lib liborig
-*lib: @LD_START_STATIC_SPEC@ @LIBGCJ_SPEC@ @LD_FINISH_STATIC_SPEC@ @LIBMATHSPEC@ @LDLIBICONV@ @GCSPEC@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) @LIBSTDCXXSPEC@ %(liborig)
+*lib: @LD_START_STATIC_SPEC@ @LIBGCJ_SPEC@ @LD_FINISH_STATIC_SPEC@ @LIBMATHSPEC@ @LDLIBICONV@ @THREADSPEC@ @ZLIBSPEC@ @SYSTEMSPEC@ %(libgcc) @LIBSTDCXXSPEC@ %(liborig)
 
-*jc1: @HASH_SYNC_SPEC@ @DIVIDESPEC@ @CHECKREFSPEC@ @JC1GCSPEC@ @EXCEPTIONSPEC@ @BACKTRACESPEC@ @IEEESPEC@ @ATOMICSPEC@ @LIBGCJ_BC_SPEC@ -fkeep-inline-functions
+*jc1: @HASH_SYNC_SPEC@ @DIVIDESPEC@ @CHECKREFSPEC@ @EXCEPTIONSPEC@ @BACKTRACESPEC@ @IEEESPEC@ @ATOMICSPEC@ @LIBGCJ_BC_SPEC@ -fkeep-inline-functions
diff --git a/libjava/testsuite/Makefile.in b/libjava/testsuite/Makefile.in
index 841d517444f..d5e6755400b 100644
--- a/libjava/testsuite/Makefile.in
+++ b/libjava/testsuite/Makefile.in
@@ -183,7 +183,6 @@ EXCEPTIONSPEC = @EXCEPTIONSPEC@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
 GCC_FOR_ECJX = @GCC_FOR_ECJX@
-GCDEPS = @GCDEPS@
 GCINCS = @GCINCS@
 GCJ = @GCJ@
 GCJDEPMODE = @GCJDEPMODE@
@@ -193,8 +192,6 @@ GCJVERSION = @GCJVERSION@
 GCJ_BIN_DIR = @GCJ_BIN_DIR@
 GCJ_FOR_ECJX = @GCJ_FOR_ECJX@
 GCLIBS = @GCLIBS@
-GCSPEC = @GCSPEC@
-GCTESTSPEC = @GCTESTSPEC@
 GLIB_CFLAGS = @GLIB_CFLAGS@
 GLIB_LIBS = @GLIB_LIBS@
 GREP = @GREP@
@@ -212,7 +209,6 @@ INTERPRETER = @INTERPRETER@
 JAR = @JAR@
 JAVA_HOME = @JAVA_HOME@
 JAVA_VERSION = @JAVA_VERSION@
-JC1GCSPEC = @JC1GCSPEC@
 JRE_BIN_DIR = @JRE_BIN_DIR@
 JRE_DIR = @JRE_DIR@
 JRE_LIB_DIR = @JRE_LIB_DIR@
-- 
2.38.1

Reply via email to