2016-11-19 Matthias Klose * 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-19 Matthias Klose * doc/install.texi: Document configure options --enable-objc-gc and --with-target-bdw-gc. config/ 2016-11-19 Matthias Klose * pkg.m4: New file. libobjc/ 2016-11-19 Matthias Klose * 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-19 Matthias Klose Remove Index: Makefile.def =================================================================== --- Makefile.def (revision 242638) +++ Makefile.def (working copy) @@ -166,7 +166,6 @@ target_modules = { module= libgloss; no_check=true; }; target_modules = { module= libffi; no_install=true; }; target_modules = { module= zlib; }; -target_modules = { module= boehm-gc; }; target_modules = { module= rda; }; target_modules = { module= libada; }; target_modules = { module= libgomp; bootstrap= true; lib_path=.libs; }; @@ -543,7 +542,6 @@ // a dependency on libgcc for native targets to configure. lang_env_dependencies = { module=libiberty; no_c=true; }; -dependencies = { module=configure-target-boehm-gc; on=all-target-libstdc++-v3; }; dependencies = { module=configure-target-fastjar; on=configure-target-zlib; }; dependencies = { module=all-target-fastjar; on=all-target-zlib; }; dependencies = { module=configure-target-libgo; on=configure-target-libffi; }; @@ -551,8 +549,6 @@ dependencies = { module=all-target-libgo; on=all-target-libbacktrace; }; dependencies = { module=all-target-libgo; on=all-target-libffi; }; dependencies = { module=all-target-libgo; on=all-target-libatomic; }; -dependencies = { module=configure-target-libobjc; on=configure-target-boehm-gc; }; -dependencies = { module=all-target-libobjc; on=all-target-boehm-gc; }; dependencies = { module=configure-target-libstdc++-v3; on=configure-target-libgomp; }; dependencies = { module=configure-target-liboffloadmic; on=configure-target-libgomp; }; dependencies = { module=configure-target-libsanitizer; on=all-target-libstdc++-v3; }; Index: configure.ac =================================================================== --- configure.ac (revision 242638) +++ configure.ac (working copy) @@ -29,6 +29,7 @@ m4_include([ltversion.m4]) m4_include([lt~obsolete.m4]) m4_include([config/isl.m4]) +m4_include([config/pkg.m4]) AC_INIT(move-if-change) AC_PREREQ(2.64) @@ -161,7 +162,6 @@ target-libssp \ target-libquadmath \ target-libgfortran \ - target-boehm-gc \ target-libffi \ target-libobjc \ target-libada \ @@ -2060,22 +2060,36 @@ AC_ARG_ENABLE(objc-gc, [AS_HELP_STRING([--enable-objc-gc], [enable use of Boehm's garbage collector with the - GNU Objective-C runtime])], -[case ,${enable_languages},:${enable_objc_gc}:${noconfigdirs} in - *,objc,*:*:yes:*target-boehm-gc*) - AC_MSG_ERROR([Boehm's garbage collector was requested yet not supported in this configuration]) - ;; -esac]) - -# Make sure we only build Boehm's garbage collector if required. -case ,${enable_languages},:${enable_objc_gc} in - *,objc,*:yes) - # Keep target-boehm-gc if requested for Objective-C. - ;; - *) - # Otherwise remove target-boehm-gc. - noconfigdirs="$noconfigdirs target-boehm-gc" - ;; + 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-bdw-gc-include=PATH/include + plus --with-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_languages},:${enable_objc_gc} in *,objc,*:yes|*,objc,*:auto) + 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, first error checking, complete checking in libobjc + 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 + fi esac # Disable libcilkrts, libitm, libsanitizer, libvtv, liboffloadmic if we're not building C++ Index: gcc/doc/install.texi =================================================================== --- gcc/doc/install.texi (revision 242638) +++ gcc/doc/install.texi (working copy) @@ -2143,6 +2143,36 @@ overrides, you can pass a setting for @env{CONFIG_SITE} and set variables in the site file. +@subheading Objective-C-Specific Options + +The following options apply to the build of the Objective-C runtime library. + +@table @code +@item --enable-objc-gc +Specify that an additional variant of the GNU Objective-C runtime library +is built, using an external build of the Boehm-Demers-Weiser garbage +collector (@uref{http://www.hboehm.info/gc/}). This library needs to be +available for each multilib variant, unless configured with +@option{--enable-objc-gc=@samp{auto}} in which case the build of the +additional runtime library is skipped and the build continues. + +@item --with-target-bdw-gc=@var{list} +@itemx --with-target-bdw-gc-include=@var{list} +@itemx --with-target-bdw-gc-lib=@var{list} +Specify search directories for the garbage collector header files and +libraries. @var{list} is a comma separated list of key value pairs of the +form @samp{@var{multilibdir}@=@var{path}}, where the default multilib key +is named as @samp{.} (dot), or is omitted (e.g. +@samp{--with-target-bdw-gc=/opt/bdw-gc,32=/opt-bdw-gc32}). + +The options @option{--with-target-bdw-gc-include} and +@option{--with-target-bdw-gc-include} must always specified together for +each multilib variant and take precedence over +@option{--with-target-bdw-gc-include}. If none of these options are +specified, the values are taken from the @command{pkg-config} +@samp{bdw-gc} module. +@end table + @html

Index: libobjc/Makefile.in =================================================================== --- libobjc/Makefile.in (revision 242638) +++ libobjc/Makefile.in (working copy) @@ -47,8 +47,6 @@ top_builddir = . --include ../boehm-gc/threads.mk - libdir = $(exec_prefix)/lib libsubdir = $(libdir)/gcc/$(target_noncanonical)/$(gcc_version) @@ -95,7 +93,7 @@ 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 \ Index: libobjc/configure.ac =================================================================== --- libobjc/configure.ac (revision 242638) +++ libobjc/configure.ac (working copy) @@ -18,6 +18,8 @@ #along with GCC; see the file COPYING3. If not see #. +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 @@ [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,163 @@ 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-bdw-gc-include=PATH/include + plus --with-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, first error checking, complete checking in libobjc + 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 + 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]) + use_bdw_gc=maybe +esac + +if test "$use_bdw_gc" = maybe; then + 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_init()])], + [ + AC_RUN_IFELSE([AC_LANG_SOURCE([[ + #include + 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 +fi + +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 # ------ Index: libobjc/gc.c =================================================================== --- libobjc/gc.c (revision 242638) +++ libobjc/gc.c (working copy) @@ -36,7 +36,7 @@ #include "objc/runtime.h" #include "objc-private/module-abi-8.h" -#include +#include #include /* gc_typed.h uses the following but doesn't declare them */ @@ -44,7 +44,7 @@ typedef GC_signed_word signed_word; #define BITS_PER_WORD (CHAR_BIT * sizeof (word)) -#include +#include /* The following functions set up in `mask` the corresponding pointers. The offset is incremented with the size of the type. */ Index: libobjc/memory.c =================================================================== --- libobjc/memory.c (revision 242638) +++ libobjc/memory.c (working copy) @@ -41,7 +41,7 @@ #include "objc/runtime.h" #if OBJC_WITH_GC -#include +#include void * objc_malloc (size_t size) Index: libobjc/objects.c =================================================================== --- libobjc/objects.c (revision 242638) +++ libobjc/objects.c (working copy) @@ -31,8 +31,8 @@ #include /* For memcpy() */ #if OBJC_WITH_GC -# include -# include +# include +# include #endif /* FIXME: The semantics of extraBytes are not really clear. */