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 if test "$GCC" = yes; then
498 if test "${enable_cplusplus}" = yes; then
500 *-*-cygwin* | *-*-mingw* | *-*-msys*)
501 AC_MSG_CHECKING([whether libsupc++ required])
502 SUPC="`$CXX -print-file-name=libsupc++.a 2>/dev/null`"
503 if test -n "$SUPC" -a "$SUPC" != "libsupc++.a"; then
516 AC_SUBST(AM_CPPFLAGS)
519 # Configuration of shared libraries
521 AC_MSG_CHECKING(whether to build shared libraries)
532 AC_MSG_RESULT($enable_shared)
534 # Compile with GC_DLL defined unless building static libraries.
535 if test "${enable_shared}" != no -a "${enable_static}" != yes; then
537 if test "$GCC" = yes; then
538 # Pass -fvisibility=hidden option if supported
539 AC_MSG_CHECKING([whether compiler supports -fvisibility])
541 CFLAGS="-Werror -fvisibility=hidden $CFLAGS"
542 AC_TRY_COMPILE([],[], [ac_cv_fvisibility_hidden=yes],
543 [ac_cv_fvisibility_hidden=no])
545 AS_IF([test "$ac_cv_fvisibility_hidden" = yes],
546 [CFLAGS="-DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden $CFLAGS"],
547 [CFLAGS="-DGC_NO_VISIBILITY $CFLAGS"])
548 AC_MSG_RESULT($ac_cv_fvisibility_hidden)
553 *-*-cygwin* | *-*-mingw* | *-*-msys*)
554 # Do not require the clients to link with "user32" system library.
555 AC_DEFINE([DONT_USE_USER32_DLL], 1,
556 [Do not use user32.dll import library (Win32).])
557 # Use inline version of GC new and delete operators in test_cpp
558 # otherwise the system ones might be used instead because of arbitrary
559 # ordering of object files when linking.
560 CXXFLAGS="$CXXFLAGS -DGC_NOT_DLL"
565 # Configuration of machine-dependent code
567 AC_MSG_CHECKING(which machine-dependent code should be used)
571 if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
573 "OpenBSD/Alpha without dlopen(). Shared library support is disabled.")
576 i?86-*-solaris2.[[89]])
577 # PROC_VDB appears to work in 2.8 and 2.9 but not in 2.10+ (for now).
578 AC_DEFINE([SOLARIS25_PROC_VDB_BUG_FIXED], 1,
579 [See the comment in gcconfig.h.])
582 dnl AC_DEFINE(NO_EXECUTE_PERMISSION)
583 dnl This is now redundant, but it is also important for incremental GC
584 dnl performance under Irix.
587 machdep="sparc_netbsd_mach_dep.lo"
589 sparc*-*-linux* | sparc*-*-openbsd* | sparc64-*-freebsd* | sparc64-*-netbsd*)
590 machdep="sparc_mach_dep.lo"
592 sparc-sun-solaris2.3)
593 machdep="sparc_mach_dep.lo"
594 AC_DEFINE(SUNOS53_SHARED_LIB, 1,
595 [Define to work around a Solaris 5.3 bug (see dyn_load.c).])
597 sparc*-sun-solaris2*)
598 machdep="sparc_mach_dep.lo"
601 machdep="ia64_save_regs_in_stack.lo"
604 AC_DEFINE(NO_EXECUTE_PERMISSION)
607 AC_MSG_RESULT($machdep)
608 addobjs="$addobjs $machdep"
614 dnl We use these options to decide which functions to include.
615 AC_ARG_WITH(target-subdir,
616 [ --with-target-subdir=SUBDIR
617 configuring with a cross compiler])
618 AC_ARG_WITH(cross-host,
619 [ --with-cross-host=HOST configuring with a cross compiler])
621 dnl automake wants to see AC_EXEEXT. But we don't need it. And having
622 dnl it is actually a problem, because the compiler we're passed can't
623 dnl necessarily do a full link. So we fool automake here.
625 dnl autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
626 dnl to nothing, so nothing would remain between `then' and `fi' if it
627 dnl were not for the `:' below.
632 dnl The collector might not properly work on IBM AIX when
633 dnl built with gcc and -O. So we remove -O in the appropriate case.
634 AC_MSG_CHECKING(whether AIX gcc optimization fix is necessary)
637 if test "$GCC" = yes; then
645 new_CFLAGS="$new_CFLAGS $i"
654 *) AC_MSG_RESULT(no) ;;
657 dnl Include defines that have become de facto standard.
658 dnl ALL_INTERIOR_POINTERS and NO_EXECUTE_PERMISSION can be overridden
659 dnl in the startup code.
660 AC_DEFINE([NO_EXECUTE_PERMISSION], [1],
661 [Define to make the collector not allocate executable memory
663 AC_DEFINE([ALL_INTERIOR_POINTERS], [1],
664 [Define to recognise all pointers to the interior of objects.])
667 dnl Interface Selection
668 dnl -------------------
670 dnl By default, make the library as general as possible.
671 dnl enable_gcj_support=no
672 AC_ARG_ENABLE(gcj-support,
673 [AC_HELP_STRING([--disable-gcj-support], [disable support for gcj])])
674 if test x"$enable_gcj_support" != xno; then
675 AC_DEFINE(GC_GCJ_SUPPORT, 1, [Define to include support for gcj.])
678 # FIXME: For a reason, gctest hangs up on kFreeBSD if both of
679 # THREAD_LOCAL_ALLOC and GC_ENABLE_SUSPEND_THREAD are defined.
680 if test "${enable_thread_local_alloc}" = no; then
681 AC_DEFINE(GC_ENABLE_SUSPEND_THREAD)
685 AC_DEFINE([GC_ENABLE_SUSPEND_THREAD], 1,
686 [Define to turn on GC_suspend_thread support.])
691 dnl Interaction with other programs that might use signals.
692 AC_ARG_ENABLE(sigrt-signals,
693 [AC_HELP_STRING([--enable-sigrt-signals],
694 [force GC to use SIGRTMIN-based signals for thread suspend/resume])])
695 if test x"${enable_sigrt_signals}" = xyes; then
696 AC_DEFINE([GC_USESIGRT_SIGNALS], 1,
697 [Force the GC to use signals based on SIGRTMIN+k.])
704 AH_TEMPLATE([GC_HAVE_BUILTIN_BACKTRACE],
705 [Define if backtrace information is supported.])
706 AH_TEMPLATE([MAKE_BACK_GRAPH], [See doc/README.macros.])
707 AH_TEMPLATE([SAVE_CALL_COUNT],
708 [The number of caller frames saved when allocating with the
711 AC_ARG_ENABLE(gc-debug,
712 [AC_HELP_STRING([--enable-gc-debug],
713 [include full support for pointer backtracing etc.])],
714 [ if test "$enable_gc_debug" = "yes"; then
715 AC_MSG_WARN("Should define GC_DEBUG and use debug alloc in clients.")
716 AC_DEFINE([KEEP_BACK_PTRS], 1,
717 [Define to save back-pointers in debugging headers.])
719 AC_DEFINE([DBG_HDRS_ALL], 1,
720 [Define to force debug headers on all objects.])
721 AH_TEMPLATE([SHORT_DBG_HDRS],
722 [Shorten the headers to minimize object size at the expense
723 of checking for writes past the end (see doc/README.macros).])
727 AC_DEFINE(MAKE_BACK_GRAPH)
728 AC_DEFINE(SAVE_CALL_COUNT, 8)
729 AC_CHECK_LIB(unwind, backtrace, [
730 AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
732 AC_MSG_WARN("Client code may need to link against libunwind.")
735 x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
736 AC_DEFINE(MAKE_BACK_GRAPH)
737 AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
738 AC_DEFINE(SAVE_CALL_COUNT, 8)
741 AC_DEFINE(MAKE_BACK_GRAPH)
745 AM_CONDITIONAL([MAKE_BACK_GRAPH], [test x"$enable_gc_debug" = xyes])
746 AM_CONDITIONAL([KEEP_BACK_PTRS], [test x"$keep_back_ptrs" = xtrue])
748 # Check for dladdr (used for debugging).
749 AC_MSG_CHECKING(for dladdr)
752 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
754 #define _GNU_SOURCE 1
755 #include <dlfcn.h>], [{
757 (void)dladdr("", &info);
758 }], [ have_dladdr=yes ])
760 AC_MSG_RESULT($have_dladdr)
761 if test x"$have_dladdr" = xyes; then
762 AC_DEFINE([HAVE_DLADDR], 1, [Define to use 'dladdr' function.])
765 # sigsetjmp could be a macro (thus AC_CHECK_FUNCS cannot be used).
766 AC_MSG_CHECKING(for sigsetjmp)
768 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
769 AC_TRY_LINK([#include <setjmp.h>],
770 [sigjmp_buf t; sigsetjmp(t, 0)],
771 [AC_MSG_RESULT(yes)],
773 AC_DEFINE([GC_NO_SIGSETJMP], [1], [Missing sigsetjmp function.])])
776 # Check for AViiON Machines running DGUX
778 AC_CHECK_HEADER(sys/dg_sys_info.h,
781 dnl :GOTCHA: we do not check anything but sys/dg_sys_info.h
782 if test $ac_is_dgux = yes; then
783 dgux_spec_opts="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
784 CFLAGS="$dgux_spec_opts $CFLAGS"
785 CXXFLAGS="$dgux_spec_opts $CXXFLAGS"
786 if test "$enable_gc_debug" = "yes"; then
787 CFLAGS="-g -mstandard $CFLAGS"
788 CXXFLAGS="-g -mstandard $CXXFLAGS"
794 AC_ARG_ENABLE(java-finalization,
795 [AC_HELP_STRING([--disable-java-finalization],
796 [disable support for java finalization])])
797 if test x"$enable_java_finalization" != xno; then
798 AC_DEFINE([JAVA_FINALIZATION], 1, [See doc/README.macros.])
801 AC_ARG_ENABLE(atomic-uncollectable,
802 [AC_HELP_STRING([--disable-atomic-uncollectible],
803 [disable support for atomic uncollectible allocation])])
804 if test x"$enable_atomic_uncollectible" != x"no"; then
805 AC_DEFINE([GC_ATOMIC_UNCOLLECTABLE], 1,
806 [Define to enable atomic uncollectible allocation.])
809 AC_ARG_ENABLE(redirect-malloc,
810 [AC_HELP_STRING([--enable-redirect-malloc],
811 [redirect malloc and friends to GC routines])])
813 if test "${enable_redirect_malloc}" = yes; then
814 if test "${enable_gc_debug}" = yes; then
815 AC_DEFINE([REDIRECT_MALLOC], GC_debug_malloc_replacement,
816 [If defined, redirect malloc to this function.])
817 AC_DEFINE([REDIRECT_REALLOC], GC_debug_realloc_replacement,
818 [If defined, redirect GC_realloc to this function.])
819 AC_DEFINE([REDIRECT_FREE], GC_debug_free,
820 [If defined, redirect free to this function.])
822 AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
824 AC_DEFINE([GC_USE_DLOPEN_WRAP], 1, [See doc/README.macros.])
827 AC_ARG_ENABLE(disclaim,
828 [AC_HELP_STRING([--disable-disclaim],
829 [disable alternative (more efficient) finalization interface])])
830 if test x"$enable_disclaim" != xno; then
831 AC_DEFINE(ENABLE_DISCLAIM, 1,
832 [Define to enable alternative finalization interface.])
834 AM_CONDITIONAL(ENABLE_DISCLAIM,
835 [test x"$enable_disclaim" != xno])
837 AC_ARG_ENABLE(large-config,
838 [AC_HELP_STRING([--enable-large-config],
839 [optimize for large (> 100 MB) heap or root set])])
840 if test "${enable_large_config}" = yes; then
841 AC_DEFINE(LARGE_CONFIG, 1,
842 [Define to optimize for large heaps or root sets.])
845 dnl This is something of a hack. When cross-compiling we turn off
846 dnl some functionality. We also enable the "small" configuration.
847 dnl These is only correct when targeting an embedded system. FIXME.
848 if test -n "${with_cross_host}"; then
849 AC_DEFINE([NO_CLOCK], 1, [Define to not use system clock (cross compiling).])
850 AC_DEFINE([SMALL_CONFIG], 1,
851 [Define to tune the collector for small heap sizes.])
854 if test "$enable_gc_debug" = "no"; then
855 AC_DEFINE([NO_DEBUGGING], 1,
856 [Disable debugging, like GC_dump and its callees.])
861 AC_ARG_ENABLE(gc-assertions,
862 [AC_HELP_STRING([--enable-gc-assertions],
863 [collector-internal assertion checking])])
864 if test "${enable_gc_assertions}" = yes; then
865 AC_DEFINE([GC_ASSERTIONS], 1,
866 [Define to enable internal debug assertions.])
870 [AS_HELP_STRING([--enable-mmap],
871 [use mmap instead of sbrk to expand the heap])],
872 gc_use_mmap=$enableval)
874 AC_ARG_ENABLE(munmap,
875 [AC_HELP_STRING([--enable-munmap=N],
876 [return page to the OS if empty for N collections
878 MUNMAP_THRESHOLD=$enableval)
879 if test x$enable_munmap != xno; then
880 AC_DEFINE([USE_MMAP], 1,
881 [Define to use mmap instead of sbrk to expand the heap.])
882 AH_TEMPLATE([USE_WINALLOC],
883 [Define to use Win32 VirtualAlloc (instead of sbrk or
884 mmap) to expand the heap.])
885 AC_DEFINE([USE_MUNMAP], 1,
886 [Define to return memory to OS with munmap calls
887 (see doc/README.macros).])
888 if test x$MUNMAP_THRESHOLD = x -o x$MUNMAP_THRESHOLD = xyes; then
891 AC_DEFINE_UNQUOTED([MUNMAP_THRESHOLD], [${MUNMAP_THRESHOLD}],
892 [Number of GC cycles to wait before unmapping an unused block.])
894 if test "${gc_use_mmap}" = "yes"; then
895 AC_DEFINE([USE_MMAP], 1,
896 [Define to use mmap instead of sbrk to expand the heap.])
900 AC_ARG_ENABLE(dynamic-loading,
901 [AS_HELP_STRING([--disable-dynamic-loading],
902 [build the collector with disabled tracing
903 of dynamic library data roots])])
904 if test "${enable_dynamic_loading}" = "no"; then
905 AC_DEFINE([IGNORE_DYNAMIC_LOADING], 1,
906 [Do not define DYNAMIC_LOADING even if supported (i.e., build the
907 collector with disabled tracing of dynamic library data roots).])
910 AC_ARG_ENABLE(register-main-static-data,
911 [AS_HELP_STRING([--disable-register-main-static-data],
912 [skip the initial guess of data root sets])])
913 if test "${enable_register_main_static_data}" = "no"; then
914 AC_DEFINE([GC_DONT_REGISTER_MAIN_STATIC_DATA], 1,
915 [Skip the initial guess of data root sets.])
918 AC_ARG_ENABLE(checksums,
919 [AS_HELP_STRING([--enable-checksums],
920 [report on erroneously cleared dirty bits at
921 substantial performance cost; use only for
922 debugging of the incremental collector])])
923 if test x$enable_checksums = xyes; then
924 if test x$enable_munmap != xno -o x$THREADS != xnone; then
925 AC_MSG_ERROR([CHECKSUMS not compatible with USE_MUNMAP or threads])
927 AC_DEFINE([CHECKSUMS], 1,
928 [Erroneously cleared dirty bits checking. Use only for
929 debugging of the incremental collector.])
931 AM_CONDITIONAL([CHECKSUMS], test x$enable_checksums = xyes)
933 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
935 AC_ARG_ENABLE(werror,
936 [AS_HELP_STRING([--enable-werror], [pass -Werror to the C compiler])],
937 werror_flag=$enableval, werror_flag=no)
938 if test x$werror_flag = xyes; then
939 WERROR_CFLAGS="-Werror"
941 # _dyld_bind_fully_image_containing_address is deprecated in OS X 10.5+
943 WERROR_CFLAGS="$WERROR_CFLAGS -Wno-deprecated-declarations"
947 AC_SUBST([WERROR_CFLAGS])
949 AC_ARG_ENABLE(single-obj-compilation,
950 [AC_HELP_STRING([--enable-single-obj-compilation],
951 [compile all libgc source files into single .o
952 (default: yes if static libraries are disabled)])],
953 [], [ AS_IF([test x"$enable_static" = xno],
954 [enable_single_obj_compilation=yes]) ])
955 AM_CONDITIONAL([SINGLE_GC_OBJ],
956 [test x"$enable_single_obj_compilation" = xyes])
959 [AS_HELP_STRING([--enable-gcov], [turn on code coverage analysis])])
960 if test "$enable_gcov" = "yes"; then
961 CFLAGS="$CFLAGS --coverage"
962 if test "${enable_shared}" = no; then
963 # FIXME: As of g++-4.8.4/x86_64, in case of shared library build, test_cpp
964 # linkage fails with "hidden symbol atexit is referenced by DSO" message.
965 CXXFLAGS="$CXXFLAGS --coverage"
967 # Turn off optimization to get accurate line numbers.
968 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'`
969 CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'`
973 [AC_HELP_STRING([--disable-docs],
974 [do not build and install documentation])])
975 AM_CONDITIONAL(ENABLE_DOCS, test x$enable_docs != xno)
977 AM_CONDITIONAL(ENABLE_SHARED, test x$enable_shared = xyes)
982 # Do we want to use an external libatomic_ops? By default use it if it's
984 AC_ARG_WITH([libatomic-ops],
985 [AS_HELP_STRING([--with-libatomic-ops[=yes|no|check|none]],
986 [Use an external libatomic_ops? (default: check;
987 none: use compiler intrinsics or no thread support)])],
988 [], [ AS_IF([test x"$THREADS" != xnone],
989 [with_libatomic_ops=check], [with_libatomic_ops=none]) ])
991 # Check whether compiler atomic intrinsics can be used.
992 if test x"$with_libatomic_ops" = xcheck; then
993 AC_MSG_CHECKING(for compiler intrinsics support)
995 CFLAGS="$CFLAGS $CFLAGS_EXTRA -DGC_BUILTIN_ATOMIC"
996 CFLAGS="$CFLAGS -I${srcdir}/include -I${srcdir}/tests"
997 AC_TRY_RUN([#include "test_atomic_ops.c"],
999 with_libatomic_ops=none],
1000 [AC_MSG_RESULT(no)], [AC_MSG_RESULT(skipped because cross-compiling)])
1001 CFLAGS="$old_CFLAGS"
1004 # Check for an external libatomic_ops if the above answer is "yes" or "check".
1005 # If not found, fail on "yes", and convert "check" to "no".
1006 # First, check that libatomic_ops usage is not disabled explicitly.
1007 missing_libatomic_ops=false
1008 AS_IF([test x"$with_libatomic_ops" != xno -a x"$with_libatomic_ops" != xnone],
1009 [ missing_libatomic_ops=true ])
1011 dnl To avoid "syntax error near unexpected token ATOMIC_OPS" configure error
1012 dnl observed by some clients, the following 3 code lines are commented out:
1014 dnl AS_IF([test x$missing_libatomic_ops = xtrue],
1015 dnl [ PKG_CHECK_MODULES([ATOMIC_OPS], [atomic_ops],
1016 dnl [ missing_libatomic_ops=false ], [ [] ]) ])
1018 dnl Retry with AC_CHECK_HEADER if PKG_CHECK_MODULES failed.
1019 AS_IF([test x$missing_libatomic_ops = xtrue],
1020 [ AC_CHECK_HEADER([atomic_ops.h], [missing_libatomic_ops=false]) ])
1021 AS_IF([test x$missing_libatomic_ops = xtrue],
1022 [ AS_IF([test x"$with_libatomic_ops" != xcheck],
1023 [ AC_MSG_ERROR([An external libatomic_ops was not found]) ])
1024 with_libatomic_ops=no ])
1026 # If we have neither an external or an internal version, offer a useful hint
1028 AS_IF([test x"$with_libatomic_ops" = xno \
1029 -a ! -e "$srcdir/libatomic_ops/src/atomic_ops.h"],
1030 [ AC_MSG_ERROR([libatomic_ops is required. You can either install it on
1031 your system, or fetch and unpack a recent version into the
1032 source directory and link or rename it to libatomic_ops.]) ])
1034 # Finally, emit the definitions for bundled or external AO.
1035 AC_MSG_CHECKING([which libatomic_ops to use])
1036 AS_IF([test x"$with_libatomic_ops" != xno],
1037 [ AS_IF([test x"$with_libatomic_ops" != xnone -a x"$THREADS" != xnone],
1038 [ AC_MSG_RESULT([external])
1039 ATOMIC_OPS_LIBS="-latomic_ops"
1040 AC_SUBST([ATOMIC_OPS_LIBS]) ],
1041 [ AC_MSG_RESULT([none])
1042 AS_IF([test x"$THREADS" != xnone],
1043 [ AC_DEFINE([GC_BUILTIN_ATOMIC], [1],
1044 [Use C11 (GCC) atomic intrinsics instead of
1045 libatomic_ops primitives.]) ]) ])
1046 AO_TRYLINK_CFLAGS="" ],
1047 [ AC_MSG_RESULT([internal])
1048 AO_TRYLINK_CFLAGS="-I${srcdir}/libatomic_ops/src"
1049 ATOMIC_OPS_CFLAGS='-I$(top_builddir)/libatomic_ops/src -I$(top_srcdir)/libatomic_ops/src'
1051 AC_SUBST([ATOMIC_OPS_CFLAGS])
1052 AC_CONFIG_SUBDIRS([libatomic_ops])
1054 AM_CONDITIONAL([USE_INTERNAL_LIBATOMIC_OPS],
1055 [test x$with_libatomic_ops = xno -a x"$THREADS" != xnone])
1056 AM_CONDITIONAL([NEED_ATOMIC_OPS_ASM],
1057 [test x$with_libatomic_ops = xno -a x$need_atomic_ops_asm = xtrue])
1059 # Check whether particular AO primitives are emulated with locks.
1060 # The check below is based on the fact that linking with the libatomic_ops
1061 # binary file is not needed in case of absence of the emulation (except for
1063 AS_IF([test x$with_libatomic_ops != xnone -a x$need_atomic_ops_asm != xtrue],
1064 [ old_CFLAGS="$CFLAGS"
1065 CFLAGS="$CFLAGS $AO_TRYLINK_CFLAGS $CFLAGS_EXTRA"
1066 AC_MSG_CHECKING([for lock-free AO_or primitive])
1067 AC_TRY_LINK([#include "atomic_ops.h"],
1068 [AO_t x=0;AO_or(&x,1)],
1069 [ AC_MSG_RESULT(yes)
1070 AC_DEFINE([HAVE_LOCKFREE_AO_OR], [1],
1071 [libatomic_ops AO_or primitive implementation is lock-free.]) ],
1072 [ AC_MSG_RESULT(no) ])
1073 AC_MSG_CHECKING([for lock-free AO load/store, test-and-set primitives])
1074 AC_TRY_LINK([#include "atomic_ops.h"],
1075 [AO_t x=0;unsigned char c=0;AO_TS_t z=AO_TS_INITIALIZER;
1076 (void)AO_test_and_set_acquire(&z);AO_CLEAR(&z);AO_compiler_barrier();
1077 AO_store(&x,AO_load(&x)+1);AO_char_store(&c,AO_char_load(&c)+1);
1078 AO_store_release(&x,AO_load_acquire(&x)+1)],
1079 [ AC_MSG_RESULT(yes) ],
1081 use_thread_local_alloc=no
1082 AC_DEFINE([BASE_ATOMIC_OPS_EMULATED], [1],
1083 [AO load, store and/or test-and-set primitives are
1084 implemented in libatomic_ops using locks.]) ])
1085 AS_IF([test x$use_parallel_mark != xno],
1087 [for lock-free compare-and-swap and fetch-and-add primitives])
1089 [#define AO_REQUIRE_CAS
1090 #include "atomic_ops.h"],
1091 [AO_t x=0;(void)AO_fetch_and_add(&x,1);(void)AO_compare_and_swap(&x,1,2)],
1092 [ AC_MSG_RESULT(yes) ],
1094 use_parallel_mark=no ]) ])
1095 CFLAGS="$old_CFLAGS" ])
1097 AS_IF([test x$use_parallel_mark != xno],
1098 [ AC_DEFINE(PARALLEL_MARK) ])
1099 AS_IF([test x$use_thread_local_alloc != xno],
1100 [ AC_DEFINE(THREAD_LOCAL_ALLOC) ])
1101 AM_CONDITIONAL(THREAD_LOCAL_ALLOC, test x$use_thread_local_alloc != xno)
1103 AC_ARG_ENABLE(handle-fork,
1104 [ AC_HELP_STRING([--enable-handle-fork[=yes|no|auto|manual]],
1105 [attempt to ensure a usable collector after fork()
1106 in multi-threaded programs (default: auto;
1107 manual: GC_atfork_prepare/parent/child should be
1108 called by the client)]) ])
1109 if test "${enable_handle_fork}" = yes; then
1110 AC_DEFINE(HANDLE_FORK, 1,
1111 [Define to install pthread_atfork() handlers by default.])
1112 elif test "${enable_handle_fork}" = no; then
1113 AC_DEFINE(NO_HANDLE_FORK, 1,
1114 [Prohibit installation of pthread_atfork() handlers.])
1115 elif test "${enable_handle_fork}" != manual -a x$THREADS = xposix; then
1116 # If the option is omitted, pthread_atfork handlers are installed
1117 # by default for the targets where pthread_atfork is known to work.
1120 # Android NDK does not provide pthread_atfork.
1123 # The incremental mode (which is off if parallel marking) conflicts
1124 # with fork handling on Darwin.
1125 if test x$use_parallel_mark != xno; then
1126 AC_DEFINE(HANDLE_FORK)
1129 *-*-aix* | *-*-cygwin* | *-*-freebsd* | *-*-haiku* | \
1130 *-*-hpux11* | *-*-irix* | *-*-kfreebsd*-gnu | \
1131 *-*-*linux* | *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)
1132 AC_DEFINE(HANDLE_FORK)
1137 dnl Produce the Files
1138 dnl -----------------
1140 AC_CONFIG_FILES([Makefile bdw-gc.pc])
1142 AC_CONFIG_COMMANDS([default],,
1143 [ srcdir="${srcdir}"
1145 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}