[m-rev.] [PATCH 3/4] Make changes required to upgrade to Boehm GC 7.4.2

Paul Bone paul at bone.id.au
Wed Jun 25 11:09:30 AEST 2014


GC_stackbottom, GC_gc_no and GC_dont_gc are now deprecated.  These changes
use new options in the API where possible.

Update scripts to copy the boehm_gc directory correctly.

Pase Boehm GC the correct flags for thread support

Update documentation regarding the version of Boehm GC.

runtime/mercury_wrapper.c:
    Don't use the deprecated GC_dont_gc variable.

library/benchmarking.m:
    Use GC_get_stackbottom() to get the bottom of stack and GC_get_gc_no()
    to get the number of collections so far.

util/mkinit.c:
    Do not explicitly set GC_stackbottom anymore, except on AIX where it
    cannot be found automatically.

scripts/prepare_install_dir.in:
stools/bootcheck:
    Add some missing files present in Boehm GC 7.4.2 that wern't present
    earlier and remove some old ones.

.README.in:
bindist/bindist.README:
    Update documentation regarding the version of Boehm GC.

compiler/notes/upgrade_boehm_gc.html:
    Documentation fix

configure.ac:
    Something in Boehm GC's build system has changed and we must now pass
    -DGC_THREADS whenever building threadsafe versions of BOehm GC.  This is now
    done using the BOEHM_MISC_CFLAGS_FOR_THREADS autoconf variable, which has
    been renamed to BOEHM_CFLAGS_FOR_THREADS now that it is more generally used.

    Boehm GC no longer (or perhaps never did) require developers to specify the
    type of threading to use, eg -DGC_LINUX_THREADS rather than -DGC_THREADS.
    With the exception of win32-pthreads.  We now pass -DGC_THREADS whereever
    possible.

Mmake.common.in:
    Rename BOEHM_MISC_CFLAGS_FOR_THREADS.
---
 .README.in                           | 26 ++++++++++++++++++++------
 Mmake.common.in                      |  6 +++---
 bindist/bindist.README               | 15 +++++++++++----
 compiler/notes/upgrade_boehm_gc.html |  4 ++--
 configure.ac                         | 31 +++++++++++++++++++++----------
 library/benchmarking.m               | 11 ++++++++---
 runtime/mercury_wrapper.c            |  2 +-
 scripts/prepare_install_dir.in       |  9 ++++-----
 tools/bootcheck                      |  5 ++---
 util/mkinit.c                        |  7 ++++++-
 10 files changed, 78 insertions(+), 38 deletions(-)

diff --git a/.README.in b/.README.in
index 2d02fab..19845c6 100644
--- a/.README.in
+++ b/.README.in
@@ -16,13 +16,21 @@ Mercury compiler, version @VERSION at .
 	contact us.  We are willing to offer alternative arrangements,
 	if the need should arise.
 	
-The subdirectory `boehm_gc' contains a slightly modified copy of version 7.2 of
-the conservative garbage collector distributed by Hans Boehm:
+The subdirectory `boehm_gc' contains a slightly modified copy of version
+7.4.2 of the conservative garbage collector distributed by Hans Boehm:
 
-	Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
-	Copyright (c) 1991-1995 by Xerox Corporation.  All rights reserved.
-	Copyright (c) 1996-1999 by Silicon Graphics.  All rights reserved.
-	Copyright (c) 1999-2001 by Hewlett-Packard. All rights reserved.
+    Copyright (c) 1988, 1989 Hans-J. Boehm, Alan J. Demers
+    Copyright (c) 1991-1996 by Xerox Corporation. All rights reserved.
+    Copyright (c) 1996-1999 by Silicon Graphics. All rights reserved.
+    Copyright (c) 1999-2011 by Hewlett-Packard Development Company.
+
+    The file boehm_gc/linux_threads.c is also
+
+        Copyright (c) 1998 by Fergus Henderson. All rights reserved.
+
+    The files boehm_gc/Makefile.am, and boehm_gc/configure.in are
+
+        Copyright (c) 2001 by Red Hat Inc. All rights reserved.
 
 	THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
 	OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
