summaryrefslogtreecommitdiff
path: root/source/l/gc
diff options
context:
space:
mode:
Diffstat (limited to 'source/l/gc')
-rwxr-xr-xsource/l/gc/gc.SlackBuild69
-rw-r--r--source/l/gc/gc.test-stack-infinite-loop.diff67
-rw-r--r--source/l/gc/noelision.patch127
-rw-r--r--source/l/gc/refer_to_GC_setup_mark_lock_only_in_PARALLEL_MARK_code.patch26
-rw-r--r--source/l/gc/slack-desc2
5 files changed, 204 insertions, 87 deletions
diff --git a/source/l/gc/gc.SlackBuild b/source/l/gc/gc.SlackBuild
index 70c9595a..186f3987 100755
--- a/source/l/gc/gc.SlackBuild
+++ b/source/l/gc/gc.SlackBuild
@@ -1,6 +1,7 @@
#!/bin/sh
-# Copyright 2013 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2013, 2014, 2015 Patrick J. Volkerding, Sebeka, MN, USA
+# Copyright 2014 Heinz Wiesinger, Amsterdam, NL
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
@@ -23,12 +24,12 @@
PKGNAM=gc
VERSION=${VERSION:-$(echo $PKGNAM-*.tar.xz | rev | cut -f 3- -d . | cut -f 1 -d - | rev)}
-BUILD=${BUILD:-1}
+BUILD=${BUILD:-3}
# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
case "$( uname -m )" in
- i?86) export ARCH=i486 ;;
+ i?86) export ARCH=i586 ;;
arm*) export ARCH=arm ;;
# Unless $ARCH is already set, use uname -m for all other archs:
*) export ARCH=$( uname -m ) ;;
@@ -43,8 +44,8 @@ PKG=$TMP/package-$PKGNAM
rm -rf $PKG
mkdir -p $PKG/usr
-if [ "$ARCH" = "i486" ]; then
- SLKCFLAGS="-O2 -march=i486 -mtune=i686"
+if [ "$ARCH" = "i586" ]; then
+ SLKCFLAGS="-O2 -march=i586 -mtune=i686"
LIBDIRSUFFIX=""
elif [ "$ARCH" = "s390" ]; then
SLKCFLAGS="-O2"
@@ -61,6 +62,8 @@ cd $TMP
rm -rf $PKGNAM-$VERSION $PKGNAM-$(echo $VERSION | cut -b 1-3)
tar xvf $CWD/$PKGNAM-$VERSION.tar.xz || exit 1
cd $PKGNAM-$VERSION 2> /dev/null || cd $PKGNAM-$(echo $VERSION | cut -b 1-3) || exit 1
+tar xvf $CWD/libatomic_ops-$VERSION.tar.xz || exit 1
+mv libatomic_ops-$VERSION libatomic_ops
chown -R root:root .
find . \
\( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \
@@ -68,17 +71,29 @@ find . \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
-exec chmod 644 {} \;
-zcat $CWD/gc.test-stack-infinite-loop.diff.gz | patch -p1 --verbose || exit 1
+# https://github.com/ivmai/bdwgc/pull/51
+zcat $CWD/noelision.patch.gz | patch -p1 --verbose || exit 1
-CFLAGS="$SLKCFLAGS" \
+# Guarding GC_setup_mark_lock usage with PARALLEL_MARK is required to avoid
+# an undefined reference in non-PARALLEL_MARK configurations:
+zcat $CWD/refer_to_GC_setup_mark_lock_only_in_PARALLEL_MARK_code.patch.gz | patch -p0 --verbose || exit 1
+
+sed -i 's#pkgdata#doc#' doc/doc.am
+sed -i 's#pkgdata#doc#' libatomic_ops/Makefile.am
+sed -i 's#pkgdata#doc#' libatomic_ops/doc/Makefile.am
+
+autoreconf -vif
+automake --add-missing
+
+# See bugzilla.redhat.com/689877 for -DUSE_GET_STACKBASE_FOR_MAIN
+
+CFLAGS="$SLKCFLAGS -DUSE_GET_STACKBASE_FOR_MAIN" \
./configure \
--prefix=/usr \
--libdir=/usr/lib${LIBDIRSUFFIX} \
--infodir=/usr/info \
--mandir=/usr/man \
- --disable-static \
--disable-dependency-tracking \
- --disable-static \
--enable-cplusplus \
--enable-large-config \
--enable-parallel-mark \
@@ -86,10 +101,32 @@ CFLAGS="$SLKCFLAGS" \
--with-libatomic-ops=no \
--build=$ARCH-slackware-linux
+# NOTE: Using --disable-static exports a subset of symbols, and has caused
+# some things that use gc to break. So it is recommended to build the static
+# libraries and then remove them before packaging.
+
# Does not like parallel make...
make $NUMJOBS || make || exit 1
make install DESTDIR=$PKG || exit 1
+mkdir -p $PKG/usr/man/man3
+sed -i -e 's/GC_MALLOC 1L/gc 3/' doc/gc.man
+install -m 644 doc/gc.man $PKG/usr/man/man3/gc.3
+
+# Install libatomic_ops
+cd libatomic_ops
+ make install DESTDIR=$PKG || exit 1
+cd -
+
+# Remove static libraries that we don't want in the package, and fix the
+# .la files to remove the references to them:
+( cd $PKG/usr/lib${LIBDIRSUFFIX}
+ for static in libcord libgc libgccpp ; do
+ rm --verbose ${static}.a
+ sed -i "s#old_library='.*'#old_library=''#g" ${static}.la
+ done
+)
+
find $PKG | xargs file | grep -e "executable" -e "shared object" | grep ELF \
| cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null
@@ -108,18 +145,12 @@ if [ -d $PKG/usr/man ]; then
)
fi
-# Compress info files, if any:
-if [ -d $PKG/usr/info ]; then
- ( cd $PKG/usr/info
- rm -f dir
- gzip -9 *
- )
-fi
-
mkdir -p $PKG/usr/doc/$PKGNAM-$VERSION
+mv $PKG/usr/share/doc/* $PKG/usr/doc/$PKGNAM-$VERSION/
+rm -f $PKG/usr/doc/$PKGNAM-$VERSION/gc/gc.man
+rm -rf $PKG/usr/share
cp -a \
- AUTHORS COPYING* FAQ GUILE-VERSION \
- HACKING INSTALL LICENSE NEWS README* THANKS \
+ README.QUICK TODO \
$PKG/usr/doc/$PKGNAM-$VERSION
mkdir -p $PKG/install
diff --git a/source/l/gc/gc.test-stack-infinite-loop.diff b/source/l/gc/gc.test-stack-infinite-loop.diff
deleted file mode 100644
index 49a6046e..00000000
--- a/source/l/gc/gc.test-stack-infinite-loop.diff
+++ /dev/null
@@ -1,67 +0,0 @@
-diff --git a/libatomic_ops/tests/test_atomic.c b/libatomic_ops/tests/test_atomic.c
-index e354024..b8906e9 100644
---- a/libatomic_ops/tests/test_atomic.c
-+++ b/libatomic_ops/tests/test_atomic.c
-@@ -77,7 +77,10 @@ void * acqrel_thr(void *id)
- {
- AO_t my_counter1;
- if (me != 1)
-- fprintf(stderr, "acqrel test: too many threads\n");
-+ {
-+ fprintf(stderr, "acqrel test: too many threads\n");
-+ abort();
-+ }
- my_counter1 = AO_load(&counter1);
- AO_store(&counter1, my_counter1 + 1);
- AO_store_release_write(&counter2, my_counter1 + 1);
-diff --git a/libatomic_ops/tests/test_malloc.c b/libatomic_ops/tests/test_malloc.c
-index a1f4179..a19ffd5 100644
---- a/libatomic_ops/tests/test_malloc.c
-+++ b/libatomic_ops/tests/test_malloc.c
-@@ -151,6 +151,7 @@ void * run_one_test(void * arg) {
- if (0 == p) {
- # ifdef HAVE_MMAP
- fprintf(stderr, "AO_malloc(%d) failed\n", LARGE_OBJ_SIZE);
-+ abort();
- # else
- fprintf(stderr, "AO_malloc(%d) failed: This is normal without mmap\n",
- LARGE_OBJ_SIZE);
-diff --git a/libatomic_ops/tests/test_stack.c b/libatomic_ops/tests/test_stack.c
-index bf3180d..e654c35 100644
---- a/libatomic_ops/tests/test_stack.c
-+++ b/libatomic_ops/tests/test_stack.c
-@@ -97,14 +97,23 @@ void check_list(int n)
- p = (list_element *)AO_REAL_NEXT_PTR(p -> next))
- {
- if (p -> data > n || p -> data <= 0)
-- fprintf(stderr, "Found erroneous list element %d\n", p -> data);
-+ {
-+ fprintf(stderr, "Found erroneous list element %d\n", i);
-+ abort();
-+ }
- if (marks[p -> data] != 0)
-- fprintf(stderr, "Found duplicate list element %d\n", p -> data);
-+ {
-+ fprintf(stderr, "Found duplicate list element %d\n", i);
-+ abort();
-+ }
- marks[p -> data] = 1;
- }
- for (i = 1; i <= n; ++i)
- if (marks[i] != 1)
-- fprintf(stderr, "Missing list element %d\n", i);
-+ {
-+ fprintf(stderr, "Missing list element %d\n", i);
-+ abort();
-+ }
- }
-
- volatile AO_t ops_performed = 0;
-@@ -218,6 +227,7 @@ int main(int argc, char **argv)
- int code;
- if ((code = pthread_join(thread[i], 0)) != 0) {
- fprintf(stderr, "Thread join failed %u\n", code);
-+ abort();
- }
- }
- times[nthreads][exper_n] = (unsigned long)(get_msecs() - start_time);
diff --git a/source/l/gc/noelision.patch b/source/l/gc/noelision.patch
new file mode 100644
index 00000000..0e1515ea
--- /dev/null
+++ b/source/l/gc/noelision.patch
@@ -0,0 +1,127 @@
+diff --git c/include/private/gc_priv.h w/include/private/gc_priv.h
+index 0ad92fc..b877fac 100644
+--- c/include/private/gc_priv.h
++++ w/include/private/gc_priv.h
+@@ -2368,6 +2368,7 @@ GC_INNER ptr_t GC_store_debug_info(ptr_t p, word sz, const char *str,
+ /* GC_notify_all_builder() is called when GC_fl_builder_count */
+ /* reaches 0. */
+
++ GC_INNER void GC_setup_mark_lock(void);
+ GC_INNER void GC_acquire_mark_lock(void);
+ GC_INNER void GC_release_mark_lock(void);
+ GC_INNER void GC_notify_all_builder(void);
+diff --git c/include/private/gcconfig.h w/include/private/gcconfig.h
+index c753cc2..b5ed075 100644
+--- c/include/private/gcconfig.h
++++ w/include/private/gcconfig.h
+@@ -1357,6 +1357,11 @@
+ # define PREFETCH_FOR_WRITE(x) \
+ __asm__ __volatile__ ("prefetchw %0" : : "m"(*(char *)(x)))
+ # endif
++# if defined(__GLIBC__)
++ /* Workaround lock elision implementation for some glibc. */
++# define GLIBC_2_19_TSX_BUG
++# include <gnu/libc-version.h> /* for gnu_get_libc_version() */
++# endif
+ # endif
+ # ifdef CYGWIN32
+ # define OS_TYPE "CYGWIN32"
+@@ -2257,6 +2262,11 @@
+ /* FIXME: This seems to be fixed in GLibc v2.14. */
+ # define GETCONTEXT_FPU_EXCMASK_BUG
+ # endif
++# if defined(__GLIBC__)
++ /* Workaround lock elision implementation for some glibc. */
++# define GLIBC_2_19_TSX_BUG
++# include <gnu/libc-version.h> /* for gnu_get_libc_version() */
++# endif
+ # endif
+ # ifdef DARWIN
+ # define OS_TYPE "DARWIN"
+diff --git c/include/private/pthread_support.h w/include/private/pthread_support.h
+index 525a9aa..017f194 100644
+--- c/include/private/pthread_support.h
++++ w/include/private/pthread_support.h
+@@ -148,6 +148,8 @@ GC_INNER_PTHRSTART GC_thread GC_start_rtn_prepare_thread(
+ struct GC_stack_base *sb, void *arg);
+ GC_INNER_PTHRSTART void GC_thread_exit_proc(void *);
+
++GC_INNER void GC_setup_mark_lock(void);
++
+ #endif /* GC_PTHREADS && !GC_WIN32_THREADS */
+
+ #endif /* GC_PTHREAD_SUPPORT_H */
+diff --git c/misc.c w/misc.c
+index df434a1..3aca41d 100644
+--- c/misc.c
++++ w/misc.c
+@@ -875,6 +875,9 @@ GC_API void GC_CALL GC_init(void)
+ /* else */ InitializeCriticalSection (&GC_allocate_ml);
+ }
+ # endif /* GC_WIN32_THREADS */
++# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
++ GC_setup_mark_lock();
++# endif /* GC_PTHREADS */
+ # if (defined(MSWIN32) || defined(MSWINCE)) && defined(THREADS)
+ InitializeCriticalSection(&GC_write_cs);
+ # endif
+diff --git c/pthread_support.c w/pthread_support.c
+index c00b93d..8a7c50b 100644
+--- c/pthread_support.c
++++ w/pthread_support.c
+@@ -1979,6 +1979,55 @@ GC_INNER void GC_lock(void)
+
+ static pthread_cond_t builder_cv = PTHREAD_COND_INITIALIZER;
+
++#ifdef GLIBC_2_19_TSX_BUG
++ /* Parse string like <major>[.<minor>[<tail>]] and return major value. */
++ static int parse_version(int *pminor, const char *pverstr) {
++ char *endp;
++ unsigned long value = strtoul(pverstr, &endp, 10);
++ int major = (int)value;
++
++ if (major < 0 || (char *)pverstr == endp || (unsigned)major != value) {
++ /* Parse error */
++ return -1;
++ }
++ if (*endp != '.') {
++ /* No minor part. */
++ *pminor = -1;
++ } else {
++ value = strtoul(endp + 1, &endp, 10);
++ *pminor = (int)value;
++ if (*pminor < 0 || (unsigned)(*pminor) != value) {
++ return -1;
++ }
++ }
++ return major;
++ }
++#endif /* GLIBC_2_19_TSX_BUG */
++
++GC_INNER void GC_setup_mark_lock(void)
++{
++# ifdef GLIBC_2_19_TSX_BUG
++ pthread_mutexattr_t mattr;
++ int glibc_minor = -1;
++ int glibc_major = parse_version(&glibc_minor, gnu_get_libc_version());
++
++ if (glibc_major > 2 || (glibc_major == 2 && glibc_minor >= 19)) {
++ /* TODO: disable this workaround for glibc with fixed TSX */
++ /* This disables lock elision to workaround a bug in glibc 2.19+ */
++ if (0 != pthread_mutexattr_init(&mattr)) {
++ ABORT("pthread_mutexattr_init failed");
++ }
++ if (0 != pthread_mutexattr_settype(&mattr, PTHREAD_MUTEX_NORMAL)) {
++ ABORT("pthread_mutexattr_settype failed");
++ }
++ if (0 != pthread_mutex_init(&mark_mutex, &mattr)) {
++ ABORT("pthread_mutex_init failed");
++ }
++ pthread_mutexattr_destroy(&mattr);
++ }
++# endif
++}
++
+ GC_INNER void GC_acquire_mark_lock(void)
+ {
+ GC_ASSERT(GC_mark_lock_holder != NUMERIC_THREAD_ID(pthread_self()));
diff --git a/source/l/gc/refer_to_GC_setup_mark_lock_only_in_PARALLEL_MARK_code.patch b/source/l/gc/refer_to_GC_setup_mark_lock_only_in_PARALLEL_MARK_code.patch
new file mode 100644
index 00000000..6e63c777
--- /dev/null
+++ b/source/l/gc/refer_to_GC_setup_mark_lock_only_in_PARALLEL_MARK_code.patch
@@ -0,0 +1,26 @@
+Guarding GC_setup_mark_lock usage with PARALLEL_MARK is required to avoid
+an undefined reference in non-PARALLEL_MARK configurations:
+commit 4c8e0dc234e671c4d64ffab9d4f94b6cd8cc2f63
+Author: Thomas Schwinge < thomas at codesourcery.com >
+Date: Mon Sep 22 13:36:00 2014 +0200
+ Refer to GC_setup_mark_lock only in PARALLEL_MARK code.
+
+ ./.libs/libgc.so: undefined reference to `GC_setup_mark_lock'
+
+ * misc.c (GC_init): Guard GC_setup_mark_lock usage.
+---
+ misc.c | 2 +-
+ 1 file changed, 1 insertion(+), 1 deletion(-)
+diff --git misc.c misc.c
+index 41bd3f4..721a999 100644
+--- misc.c
++++ misc.c
+@@ -889,7 +889,7 @@ GC_API void GC_CALL GC_init(void)
+ /* else */ InitializeCriticalSection (&GC_allocate_ml);
+ }
+ # endif /* GC_WIN32_THREADS */
+-# if defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
++# if defined(PARALLEL_MARK) && defined(GC_PTHREADS) && !defined(GC_WIN32_THREADS)
+ GC_setup_mark_lock();
+ # endif /* GC_PTHREADS */
+ # if (defined(MSWIN32) || defined(MSWINCE)) && defined(THREADS)
diff --git a/source/l/gc/slack-desc b/source/l/gc/slack-desc
index 4e747f8f..9fce3ef0 100644
--- a/source/l/gc/slack-desc
+++ b/source/l/gc/slack-desc
@@ -11,7 +11,7 @@ gc:
gc: The Boehm-Demers-Weiser conservative garbage collector can be used as
gc: a garbage collecting replacement for C malloc or C++ new.
gc:
-gc: Homepage: http://www.hpl.hp.com/personal/Hans_Boehm/gc/
+gc: Homepage: http://www.hboehm.info/gc/
gc:
gc:
gc: