2 # Process this file with autoconf to produce a configure script.
5 AC_INIT(package-unused, version-unused, libsanitizer)
6 AC_CONFIG_SRCDIR([include/sanitizer/common_interface_defs.h])
8 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
9 AC_ARG_ENABLE(version-specific-runtime-libs,
10 [ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
12 yes) version_specific_libs=yes ;;
13 no) version_specific_libs=no ;;
14 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
16 [version_specific_libs=no])
17 AC_MSG_RESULT($version_specific_libs)
19 AC_USE_SYSTEM_EXTENSIONS
21 # Do not delete or change the following two lines. For why, see
22 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
24 target_alias=${target_alias-$host_alias}
25 AC_SUBST(target_alias)
26 GCC_LIBSTDCXX_RAW_CXX_FLAGS
28 AM_INIT_AUTOMAKE(foreign no-dist)
29 AM_ENABLE_MULTILIB(, ..)
32 # Calculate toolexeclibdir
33 # Also toolexecdir, though it's only used in toolexeclibdir
34 case ${version_specific_libs} in
36 # Need the gcc compiler version to know where to install libraries
37 # and header files if --enable-version-specific-runtime-libs option
39 toolexecdir='$(libdir)/gcc/$(target_alias)'
40 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
43 if test -n "$with_cross_host" &&
44 test x"$with_cross_host" != x"no"; then
45 # Install a library built with a cross compiler in tooldir, not libdir.
46 toolexecdir='$(exec_prefix)/$(target_alias)'
47 toolexeclibdir='$(toolexecdir)/lib'
49 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
50 toolexeclibdir='$(libdir)'
52 multi_os_directory=`$CC -print-multi-os-directory`
53 case $multi_os_directory in
54 .) ;; # Avoid trailing /.
55 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
60 AC_SUBST(toolexeclibdir)
62 # Checks for programs.
73 "") AC_MSG_ERROR([can't build without awk]) ;;
76 AC_SUBST(enable_shared)
77 AC_SUBST(enable_static)
79 AC_CHECK_SIZEOF([void *])
81 if test "${multilib}" = "yes"; then
82 multilib_arg="--enable-multilib"
87 # Get target configury.
90 . ${srcdir}/configure.tgt
91 AM_CONDITIONAL(TSAN_SUPPORTED, [test "x$TSAN_SUPPORTED" = "xyes"])
92 AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"])
94 # Check for functions needed.
95 AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime)
97 # Common libraries that we need to link against for all sanitizer libs.
98 link_sanitizer_common='-lpthread -ldl -lm'
100 # Set up the set of additional libraries that we need to link against for libasan.
101 link_libasan=$link_sanitizer_common
102 AC_SUBST(link_libasan)
104 # Set up the set of additional libraries that we need to link against for libtsan.
105 link_libtsan=$link_sanitizer_common
106 AC_SUBST(link_libtsan)
108 # Set up the set of additional libraries that we need to link against for libubsan.
109 link_libubsan=$link_sanitizer_common
110 AC_SUBST(link_libubsan)
112 # Set up the set of additional libraries that we need to link against for liblsan.
113 link_liblsan=$link_sanitizer_common
114 AC_SUBST(link_liblsan)
116 # At least for glibc, clock_gettime is in librt. But don't pull that
117 # in if it still doesn't give us the function we want. This
118 # test is copied from libgomp.
119 if test $ac_cv_func_clock_gettime = no; then
120 AC_CHECK_LIB(rt, clock_gettime,
121 [link_libasan="-lrt $link_libasan"
122 link_libtsan="-lrt $link_libtsan"
123 # Other sanitizers do not override clock_* API
128 *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;;
129 *) MAC_INTERPOSE=false ;;
131 AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE)
133 backtrace_supported=yes
135 AC_MSG_CHECKING([for necessary platform features])
138 # Some old Linux distributions miss required syscalls.
139 sanitizer_supported=no
140 AC_TRY_COMPILE([#include <sys/syscall.h>],[
141 syscall (__NR_gettid);
142 syscall (__NR_futex);
143 syscall (__NR_exit_group);
144 ], [sanitizer_supported=yes])
147 sanitizer_supported=yes
150 AC_MSG_RESULT($sanitizer_supported)
151 AM_CONDITIONAL(SANITIZER_SUPPORTED, test "$sanitizer_supported" = yes)
153 # Test for __sync support.
154 AC_CACHE_CHECK([__sync extensions],
155 [libsanitizer_cv_sys_sync],
156 [if test -n "${with_target_subdir}"; then
157 libsanitizer_cv_sys_sync=yes
160 [AC_LANG_PROGRAM([int i;],
161 [__sync_bool_compare_and_swap (&i, i, i);
162 __sync_lock_test_and_set (&i, 1);
163 __sync_lock_release (&i);])],
164 [libsanitizer_cv_sys_sync=yes],
165 [libsanitizer_cv_sys_sync=no])
167 if test "$libsanitizer_cv_sys_sync" = "yes"; then
168 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
169 [Define to 1 if you have the __sync functions])
172 # Test for __atomic support.
173 AC_CACHE_CHECK([__atomic extensions],
174 [libsanitizer_cv_sys_atomic],
175 [if test -n "${with_target_subdir}"; then
176 libsanitizer_cv_sys_atomic=yes
179 [AC_LANG_PROGRAM([int i;],
180 [__atomic_load_n (&i, __ATOMIC_ACQUIRE);
181 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
182 [libsanitizer_cv_sys_atomic=yes],
183 [libsanitizer_cv_sys_atomic=no])
185 if test "$libsanitizer_cv_sys_atomic" = "yes"; then
186 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
187 [Define to 1 if you have the __atomic functions])
190 # The library needs to be able to read the executable itself. Compile
191 # a file to determine the executable format. The awk script
192 # filetype.awk prints out the file type.
193 AC_CACHE_CHECK([output filetype],
194 [libsanitizer_cv_sys_filetype],
197 [AC_LANG_PROGRAM([int i;], [int j;])],
198 [filetype=`${AWK} -f $srcdir/../libbacktrace/filetype.awk conftest.$ac_objext`],
199 [AC_MSG_FAILURE([compiler failed])])
200 libsanitizer_cv_sys_filetype=$filetype])
202 # Match the file type to decide what files to compile.
204 case "$libsanitizer_cv_sys_filetype" in
205 elf*) FORMAT_FILE="elf.lo" ;;
206 *) AC_MSG_WARN([could not determine output file type])
207 FORMAT_FILE="unknown.lo"
208 backtrace_supported=no
211 AC_SUBST(FORMAT_FILE)
215 case "$libsanitizer_cv_sys_filetype" in
219 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
221 BACKTRACE_SUPPORTED=0
222 if test "$backtrace_supported" = "yes"; then
223 BACKTRACE_SUPPORTED=1
225 AC_SUBST(BACKTRACE_SUPPORTED)
227 GCC_HEADER_STDINT(gstdint.h)
229 AC_CHECK_HEADERS(sys/mman.h alloca.h)
230 if test "$ac_cv_header_sys_mman_h" = "no"; then
233 if test -n "${with_target_subdir}"; then
234 # When built as a GCC target library, we can't do a link test. We
235 # simply assume that if we have mman.h, we have mmap.
238 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
241 if test "$have_mmap" = "no"; then
247 #include <sys/mman.h>
248 #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
249 #error no MAP_ANONYMOUS
251 ], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
256 BACKTRACE_USES_MALLOC=0
257 if test "$ALLOC_FILE" = "alloc.lo"; then
258 BACKTRACE_USES_MALLOC=1
260 AC_SUBST(BACKTRACE_USES_MALLOC)
262 # Don't care about thread support
263 BACKTRACE_SUPPORTS_THREADS=0
264 AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
266 # Check for dl_iterate_phdr.
267 AC_CHECK_HEADERS(link.h)
268 if test "$ac_cv_header_link_h" = "no"; then
269 have_dl_iterate_phdr=no
271 # When built as a GCC target library, we can't do a link test.
272 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
273 [have_dl_iterate_phdr=no])
276 # Avoid dl_iterate_phdr on Solaris 10, where it is in the
277 # header file but is only in -ldl.
278 have_dl_iterate_phdr=no ;;
281 if test "$have_dl_iterate_phdr" = "yes"; then
282 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
285 # Check for the fcntl function.
286 if test -n "${with_target_subdir}"; then
288 *-*-mingw*) have_fcntl=no ;;
292 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
294 if test "$have_fcntl" = "yes"; then
295 AC_DEFINE([HAVE_FCNTL], 1,
296 [Define to 1 if you have the fcntl function])
299 AC_CHECK_DECLS(strnlen)
301 # Check for getexecname function.
302 if test -n "${with_target_subdir}"; then
304 *-*-solaris2*) have_getexecname=yes ;;
305 *) have_getexecname=no ;;
308 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
310 if test "$have_getexecname" = "yes"; then
311 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
314 AM_CONDITIONAL(LIBBACKTRACE_SUPPORTED,
315 [test "x${BACKTRACE_SUPPORTED}x${BACKTRACE_USES_MALLOC}" = "x1x0"])
317 AH_BOTTOM([#include "libbacktrace/backtrace-rename.h"])
318 AC_CONFIG_FILES([Makefile libsanitizer.spec libbacktrace/backtrace-supported.h])
319 AC_CONFIG_HEADER(config.h)
321 AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan asan ubsan], [DIR/Makefile ]),
322 [cat > vpsed$$ << \_EOF
323 s!`test -f '$<' || echo '$(srcdir)/'`!!
325 sed -f vpsed$$ $ac_file > tmp$$
328 echo 'MULTISUBDIR =' >> $ac_file
330 . ${multi_basedir}/config-ml.in
331 AS_UNSET([ml_norecursion])
334 if test "x$TSAN_SUPPORTED" = "xyes"; then
335 AC_CONFIG_FILES(AC_FOREACH([DIR], [tsan], [DIR/Makefile ]),
336 [cat > vpsed$$ << \_EOF
337 s!`test -f '$<' || echo '$(srcdir)/'`!!
339 sed -f vpsed$$ $ac_file > tmp$$
342 echo 'MULTISUBDIR =' >> $ac_file
344 . ${multi_basedir}/config-ml.in
345 AS_UNSET([ml_norecursion])
349 AC_SUBST([TSAN_TARGET_DEPENDENT_OBJECTS])