Debian Codegraph @

gc/configure.ac

raw
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-2021 Ivan Maidanski
4 #
5 # THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
6 # OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
7 #
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.
13
14 dnl Process this file with autoconf to produce configure.
15
16 dnl Initialization.
17 AC_INIT([gc],[8.2.8],[https://github.com/ivmai/bdwgc/issues])
18 dnl Version must conform to: [0-9]+[.][0-9]+[.][0-9]+
19
20 AC_CONFIG_SRCDIR(gcj_mlc.c)
21 AC_CONFIG_MACRO_DIR([m4])
22 AC_CANONICAL_TARGET
23 AC_PREREQ([2.71])
24 GC_SET_VERSION
25 AM_INIT_AUTOMAKE([foreign nostdinc subdir-objects])
26 AC_CONFIG_HEADERS([include/config.h])
27 AM_MAINTAINER_MODE
28
29 AC_SUBST(PACKAGE)
30 AC_SUBST(GC_VERSION)
31
32 AM_PROG_CC_C_O
33 AC_PROG_CXX
34 AM_PROG_AS
35 AC_PROG_INSTALL
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 LT_INIT) is undefined, Libtool installation should be checked.
41
42 # Special CFLAGS to use when building
43 gc_cflags=""
44
45 # Set to "yes" on platforms where mmap should be used instead of sbrk.
46 # This will define USE_MMAP.
47 gc_use_mmap=""
48
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"
53 else
54 case "$host" in
55 hppa*-*-hpux* )
56 if test :$GCC: != :"yes": ; then
57 gc_cflags="${gc_cflags} +ESdbgasm"
58 fi
59 # :TODO: actually we should check using Autoconf if
60 # the compiler supports this option.
61 ;;
62 esac
63 fi
64
65 # target_optspace --enable-target-optspace ("yes", "no", "")
66 case "${target_optspace}:${host}" in
67 yes:*)
68 gc_cflags="${gc_cflags} -Os"
69 ;;
70 :m32r-* | :d10v-* | :d30v-*)
71 gc_cflags="${gc_cflags} -Os"
72 ;;
73 no:* | :*)
74 # Nothing.
75 ;;
76 esac
77
78 # Set any host dependent compiler flags.
79 case "${host}" in
80 mips-tx39-*|mipstx39-unknown-*)
81 gc_cflags="${gc_cflags} -G 0"
82 ;;
83 *)
84 ;;
85 esac
86
87 AC_MSG_CHECKING([for emscripten])
88 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
89 # ifndef __EMSCRIPTEN__
90 # error This is not Emscripten
91 # endif
92 ]])], [emscripten=yes], [emscripten=no])
93 AM_CONDITIONAL(EMSCRIPTEN, test x$emscripten = xyes)
94 AC_MSG_RESULT([$emscripten])
95
96 AC_ARG_ENABLE(emscripten-asyncify,
97 [AS_HELP_STRING([--enable-emscripten-asyncify],
98 [use Emscripten asyncify feature])])
99 # Use this option if your program is targeting -sASYNCIFY. The latter is
100 # required to scan the stack, ASYNCIFY_STACK_SIZE is probably needed for
101 # gctest only.
102 AS_IF([test "${emscripten}" = yes -a "${enable_emscripten_asyncify}" = yes],
103 [gc_cflags="${gc_cflags} -DEMSCRIPTEN_ASYNCIFY"
104 gc_cflags="${gc_cflags} -sASYNCIFY -sASYNCIFY_STACK_SIZE=128000"])
105
106 GC_CFLAGS=${gc_cflags}
107 AC_SUBST(GC_CFLAGS)
108
109 dnl Extra user-defined flags to pass both to C and C++ compilers.
110 AC_SUBST([CFLAGS_EXTRA])
111
112 AC_ARG_ENABLE(threads,
113 [AS_HELP_STRING([--enable-threads=TYPE], [choose threading package])],
114 THREADS=$enableval,
115 [ AC_MSG_CHECKING([for thread model used by GCC])
116 THREADS=`$CC -v 2>&1 | sed -n 's/^Thread model: //p'`
117 if test -z "$THREADS" -o "x$emscripten" = "xyes"; then
118 THREADS=no
119 fi
120 if test "$THREADS" = "posix"; then
121 case "$host" in
122 *-*-mingw*)
123 # Adjust thread model if cross-compiling for MinGW.
124 THREADS=win32
125 ;;
126 esac
127 fi
128 AC_MSG_RESULT([$THREADS]) ])
129
130 AC_ARG_ENABLE(parallel-mark,
131 [AS_HELP_STRING([--disable-parallel-mark],
132 [do not parallelize marking and free list construction])],
133 [case "$THREADS" in
134 no | none | single)
135 if test "${enable_parallel_mark}" != no; then
136 AC_MSG_ERROR([Parallel mark requires --enable-threads=x spec])
137 fi
138 ;;
139 esac])
140
141 AC_ARG_ENABLE(thread-local-alloc,
142 [AS_HELP_STRING([--disable-thread-local-alloc],
143 [turn off thread-local allocation optimization])],
144 [case "$THREADS" in
145 no | none | single)
146 if test "${enable_thread_local_alloc}" = yes; then
147 AC_MSG_ERROR(
148 [Thread-local allocation requires --enable-threads=x spec])
149 fi
150 ;;
151 esac])
152
153 AC_ARG_ENABLE(threads-discovery,
154 [AS_HELP_STRING([--disable-threads-discovery],
155 [disable threads discovery in GC])])
156 if test "${enable_threads_discovery}" = no; then
157 AC_DEFINE([GC_NO_THREADS_DISCOVERY], 1,
158 [Disable threads discovery in GC.])
159 fi
160
161 AC_ARG_ENABLE(cplusplus,
162 [AS_HELP_STRING([--enable-cplusplus], [install C++ support])])
163
164 dnl Features which may be selected in the following thread-detection switch.
165 AH_TEMPLATE([PARALLEL_MARK], [Define to enable parallel marking.])
166 AH_TEMPLATE([THREAD_LOCAL_ALLOC],
167 [Define to enable thread-local allocation optimization.])
168 AH_TEMPLATE([USE_COMPILER_TLS],
169 [Define to use of compiler-support for thread-local variables.])
170
171 dnl Thread selection macros.
172 AH_TEMPLATE([GC_THREADS], [Define to support platform-specific
173 threads.])
174 AH_TEMPLATE([GC_WIN32_PTHREADS],
175 [Define to support pthreads-win32 or winpthreads.])
176
177 dnl System header feature requests.
178 AH_TEMPLATE([_POSIX_C_SOURCE], [The POSIX feature macro.])
179 AH_TEMPLATE([_PTHREADS], [Indicates the use of pthreads (NetBSD).])
180
181 dnl Win32-specific API usage controls.
182 AH_TEMPLATE([GC_UNDERSCORE_STDCALL],
183 [Explicitly prefix exported/imported WINAPI symbols with '_'.])
184 AH_TEMPLATE([UNICODE],
185 [Use Unicode (W) variant of Win32 API instead of ASCII (A) one.])
186
187 dnl GC API symbols export control.
188 AH_TEMPLATE([GC_DLL],
189 [Define to build dynamic libraries with only API symbols exposed.])
190
191 dnl Check for a flavor of supported inline keyword.
192 old_CFLAGS="$CFLAGS"
193 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
194 AC_C_INLINE
195 CFLAGS="$old_CFLAGS"
196
197 THREADDLLIBS=
198 need_atomic_ops_asm=false
199 need_lib_rt=false
200 compile_asm=false
201 use_parallel_mark=no
202 use_thread_local_alloc=no
203 # Libraries needed to support dynamic loading and/or threads.
204 case "$THREADS" in
205 no | none | single)
206 THREADS=none
207 ;;
208 posix | pthreads)
209 THREADS=posix
210 default_threadlibs=false
211 # Common defines for most POSIX platforms.
212 case "$host" in
213 *-*-aix* | *-*-android* | *-*-cygwin* | *-*-darwin* | *-*-dragonfly* | \
214 *-*-freebsd* | *-*-haiku* | *-*-hpux11* | *-*-irix* | \
215 *-*-kfreebsd*-gnu | *-*-gnu* | *-*-*linux* | *-*-msys* | *-*-nacl* | \
216 *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)
217 AC_DEFINE(GC_THREADS)
218 AC_DEFINE([_REENTRANT], [1],
219 [Required define if using POSIX threads.])
220 use_parallel_mark=$enable_parallel_mark
221 use_thread_local_alloc=$enable_thread_local_alloc
222 default_threadlibs=true
223 AC_MSG_WARN("Explicit GC_INIT() calls may be required.")
224 ;;
225 esac
226 AC_CHECK_LIB(pthread, pthread_self, THREADDLLIBS="-lpthread",,)
227 case "$host" in
228 *-*-hpux11*)
229 AC_MSG_WARN("Only HP/UX 11 POSIX threads are supported.")
230 AC_DEFINE(_POSIX_C_SOURCE,199506L)
231 THREADDLLIBS="-lpthread"
232 # HPUX needs REENTRANT for the _r calls.
233 need_lib_rt=true
234 ;;
235 *-*-openbsd*)
236 AM_CFLAGS="$AM_CFLAGS -pthread"
237 THREADDLLIBS=-pthread
238 ;;
239 *-*-freebsd*)
240 AM_CFLAGS="$AM_CFLAGS -pthread"
241 ;;
242 *-*-kfreebsd*-gnu)
243 AM_CFLAGS="$AM_CFLAGS -pthread"
244 THREADDLLIBS=-pthread
245 ;;
246 *-*-gnu*) # E.g. linux but excluding kfreebsd.
247 # The default THREADDLLIBS.
248 ;;
249 *-*-netbsd*)
250 AC_MSG_WARN("Only on NetBSD 2.0 or later.")
251 AC_DEFINE(_PTHREADS)
252 THREADDLLIBS="-lpthread"
253 need_lib_rt=true
254 ;;
255 *-*-solaris*)
256 THREADDLLIBS="-lpthread"
257 need_lib_rt=true
258 ;;
259 *-*-cygwin* | *-*-msys*)
260 # Cygwin doesn't have a real libpthread, so Libtool can't link
261 # against it.
262 THREADDLLIBS=""
263 win32_threads=true
264 ;;
265 *-*-mingw*)
266 AC_DEFINE(GC_WIN32_PTHREADS)
267 # Using pthreads-win32 (or other non-Cygwin pthreads) library.
268 THREADDLLIBS="-lpthread"
269 use_parallel_mark=$enable_parallel_mark
270 use_thread_local_alloc=$enable_thread_local_alloc
271 win32_threads=true
272 ;;
273 *-*-darwin*)
274 darwin_threads=true
275 ;;
276 *-*-osf*)
277 AM_CFLAGS="$AM_CFLAGS -pthread"
278 THREADDLLIBS="-lpthread"
279 need_lib_rt=true
280 ;;
281 *)
282 AS_IF([test x$default_threadlibs != xtrue],
283 [ AC_MSG_ERROR(
284 [Pthreads not supported by the GC on this platform]) ])
285 # The default THREADDLLIBS.
286 ;;
287 esac
288 case "$host" in
289 sparc*-*-solaris*)
290 if test "$GCC" != yes; then
291 need_atomic_ops_asm=true
292 fi
293 ;;
294 esac
295 ;;
296 mcf | win32)
297 AC_DEFINE(GC_THREADS)
298 use_parallel_mark=$enable_parallel_mark
299 if test "${enable_parallel_mark}" != no \
300 -o "${enable_shared}" != yes -o "${enable_static}" != no; then
301 # Imply THREAD_LOCAL_ALLOC unless GC_DLL.
302 use_thread_local_alloc=$enable_thread_local_alloc
303 fi
304 if test "${enable_win32_dllmain}" = yes; then
305 AC_DEFINE(GC_INSIDE_DLL, 1,
306 [Enable Win32 DllMain-based approach of threads registering.])
307 fi
308 win32_threads=true
309 AC_DEFINE([EMPTY_GETENV_RESULTS], [1],
310 [Wine getenv may not return NULL for missing entry.])
311 ;;
312 dgux386)
313 AC_DEFINE(GC_THREADS)
314 # Use pthread GCC switch
315 THREADDLLIBS=-pthread
316 use_parallel_mark=$enable_parallel_mark
317 use_thread_local_alloc=$enable_thread_local_alloc
318 AC_MSG_WARN("Explicit GC_INIT() calls may be required.")
319 AM_CFLAGS="-pthread $AM_CFLAGS"
320 ;;
321 aix)
322 THREADS=posix
323 THREADDLLIBS=-lpthread
324 AC_DEFINE(GC_THREADS)
325 AC_DEFINE(_REENTRANT)
326 use_parallel_mark=$enable_parallel_mark
327 use_thread_local_alloc=$enable_thread_local_alloc
328 ;;
329 rtems)
330 THREADS=posix
331 AC_DEFINE(GC_THREADS)
332 use_parallel_mark=$enable_parallel_mark
333 use_thread_local_alloc=$enable_thread_local_alloc
334 ;;
335 decosf1 | irix | mach | os2 | solaris | dce | vxworks)
336 AC_MSG_ERROR(thread package $THREADS not yet supported)
337 ;;
338 *)
339 AC_MSG_ERROR($THREADS is an unknown thread package)
340 ;;
341 esac
342
343 # Check whether -lrt linker option is needed to use clock_gettime.
344 if test "x$need_lib_rt" != xtrue; then
345 AC_MSG_CHECKING(for clock_gettime without additional libraries)
346 AC_LINK_IFELSE([AC_LANG_PROGRAM([#include <time.h>],
347 [struct timespec t; clock_gettime(CLOCK_REALTIME, &t)])],
348 [AC_MSG_RESULT(yes)],
349 [AC_MSG_RESULT(no)
350 AC_CHECK_LIB(rt, clock_gettime, [need_lib_rt=true])])
351 fi
352
353 if test "x$need_lib_rt" = xtrue; then
354 THREADDLLIBS="$THREADDLLIBS -lrt"
355 fi
356 AC_SUBST(THREADDLLIBS)
357
358 AM_CONDITIONAL(THREADS, test x$THREADS != xnone)
359 AM_CONDITIONAL(PTHREADS, test x$THREADS = xposix)
360 AM_CONDITIONAL(DARWIN_THREADS, test x$darwin_threads = xtrue)
361 AM_CONDITIONAL(WIN32_THREADS, test x$win32_threads = xtrue)
362
363 compiler_suncc=no
364 pthread_start_standalone=no
365 case "$host" in
366 *-*-*linux*)
367 # Turn on the workaround described in pthread_start.c.
368 AS_IF([test "$THREADS" = posix], [pthread_start_standalone=yes])
369 ;;
370 powerpc-*-darwin*)
371 powerpc_darwin=true
372 ;;
373 *-*-solaris*)
374 if test "$GCC" != yes; then
375 # Solaris SunCC
376 compiler_suncc=yes
377 CFLAGS="-O $CFLAGS"
378 fi
379 ;;
380 *-*-wince*)
381 if test "$enable_gc_debug" != "no"; then
382 AC_DEFINE([GC_READ_ENV_FILE], 1,
383 [Read environment variables from the GC 'env' file.])
384 fi
385 ;;
386 esac
387 AM_CONDITIONAL(PTHREAD_START_STANDALONE,
388 test x$pthread_start_standalone = xyes)
389
390 if test "$GCC" = yes; then
391 # Output all warnings.
392 AC_MSG_CHECKING([whether compiler supports -Wextra])
393 old_CFLAGS="$CFLAGS"
394 CFLAGS="-Wextra $CFLAGS"
395 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ac_cv_cc_wextra=yes],[ac_cv_cc_wextra=no])
396 CFLAGS="$old_CFLAGS"
397 AC_MSG_RESULT($ac_cv_cc_wextra)
398 AS_IF([test "$ac_cv_cc_wextra" = yes], [WEXTRA="-Wextra"], [WEXTRA="-W"])
399 AC_MSG_CHECKING([whether compiler supports -Wpedantic])
400 CFLAGS="-Wpedantic -Wno-long-long $CFLAGS"
401 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
402 extern int quiet;
403 ]])],[ac_cv_cc_pedantic=yes],[ac_cv_cc_pedantic=no])
404 CFLAGS="$old_CFLAGS"
405 AC_MSG_RESULT($ac_cv_cc_pedantic)
406 WPEDANTIC=
407 AS_IF([test "$ac_cv_cc_pedantic" = yes],
408 [WPEDANTIC="-Wpedantic -Wno-long-long"])
409 CFLAGS="-Wall $WEXTRA $WPEDANTIC $CFLAGS"
410 CXXFLAGS="-Wall $WEXTRA $WPEDANTIC $CXXFLAGS"
411 fi
412
413 AC_MSG_CHECKING(for xlc)
414 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
415 #ifndef __xlC__
416 # error
417 #endif
418 ]])],[compiler_xlc=yes],[compiler_xlc=no])
419 AC_MSG_RESULT($compiler_xlc)
420 if test $compiler_xlc = yes -a "$powerpc_darwin" = true; then
421 # the darwin stack-frame-walking code is completely broken on xlc
422 AC_DEFINE([DARWIN_DONT_PARSE_STACK], 1, [See doc/README.macros.])
423 fi
424
425 # XLC neither requires nor tolerates the unnecessary assembler goop.
426 # Similar for the Sun C compiler.
427 AM_CONDITIONAL([ASM_WITH_CPP_UNSUPPORTED],
428 [test $compiler_xlc = yes -o $compiler_suncc = yes])
429
430 if test "$GCC" = yes; then
431 # Disable aliasing optimization unless forced to.
432 AC_MSG_CHECKING([whether compiler supports -fno-strict-aliasing])
433 ac_cv_fno_strict_aliasing=no
434 for cflag in $CFLAGS; do
435 case "$cflag" in
436 -fstrict-aliasing)
437 # Opposite option already present
438 ac_cv_fno_strict_aliasing=skipped
439 break
440 ;;
441 esac
442 done
443 if test "$ac_cv_fno_strict_aliasing" != skipped; then
444 old_CFLAGS="$CFLAGS"
445 CFLAGS="$CFLAGS -fno-strict-aliasing"
446 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ac_cv_fno_strict_aliasing=yes],[])
447 CFLAGS="$old_CFLAGS"
448 AS_IF([test "$ac_cv_fno_strict_aliasing" = yes],
449 [CFLAGS="$CFLAGS -fno-strict-aliasing"], [])
450 fi
451 AC_MSG_RESULT($ac_cv_fno_strict_aliasing)
452 fi
453
454 # Check for getcontext (uClibc can be configured without it, for example)
455 AC_CHECK_FUNC([getcontext], [],
456 [ AC_DEFINE([NO_GETCONTEXT], [1], [Missing getcontext function.]) ])
457
458 # Check whether dl_iterate_phdr exists (as a strong symbol).
459 AC_CHECK_FUNCS([dl_iterate_phdr])
460
461 case "$host" in
462 # While IRIX 6 has libdl for the O32 and N32 ABIs, it's missing for N64
463 # and unnecessary everywhere.
464 mips-sgi-irix6*) ;;
465 # We never want libdl on darwin. It is a fake libdl that just ends up making
466 # dyld calls anyway. The same applies to Cygwin.
467 *-*-cygwin* | *-*-darwin* | *-*-msys*)
468 ;;
469 *)
470 AC_CHECK_LIB(dl, dlopen, THREADDLLIBS="$THREADDLLIBS -ldl")
471 ;;
472 esac
473
474 case "$host" in
475 *-*-hpux*)
476 avoid_cpp_lib=yes;;
477 *)
478 avoid_cpp_lib=no;
479 ;;
480 esac
481 AM_CONDITIONAL(AVOID_CPP_LIB,test $avoid_cpp_lib = yes)
482
483 # Check for various headers.
484 AC_CHECK_HEADER([execinfo.h], [],
485 [ AC_DEFINE([GC_MISSING_EXECINFO_H], [1], [Missing execinfo.h header.]) ])
486
487 # extra LD Flags which are required for targets
488 case "${host}" in
489 *-*-darwin*)
490 extra_ldflags_libgc=-Wl,-single_module
491 ;;
492 esac
493 AC_SUBST(extra_ldflags_libgc)
494
495 AC_SUBST(EXTRA_TEST_LIBS)
496
497 target_all=libgc.la
498 AC_SUBST(target_all)
499
500 dnl If the target is an eCos system, use the appropriate eCos
501 dnl I/O routines.
502 dnl FIXME: this should not be a local option but a global target
503 dnl system; at present there is no eCos target.
504 TARGET_ECOS="no"
505 AC_ARG_WITH(ecos,
506 [ --with-ecos enable runtime eCos target support],
507 TARGET_ECOS="$with_ecos"
508 )
509
510 addobjs=
511 addlibs=
512 CXXLIBS=
513
514 case "$TARGET_ECOS" in
515 no)
516 ;;
517 *)
518 AC_DEFINE([ECOS], 1, [Define to enable eCos target support.])
519 AM_CPPFLAGS="-I${TARGET_ECOS}/include $AM_CPPFLAGS"
520 addobjs="$addobjs ecos.lo"
521 ;;
522 esac
523
524 AM_CONDITIONAL(CPLUSPLUS, test "${enable_cplusplus}" = yes)
525
526 AC_ARG_ENABLE(throw-bad-alloc-library,
527 [AS_HELP_STRING([--disable-throw-bad-alloc-library],
528 [do not build C++ gctba library])])
529 AM_CONDITIONAL(GC_TBA_LIBRARY,
530 test "${enable_cplusplus}" = yes \
531 -a "${enable_throw_bad_alloc_library}" != no)
532
533 if test "$GCC" = yes; then
534 if test "${enable_cplusplus}" = yes; then
535 case "$host" in
536 *-*-cygwin* | *-*-mingw* | *-*-msys*)
537 AC_MSG_CHECKING([whether libsupc++ required])
538 SUPC="`$CXX -print-file-name=libsupc++.a 2>/dev/null`"
539 if test -n "$SUPC" -a "$SUPC" != "libsupc++.a"; then
540 AC_MSG_RESULT(yes)
541 CXXLIBS="-lsupc++"
542 else
543 AC_MSG_RESULT(no)
544 fi
545 ;;
546 esac
547 fi
548 fi
549
550 AC_SUBST(CXX)
551 AC_SUBST(AM_CFLAGS)
552 AC_SUBST(AM_CPPFLAGS)
553 AC_SUBST(CXXLIBS)
554
555 # Configuration of shared libraries
556 #
557 AC_MSG_CHECKING(whether to build shared libraries)
558 AC_ENABLE_SHARED
559
560 case "$host" in
561 alpha-*-openbsd*)
562 enable_shared=no
563 ;;
564 *)
565 ;;
566 esac
567
568 AC_MSG_RESULT($enable_shared)
569
570 # Compile with GC_DLL defined unless building static libraries.
571 if test "${enable_shared}" != no -a "${enable_static}" != yes; then
572 AC_DEFINE(GC_DLL)
573 if test "$GCC" = yes; then
574 # Pass -fvisibility=hidden option if supported
575 AC_MSG_CHECKING([whether compiler supports -fvisibility])
576 old_CFLAGS="$CFLAGS"
577 CFLAGS="-Werror -fvisibility=hidden $CFLAGS"
578 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[ac_cv_fvisibility_hidden=yes],[ac_cv_fvisibility_hidden=no])
579 CFLAGS="$old_CFLAGS"
580 AS_IF([test "$ac_cv_fvisibility_hidden" = yes],
581 [CFLAGS="-DGC_VISIBILITY_HIDDEN_SET -fvisibility=hidden $CFLAGS"],
582 [CFLAGS="-DGC_NO_VISIBILITY $CFLAGS"])
583 AC_MSG_RESULT($ac_cv_fvisibility_hidden)
584 fi
585 else
586
587 case "$host" in
588 *-*-cygwin* | *-*-mingw* | *-*-msys*)
589 # Do not require the clients to link with "user32" system library.
590 AC_DEFINE([DONT_USE_USER32_DLL], 1,
591 [Do not use user32.dll import library (Win32).])
592 # Use inline version of GC new and delete operators in test_cpp
593 # otherwise the system ones might be used instead because of arbitrary
594 # ordering of object files when linking.
595 CXXFLAGS="$CXXFLAGS -DGC_NOT_DLL"
596 ;;
597 esac
598 fi
599
600 # Configuration of machine-dependent code
601 #
602 AC_MSG_CHECKING(which machine-dependent code should be used)
603 machdep=
604 case "$host" in
605 alpha-*-openbsd*)
606 if test x"${ac_cv_lib_dl_dlopen}" != xyes ; then
607 AC_MSG_WARN(
608 "OpenBSD/Alpha without dlopen(). Shared library support is disabled.")
609 fi
610 ;;
611 i?86-*-solaris2.[[89]])
612 # PROC_VDB appears to work in 2.8 and 2.9 but not in 2.10+ (for now).
613 AC_DEFINE([SOLARIS25_PROC_VDB_BUG_FIXED], 1,
614 [See the comment in gcconfig.h.])
615 ;;
616 sparc-*-netbsd*)
617 machdep="sparc_netbsd_mach_dep.lo"
618 compile_asm=true
619 ;;
620 sparc*-*-linux* | sparc*-*-openbsd* | sparc64-*-freebsd* | sparc64-*-netbsd*)
621 machdep="sparc_mach_dep.lo"
622 compile_asm=true
623 ;;
624 sparc-sun-solaris2.3)
625 machdep="sparc_mach_dep.lo"
626 compile_asm=true
627 AC_DEFINE(SUNOS53_SHARED_LIB, 1,
628 [Define to work around a Solaris 5.3 bug (see dyn_load.c).])
629 ;;
630 sparc*-sun-solaris2*)
631 machdep="sparc_mach_dep.lo"
632 compile_asm=true
633 ;;
634 ia64-*-*)
635 machdep="ia64_save_regs_in_stack.lo"
636 ;;
637 esac
638 AC_MSG_RESULT($machdep)
639 addobjs="$addobjs $machdep"
640 AC_SUBST(addobjs)
641 AC_SUBST(addlibs)
642
643 LT_INIT
644
645 # Suppress "extension used" clang warning (when compiling .S files).
646 if test x$compile_asm = xtrue -a "$GCC" = yes; then
647 AC_MSG_CHECKING([whether compiler supports -Wno-language-extension-token])
648 old_CFLAGS="$CFLAGS"
649 CFLAGS="$CFLAGS -Werror -Wno-language-extension-token"
650 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
651 [ac_cv_lang_ext_token=yes], [ac_cv_lang_ext_token=no])
652 CFLAGS="$old_CFLAGS"
653 AS_IF([test "$ac_cv_lang_ext_token" = yes],
654 [CFLAGS="$CFLAGS -Wno-language-extension-token"])
655 AC_MSG_RESULT($ac_cv_lang_ext_token)
656 fi
657
658 dnl We use these options to decide which functions to include.
659 AC_ARG_WITH(target-subdir,
660 [ --with-target-subdir=SUBDIR
661 configuring with a cross compiler])
662 AC_ARG_WITH(cross-host,
663 [ --with-cross-host=HOST configuring with a cross compiler])
664
665 dnl automake wants to see AC_EXEEXT. But we don't need it. And having
666 dnl it is actually a problem, because the compiler we're passed can't
667 dnl necessarily do a full link. So we fool automake here.
668 if false; then
669 dnl autoconf 2.50 runs AC_EXEEXT by default, and the macro expands
670 dnl to nothing, so nothing would remain between `then' and `fi' if it
671 dnl were not for the `:' below.
672 :
673 AC_EXEEXT
674 fi
675
676 dnl The collector might not properly work on IBM AIX when
677 dnl built with gcc and -O. So we remove -O in the appropriate case.
678 AC_MSG_CHECKING(whether AIX gcc optimization fix is necessary)
679 case "$host" in
680 *aix*)
681 if test "$GCC" = yes; then
682 AC_MSG_RESULT(yes)
683 new_CFLAGS=
684 for i in $CFLAGS; do
685 case "$i" in
686 -O*)
687 ;;
688 *)
689 new_CFLAGS="$new_CFLAGS $i"
690 ;;
691 esac
692 done
693 CFLAGS="$new_CFLAGS"
694 else
695 AC_MSG_RESULT(no)
696 fi
697 ;;
698 *) AC_MSG_RESULT(no) ;;
699 esac
700
701 dnl Include defines that have become de facto standard.
702 dnl ALL_INTERIOR_POINTERS and NO_EXECUTE_PERMISSION can be overridden
703 dnl in the startup code.
704 AC_DEFINE([NO_EXECUTE_PERMISSION], [1],
705 [Define to make the collector not allocate executable memory
706 by default.])
707 AC_DEFINE([ALL_INTERIOR_POINTERS], [1],
708 [Define to recognise all pointers to the interior of objects.])
709
710
711 dnl Interface Selection
712 dnl -------------------
713 dnl
714 dnl By default, make the library as general as possible.
715 AC_ARG_ENABLE(gcj-support,
716 [AS_HELP_STRING([--disable-gcj-support], [disable support for gcj])])
717 if test x"$enable_gcj_support" != xno; then
718 AC_DEFINE(GC_GCJ_SUPPORT, 1, [Define to include support for gcj.])
719 case "$host" in
720 *-*-kfreebsd*-gnu)
721 # FIXME: For a reason, gctest hangs up on kFreeBSD if both of
722 # THREAD_LOCAL_ALLOC and GC_ENABLE_SUSPEND_THREAD are defined.
723 if test "${enable_thread_local_alloc}" = no; then
724 AC_DEFINE(GC_ENABLE_SUSPEND_THREAD)
725 fi
726 ;;
727 *)
728 AC_DEFINE([GC_ENABLE_SUSPEND_THREAD], 1,
729 [Define to turn on GC_suspend_thread support.])
730 ;;
731 esac
732 fi
733 AM_CONDITIONAL(ENABLE_GCJ_SUPPORT, [test x"enable_gcj_support" != xno])
734
735 dnl Interaction with other programs that might use signals.
736 AC_ARG_ENABLE(sigrt-signals,
737 [AS_HELP_STRING([--enable-sigrt-signals],
738 [force GC to use SIGRTMIN-based signals for thread suspend/resume])])
739 if test x"${enable_sigrt_signals}" = xyes; then
740 AC_DEFINE([GC_USESIGRT_SIGNALS], 1,
741 [Force the GC to use signals based on SIGRTMIN+k.])
742 fi
743
744
745 dnl Debugging
746 dnl ---------
747
748 AH_TEMPLATE([GC_HAVE_BUILTIN_BACKTRACE],
749 [Define if backtrace information is supported.])
750 AH_TEMPLATE([MAKE_BACK_GRAPH], [See doc/README.macros.])
751 AH_TEMPLATE([SAVE_CALL_COUNT],
752 [The number of caller frames saved when allocating with the
753 debugging API.])
754 UNWINDLIBS=
755 AC_ARG_ENABLE(gc-debug,
756 [AS_HELP_STRING([--enable-gc-debug],
757 [include full support for pointer backtracing etc.])],
758 [ if test "$enable_gc_debug" = "yes"; then
759 AC_MSG_WARN("Should define GC_DEBUG and use debug alloc in clients.")
760 AC_DEFINE([KEEP_BACK_PTRS], 1,
761 [Define to save back-pointers in debugging headers.])
762 keep_back_ptrs=true
763 AC_DEFINE([DBG_HDRS_ALL], 1,
764 [Define to force debug headers on all objects.])
765 AH_TEMPLATE([SHORT_DBG_HDRS],
766 [Shorten the headers to minimize object size at the expense
767 of checking for writes past the end (see doc/README.macros).])
768
769 case $host in
770 ia64-*-linux* )
771 AC_DEFINE(MAKE_BACK_GRAPH)
772 AC_DEFINE(SAVE_CALL_COUNT, 8)
773 AC_CHECK_LIB(unwind, backtrace, [
774 AC_DEFINE(GC_HAVE_BUILTIN_BACKTRACE)
775 UNWINDLIBS=-lunwind
776 AC_MSG_WARN("Client code may need to link against libunwind.")
777 ])
778 ;;
779 x86-*-linux* | i586-*-linux* | i686-*-linux* | x86_64-*-linux* )
780 AC_DEFINE(MAKE_BACK_GRAPH)
781 AC_MSG_WARN("Client must not use -fomit-frame-pointer.")
782 AC_DEFINE(SAVE_CALL_COUNT, 8)
783 ;;
784 i[3456]86-*-dgux*)
785 AC_DEFINE(MAKE_BACK_GRAPH)
786 ;;
787 esac
788 fi ])
789 AM_CONDITIONAL([MAKE_BACK_GRAPH], [test x"$enable_gc_debug" = xyes])
790 AM_CONDITIONAL([KEEP_BACK_PTRS], [test x"$keep_back_ptrs" = xtrue])
791
792 # Check whether a compiler warning of unsafe __builtin_return_address(1)
793 # could be suppressed by -Wno-frame-address option.
794 # __builtin_return_address(1) is used by libgc for debugging purposes only.
795 AC_MSG_CHECKING([whether -Wno-frame-address works])
796 use_wno_error_frame_address=no
797 old_CFLAGS="$CFLAGS"
798 CFLAGS="$CFLAGS -Werror -Wno-frame-address $CFLAGS_EXTRA"
799 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[{
800 if (!__builtin_return_address(1)) return 1;
801 }]])],[ use_wno_error_frame_address=yes ],[])
802 CFLAGS="$old_CFLAGS"
803 AC_MSG_RESULT($use_wno_error_frame_address)
804 if test x"$use_wno_error_frame_address" = xyes; then
805 CFLAGS="$CFLAGS -Wno-frame-address"
806 fi
807
808 # Check for dladdr (used for debugging).
809 AC_MSG_CHECKING(for dladdr)
810 have_dladdr=no
811 old_CFLAGS="$CFLAGS"
812 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
813 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
814 #define _GNU_SOURCE 1
815 #include <dlfcn.h>]], [[{
816 Dl_info info;
817 (void)dladdr("", &info);
818 }]])],[ have_dladdr=yes ],[])
819 CFLAGS="$old_CFLAGS"
820 AC_MSG_RESULT($have_dladdr)
821 if test x"$have_dladdr" = xyes; then
822 AC_DEFINE([HAVE_DLADDR], 1, [Define to use 'dladdr' function.])
823 fi
824
825 # sigsetjmp could be a macro (thus AC_CHECK_FUNCS cannot be used).
826 AC_MSG_CHECKING(for sigsetjmp)
827 old_CFLAGS="$CFLAGS"
828 CFLAGS="$CFLAGS $CFLAGS_EXTRA"
829 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <setjmp.h>]], [[sigjmp_buf t; sigsetjmp(t, 0)]])],[AC_MSG_RESULT(yes)],[AC_MSG_RESULT(no)
830 AC_DEFINE([GC_NO_SIGSETJMP], [1], [Missing sigsetjmp function.])])
831 CFLAGS="$old_CFLAGS"
832
833 # pthread_setname_np, if available, may have 1, 2 or 3 arguments.
834 AS_IF([test "$THREADS" = posix],
835 [AC_MSG_CHECKING(for pthread_setname_np)
836 old_CFLAGS="$CFLAGS"
837 CFLAGS="$CFLAGS $CFLAGS_EXTRA -Werror"
838 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
839 # define _GNU_SOURCE 1
840 # include <pthread.h>
841 ]], [[pthread_setname_np("thread-name")]])],[AC_MSG_RESULT([yes (w/o tid)])
842 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITHOUT_TID], [1],
843 [Define to use 'pthread_setname_np(const char*)' function.])],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
844 # define _GNU_SOURCE 1
845 # include <pthread.h>
846 ]], [[pthread_setname_np(pthread_self(), "thread-name-%u", 0)]])],[AC_MSG_RESULT([yes (with tid and arg)])
847 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID_AND_ARG], [1],
848 [Define to use 'pthread_setname_np(pthread_t, const char*, void *)'
849 function.])],[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
850 # define _GNU_SOURCE 1
851 # include <pthread.h>
852 ]], [[pthread_setname_np(pthread_self(), "thread-name")]])],[AC_MSG_RESULT([yes (with tid)])
853 AC_DEFINE([HAVE_PTHREAD_SETNAME_NP_WITH_TID], [1],
854 [Define to use 'pthread_setname_np(pthread_t, const char*)'
855 function.])],[AC_MSG_RESULT(no)])])])
856 CFLAGS="$old_CFLAGS"])
857
858 # Check for AViiON Machines running DGUX
859 ac_is_dgux=no
860 AC_CHECK_HEADER(sys/dg_sys_info.h,
861 [ac_is_dgux=yes;])
862
863 dnl :GOTCHA: we do not check anything but sys/dg_sys_info.h
864 if test $ac_is_dgux = yes; then
865 dgux_spec_opts="-DDGUX -D_DGUX_SOURCE -Di386 -mno-legend -O2"
866 CFLAGS="$dgux_spec_opts $CFLAGS"
867 CXXFLAGS="$dgux_spec_opts $CXXFLAGS"
868 if test "$enable_gc_debug" = "yes"; then
869 CFLAGS="-g -mstandard $CFLAGS"
870 CXXFLAGS="-g -mstandard $CXXFLAGS"
871 fi
872 AC_SUBST(CFLAGS)
873 AC_SUBST(CXXFLAGS)
874 fi
875
876 AC_ARG_ENABLE(java-finalization,
877 [AS_HELP_STRING([--disable-java-finalization],
878 [disable support for java finalization])])
879 if test x"$enable_java_finalization" != xno; then
880 AC_DEFINE([JAVA_FINALIZATION], 1, [See doc/README.macros.])
881 fi
882
883 AC_ARG_ENABLE(atomic-uncollectable,
884 [AS_HELP_STRING([--disable-atomic-uncollectible],
885 [disable support for atomic uncollectible allocation])])
886 if test x"$enable_atomic_uncollectible" != x"no"; then
887 AC_DEFINE([GC_ATOMIC_UNCOLLECTABLE], 1,
888 [Define to enable atomic uncollectible allocation.])
889 fi
890
891 AC_ARG_ENABLE(redirect-malloc,
892 [AS_HELP_STRING([--enable-redirect-malloc],
893 [redirect malloc and friends to GC routines])])
894
895 if test "${enable_redirect_malloc}" = yes; then
896 if test "${enable_gc_debug}" = yes; then
897 AC_DEFINE([REDIRECT_MALLOC], GC_debug_malloc_replacement,
898 [If defined, redirect malloc to this function.])
899 AC_DEFINE([REDIRECT_REALLOC], GC_debug_realloc_replacement,
900 [If defined, redirect GC_realloc to this function.])
901 AC_DEFINE([REDIRECT_FREE], GC_debug_free,
902 [If defined, redirect free to this function.])
903 else
904 AC_DEFINE(REDIRECT_MALLOC, GC_malloc)
905 fi
906 AC_DEFINE([GC_USE_DLOPEN_WRAP], 1, [See doc/README.macros.])
907 fi
908
909 AC_ARG_ENABLE(disclaim,
910 [AS_HELP_STRING([--disable-disclaim],
911 [disable alternative (more efficient) finalization interface])])
912 if test x"$enable_disclaim" != xno; then
913 AC_DEFINE(ENABLE_DISCLAIM, 1,
914 [Define to enable alternative finalization interface.])
915 fi
916 AM_CONDITIONAL(ENABLE_DISCLAIM,
917 [test x"$enable_disclaim" != xno])
918
919 AC_ARG_ENABLE(large-config,
920 [AS_HELP_STRING([--enable-large-config],
921 [optimize for large (> 100 MB) heap or root set])])
922 if test "${enable_large_config}" = yes; then
923 AC_DEFINE(LARGE_CONFIG, 1,
924 [Define to optimize for large heaps or root sets.])
925 fi
926
927 dnl This is something of a hack. When cross-compiling we turn off
928 dnl some functionality. We also enable the "small" configuration.
929 dnl These is only correct when targeting an embedded system. FIXME.
930 if test -n "${with_cross_host}"; then
931 AC_DEFINE([NO_CLOCK], 1, [Define to not use system clock (cross compiling).])
932 AC_DEFINE([SMALL_CONFIG], 1,
933 [Define to tune the collector for small heap sizes.])
934 fi
935
936 if test "$enable_gc_debug" = "no"; then
937 AC_DEFINE([NO_DEBUGGING], 1,
938 [Disable debugging, like GC_dump and its callees.])
939 fi
940
941 AC_SUBST(UNWINDLIBS)
942
943 AC_ARG_ENABLE(gc-assertions,
944 [AS_HELP_STRING([--enable-gc-assertions],
945 [collector-internal assertion checking])])
946 if test "${enable_gc_assertions}" = yes; then
947 AC_DEFINE([GC_ASSERTIONS], 1,
948 [Define to enable internal debug assertions.])
949 fi
950
951 AC_ARG_ENABLE(mmap,
952 [AS_HELP_STRING([--enable-mmap],
953 [use mmap instead of sbrk to expand the heap])],
954 gc_use_mmap=$enableval)
955
956 AC_ARG_ENABLE(munmap,
957 [AS_HELP_STRING([--enable-munmap=N],
958 [return page to the OS if empty for N collections
959 (default: 6)])],
960 MUNMAP_THRESHOLD=$enableval)
961 if test x$enable_munmap != xno; then
962 AC_DEFINE([USE_MMAP], 1,
963 [Define to use mmap instead of sbrk to expand the heap.])
964 AH_TEMPLATE([USE_WINALLOC],
965 [Define to use Win32 VirtualAlloc (instead of sbrk or
966 mmap) to expand the heap.])
967 AC_DEFINE([USE_MUNMAP], 1,
968 [Define to return memory to OS with munmap calls
969 (see doc/README.macros).])
970 if test x$MUNMAP_THRESHOLD = x -o x$MUNMAP_THRESHOLD = xyes; then
971 MUNMAP_THRESHOLD=6
972 fi
973 AC_DEFINE_UNQUOTED([MUNMAP_THRESHOLD], [${MUNMAP_THRESHOLD}],
974 [Number of GC cycles to wait before unmapping an unused block.])
975 else
976 if test "${gc_use_mmap}" = "yes"; then
977 AC_DEFINE([USE_MMAP], 1,
978 [Define to use mmap instead of sbrk to expand the heap.])
979 fi
980 fi
981
982 AC_ARG_ENABLE(dynamic-loading,
983 [AS_HELP_STRING([--disable-dynamic-loading],
984 [build the collector with disabled tracing
985 of dynamic library data roots])])
986 if test "${enable_dynamic_loading}" = "no"; then
987 AC_DEFINE([IGNORE_DYNAMIC_LOADING], 1,
988 [Do not define DYNAMIC_LOADING even if supported (i.e., build the
989 collector with disabled tracing of dynamic library data roots).])
990 fi
991
992 AC_ARG_ENABLE(register-main-static-data,
993 [AS_HELP_STRING([--disable-register-main-static-data],
994 [skip the initial guess of data root sets])])
995 if test "${enable_register_main_static_data}" = "no"; then
996 AC_DEFINE([GC_DONT_REGISTER_MAIN_STATIC_DATA], 1,
997 [Skip the initial guess of data root sets.])
998 fi
999
1000 AC_ARG_ENABLE(checksums,
1001 [AS_HELP_STRING([--enable-checksums],
1002 [report on erroneously cleared dirty bits at
1003 substantial performance cost; use only for
1004 debugging of the incremental collector])])
1005 if test x$enable_checksums = xyes; then
1006 if test x$enable_munmap != xno -o x$THREADS != xnone; then
1007 AC_MSG_ERROR([CHECKSUMS not compatible with USE_MUNMAP or threads])
1008 fi
1009 AC_DEFINE([CHECKSUMS], 1,
1010 [Erroneously cleared dirty bits checking. Use only for
1011 debugging of the incremental collector.])
1012 fi
1013 AM_CONDITIONAL([CHECKSUMS], test x$enable_checksums = xyes)
1014
1015 AM_CONDITIONAL(USE_LIBDIR, test -z "$with_cross_host")
1016
1017 AC_ARG_ENABLE(werror,
1018 [AS_HELP_STRING([--enable-werror], [pass -Werror to the C compiler])],
1019 werror_flag=$enableval, werror_flag=no)
1020 if test x$werror_flag = xyes; then
1021 WERROR_CFLAGS="-Werror"
1022 case "$host" in
1023 # _dyld_bind_fully_image_containing_address is deprecated in OS X 10.5+
1024 *-*-darwin*)
1025 WERROR_CFLAGS="$WERROR_CFLAGS -Wno-deprecated-declarations"
1026 ;;
1027 esac
1028 fi
1029 AC_SUBST([WERROR_CFLAGS])
1030
1031 AC_ARG_ENABLE(single-obj-compilation,
1032 [AS_HELP_STRING([--enable-single-obj-compilation],
1033 [compile all libgc source files into single .o
1034 (default: yes if static libraries are disabled)])],
1035 [], [ AS_IF([test x"$enable_static" = xno],
1036 [enable_single_obj_compilation=yes]) ])
1037 AM_CONDITIONAL([SINGLE_GC_OBJ],
1038 [test x"$enable_single_obj_compilation" = xyes])
1039
1040 AC_ARG_ENABLE(gcov,
1041 [AS_HELP_STRING([--enable-gcov], [turn on code coverage analysis])])
1042 if test "$enable_gcov" = "yes"; then
1043 CFLAGS="-D NTHREADS=20 $CFLAGS --coverage"
1044 if test "${enable_shared}" = no; then
1045 # FIXME: As of g++-4.8.4/x64, in case of shared library build, test_cpp
1046 # linkage fails with "hidden symbol atexit is referenced by DSO" message.
1047 CXXFLAGS="$CXXFLAGS --coverage"
1048 fi
1049 # Turn off optimization to get accurate line numbers.
1050 CFLAGS=`echo "$CFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'`
1051 CXXFLAGS=`echo "$CXXFLAGS" | sed -e 's/-O\(1\|2\|3\|4\|s\|fast\)\?//g'`
1052 fi
1053
1054 AC_ARG_ENABLE(docs,
1055 [AS_HELP_STRING([--disable-docs],
1056 [do not build and install documentation])])
1057 AM_CONDITIONAL(ENABLE_DOCS, test x$enable_docs != xno)
1058
1059 AM_CONDITIONAL(ENABLE_SHARED, test x$enable_shared = xyes)
1060
1061 # Atomic Ops
1062 # ----------
1063
1064 # Do we want to use an external libatomic_ops? By default use it if it's
1065 # found.
1066 AC_ARG_WITH([libatomic-ops],
1067 [AS_HELP_STRING([--with-libatomic-ops[=yes|no|check|none]],
1068 [use an external libatomic_ops? (default: check;
1069 none: use compiler intrinsics or no thread support)])],
1070 [], [ AS_IF([test x"$THREADS" != xnone],
1071 [with_libatomic_ops=check], [with_libatomic_ops=none]) ])
1072
1073 # Check whether compiler atomic intrinsics can be used.
1074 if test x"$with_libatomic_ops" = xcheck; then
1075 AC_MSG_CHECKING(for compiler intrinsics support)
1076 old_CFLAGS="$CFLAGS"
1077 CFLAGS="$CFLAGS $CFLAGS_EXTRA -DGC_BUILTIN_ATOMIC"
1078 CFLAGS="$CFLAGS -I${srcdir}/include -I${srcdir}/tests"
1079 AC_RUN_IFELSE([AC_LANG_SOURCE([[#include "test_atomic_ops.c"]])],[AC_MSG_RESULT(yes)
1080 with_libatomic_ops=none],[AC_MSG_RESULT(no)],[AC_MSG_RESULT(skipped because cross-compiling)])
1081 CFLAGS="$old_CFLAGS"
1082 fi
1083
1084 # Check for an external libatomic_ops if the above answer is "yes" or "check".
1085 # If not found, fail on "yes", and convert "check" to "no".
1086 # First, check that libatomic_ops usage is not disabled explicitly.
1087 missing_libatomic_ops=false
1088 AS_IF([test x"$with_libatomic_ops" != xno -a x"$with_libatomic_ops" != xnone],
1089 [ missing_libatomic_ops=true ])
1090
1091 dnl To avoid "syntax error near unexpected token ATOMIC_OPS" configure error
1092 dnl observed by some clients, the following 3 code lines are commented out:
1093 dnl
1094 dnl AS_IF([test x$missing_libatomic_ops = xtrue],
1095 dnl [ PKG_CHECK_MODULES([ATOMIC_OPS], [atomic_ops],
1096 dnl [ missing_libatomic_ops=false ], [ [] ]) ])
1097
1098 dnl Retry with AC_CHECK_HEADER if PKG_CHECK_MODULES failed.
1099 AS_IF([test x$missing_libatomic_ops = xtrue],
1100 [ AC_CHECK_HEADER([atomic_ops.h], [missing_libatomic_ops=false]) ])
1101 AS_IF([test x$missing_libatomic_ops = xtrue],
1102 [ AS_IF([test x"$with_libatomic_ops" != xcheck],
1103 [ AC_MSG_ERROR([An external libatomic_ops was not found]) ])
1104 with_libatomic_ops=no ])
1105
1106 # If we have neither an external or an internal version, offer a useful hint
1107 # and exit.
1108 AS_IF([test x"$with_libatomic_ops" = xno \
1109 -a ! -e "$srcdir/libatomic_ops/src/atomic_ops.h"],
1110 [ AC_MSG_ERROR([libatomic_ops is required. You can either install it on
1111 your system, or fetch and unpack a recent version into the
1112 source directory and link or rename it to libatomic_ops.]) ])
1113
1114 # Finally, emit the definitions for bundled or external AO.
1115 AC_MSG_CHECKING([which libatomic_ops to use])
1116 AS_IF([test x"$with_libatomic_ops" != xno],
1117 [ AS_IF([test x"$with_libatomic_ops" != xnone -a x"$THREADS" != xnone],
1118 [ AC_MSG_RESULT([external])
1119 ATOMIC_OPS_LIBS="-latomic_ops"
1120 AC_SUBST([ATOMIC_OPS_LIBS]) ],
1121 [ AC_MSG_RESULT([none])
1122 AS_IF([test x"$THREADS" != xnone],
1123 [ AC_DEFINE([GC_BUILTIN_ATOMIC], [1],
1124 [Use GCC atomic intrinsics instead of
1125 libatomic_ops primitives.]) ]) ])
1126 AO_TRYLINK_CFLAGS="" ],
1127 [ AC_MSG_RESULT([internal])
1128 AO_TRYLINK_CFLAGS="-I${srcdir}/libatomic_ops/src"
1129 ATOMIC_OPS_CFLAGS='-I$(top_builddir)/libatomic_ops/src -I$(top_srcdir)/libatomic_ops/src'
1130 ATOMIC_OPS_LIBS=""
1131 AC_SUBST([ATOMIC_OPS_CFLAGS])
1132 AC_CONFIG_SUBDIRS([libatomic_ops])
1133 ])
1134 AM_CONDITIONAL([USE_INTERNAL_LIBATOMIC_OPS],
1135 [test x$with_libatomic_ops = xno -a x"$THREADS" != xnone])
1136 AM_CONDITIONAL([NEED_ATOMIC_OPS_ASM],
1137 [test x$with_libatomic_ops = xno -a x$need_atomic_ops_asm = xtrue])
1138
1139 # Check whether particular AO primitives are emulated with locks.
1140 # The check below is based on the fact that linking with the libatomic_ops
1141 # binary file is not needed in case of absence of the emulation (except for
1142 # Solaris SPARC).
1143 AS_IF([test x$with_libatomic_ops != xnone -a x$need_atomic_ops_asm != xtrue],
1144 [ old_CFLAGS="$CFLAGS"
1145 CFLAGS="$CFLAGS $AO_TRYLINK_CFLAGS $CFLAGS_EXTRA"
1146 AC_MSG_CHECKING([for lock-free AO_or primitive])
1147 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "atomic_ops.h"]], [[AO_t x=0;AO_or(&x,1)]])],[ AC_MSG_RESULT(yes)
1148 AC_DEFINE([HAVE_LOCKFREE_AO_OR], [1],
1149 [libatomic_ops AO_or primitive implementation is lock-free.]) ],[ AC_MSG_RESULT(no) ])
1150 AC_MSG_CHECKING([for lock-free AO load/store, test-and-set primitives])
1151 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include "atomic_ops.h"]], [[AO_t x=0;unsigned char c=0;AO_TS_t z=AO_TS_INITIALIZER;
1152 (void)AO_test_and_set_acquire(&z);AO_CLEAR(&z);AO_compiler_barrier();
1153 AO_store(&x,AO_load(&x)+1);AO_char_store(&c,AO_char_load(&c)+1);
1154 AO_store_release(&x,AO_load_acquire(&x)+1)]])],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no)
1155 use_thread_local_alloc=no
1156 AC_DEFINE([BASE_ATOMIC_OPS_EMULATED], [1],
1157 [AO load, store and/or test-and-set primitives are
1158 implemented in libatomic_ops using locks.]) ])
1159 AS_IF([test x$use_parallel_mark != xno],
1160 [ AC_MSG_CHECKING(
1161 [for lock-free compare-and-swap and fetch-and-add primitives])
1162 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#define AO_REQUIRE_CAS
1163 #include "atomic_ops.h"]], [[AO_t x=0;(void)AO_fetch_and_add(&x,1);(void)AO_compare_and_swap(&x,1,2)]])],[ AC_MSG_RESULT(yes) ],[ AC_MSG_RESULT(no)
1164 use_parallel_mark=no ]) ])
1165 CFLAGS="$old_CFLAGS" ])
1166
1167 AS_IF([test x$use_parallel_mark != xno],
1168 [ AC_DEFINE(PARALLEL_MARK) ])
1169 AS_IF([test x$use_thread_local_alloc != xno],
1170 [ AC_DEFINE(THREAD_LOCAL_ALLOC) ])
1171 AM_CONDITIONAL(THREAD_LOCAL_ALLOC, test x$use_thread_local_alloc != xno)
1172
1173 AC_ARG_ENABLE(handle-fork,
1174 [AS_HELP_STRING([--enable-handle-fork[=yes|no|auto|manual]],
1175 [attempt to ensure a usable collector after fork()
1176 in multi-threaded programs (default: auto;
1177 manual: GC_atfork_prepare/parent/child should be
1178 called by the client)])])
1179 if test "${enable_handle_fork}" = yes; then
1180 AC_DEFINE(HANDLE_FORK, 1,
1181 [Define to install pthread_atfork() handlers by default.])
1182 elif test "${enable_handle_fork}" = no; then
1183 AC_DEFINE(NO_HANDLE_FORK, 1,
1184 [Prohibit installation of pthread_atfork() handlers.])
1185 elif test "${enable_handle_fork}" != manual -a x$THREADS = xposix; then
1186 # If the option is omitted, pthread_atfork handlers are installed
1187 # by default for the targets where pthread_atfork is known to work.
1188 case "$host" in
1189 *-*-aix* | *-*-android* | *-*-cygwin* | *-*-darwin* | *-*-freebsd* | \
1190 *-*-haiku* | *-*-hpux11* | *-*-irix* | *-*-kfreebsd*-gnu | \
1191 *-*-*linux* | *-*-netbsd* | *-*-openbsd* | *-*-osf* | *-*-solaris*)
1192 AC_DEFINE(HANDLE_FORK)
1193 ;;
1194 esac
1195 fi
1196
1197 dnl Produce the Files
1198 dnl -----------------
1199
1200 AC_CONFIG_FILES([Makefile bdw-gc.pc])
1201
1202 AC_CONFIG_COMMANDS([default],,
1203 [ srcdir="${srcdir}"
1204 host=${host}
1205 CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
1206 CC="${CC}"
1207 DEFS="$DEFS" ])
1208
1209 AC_OUTPUT