1 # Copyright (c) 1999-2001 by Red Hat, Inc. All rights reserved.
2 # Copyright (c) 2005-2009 Hewlett-Packard Development Company, L.P.
3 # Copyright (c) 2009-2019 Ivan Maidanski
5 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6 # OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
8 # Permission is hereby granted to use or copy this program
9 # for any purpose, provided the above notices are retained on all copies.
10 # Permission to modify the code and to distribute modified code is granted,
11 # provided the above notices are retained, and a notice that the code was
12 # modified is included with the above copyright notice.
14 dnl Process this file with autoconf to produce configure.
17 AC_INIT(gc,8.1.0,https://github.com/ivmai/bdwgc/issues)
18 dnl Version must conform to: [0-9]+[.][0-9]+[.][0-9]+
20 AC_CONFIG_SRCDIR(gcj_mlc.c)
21 AC_CONFIG_MACRO_DIR([m4])
25 AM_INIT_AUTOMAKE([foreign nostdinc subdir-objects])
26 AC_CONFIG_HEADERS([include/config.h])
36 LT_INIT([disable-static])
37 # Only the shared libraries are produced by default, use "--enable-static"
38 # option to override it.
39 dnl Note: If Autoconf reports that LIBTOOL (or AC_ENABLE_SHARED, or
40 dnl AC_PROG_LIBTOOL) is undefined, Libtool installation should be checked.
42 # Special CFLAGS to use when building
45 # gc_use_mmap Set to "yes" on platforms where mmap should be used instead
46 # of sbrk. This will define USE_MMAP.
49 # We should set -fexceptions if we are using gcc and might be used
50 # inside something like gcj. This is the zeroth approximation:
51 if test :"$GCC": = :yes: ; then
52 gc_cflags="${gc_cflags} -fexceptions"
56 if test :$GCC: != :"yes": ; then
57 gc_cflags="${gc_flags} +ESdbgasm"
59 # :TODO: actually we should check using Autoconf if
60 # the compiler supports this option.
67 # FIXME: This seems to be no longer needed as configured in gcconfig.h
72 # target_optspace --enable-target-optspace ("yes", "no", "")
73 case "${target_optspace}:${host}" in
75 gc_cflags="${gc_cflags} -Os"
77 :m32r-* | :d10v-* | :d30v-*)
78 gc_cflags="${gc_cflags} -Os"
85 # Set any host dependent compiler flags.
87 mips-tx39-*|mipstx39-unknown-*)
88 gc_cflags="${gc_cflags} -G 0"
95 GC_CFLAGS=${gc_cflags}
98 dnl Extra user-defined flags to pass both to C and C++ compilers.
99 AC_SUBST([CFLAGS_EXTRA])
101 AC_ARG_ENABLE(threads,
102 [AC_HELP_STRING([--enable-threads=TYPE], [choose threading package])],
104 [ AC_MSG_CHECKING([for thread model used by GCC])
105 THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
106 if test -z "$THREADS"; then
109 if test "$THREADS" = "posix"; then
112 # Adjust thread model if cross-compiling for MinGW.
117 AC_MSG_RESULT([$THREADS]) ])
119 AC_ARG_ENABLE(parallel-mark,
120 [AC_HELP_STRING([--disable-parallel-mark],
121 [do not parallelize marking and free list construction])],
124 if test "${enable_parallel_mark}" != no; then
125 AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
131 AC_ARG_ENABLE(thread-local-alloc,
132 [AS_HELP_STRING([--disable-thread-local-alloc],
133 [turn off thread-local allocation optimization])],
136 if test "${enable_thread_local_alloc}" = yes; then
138 [Thread-local allocation requires --enable-threads=x spec])
143 AC_ARG_ENABLE(threads-discovery,
144 [AS_HELP_STRING([--disable-threads-discovery],
145 [disable threads discovery in GC])])
146 if test "${enable_threads_discovery}" = no; then
147 AC_DEFINE([GC_NO_THREADS_DISCOVERY], 1,
148 [Disable threads discovery in GC.])
151 AC_ARG_ENABLE(cplusplus,
152 [AC_HELP_STRING([--enable-cplusplus], [install C++ support])])
154 dnl Features which may be selected in the following thread-detection switch.
155 AH_TEMPLATE([PARALLEL_MARK], [Define to enable parallel marking.])
156 AH_TEMPLATE([THREAD_LOCAL_ALLOC],
157 [Define to enable thread-local allocation optimization.])
158 AH_TEMPLATE([USE_COMPILER_TLS],
159 [Define to use of compiler-support for thread-local variables.])
161 dnl Thread selection macros.
162 AH_TEMPLATE([GC_THREADS], [Define to support platform-specific
164 AH_TEMPLATE([GC_WIN32_PTHREADS],
165 [Define to support pthreads-win32 or winpthreads.])
167 dnl System header feature requests.
168 AH_TEMPLATE([_POSIX_C_SOURCE], [The POSIX feature macro.])
169 AH_TEMPLATE([_PTHREADS], [Indicates the use of pthreads (NetBSD).])
171 dnl Win32-specific API usage controls.
172 AH_TEMPLATE([GC_UNDERSCORE_STDCALL],
173 [Explicitly prefix exported/imported WINAPI symbols with '_'.])
174 AH_TEMPLATE([UNICODE],
175 [Use Unicode (W) variant of Win32 API instead of ASCII (A) one.])
177 dnl GC API symbols export control.
178 AH_TEMPLATE([GC_DLL],
179 [Define to build dynamic libraries with only API symbols exposed.])
181 dnl Check for a flavor of supported inline keyword.
183 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
188 need_atomic_ops_asm=false
190 use_thread_local_alloc=no
191 # Libraries needed to support dynamic loading and/or threads.
198 default_threadlibs=false
199 # Common defines for most POSIX platforms.
201 *-*-aix* | *-*-android* | *-*-cygwin* | *-*-darwin* | *-*-dragonfly* | \
202 *-*-freebsd* | *-*-haiku* | *-*-hpux11* | *-*-irix* | \
203 *-*-kfreebsd*-gnu | *-*-gnu* | *-*-*linux* | *-*-msys* | *-*-nacl* | \
204 *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)
205 AC_DEFINE(GC_THREADS)
206 AC_DEFINE([_REENTRANT], [1],
207 [Required define if using POSIX threads.])
208 use_parallel_mark=$enable_parallel_mark
209 use_thread_local_alloc=$enable_thread_local_alloc
210 default_threadlibs=true
211 AC_MSG_WARN("Explicit GC_INIT() calls may be required.")
214 AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
217 AC_MSG_WARN("Only HP/UX 11 POSIX threads are supported.")
218 AC_DEFINE(_POSIX_C_SOURCE,199506L)
219 THREADDLLIBS="-lpthread -lrt"
220 # HPUX needs REENTRANT for the _r calls.
223 AM_CFLAGS="$AM_CFLAGS -pthread"
224 THREADDLLIBS=-pthread
227 AM_CFLAGS="$AM_CFLAGS -pthread"
230 AM_CFLAGS="$AM_CFLAGS -pthread"
231 THREADDLLIBS=-pthread
233 *-*-gnu*) # E.g. linux but excluding kfreebsd.
234 # The default THREADDLLIBS.
237 AC_MSG_WARN("Only on NetBSD 2.0 or later.")
239 THREADDLLIBS="-lpthread -lrt"
242 THREADDLLIBS="-lpthread -lrt"
244 *-*-cygwin* | *-*-msys*)
245 # Cygwin doesn't have a real libpthread, so Libtool can't link
251 AC_DEFINE(GC_WIN32_PTHREADS)
252 # Using pthreads-win32 (or other non-Cygwin pthreads) library.
253 THREADDLLIBS="-lpthread"
254 use_parallel_mark=$enable_parallel_mark
255 use_thread_local_alloc=$enable_thread_local_alloc
262 AM_CFLAGS="$AM_CFLAGS -pthread"
263 THREADDLLIBS="-lpthread -lrt"
266 AS_IF([test x$default_threadlibs != xtrue],
268 [Pthreads not supported by the GC on this platform]) ])
269 # The default THREADDLLIBS.
274 if test "$GCC" != yes; then
275 need_atomic_ops_asm=true
281 AC_DEFINE(GC_THREADS)
282 use_parallel_mark=$enable_parallel_mark
283 if test "${enable_parallel_mark}" != no \
284 -o "${enable_shared}" != yes -o "${enable_static}" != no; then
285 # Imply THREAD_LOCAL_ALLOC unless GC_DLL.
286 use_thread_local_alloc=$enable_thread_local_alloc
288 if test "${enable_win32_dllmain}" = yes; then
289 AC_DEFINE(GC_INSIDE_DLL, 1,
290 [Enable Win32 DllMain-based approach of threads registering.])
293 AC_DEFINE([EMPTY_GETENV_RESULTS], [1],
294 [Wine getenv may not return NULL for missing entry.])
297 AC_DEFINE(GC_THREADS)
299 AC_MSG_RESULT($THREADDLLIBS)
300 # Use pthread GCC switch
301 THREADDLLIBS=-pthread
302 use_parallel_mark=$enable_parallel_mark
303 use_thread_local_alloc=$enable_thread_local_alloc
304 AC_MSG_WARN("Explicit GC_INIT() calls may be required.")
305 AM_CFLAGS="-pthread $AM_CFLAGS"
309 THREADDLLIBS=-lpthread
310 AC_DEFINE(GC_THREADS)
311 AC_DEFINE(_REENTRANT)
312 use_parallel_mark=$enable_parallel_mark
313 use_thread_local_alloc=$enable_thread_local_alloc
317 AC_DEFINE(GC_THREADS)
318 use_parallel_mark=$enable_parallel_mark
319 use_thread_local_alloc=$enable_thread_local_alloc
321 decosf1 | irix | mach | os2 | solaris | dce | vxworks)
322 AC_MSG_ERROR(thread package $THREADS not yet supported)
325 AC_MSG_ERROR($THREADS is an unknown thread package)
328 AC_SUBST(THREADDLLIBS)
329 AM_CONDITIONAL(THREADS, test x$THREADS != xnone)
330 AM_CONDITIONAL(PTHREADS, test x$THREADS = xposix)
331 AM_CONDITIONAL(DARWIN_THREADS, test x$darwin_threads = xtrue)
332 AM_CONDITIONAL(WIN32_THREADS, test x$win32_threads = xtrue)
335 pthread_start_standalone=no
338 # Turn on the workaround described in pthread_start.c.
339 AS_IF([test "$THREADS" = posix], [pthread_start_standalone=yes])
345 if test "$GCC" != yes; then
352 if test "$enable_gc_debug" != "no"; then
353 AC_DEFINE([GC_READ_ENV_FILE], 1,
354 [Read environment variables from the GC 'env' file.])
358 AM_CONDITIONAL(PTHREAD_START_STANDALONE,
359 test x$pthread_start_standalone = xyes)
361 if test "$GCC" = yes; then
362 # Output all warnings.
363 AC_MSG_CHECKING([whether compiler supports -Wextra])
365 CFLAGS="-Wextra $CFLAGS"
366 AC_TRY_COMPILE([],[], [ac_cv_cc_wextra=yes], [ac_cv_cc_wextra=no])
368 AC_MSG_RESULT($ac_cv_cc_wextra)
369 AS_IF([test "$ac_cv_cc_wextra" = yes], [WEXTRA="-Wextra"], [WEXTRA="-W"])
370 AC_MSG_CHECKING([whether compiler supports -Wpedantic])
371 CFLAGS="-Wpedantic -Wno-long-long $CFLAGS"
374 ], [ac_cv_cc_pedantic=yes], [ac_cv_cc_pedantic=no])
376 AC_MSG_RESULT($ac_cv_cc_pedantic)
378 AS_IF([test "$ac_cv_cc_pedantic" = yes],
379 [WPEDANTIC="-Wpedantic -Wno-long-long"])
380 CFLAGS="-Wall $WEXTRA $WPEDANTIC $CFLAGS"
381 CXXFLAGS="-Wall $WEXTRA $WPEDANTIC $CXXFLAGS"
384 AC_MSG_CHECKING(for xlc)
389 ], [compiler_xlc=yes], [compiler_xlc=no])
390 AC_MSG_RESULT($compiler_xlc)
391 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
392 # the darwin stack-frame-walking code is completely broken on xlc
393 AC_DEFINE([DARWIN_DONT_PARSE_STACK], 1, [See doc/README.macros.])
396 # XLC neither requires nor tolerates the unnecessary assembler goop.
397 # Similar for the Sun C compiler.
398 AM_CONDITIONAL([ASM_WITH_CPP_UNSUPPORTED],
399 [test $compiler_xlc = yes -o $compiler_suncc = yes])
401 if test "$GCC" = yes; then
402 # Disable aliasing optimization unless forced to.
403 AC_MSG_CHECKING([whether compiler supports -fno-strict-aliasing])
404 ac_cv_fno_strict_aliasing=no
405 for cflag in $CFLAGS; do
408 # Opposite option already present
409 ac_cv_fno_strict_aliasing=skipped
414 if test "$ac_cv_fno_strict_aliasing" != skipped; then
416 CFLAGS="$CFLAGS -fno-strict-aliasing"
417 AC_TRY_COMPILE([],[], [ac_cv_fno_strict_aliasing=yes], [])
419 AS_IF([test "$ac_cv_fno_strict_aliasing" = yes],
420 [CFLAGS="$CFLAGS -fno-strict-aliasing"], [])
422 AC_MSG_RESULT($ac_cv_fno_strict_aliasing)
425 # Check for getcontext (uClibc can be configured without it, for example)
426 AC_CHECK_FUNC([getcontext], [],
427 [ AC_DEFINE([NO_GETCONTEXT], [1], [Missing getcontext function.]) ])
429 # Check whether dl_iterate_phdr exists (as a strong symbol).
430 AC_CHECK_FUNCS([dl_iterate_phdr])
433 # While IRIX 6 has libdl for the O32 and N32 ABIs, it's missing for N64
434 # and unnecessary everywhere.
436 # We never want libdl on darwin. It is a fake libdl that just ends up making
437 # dyld calls anyway. The same applies to Cygwin.
438 *-*-cygwin* | *-*-darwin* | *-*-msys*)
441 AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
452 AM_CONDITIONAL(AVOID_CPP_LIB,test $avoid_cpp_lib = yes)
454 # Check for various headers.
455 AC_CHECK_HEADER([execinfo.h], [],
456 [ AC_DEFINE([GC_MISSING_EXECINFO_H], [1], [Missing execinfo.h header.]) ])
458 # extra LD Flags which are required for targets
461 extra_ldflags_libgc=-Wl,-single_module
464 AC_SUBST(extra_ldflags_libgc)
466 AC_SUBST(EXTRA_TEST_LIBS)
471 dnl If the target is an eCos system, use the appropriate eCos
473 dnl FIXME: this should not be a local option but a global target
474 dnl system; at present there is no eCos target.
477 [ --with-ecos enable runtime eCos target support],
478 TARGET_ECOS="$with_ecos"
485 case "$TARGET_ECOS" in
489 AC_DEFINE([ECOS], 1, [Define to enable eCos target support.])
490 AM_CPPFLAGS="-I${TARGET_ECOS}/include $AM_CPPFLAGS"
491 addobjs="$addobjs ecos.lo"
495 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
497 AC_ARG_ENABLE(throw-bad-alloc-library,
498 [AC_HELP_STRING([--disable-throw-bad-alloc-library],
499 [do not build C++ gctba library])])
500 AM_CONDITIONAL(GC_TBA_LIBRARY,
501 test "${enable_cplusplus}" = yes \
502 -a "${enable_throw_bad_alloc_library}" != no)
504 if test "$GCC" = yes; then
505 if test "${enable_cplusplus}" = yes; then
507 *-*-cygwin* | *-*-mingw* | *-*-msys*)
508 AC_MSG_CHECKING([whether libsupc++ required])
509 SUPC="`$CXX -print-file-name=libsupc++.a 2>/dev/null`"
510 if test -n "$SUPC" -a "$SUPC" != "libsupc++.a"; then
523 AC_SUBST(AM_CPPFLAGS)
526 # Configuration of shared libraries
528 AC_MSG_CHECKING(whether to build shared libraries)
539 AC_MSG_RESULT($enable_shared)
541 # Compile with GC_DLL defined unless building static libraries.
542 if test "${enable_shared}" != no -a "${enable_static}" != yes; then
544 if test "$GCC" = yes; then
545 # Pass -fvisibility=hidden option if supported
546 AC_MSG_CHECKING([whether compiler supports -fvisibility])
548 CFLAGS="-Werror -fvisibility=hidden $CFLAGS"
549 AC_TRY_COMPILE([],[], [ac_cv_fvisibility_hidden=yes],
550 [ac_cv_fvisibility_hidden=no])
552 AS_IF([test "$ac_cv_fvisibility_hidden" = yes],
553 [CFLAGS="-DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden $CFLAGS"],
554 [CFLAGS="-DGC_NO_VISIBILITY $CFLAGS"])
555 AC_MSG_RESULT($ac_cv_fvisibility_hidden)
560 *-*-cygwin* | *-*-mingw* | *-*-msys*)
561 # Do not require the clients to link with "user32" system library.
562 AC_DEFINE([DONT_USE_USER32_DLL], 1,
563 [Do not use user32.dll import library (Win32).])
564 # Use inline version of GC new and delete operators in test_cpp
565 # otherwise the system ones might be used instead because of arbitrary
566 # ordering of object files when linking.
567 CXXFLAGS="$CXXFLAGS -DGC_NOT_DLL"
572 # Configuration of machine-dependent code
574 AC_MSG_CHECKING(which machine-dependent code should be used)
578 if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
580 "OpenBSD/Alpha without dlopen(). Shared library support is disabled.")
583 i?86-*-solaris2.[[89]])
584 # PROC_VDB appears to work in 2.8 and 2.9 but not in 2.10+ (for now).
585 AC_DEFINE([SOLARIS25_PROC_VDB_BUG_FIXED], 1,
586 [See the comment in gcconfig.h.])
589 dnl AC_DEFINE(NO_EXECUTE_PERMISSION)
590 dnl This is now redundant, but it is also important for incremental GC
591 dnl performance under Irix.
594 machdep="sparc_netbsd_mach_dep.lo"
596 sparc*-*-linux* | sparc*-*-openbsd* | sparc64-*-freebsd* | sparc64-*-netbsd*)
597 machdep="sparc_mach_dep.lo"
599 sparc-sun-solaris2.3)
600 machdep="sparc_mach_dep.lo"
601 AC_DEFINE(SUNOS53_SHARED_LIB, 1,
602 [Define to work around a Solaris 5.3 bug (see dyn_load.c).])
604 sparc*-sun-solaris2*)
605 machdep="sparc_mach_dep.lo"
608 machdep="ia64_save_regs_in_stack.lo"
611 AC_DEFINE(NO_EXECUTE_PERMISSION)
614 AC_MSG_RESULT($machdep)
615 addobjs="$addobjs $machdep"
621 dnl We use these options to decide which functions to include.
622 AC_ARG_WITH(target-subdir,
623 [ --with-target-subdir=SUBDIR
624 configuring with a cross compiler])
625 AC_ARG_WITH(cross-host,
626 [ --with-cross-host=HOST configuring with a cross compiler])
628 dnl automake wants to see AC_EXEEXT. But we don't need it. And having
629 dnl it is actually a problem, because the compiler we're passed can't
630 dnl necessarily do a full link. So we fool automake here.
632 dnl autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
633 dnl to nothing, so nothing would remain between `then' and `fi' if it
634 dnl were not for the `:' below.
639 dnl The collector might not properly work on IBM AIX when
640 dnl built with gcc and -O. So we remove -O in the appropriate case.
641 AC_MSG_CHECKING(whether AIX gcc optimization fix is necessary)
644 if test "$GCC" = yes; then
652 new_CFLAGS="$new_CFLAGS $i"
661 *) AC_MSG_RESULT(no) ;;
664 dnl Include defines that have become de facto standard.
665 dnl ALL_INTERIOR_POINTERS and NO_EXECUTE_PERMISSION can be overridden
666 dnl in the startup code.
667 AC_DEFINE([NO_EXECUTE_PERMISSION], [1],
668 [Define to make the collector not allocate executable memory
670 AC_DEFINE([ALL_INTERIOR_POINTERS], [1],
671 [Define to recognise all pointers to the interior of objects.])
674 dnl Interface Selection
675 dnl -------------------
677 dnl By default, make the library as general as possible.
678 dnl enable_gcj_support=no
679 AC_ARG_ENABLE(gcj-support,
680 [AC_HELP_STRING([--disable-gcj-support], [disable support for gcj])])
681 if test x"$enable_gcj_support" != xno; then
682 AC_DEFINE(GC_GCJ_SUPPORT, 1, [Define to include support for gcj.])
685 # FIXME: For a reason, gctest hangs up on kFreeBSD if both of
686 # THREAD_LOCAL_ALLOC and GC_ENABLE_SUSPEND_THREAD are defined.
687 if test "${enable_thread_local_alloc}" = no; then
688 AC_DEFINE(GC_ENABLE_SUSPEND_THREAD)
692 AC_DEFINE([GC_ENABLE_SUSPEND_THREAD], 1,
693 [Define to turn on GC_suspend_thread support.])
698 dnl Interaction with other programs that might use signals.
699 AC_ARG_ENABLE(sigrt-signals,
700 [AC_HELP_STRING([--enable-sigrt-signals],
701 [force GC to use SIGRTMIN-based signals for thread suspend/resume])])
702 if test x"${enable_sigrt_signals}" = xyes; then
703 AC_DEFINE([GC_USESIGRT_SIGNALS], 1,
704 [Force the GC to use signals based on SIGRTMIN+k.])
711 AH_TEMPLATE([GC_HAVE_BUILTIN_BACKTRACE],
712 [Define if backtrace information is supported.])
713 AH_TEMPLATE([MAKE_BACK_GRAPH], [See doc/README.macros.])
714 AH_TEMPLATE([SAVE_CALL_COUNT],
715 [The number of caller frames saved when allocating with the
718 AC_ARG_ENABLE(gc-debug,
719 [AC_HELP_STRING([--enable-gc-debug],
720 [include full support for pointer backtracing etc.])],
721 [ if test "$enable_gc_debug" = "yes"; then
722 AC_MSG_WARN("Should define GC_DEBUG and use debug alloc in clients.")
723 AC_DEFINE([KEEP_BACK_PTRS], 1,
724 [Define to save back-pointers in debugging headers.])
726 AC_DEFINE([DBG_HDRS_ALL], 1,
727 [Define to force debug headers on all objects.])
728 AH_TEMPLATE([SHORT_DBG_HDRS],
729 [Shorten the headers to minimize object size at the expense
730 of checking for writes past the end (see doc/README.macros).])
734 AC_DEFINE(MAKE_BACK_GRAPH)
735 AC_DEFINE(SAVE_CALL_COUNT, 8)
736 AC_CHECK_LIB(unwind, backtrace, [
737 AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
739 AC_MSG_WARN("Client code may need to link against libunwind.")
742 x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
743 AC_DEFINE(MAKE_BACK_GRAPH)
744 AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
745 AC_DEFINE(SAVE_CALL_COUNT, 8)
748 AC_DEFINE(MAKE_BACK_GRAPH)
752 AM_CONDITIONAL([MAKE_BACK_GRAPH], [test x"$enable_gc_debug" = xyes])
753 AM_CONDITIONAL([KEEP_BACK_PTRS], [test x"$keep_back_ptrs" = xtrue])
755 # Check for dladdr (used for debugging).
756 AC_MSG_CHECKING(for dladdr)
759 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
761 #define _GNU_SOURCE 1
762 #include <dlfcn.h>], [{
764 (void)dladdr("", &info);
765 }], [ have_dladdr=yes ])
767 AC_MSG_RESULT($have_dladdr)
768 if test x"$have_dladdr" = xyes; then
769 AC_DEFINE([HAVE_DLADDR], 1, [Define to use 'dladdr' function.])
772 # sigsetjmp could be a macro (thus AC_CHECK_FUNCS cannot be used).
773 AC_MSG_CHECKING(for sigsetjmp)
775 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
776 AC_TRY_LINK([#include <setjmp.h>],
777 [sigjmp_buf t; sigsetjmp(t, 0)],
778 [AC_MSG_RESULT(yes)],
780 AC_DEFINE([GC_NO_SIGSETJMP], [1], [Missing sigsetjmp function.])])
783 # pthread_setname_np, if available, may have 1, 2 or 3 arguments.
784 AS_IF([test "$THREADS" = posix],
785 [AC_MSG_CHECKING(for pthread_setname_np)
787 CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror"
788 AC_TRY_COMPILE([#include <pthread.h>],
789 [pthread_setname_np("thread-name")],
790 [AC_MSG_RESULT([yes (w/o tid)])
791 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID], [1],
792 [Define to use 'pthread_setname_np(const char*)' function.])],
793 [AC_TRY_COMPILE([#include <pthread.h>],
794 [pthread_setname_np(pthread_self(), "thread-name-%u", 0)],
795 [AC_MSG_RESULT([yes (with tid and arg)])
796 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG], [1],
797 [Define to use 'pthread_setname_np(pthread_t, const char*, void *)'
801 #define _GNU_SOURCE 1
802 #elif defined(__linux__) || defined(__GLIBC__) || defined(__GNU__)
803 #define _GNU_SOURCE 1
805 #include <pthread.h>],
806 [pthread_setname_np(pthread_self(), "thread-name")],
807 [AC_MSG_RESULT([yes (with tid)])
808 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID], [1],
809 [Define to use 'pthread_setname_np(pthread_t, const char*)'
811 [AC_MSG_RESULT(no)])])])
812 CFLAGS="$old_CFLAGS"])
814 # Check for AViiON Machines running DGUX
816 AC_CHECK_HEADER(sys/dg_sys_info.h,
819 dnl :GOTCHA: we do not check anything but sys/dg_sys_info.h
820 if test $ac_is_dgux = yes; then
821 dgux_spec_opts="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
822 CFLAGS="$dgux_spec_opts $CFLAGS"
823 CXXFLAGS="$dgux_spec_opts $CXXFLAGS"
824 if test "$enable_gc_debug" = "yes"; then
825 CFLAGS="-g -mstandard $CFLAGS"
826 CXXFLAGS="-g -mstandard $CXXFLAGS"
832 AC_ARG_ENABLE(java-finalization,
833 [AC_HELP_STRING([--disable-java-finalization],
834 [disable support for java finalization])])
835 if test x"$enable_java_finalization" != xno; then
836 AC_DEFINE([JAVA_FINALIZATION], 1, [See doc/README.macros.])
839 AC_ARG_ENABLE(atomic-uncollectable,
840 [AC_HELP_STRING([--disable-atomic-uncollectible],
841 [disable support for atomic uncollectible allocation])])
842 if test x"$enable_atomic_uncollectible" != x"no"; then
843 AC_DEFINE([GC_ATOMIC_UNCOLLECTABLE], 1,
844 [Define to enable atomic uncollectible allocation.])
847 AC_ARG_ENABLE(redirect-malloc,
848 [AC_HELP_STRING([--enable-redirect-malloc],
849 [redirect malloc and friends to GC routines])])
851 if test "${enable_redirect_malloc}" = yes; then
852 if test "${enable_gc_debug}" = yes; then
853 AC_DEFINE([REDIRECT_MALLOC], GC_debug_malloc_replacement,
854 [If defined, redirect malloc to this function.])
855 AC_DEFINE([REDIRECT_REALLOC], GC_debug_realloc_replacement,
856 [If defined, redirect GC_realloc to this function.])
857 AC_DEFINE([REDIRECT_FREE], GC_debug_free,
858 [If defined, redirect free to this function.])
860 AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
862 AC_DEFINE([GC_USE_DLOPEN_WRAP], 1, [See doc/README.macros.])
865 AC_ARG_ENABLE(disclaim,
866 [AC_HELP_STRING([--disable-disclaim],
867 [disable alternative (more efficient) finalization interface])])
868 if test x"$enable_disclaim" != xno; then
869 AC_DEFINE(ENABLE_DISCLAIM, 1,
870 [Define to enable alternative finalization interface.])
872 AM_CONDITIONAL(ENABLE_DISCLAIM,
873 [test x"$enable_disclaim" != xno])
875 AC_ARG_ENABLE(large-config,
876 [AC_HELP_STRING([--enable-large-config],
877 [optimize for large (> 100 MB) heap or root set])])
878 if test "${enable_large_config}" = yes; then
879 AC_DEFINE(LARGE_CONFIG, 1,
880 [Define to optimize for large heaps or root sets.])
883 dnl This is something of a hack. When cross-compiling we turn off
884 dnl some functionality. We also enable the "small" configuration.
885 dnl These is only correct when targeting an embedded system. FIXME.
886 if test -n "${with_cross_host}"; then
887 AC_DEFINE([NO_CLOCK], 1, [Define to not use system clock (cross compiling).])
888 AC_DEFINE([SMALL_CONFIG], 1,
889 [Define to tune the collector for small heap sizes.])
892 if test "$enable_gc_debug" = "no"; then
893 AC_DEFINE([NO_DEBUGGING], 1,
894 [Disable debugging, like GC_dump and its callees.])
899 AC_ARG_ENABLE(gc-assertions,
900 [AC_HELP_STRING([--enable-gc-assertions],
901 [collector-internal assertion checking])])
902 if test "${enable_gc_assertions}" = yes; then
903 AC_DEFINE([GC_ASSERTIONS], 1,
904 [Define to enable internal debug assertions.])
908 [AS_HELP_STRING([--enable-mmap],
909 [use mmap instead of sbrk to expand the heap])],
910 gc_use_mmap=$enableval)
912 AC_ARG_ENABLE(munmap,
913 [AC_HELP_STRING([--enable-munmap=N],
914 [return page to the OS if empty for N collections
916 MUNMAP_THRESHOLD=$enableval)
917 if test x$enable_munmap != xno; then
918 AC_DEFINE([USE_MMAP], 1,
919 [Define to use mmap instead of sbrk to expand the heap.])
920 AH_TEMPLATE([USE_WINALLOC],
921 [Define to use Win32 VirtualAlloc (instead of sbrk or
922 mmap) to expand the heap.])
923 AC_DEFINE([USE_MUNMAP], 1,
924 [Define to return memory to OS with munmap calls
925 (see doc/README.macros).])
926 if test x$MUNMAP_THRESHOLD = x -o x$MUNMAP_THRESHOLD = xyes; then
929 AC_DEFINE_UNQUOTED([MUNMAP_THRESHOLD], [${MUNMAP_THRESHOLD}],
930 [Number of GC cycles to wait before unmapping an unused block.])
932 if test "${gc_use_mmap}" = "yes"; then
933 AC_DEFINE([USE_MMAP], 1,
934 [Define to use mmap instead of sbrk to expand the heap.])
938 AC_ARG_ENABLE(dynamic-loading,
939 [AS_HELP_STRING([--disable-dynamic-loading],
940 [build the collector with disabled tracing
941 of dynamic library data roots])])
942 if test "${enable_dynamic_loading}" = "no"; then
943 AC_DEFINE([IGNORE_DYNAMIC_LOADING], 1,
944 [Do not define DYNAMIC_LOADING even if supported (i.e., build the
945 collector with disabled tracing of dynamic library data roots).])
948 AC_ARG_ENABLE(register-main-static-data,
949 [AS_HELP_STRING([--disable-register-main-static-data],
950 [skip the initial guess of data root sets])])
951 if test "${enable_register_main_static_data}" = "no"; then
952 AC_DEFINE([GC_DONT_REGISTER_MAIN_STATIC_DATA], 1,
953 [Skip the initial guess of data root sets.])
956 AC_ARG_ENABLE(checksums,
957 [AS_HELP_STRING([--enable-checksums],
958 [report on erroneously cleared dirty bits at
959 substantial performance cost; use only for
960 debugging of the incremental collector])])
961 if test x$enable_checksums = xyes; then
962 if test x$enable_munmap != xno -o x$THREADS != xnone; then
963 AC_MSG_ERROR([CHECKSUMS not compatible with USE_MUNMAP or threads])
965 AC_DEFINE([CHECKSUMS], 1,
966 [Erroneously cleared dirty bits checking. Use only for
967 debugging of the incremental collector.])
969 AM_CONDITIONAL([CHECKSUMS], test x$enable_checksums = xyes)
971 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
973 AC_ARG_ENABLE(werror,
974 [AS_HELP_STRING([--enable-werror], [pass -Werror to the C compiler])],
975 werror_flag=$enableval, werror_flag=no)
976 if test x$werror_flag = xyes; then
977 WERROR_CFLAGS="-Werror"
979 # _dyld_bind_fully_image_containing_address is deprecated in OS X 10.5+
981 WERROR_CFLAGS="$WERROR_CFLAGS -Wno-deprecated-declarations"
985 AC_SUBST([WERROR_CFLAGS])
987 AC_ARG_ENABLE(single-obj-compilation,
988 [AC_HELP_STRING([--enable-single-obj-compilation],
989 [compile all libgc source files into single .o
990 (default: yes if static libraries are disabled)])],
991 [], [ AS_IF([test x"$enable_static" = xno],
992 [enable_single_obj_compilation=yes]) ])
993 AM_CONDITIONAL([SINGLE_GC_OBJ],
994 [test x"$enable_single_obj_compilation" = xyes])
997 [AS_HELP_STRING([--enable-gcov], [turn on code coverage analysis])])
998 if test "$enable_gcov" = "yes"; then
999 CFLAGS="$CFLAGS --coverage"
1000 if test "${enable_shared}" = no; then
1001 # FIXME: As of g++-4.8.4/x86_64, in case of shared library build, test_cpp
1002 # linkage fails with "hidden symbol atexit is referenced by DSO" message.
1003 CXXFLAGS="$CXXFLAGS --coverage"
1005 # Turn off optimization to get accurate line numbers.
1006 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'`
1007 CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'`
1011 [AC_HELP_STRING([--disable-docs],
1012 [do not build and install documentation])])
1013 AM_CONDITIONAL(ENABLE_DOCS, test x$enable_docs != xno)
1015 AM_CONDITIONAL(ENABLE_SHARED, test x$enable_shared = xyes)
1020 # Do we want to use an external libatomic_ops? By default use it if it's
1022 AC_ARG_WITH([libatomic-ops],
1023 [AS_HELP_STRING([--with-libatomic-ops[=yes|no|check|none]],
1024 [Use an external libatomic_ops? (default: check;
1025 none: use compiler intrinsics or no thread support)])],
1026 [], [ AS_IF([test x"$THREADS" != xnone],
1027 [with_libatomic_ops=check], [with_libatomic_ops=none]) ])
1029 # Check whether compiler atomic intrinsics can be used.
1030 if test x"$with_libatomic_ops" = xcheck; then
1031 AC_MSG_CHECKING(for compiler intrinsics support)
1032 old_CFLAGS="$CFLAGS"
1033 CFLAGS="$CFLAGS $CFLAGS_EXTRA -DGC_BUILTIN_ATOMIC"
1034 CFLAGS="$CFLAGS -I${srcdir}/include -I${srcdir}/tests"
1035 AC_TRY_RUN([#include "test_atomic_ops.c"],
1037 with_libatomic_ops=none],
1038 [AC_MSG_RESULT(no)], [AC_MSG_RESULT(skipped because cross-compiling)])
1039 CFLAGS="$old_CFLAGS"
1042 # Check for an external libatomic_ops if the above answer is "yes" or "check".
1043 # If not found, fail on "yes", and convert "check" to "no".
1044 # First, check that libatomic_ops usage is not disabled explicitly.
1045 missing_libatomic_ops=false
1046 AS_IF([test x"$with_libatomic_ops" != xno -a x"$with_libatomic_ops" != xnone],
1047 [ missing_libatomic_ops=true ])
1049 dnl To avoid "syntax error near unexpected token ATOMIC_OPS" configure error
1050 dnl observed by some clients, the following 3 code lines are commented out:
1052 dnl AS_IF([test x$missing_libatomic_ops = xtrue],
1053 dnl [ PKG_CHECK_MODULES([ATOMIC_OPS], [atomic_ops],
1054 dnl [ missing_libatomic_ops=false ], [ [] ]) ])
1056 dnl Retry with AC_CHECK_HEADER if PKG_CHECK_MODULES failed.
1057 AS_IF([test x$missing_libatomic_ops = xtrue],
1058 [ AC_CHECK_HEADER([atomic_ops.h], [missing_libatomic_ops=false]) ])
1059 AS_IF([test x$missing_libatomic_ops = xtrue],
1060 [ AS_IF([test x"$with_libatomic_ops" != xcheck],
1061 [ AC_MSG_ERROR([An external libatomic_ops was not found]) ])
1062 with_libatomic_ops=no ])
1064 # If we have neither an external or an internal version, offer a useful hint
1066 AS_IF([test x"$with_libatomic_ops" = xno \
1067 -a ! -e "$srcdir/libatomic_ops/src/atomic_ops.h"],
1068 [ AC_MSG_ERROR([libatomic_ops is required. You can either install it on
1069 your system, or fetch and unpack a recent version into the
1070 source directory and link or rename it to libatomic_ops.]) ])
1072 # Finally, emit the definitions for bundled or external AO.
1073 AC_MSG_CHECKING([which libatomic_ops to use])
1074 AS_IF([test x"$with_libatomic_ops" != xno],
1075 [ AS_IF([test x"$with_libatomic_ops" != xnone -a x"$THREADS" != xnone],
1076 [ AC_MSG_RESULT([external])
1077 ATOMIC_OPS_LIBS="-latomic_ops"
1078 AC_SUBST([ATOMIC_OPS_LIBS]) ],
1079 [ AC_MSG_RESULT([none])
1080 AS_IF([test x"$THREADS" != xnone],
1081 [ AC_DEFINE([GC_BUILTIN_ATOMIC], [1],
1082 [Use C11 (GCC) atomic intrinsics instead of
1083 libatomic_ops primitives.]) ]) ])
1084 AO_TRYLINK_CFLAGS="" ],
1085 [ AC_MSG_RESULT([internal])
1086 AO_TRYLINK_CFLAGS="-I${srcdir}/libatomic_ops/src"
1087 ATOMIC_OPS_CFLAGS='-I$(top_builddir)/libatomic_ops/src -I$(top_srcdir)/libatomic_ops/src'
1089 AC_SUBST([ATOMIC_OPS_CFLAGS])
1090 AC_CONFIG_SUBDIRS([libatomic_ops])
1092 AM_CONDITIONAL([USE_INTERNAL_LIBATOMIC_OPS],
1093 [test x$with_libatomic_ops = xno -a x"$THREADS" != xnone])
1094 AM_CONDITIONAL([NEED_ATOMIC_OPS_ASM],
1095 [test x$with_libatomic_ops = xno -a x$need_atomic_ops_asm = xtrue])
1097 # Check whether particular AO primitives are emulated with locks.
1098 # The check below is based on the fact that linking with the libatomic_ops
1099 # binary file is not needed in case of absence of the emulation (except for
1101 AS_IF([test x$with_libatomic_ops != xnone -a x$need_atomic_ops_asm != xtrue],
1102 [ old_CFLAGS="$CFLAGS"
1103 CFLAGS="$CFLAGS $AO_TRYLINK_CFLAGS $CFLAGS_EXTRA"
1104 AC_MSG_CHECKING([for lock-free AO_or primitive])
1105 AC_TRY_LINK([#include "atomic_ops.h"],
1106 [AO_t x=0;AO_or(&x,1)],
1107 [ AC_MSG_RESULT(yes)
1108 AC_DEFINE([HAVE_LOCKFREE_AO_OR], [1],
1109 [libatomic_ops AO_or primitive implementation is lock-free.]) ],
1110 [ AC_MSG_RESULT(no) ])
1111 AC_MSG_CHECKING([for lock-free AO load/store, test-and-set primitives])
1112 AC_TRY_LINK([#include "atomic_ops.h"],
1113 [AO_t x=0;unsigned char c=0;AO_TS_t z=AO_TS_INITIALIZER;
1114 (void)AO_test_and_set_acquire(&z);AO_CLEAR(&z);AO_compiler_barrier();
1115 AO_store(&x,AO_load(&x)+1);AO_char_store(&c,AO_char_load(&c)+1);
1116 AO_store_release(&x,AO_load_acquire(&x)+1)],
1117 [ AC_MSG_RESULT(yes) ],
1119 use_thread_local_alloc=no
1120 AC_DEFINE([BASE_ATOMIC_OPS_EMULATED], [1],
1121 [AO load, store and/or test-and-set primitives are
1122 implemented in libatomic_ops using locks.]) ])
1123 AS_IF([test x$use_parallel_mark != xno],
1125 [for lock-free compare-and-swap and fetch-and-add primitives])
1127 [#define AO_REQUIRE_CAS
1128 #include "atomic_ops.h"],
1129 [AO_t x=0;(void)AO_fetch_and_add(&x,1);(void)AO_compare_and_swap(&x,1,2)],
1130 [ AC_MSG_RESULT(yes) ],
1132 use_parallel_mark=no ]) ])
1133 CFLAGS="$old_CFLAGS" ])
1135 AS_IF([test x$use_parallel_mark != xno],
1136 [ AC_DEFINE(PARALLEL_MARK) ])
1137 AS_IF([test x$use_thread_local_alloc != xno],
1138 [ AC_DEFINE(THREAD_LOCAL_ALLOC) ])
1139 AM_CONDITIONAL(THREAD_LOCAL_ALLOC, test x$use_thread_local_alloc != xno)
1141 AC_ARG_ENABLE(handle-fork,
1142 [ AC_HELP_STRING([--enable-handle-fork[=yes|no|auto|manual]],
1143 [attempt to ensure a usable collector after fork()
1144 in multi-threaded programs (default: auto;
1145 manual: GC_atfork_prepare/parent/child should be
1146 called by the client)]) ])
1147 if test "${enable_handle_fork}" = yes; then
1148 AC_DEFINE(HANDLE_FORK, 1,
1149 [Define to install pthread_atfork() handlers by default.])
1150 elif test "${enable_handle_fork}" = no; then
1151 AC_DEFINE(NO_HANDLE_FORK, 1,
1152 [Prohibit installation of pthread_atfork() handlers.])
1153 elif test "${enable_handle_fork}" != manual -a x$THREADS = xposix; then
1154 # If the option is omitted, pthread_atfork handlers are installed
1155 # by default for the targets where pthread_atfork is known to work.
1158 # Android NDK does not provide pthread_atfork.
1161 # The incremental mode (which is off if parallel marking) conflicts
1162 # with fork handling on Darwin.
1163 if test x$use_parallel_mark != xno; then
1164 AC_DEFINE(HANDLE_FORK)
1167 *-*-aix* | *-*-cygwin* | *-*-freebsd* | *-*-haiku* | \
1168 *-*-hpux11* | *-*-irix* | *-*-kfreebsd*-gnu | \
1169 *-*-*linux* | *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)
1170 AC_DEFINE(HANDLE_FORK)
1175 dnl Produce the Files
1176 dnl -----------------
1178 AC_CONFIG_FILES([Makefile bdw-gc.pc])
1180 AC_CONFIG_COMMANDS([default],,
1181 [ srcdir="${srcdir}"
1183 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}