@@ -39,6 +47,12 @@ the conservative garbage collector distributed by Hans Boehm:
 	use of those files for a purpose other than building the collector may
 	require the resulting code to be covered by the GPL.
 
+    The atomic_ops library (boehm_gc/libatomic_ops) contains some code that
+    is covered by the GNU General Public License, but is not needed by, nor
+    linked into the collector library or Mercury. It is included here only
+    because the atomic_ops distribution is, for simplicity, included in its
+    entirety.
+
 A few files (config.guess, config.sub) are derived from code that is
 copyright by the Free Software Foundation, Inc, and are distributed
 under the GNU General Public License version 2.
diff --git a/Mmake.common.in b/Mmake.common.in
index c408891..7a31c8e 100644
--- a/Mmake.common.in
+++ b/Mmake.common.in
@@ -175,9 +175,9 @@ BOEHM_CFLAGS = @ENABLE_BOEHM_LARGE_CONFIG@ @ENABLE_BOEHM_USE_MUNMAP@ \
 # Additional options to pass to the C compiler when building Boehm-GC for
 # threads.
 #
-BOEHM_CFLAGS_FOR_THREADS = @ENABLE_BOEHM_THREAD_LOCAL_ALLOC@ \
-	@ENABLE_BOEHM_PARALLEL_MARK@ \
-	@BOEHM_MISC_CFLAGS_FOR_THREADS@
+BOEHM_CFLAGS_FOR_THREADS = @BOEHM_CFLAGS_FOR_THREADS@ \
+    @ENABLE_BOEHM_THREAD_LOCAL_ALLOC@ \
+	@ENABLE_BOEHM_PARALLEL_MARK@
 
 # Do we want to deal with intermodule information when building the library?
 # By default yes, since this way we note immediately when intermodule
