summaryrefslogtreecommitdiff
path: root/libobjc
diff options
context:
space:
mode:
authorMatthias Klose <doko@ubuntu.com>2016-11-30 00:12:45 +0000
committerMatthias Klose <doko@gcc.gnu.org>2016-11-30 00:12:45 +0000
commit114bf3f172d0f215a576d8964b95c0a4608563e0 (patch)
tree612b3ff1d05c431b7d883db262d72acacab4b0d8 /libobjc
parenta2b403c8bb69250b321c9d56e38f5f3537a1e696 (diff)
downloadgcc-114bf3f172d0f215a576d8964b95c0a4608563e0.tar.gz
Makefile.def: Remove reference to boehm-gc target module.
<toplevel> 2016-11-30 Matthias Klose <doko@ubuntu.com> * Makefile.def: Remove reference to boehm-gc target module. * configure.ac: Include pkg.m4, check for --with-target-bdw-gc options and for the bdw-gc pkg-config module. * configure: Regenerate. * Makefile.in: Regenerate. gcc/ 2016-11-30 Matthias Klose <doko@ubuntu.com> * doc/install.texi: Document configure options --enable-objc-gc and --with-target-bdw-gc. config/ 2016-11-30 Matthias Klose <doko@ubuntu.com> * pkg.m4: New file. libobjc/ 2016-11-30 Matthias Klose <doko@ubuntu.com> * configure.ac (--enable-objc-gc): Allow to configure with a system provided boehm-gc. * configure: Regenerate. * Makefile.in (OBJC_BOEHM_GC_LIBS): Get value from configure. * gc.c: Include system bdw-gc headers. * memory.c: Likewise * objects.c: Likewise boehm-gc/ 2016-11-30 Matthias Klose <doko@ubuntu.com> Remove From-SVN: r242985
Diffstat (limited to 'libobjc')
-rw-r--r--libobjc/ChangeLog10
-rw-r--r--libobjc/Makefile.in4
-rwxr-xr-xlibobjc/configure385
-rw-r--r--libobjc/configure.ac176
-rw-r--r--libobjc/gc.c4
-rw-r--r--libobjc/memory.c2
-rw-r--r--libobjc/objects.c4
7 files changed, 526 insertions, 59 deletions
diff --git a/libobjc/ChangeLog b/libobjc/ChangeLog
index 042d076cf2a..d38ac75e950 100644
--- a/libobjc/ChangeLog
+++ b/libobjc/ChangeLog
@@ -1,3 +1,13 @@
+2016-11-30 Matthias Klose <doko@ubuntu.com>
+
+ * configure.ac (--enable-objc-gc): Allow to configure with a
+ system provided boehm-gc.
+ * configure: Regenerate.
+ * Makefile.in (OBJC_BOEHM_GC_LIBS): Get value from configure.
+ * gc.c: Include system bdw-gc headers.
+ * memory.c: Likewise
+ * objects.c: Likewise
+
2016-11-15 Matthias Klose <doko@ubuntu.com>
* aclocal.m4: Regenerate.
diff --git a/libobjc/Makefile.in b/libobjc/Makefile.in
index b61823c5827..3329a5cb3fb 100644
--- a/libobjc/Makefile.in
+++ b/libobjc/Makefile.in
@@ -47,8 +47,6 @@ extra_ldflags_libobjc = @extra_ldflags_libobjc@
top_builddir = .
--include ../boehm-gc/threads.mk
-
libdir = $(exec_prefix)/lib
libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version)
@@ -95,7 +93,7 @@ LIBTOOL_CLEAN = $(LIBTOOL) --mode=clean
OBJC_GCFLAGS=@OBJC_GCFLAGS@
OBJC_BOEHM_GC=@OBJC_BOEHM_GC@
OBJC_BOEHM_GC_INCLUDES=@OBJC_BOEHM_GC_INCLUDES@
-OBJC_BOEHM_GC_LIBS=../boehm-gc/libgcjgc_convenience.la $(thread_libs_and_flags)
+OBJC_BOEHM_GC_LIBS=@OBJC_BOEHM_GC_LIBS@
INCLUDES = -I$(srcdir)/$(MULTISRCTOP)../gcc \
-I$(srcdir)/$(MULTISRCTOP)../gcc/config \
diff --git a/libobjc/configure b/libobjc/configure
index b692eedeff7..43a68de9977 100755
--- a/libobjc/configure
+++ b/libobjc/configure
@@ -600,6 +600,13 @@ ac_includes_default="\
ac_subst_vars='LTLIBOBJS
LIBOBJS
+OBJC_BOEHM_GC_LIBS
+OBJC_BOEHM_GC_INCLUDES
+OBJC_BOEHM_GC
+OBJC_GCFLAGS
+PKG_CONFIG_LIBDIR
+PKG_CONFIG_PATH
+PKG_CONFIG
SET_MAKE
CPP
OTOOL64
@@ -654,9 +661,6 @@ host_vendor
host_cpu
host
multi_basedir
-OBJC_BOEHM_GC_INCLUDES
-OBJC_BOEHM_GC
-OBJC_GCFLAGS
VERSION
target_subdir
host_subdir
@@ -711,7 +715,6 @@ with_build_libsubdir
with_target_subdir
with_cross_host
enable_version_specific_runtime_libs
-enable_objc_gc
enable_multilib
enable_maintainer_mode
enable_shared
@@ -721,12 +724,19 @@ enable_fast_install
with_gnu_ld
enable_libtool_lock
enable_tls
+enable_objc_gc
+with_target_bdw_gc
+with_target_bdw_gc_include
+with_target_bdw_gc_lib
'
ac_precious_vars='build_alias
host_alias
target_alias
CPP
-CPPFLAGS'
+CPPFLAGS
+PKG_CONFIG
+PKG_CONFIG_PATH
+PKG_CONFIG_LIBDIR'
# Initialize some variables set by options.
@@ -1343,8 +1353,6 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory
- --enable-objc-gc enable the use of Boehm's garbage collector with
- the GNU Objective-C runtime.
--enable-multilib build many library versions (default)
--enable-maintainer-mode enable make rules and dependencies not useful
(and sometimes confusing) to the casual installer
@@ -1354,6 +1362,8 @@ Optional Features:
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-tls Use thread-local storage [default=yes]
+ --enable-objc-gc enable use of Boehm's garbage collector with the GNU
+ Objective-C runtime
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@@ -1365,6 +1375,16 @@ Optional Packages:
--with-pic try to use only PIC/non-PIC objects [default=use
both]
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
+ --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
Some influential environment variables:
CC C compiler command
@@ -1375,6 +1395,11 @@ Some influential environment variables:
CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
+ PKG_CONFIG path to pkg-config utility
+ PKG_CONFIG_PATH
+ directories to add to pkg-config's search path
+ PKG_CONFIG_LIBDIR
+ path overriding pkg-config's built-in search path
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
@@ -2314,28 +2339,6 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $version_specific_libs" >&5
$as_echo "$version_specific_libs" >&6; }
-# Check whether --enable-objc-gc was given.
-if test "${enable_objc_gc+set}" = set; then :
- enableval=$enable_objc_gc; case $enable_objc_gc in
- no)
- OBJC_GCFLAGS=''
- OBJC_BOEHM_GC=''
- OBJC_BOEHM_GC_INCLUDES=''
- ;;
- *)
- OBJC_GCFLAGS='-DOBJC_WITH_GC=1'
- OBJC_BOEHM_GC='libobjc_gc$(libsuffix).la'
- OBJC_BOEHM_GC_INCLUDES='-I$(top_srcdir)/../boehm-gc/include -I../boehm-gc/include'
- ;;
-esac
-else
- OBJC_GCFLAGS=''; OBJC_BOEHM_GC=''; OBJC_BOEHM_GC_INCLUDES=''
-fi
-
-
-
-
-
# -----------
# Directories
# -----------
@@ -10598,7 +10601,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10601 "configure"
+#line 10604 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -10704,7 +10707,7 @@ else
lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
lt_status=$lt_dlunknown
cat > conftest.$ac_ext <<_LT_EOF
-#line 10707 "configure"
+#line 10710 "configure"
#include "confdefs.h"
#if HAVE_DLFCN_H
@@ -11499,6 +11502,326 @@ $as_echo "#define HAVE_BITFIELD_TYPE_MATTERS 1" >>confdefs.h
fi
+# -----------
+# boehm-gc
+# -----------
+
+# Check whether --enable-objc-gc was given.
+if test "${enable_objc_gc+set}" = set; then :
+ enableval=$enable_objc_gc;
+fi
+
+
+# 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 "$enable_objc_gc" in
+no)
+ use_bdw_gc=no
+ ;;
+*)
+ { $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
+
+
+
+
+
+
+
+if test "x$ac_cv_env_PKG_CONFIG_set" != "xset"; then
+ if test -n "$ac_tool_prefix"; then
+ # Extract the first word of "${ac_tool_prefix}pkg-config", so it can be a program name with args.
+set dummy ${ac_tool_prefix}pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_PKG_CONFIG+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+PKG_CONFIG=$ac_cv_path_PKG_CONFIG
+if test -n "$PKG_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
+$as_echo "$PKG_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_path_PKG_CONFIG"; then
+ ac_pt_PKG_CONFIG=$PKG_CONFIG
+ # Extract the first word of "pkg-config", so it can be a program name with args.
+set dummy pkg-config; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_ac_pt_PKG_CONFIG+set}" = set; then :
+ $as_echo_n "(cached) " >&6
+else
+ case $ac_pt_PKG_CONFIG in
+ [\\/]* | ?:[\\/]*)
+ ac_cv_path_ac_pt_PKG_CONFIG="$ac_pt_PKG_CONFIG" # Let the user override the test with a path.
+ ;;
+ *)
+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+ IFS=$as_save_IFS
+ test -z "$as_dir" && as_dir=.
+ for ac_exec_ext in '' $ac_executable_extensions; do
+ if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+ ac_cv_path_ac_pt_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
+ $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+ break 2
+ fi
+done
+ done
+IFS=$as_save_IFS
+
+ ;;
+esac
+fi
+ac_pt_PKG_CONFIG=$ac_cv_path_ac_pt_PKG_CONFIG
+if test -n "$ac_pt_PKG_CONFIG"; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_pt_PKG_CONFIG" >&5
+$as_echo "$ac_pt_PKG_CONFIG" >&6; }
+else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+ if test "x$ac_pt_PKG_CONFIG" = x; then
+ PKG_CONFIG=""
+ else
+ case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+ PKG_CONFIG=$ac_pt_PKG_CONFIG
+ fi
+else
+ PKG_CONFIG="$ac_cv_path_PKG_CONFIG"
+fi
+
+fi
+if test -n "$PKG_CONFIG"; then
+ _pkg_min_version=0.9.0
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking pkg-config is at least version $_pkg_min_version" >&5
+$as_echo_n "checking pkg-config is at least version $_pkg_min_version... " >&6; }
+ if $PKG_CONFIG --atleast-pkgconfig-version $_pkg_min_version; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+ else
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+ PKG_CONFIG=""
+ fi
+fi
+if test -n "$PKG_CONFIG" && \
+ { { $as_echo "$as_me:${as_lineno-$LINENO}: \$PKG_CONFIG --exists --print-errors \"bdw-gc\""; } >&5
+ ($PKG_CONFIG --exists --print-errors "bdw-gc") 2>&5
+ ac_status=$?
+ $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+ test $ac_status = 0; }; then
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: using bdw-gc pkg-config module" >&5
+$as_echo "using bdw-gc pkg-config module" >&6; }
+else
+ as_fn_error "no --with-target-bdw-gc options and no bdw-gc pkg-config module found" "$LINENO" 5
+fi
+ 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 ;;
+ 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-include" "$LINENO" 5
+ fi
+ bdw_inc_dir="$bdw_val"
+ 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"
+ BDW_GC_LIBS="-L$bdw_lib_dir -lgc"
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: found" >&5
+$as_echo "found" >&6; }
+ fi
+
+ { $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 $BDW_GC_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. */
+#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_echo "$as_me:${as_lineno-$LINENO}: WARNING: system bdw-gc not found, not building libobjc_gc" >&5
+$as_echo "$as_me: WARNING: system bdw-gc not found, not building libobjc_gc" >&2;}
+ use_bdw_gc=no
+ elif test x$enable_objc_gc = xyes && test x$system_bdw_gc_found = xno; then
+ as_fn_error "system bdw-gc required but 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
+
+if test "$use_bdw_gc" = no; then
+ OBJC_GCFLAGS=''
+ OBJC_BOEHM_GC=''
+ OBJC_BOEHM_GC_INCLUDES=''
+ OBJC_BOEHM_GC_LIBS=''
+else
+ OBJC_GCFLAGS='-DOBJC_WITH_GC=1'
+ OBJC_BOEHM_GC='libobjc_gc$(libsuffix).la'
+ OBJC_BOEHM_GC_INCLUDES=$BDW_GC_CFLAGS
+ OBJC_BOEHM_GC_LIBS=$BDW_GC_LIBS
+fi
+
+
+
+
+
# ------
# Output
# ------
diff --git a/libobjc/configure.ac b/libobjc/configure.ac
index 9dbc16cb9a8..0497836a964 100644
--- a/libobjc/configure.ac
+++ b/libobjc/configure.ac
@@ -18,6 +18,8 @@
#along with GCC; see the file COPYING3. If not see
#<http://www.gnu.org/licenses/>.
+m4_include([../config/pkg.m4])
+
AC_PREREQ(2.64)
AC_INIT(package-unused, version-unused,, libobjc)
AC_CONFIG_SRCDIR([objc/objc.h])
@@ -57,26 +59,6 @@ AC_ARG_ENABLE(version-specific-runtime-libs,
[version_specific_libs=no])
AC_MSG_RESULT($version_specific_libs)
-AC_ARG_ENABLE(objc-gc,
-[ --enable-objc-gc enable the use of Boehm's garbage collector with
- the GNU Objective-C runtime.],
-[case $enable_objc_gc in
- no)
- OBJC_GCFLAGS=''
- OBJC_BOEHM_GC=''
- OBJC_BOEHM_GC_INCLUDES=''
- ;;
- *)
- OBJC_GCFLAGS='-DOBJC_WITH_GC=1'
- OBJC_BOEHM_GC='libobjc_gc$(libsuffix).la'
- OBJC_BOEHM_GC_INCLUDES='-I$(top_srcdir)/../boehm-gc/include -I../boehm-gc/include'
- ;;
-esac],
-[OBJC_GCFLAGS=''; OBJC_BOEHM_GC=''; OBJC_BOEHM_GC_INCLUDES=''])
-AC_SUBST(OBJC_GCFLAGS)
-AC_SUBST(OBJC_BOEHM_GC)
-AC_SUBST(OBJC_BOEHM_GC_INCLUDES)
-
# -----------
# Directories
# -----------
@@ -214,6 +196,160 @@ GCC_CHECK_TLS
gt_BITFIELD_TYPE_MATTERS
+# -----------
+# boehm-gc
+# -----------
+
+AC_ARG_ENABLE(objc-gc,
+[AS_HELP_STRING([--enable-objc-gc],
+ [enable use of Boehm's garbage collector with the
+ GNU Objective-C runtime])])
+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 "$enable_objc_gc" in
+no)
+ use_bdw_gc=no
+ ;;
+*)
+ 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, fall back to the bdw-gc pkg-config module
+ PKG_CHECK_EXISTS(bdw-gc,
+ AC_MSG_RESULT([using bdw-gc pkg-config module]),
+ AC_MSG_ERROR([no --with-target-bdw-gc options and no bdw-gc pkg-config module found]))
+ 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 ;;
+ 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-include])
+ fi
+ bdw_inc_dir="$bdw_val"
+ 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"
+ BDW_GC_LIBS="-L$bdw_lib_dir -lgc"
+ AC_MSG_RESULT([found])
+ fi
+
+ AC_MSG_CHECKING([for system boehm-gc])
+ save_CFLAGS=$CFLAGS
+ save_LIBS=$LIBS
+ CFLAGS="$CFLAGS $BDW_GC_CFLAGS"
+ LIBS="$LIBS $BDW_GC_LIBS"
+ 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_WARN([system bdw-gc not found, not building libobjc_gc])
+ use_bdw_gc=no
+ elif test x$enable_objc_gc = xyes && test x$system_bdw_gc_found = xno; then
+ AC_MSG_ERROR([system bdw-gc required but not found])
+ else
+ use_bdw_gc=yes
+ AC_MSG_RESULT([found])
+ fi
+esac
+
+if test "$use_bdw_gc" = no; then
+ OBJC_GCFLAGS=''
+ OBJC_BOEHM_GC=''
+ OBJC_BOEHM_GC_INCLUDES=''
+ OBJC_BOEHM_GC_LIBS=''
+else
+ OBJC_GCFLAGS='-DOBJC_WITH_GC=1'
+ OBJC_BOEHM_GC='libobjc_gc$(libsuffix).la'
+ OBJC_BOEHM_GC_INCLUDES=$BDW_GC_CFLAGS
+ OBJC_BOEHM_GC_LIBS=$BDW_GC_LIBS
+fi
+AC_SUBST(OBJC_GCFLAGS)
+AC_SUBST(OBJC_BOEHM_GC)
+AC_SUBST(OBJC_BOEHM_GC_INCLUDES)
+AC_SUBST(OBJC_BOEHM_GC_LIBS)
+
# ------
# Output
# ------
diff --git a/libobjc/gc.c b/libobjc/gc.c
index a090a522ddf..d3ff1bc2517 100644
--- a/libobjc/gc.c
+++ b/libobjc/gc.c
@@ -36,7 +36,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "objc/runtime.h"
#include "objc-private/module-abi-8.h"
-#include <gc.h>
+#include <gc/gc.h>
#include <limits.h>
/* gc_typed.h uses the following but doesn't declare them */
@@ -44,7 +44,7 @@ typedef GC_word word;
typedef GC_signed_word signed_word;
#define BITS_PER_WORD (CHAR_BIT * sizeof (word))
-#include <gc_typed.h>
+#include <gc/gc_typed.h>
/* The following functions set up in `mask` the corresponding pointers.
The offset is incremented with the size of the type. */
diff --git a/libobjc/memory.c b/libobjc/memory.c
index ee28f82cf58..a439e587ab2 100644
--- a/libobjc/memory.c
+++ b/libobjc/memory.c
@@ -41,7 +41,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "objc/runtime.h"
#if OBJC_WITH_GC
-#include <gc.h>
+#include <gc/gc.h>
void *
objc_malloc (size_t size)
diff --git a/libobjc/objects.c b/libobjc/objects.c
index 056f82d4963..09aa049000e 100644
--- a/libobjc/objects.c
+++ b/libobjc/objects.c
@@ -31,8 +31,8 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include <string.h> /* For memcpy() */
#if OBJC_WITH_GC
-# include <gc.h>
-# include <gc_typed.h>
+# include <gc/gc.h>
+# include <gc/gc_typed.h>
#endif
/* FIXME: The semantics of extraBytes are not really clear. */