diff --git a/bindist/bindist.README b/bindist/bindist.README
index 8530ab2..3258a27 100644
--- a/bindist/bindist.README
+++ b/bindist/bindist.README
@@ -17,14 +17,21 @@ Mercury compiler, version <VERSION>, built on a `<FULLARCH>' system.
 	contact us.  We are willing to offer alternative arrangements,
 	if the need should arise.
 
-This distribution also contains a slightly modified copy of 
-version 7.2 of the conservative garbage collector
-distributed by Hans Boehm:
+This distribution also contains a slightly modified copy of version 7.4.2 of
+the conservative garbage collector distributed by Hans Boehm:
 
 	Copyright 1988, 1989 Hans-J. Boehm, Alan J. Demers
 	Copyright (c) 1991-1995 by Xerox Corporation.  All rights reserved.
 	Copyright (c) 1996-1999 by Silicon Graphics.  All rights reserved.
-	Copyright (c) 1999-2001 by Hewlett-Packard. All rights reserved.
+	Copyright (c) 1999-2011 by Hewlett-Packard. All rights reserved.
+
+    The file boehm_gc/linux_threads.c is also
+
+        Copyright (c) 1998 by Fergus Henderson. All rights reserved.
+
+    The files boehm_gc/Makefile.am, and boehm_gc/configure.in are
+
+        Copyright (c) 2001 by Red Hat Inc. All rights reserved.
 
 	THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
 	OR IMPLIED.  ANY USE IS AT YOUR OWN RISK.
diff --git a/compiler/notes/upgrade_boehm_gc.html b/compiler/notes/upgrade_boehm_gc.html
index 84b9d02..aae852d 100644
--- a/compiler/notes/upgrade_boehm_gc.html
+++ b/compiler/notes/upgrade_boehm_gc.html
@@ -207,8 +207,8 @@ Then use the new system to do an install (with non-empty LIBGRADES)
 and test that the installed version can compile some test programs.
 This is because the update may have added some new files which may not be
 copied into the install directories.
-Some build scripts may also need to be updated (in particular tools/bootcheck
-and scripts/prepare_tmp_dir_*).
+Some build scripts may also need to be updated (in particular
+tools/bootcheck and scripts/prepare_install_dir.in).
 </p>
 
 <p>
diff --git a/configure.ac b/configure.ac
index 720500a..ba4381d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -3068,11 +3068,11 @@ ENABLE_BOEHM_PARALLEL_MARK=
 # This following variable is used for passing any other C compiler
 # flags to the version of the Boehm GC built in parallel grades.
 #
-BOEHM_MISC_CFLAGS_FOR_THREADS=
+BOEHM_CFLAGS_FOR_THREADS="-DGC_THREADS"
 
 case "$host" in
     *solaris*)
-        CFLAGS_FOR_THREADS="-DGC_SOLARIS_PTHREADS -D_REENTRANT"
+        CFLAGS_FOR_THREADS="-DGC_THREADS -D_REENTRANT"
         THREAD_LIBS="-lpthread -lrt -ldl"
         ENABLE_BOEHM_THREAD_LOCAL_ALLOC="-DTHREAD_LOCAL_ALLOC"
         ;;
@@ -3081,7 +3081,7 @@ case "$host" in
         # Note that for old versions of Linux / glibc,
         # you may also need to make sure that you don't
         # pass -ansi to gcc.
-        CFLAGS_FOR_THREADS="-DGC_LINUX_THREADS -D_THREAD_SAFE -D_REENTRANT"
+        CFLAGS_FOR_THREADS="-DGC_THREADS -D_THREAD_SAFE -D_REENTRANT"
         THREAD_LIBS="-lpthread -ldl"
         ENABLE_BOEHM_THREAD_LOCAL_ALLOC="-DTHREAD_LOCAL_ALLOC"
         ENABLE_BOEHM_PARALLEL_MARK="-DPARALLEL_MARK"
@@ -3092,19 +3092,23 @@ case "$host" in
         # (With the current collector these settings only appear to work
         # correctly on Linux.)
         # XXX disabled as it aborts on GC_free when --enable-gc-munmap is used
-        # BOEHM_MISC_CFLAGS_FOR_THREADS="-DHBLKSIZE=32768 -DCPP_LOG_HBLKSIZE=15"
+        # BOEHM_CFLAGS_FOR_THREADS="-DGC_THREADS -DHBLKSIZE=32768 \
+        # -DCPP_LOG_HBLKSIZE=15"
         ;;
 
     *cygwin*)
         THREAD_LIBS=""
         case "$mercury_cv_cc_type" in
             msvc)
-                CFLAGS_FOR_THREADS="-DGC_WIN32_THREADS -MD"
+                CFLAGS_FOR_THREADS="-DGC_THREADS -MD"
                 LDFLAGS_FOR_THREADS="-MD"
                 LD_LIBFLAGS_FOR_THREADS="-MD"
                 ;;
             *)
-                CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB" ;;
+                CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB"
+                BOEHM_CFLAGS_FOR_THREADS="-DGC_THREADS
+                    $WIN32_GC_THREADLIB"
+                ;;
         esac
         ;;
 
@@ -3112,7 +3116,7 @@ case "$host" in
         THREAD_LIBS=""
         case "$mercury_cv_cc_type" in
             msvc)
-                CFLAGS_FOR_THREADS="-DGC_WIN32_THREADS -MD"
+                CFLAGS_FOR_THREADS="-DGC_THREADS -MD"
                 LDFLAGS_FOR_THREADS="-MD"
                 LD_LIBFLAGS_FOR_THREADS="-MD"
                 ;;
@@ -3121,14 +3125,19 @@ case "$host" in
                 then
                     # By default the MinGW port of GCC targets the i386
                     # architecture.  We need to tell it to target a later
-                    # architecture for the GCC built-in atomic ops to be available.
+                    # architecture for the GCC built-in atomic ops to be
+                    # available.
                     CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB -march=i686"
+                    BOEHM_CFLAGS_FOR_THREADS="-DGC_THREADS
+                        $WIN32_GC_THREADLIB"
                     THREAD_LIBS="-lpthread"
                 else
                     # The compiler is unconditionally linked against the thread
                     # libraries so if pthreads is not present then we need to
                     # set THREAD_LIBS to empty in order to avoid linker errors.
                     CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB"
+                    BOEHM_CFLAGS_FOR_THREADS="-DGC_THREADS
+                        $WIN32_GC_THREADLIB"
                     THREAD_LIBS=
                 fi
                 ;;
@@ -3137,11 +3146,12 @@ case "$host" in
 
     x86_64*w64*mingw32*)
         CFLAGS_FOR_THREADS="$WIN32_GC_THREADLIB"
+        BOEHM_CFLAGS_FOR_THREADS="-DGC_THREADS $WIN32_GC_THREADLIB"
         THREAD_LIBS="-lpthread"
         ;;
 
     *apple*darwin*)
-        CFLAGS_FOR_THREADS="-DGC_DARWIN_THREADS"
+        CFLAGS_FOR_THREADS="-DGC_THREADS"
         THREAD_LIBS=""
         ;;
 
@@ -3175,6 +3185,7 @@ case "$host" in
         # (2) a port of the Boehm gc for that architecture
         # that works with threads.
         CFLAGS_FOR_THREADS=""
+        BOEHM_CFLAGS_FOR_THREADS=""
         ;;
 esac
 AC_SUBST(CFLAGS_FOR_THREADS)
@@ -3183,7 +3194,7 @@ AC_SUBST(LDFLAGS_FOR_THREADS)
 AC_SUBST(LD_LIBFLAGS_FOR_THREADS)
 AC_SUBST(ENABLE_BOEHM_THREAD_LOCAL_ALLOC)
 AC_SUBST(ENABLE_BOEHM_PARALLEL_MARK)
-AC_SUBST(BOEHM_MISC_CFLAGS_FOR_THREADS)
+AC_SUBST(BOEHM_CFLAGS_FOR_THREADS)
 
 save_LIBS="$LIBS"
 LIBS="$THREAD_LIBS"
diff --git a/library/benchmarking.m b/library/benchmarking.m
index 9163a6a..4bc718c 100644
--- a/library/benchmarking.m
+++ b/library/benchmarking.m
@@ -348,9 +348,14 @@ ML_report_stats(void)
 #ifdef MR_BOEHM_GC
     {
         char local_var;
+        struct GC_stack_base base;
 
-        fprintf(stderr, "" C Stack: %.3fk,"",
-            labs(&local_var - (char *) GC_stackbottom) / 1024.0);
+        if (GC_SUCCESS == GC_get_stack_base(&base)) {
+            fprintf(stderr, "" C Stack: %.3fk,"",
+                labs(&local_var - (char *)base.mem_base) / 1024.0);
+        } else {
+            fprintf(stderr, "" Cannot locate C stack base."");
+        }
     }
 #endif
 
@@ -386,7 +391,7 @@ ML_report_stats(void)
   #endif /* MR_MPS_GC */
   #ifdef MR_BOEHM_GC
     fprintf(stderr, ""\\n#GCs: %lu, "",
-        (unsigned long) GC_gc_no);
+        (unsigned long) GC_get_gc_no());
     if (GC_mercury_calc_gc_time) {
         /* convert from unsigned long milliseconds to float seconds */
         fprintf(stderr, ""total GC time: %.2fs, "",
diff --git a/runtime/mercury_wrapper.c b/runtime/mercury_wrapper.c
index fe887e3..a218790 100644
--- a/runtime/mercury_wrapper.c
+++ b/runtime/mercury_wrapper.c
@@ -2329,7 +2329,7 @@ MR_process_options(int argc, char **argv)
 
             case 'x':
 #ifdef MR_BOEHM_GC
-                GC_dont_gc = MR_TRUE;
+                GC_disable();
 #endif
                 break;
 
diff --git a/scripts/prepare_install_dir.in b/scripts/prepare_install_dir.in
index bd1116f..e57824d 100644
--- a/scripts/prepare_install_dir.in
+++ b/scripts/prepare_install_dir.in
@@ -42,24 +42,23 @@ mkdir ${installdir}/boehm_gc/Mac_files
 mkdir ${installdir}/boehm_gc/cord
 mkdir ${installdir}/boehm_gc/include
 mkdir ${installdir}/boehm_gc/include/private
+mkdir ${installdir}/boehm_gc/src
+mkdir ${installdir}/boehm_gc/tools
 cp boehm_gc/NT_MAKEFILE ${installdir}/boehm_gc
 cp boehm_gc/*.[Mm]ak ${installdir}/boehm_gc
 cp boehm_gc/Makefile* ${installdir}/boehm_gc
 cp boehm_gc/Mmake* ${installdir}/boehm_gc
-cp boehm_gc/ac* ${installdir}/boehm_gc
 cp boehm_gc/*.cc ${installdir}/boehm_gc
 cp boehm_gc/*.cpp ${installdir}/boehm_gc
 cp boehm_gc/*.[chsS] ${installdir}/boehm_gc
-cp boehm_gc/Mac_files/*.[ch] ${installdir}/boehm_gc/Mac_files
 cp boehm_gc/cord/*.[ch] ${installdir}/boehm_gc/cord
 cp boehm_gc/include/*.[ch] ${installdir}/boehm_gc/include
 cp boehm_gc/include/private/*.[ch] ${installdir}/boehm_gc/include/private
+cp boehm_gc/src/*.[chsS] ${installdir}/boehm_gc/src
+cp boehm_gc/tools/*.[ch] ${installdir}/boehm_gc/tools
 cp boehm_gc/build_atomic_ops.sh* ${installdir}/boehm_gc
-cp -Rp boehm_gc/libatomic_ops-*[0-9] ${installdir}/boehm_gc
 cp -Rp boehm_gc/libatomic_ops ${installdir}/boehm_gc
 cp -Rp boehm_gc/extra ${installdir}/boehm_gc
-rm -fr ${installdir}/boehm_gc/libatomic_ops-*[0-9]/src/*.o
-rm -fr ${installdir}/boehm_gc/libatomic_ops-*[0-9]/src/*.a
 rm -fr ${installdir}/boehm_gc/libatomic_ops/src/*.o
 rm -fr ${installdir}/boehm_gc/libatomic_ops/src/*.a
 mkdir ${installdir}/runtime
diff --git a/tools/bootcheck b/tools/bootcheck
index a744d47..c93bb55 100755
--- a/tools/bootcheck
+++ b/tools/bootcheck
@@ -777,15 +777,14 @@ then
             cp $root/boehm_gc/Makefile.direct .
             cp $root/boehm_gc/NT_MAKEFILE .
             cp $root/boehm_gc/gc.mak .
-            cp $root/boehm_gc/ac* .
             cp $root/boehm_gc/gc_cpp.cc .
             cp $root/boehm_gc/gc_cpp.cpp .
             cp $root/boehm_gc/build_atomic_ops.sh* .
             cp -r $root/boehm_gc/cord .
-            cp -r $root/boehm_gc/Mac_files .
-            cp -r $root/boehm_gc/libatomic_ops-*[0-9] .
             cp -r $root/boehm_gc/libatomic_ops .
             cp -r $root/boehm_gc/extra .
+            cp -r $root/boehm_gc/src .
+            cp -r $root/boehm_gc/tools .
             cd $root/$stage2dir
         else
             $LN_S $root/boehm_gc .
diff --git a/util/mkinit.c b/util/mkinit.c
index 0309215..741f60b 100644
--- a/util/mkinit.c
+++ b/util/mkinit.c
@@ -383,10 +383,15 @@ static const char mercury_funcs1[] =
     "   ** For the Boehm GC, if the stackbottom argument is NULL then\n"
     "   ** do not explicitly register the bottom of the stack, but\n"
     "   ** let the collector determine an appropriate value itself.\n"
+    "   **\n"
+    "   ** Boehm GC 7.4.2 deprecates the use of GC_stackbottom and\n"
+    "   ** prohibits the use of the alterantive GC_register_my_thread()\n"
+    "   ** for the primordial thread. Therefore we no-longer attempt to\n"
+    "   ** register the bottom of the C stack except on AIX.\n"
     "   */\n"
     "   #if defined(MR_HGC)\n"
     "    MR_hgc_set_stack_bot(stackbottom);\n"
-    "   #elif defined(MR_BOEHM_GC)\n"
+    "   #elif defined(MR_BOEHM_GC) && defined(_AIX)\n"
     "       if (stackbottom != NULL) {\n"
     "           GC_stackbottom = stackbottom;\n"
     "       }\n"
-- 
2.0.0




More information about the reviews mailing list