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 AM_ENABLE_MULTILIB(, ..)
10 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
11 AC_ARG_ENABLE(version-specific-runtime-libs,
12 [ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ],
14 yes) version_specific_libs=yes ;;
15 no) version_specific_libs=no ;;
16 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);;
18 [version_specific_libs=no])
19 AC_MSG_RESULT($version_specific_libs)
21 AC_USE_SYSTEM_EXTENSIONS
23 # Do not delete or change the following two lines. For why, see
24 # http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html
26 target_alias=${target_alias-$host_alias}
27 AC_SUBST(target_alias)
28 GCC_LIBSTDCXX_RAW_CXX_FLAGS
30 AM_INIT_AUTOMAKE(foreign no-dist)
33 # Calculate toolexeclibdir
34 # Also toolexecdir, though it's only used in toolexeclibdir
35 case ${version_specific_libs} in
37 # Need the gcc compiler version to know where to install libraries
38 # and header files if --enable-version-specific-runtime-libs option
40 toolexecdir='$(libdir)/gcc/$(target_alias)'
41 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)'
44 if test -n "$with_cross_host" &&
45 test x"$with_cross_host" != x"no"; then
46 # Install a library built with a cross compiler in tooldir, not libdir.
47 toolexecdir='$(exec_prefix)/$(target_alias)'
48 toolexeclibdir='$(toolexecdir)/lib'
50 toolexecdir='$(libdir)/gcc-lib/$(target_alias)'
51 toolexeclibdir='$(libdir)'
53 multi_os_directory=`$CC -print-multi-os-directory`
54 case $multi_os_directory in
55 .) ;; # Avoid trailing /.
56 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;;
61 AC_SUBST(toolexeclibdir)
63 # Checks for programs.
74 "") AC_MSG_ERROR([can't build without awk]) ;;
77 AC_SUBST(enable_shared)
78 AC_SUBST(enable_static)
80 AC_CHECK_SIZEOF([void *])
82 if test "${multilib}" = "yes"; then
83 multilib_arg="--enable-multilib"
88 # Get target configury.
91 . ${srcdir}/configure.tgt
92 AM_CONDITIONAL(TSAN_SUPPORTED, [test "x$TSAN_SUPPORTED" = "xyes"])
93 AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"])
95 # Check for functions needed.
96 AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime)
98 # Common libraries that we need to link against for all sanitizer libs.
99 link_sanitizer_common='-lpthread -ldl -lm'
101 # Set up the set of additional libraries that we need to link against for libasan.
102 link_libasan=$link_sanitizer_common
103 AC_SUBST(link_libasan)
105 # Set up the set of additional libraries that we need to link against for libtsan.
106 link_libtsan=$link_sanitizer_common
107 AC_SUBST(link_libtsan)
109 # Set up the set of additional libraries that we need to link against for libubsan.
110 link_libubsan=$link_sanitizer_common
111 AC_SUBST(link_libubsan)
113 # Set up the set of additional libraries that we need to link against for liblsan.
114 link_liblsan=$link_sanitizer_common
115 AC_SUBST(link_liblsan)
117 # At least for glibc, clock_gettime is in librt. But don't pull that
118 # in if it still doesn't give us the function we want. This
119 # test is copied from libgomp.
120 if test $ac_cv_func_clock_gettime = no; then
121 AC_CHECK_LIB(rt, clock_gettime,
122 [link_libasan="-lrt $link_libasan"
123 link_libtsan="-lrt $link_libtsan"
124 # Other sanitizers do not override clock_* API
129 *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;;
130 *) MAC_INTERPOSE=false ;;
132 AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE)
134 backtrace_supported=yes
136 AC_MSG_CHECKING([for necessary platform features])
139 # Some old Linux distributions miss required syscalls.
140 sanitizer_supported=no
141 AC_TRY_COMPILE([#include <sys/syscall.h>],[
142 syscall (__NR_gettid);
143 syscall (__NR_futex);
144 syscall (__NR_exit_group);
145 ], [sanitizer_supported=yes])
148 sanitizer_supported=yes
151 AC_MSG_RESULT($sanitizer_supported)
152 AM_CONDITIONAL(SANITIZER_SUPPORTED, test "$sanitizer_supported" = yes)
154 # Test for __sync support.
155 AC_CACHE_CHECK([__sync extensions],
156 [libsanitizer_cv_sys_sync],
157 [if test -n "${with_target_subdir}"; then
158 libsanitizer_cv_sys_sync=yes
161 [AC_LANG_PROGRAM([int i;],
162 [__sync_bool_compare_and_swap (&i, i, i);
163 __sync_lock_test_and_set (&i, 1);
164 __sync_lock_release (&i);])],
165 [libsanitizer_cv_sys_sync=yes],
166 [libsanitizer_cv_sys_sync=no])
168 if test "$libsanitizer_cv_sys_sync" = "yes"; then
169 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
170 [Define to 1 if you have the __sync functions])
173 # Test for __atomic support.
174 AC_CACHE_CHECK([__atomic extensions],
175 [libsanitizer_cv_sys_atomic],
176 [if test -n "${with_target_subdir}"; then
177 libsanitizer_cv_sys_atomic=yes
180 [AC_LANG_PROGRAM([int i;],
181 [__atomic_load_n (&i, __ATOMIC_ACQUIRE);
182 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
183 [libsanitizer_cv_sys_atomic=yes],
184 [libsanitizer_cv_sys_atomic=no])
186 if test "$libsanitizer_cv_sys_atomic" = "yes"; then
187 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
188 [Define to 1 if you have the __atomic functions])
191 # The library needs to be able to read the executable itself. Compile
192 # a file to determine the executable format. The awk script
193 # filetype.awk prints out the file type.
194 AC_CACHE_CHECK([output filetype],
195 [libsanitizer_cv_sys_filetype],
198 [AC_LANG_PROGRAM([int i;], [int j;])],
199 [filetype=`${AWK} -f $srcdir/../libbacktrace/filetype.awk conftest.$ac_objext`],
200 [AC_MSG_FAILURE([compiler failed])])
201 libsanitizer_cv_sys_filetype=$filetype])
203 # Match the file type to decide what files to compile.
205 case "$libsanitizer_cv_sys_filetype" in
206 elf*) FORMAT_FILE="elf.lo" ;;
207 *) AC_MSG_WARN([could not determine output file type])
208 FORMAT_FILE="unknown.lo"
209 backtrace_supported=no
212 AC_SUBST(FORMAT_FILE)
216 case "$libsanitizer_cv_sys_filetype" in
220 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
222 BACKTRACE_SUPPORTED=0
223 if test "$backtrace_supported" = "yes"; then
224 BACKTRACE_SUPPORTED=1
226 AC_SUBST(BACKTRACE_SUPPORTED)
228 GCC_HEADER_STDINT(gstdint.h)
230 AC_CHECK_HEADERS(sys/mman.h alloca.h)
231 if test "$ac_cv_header_sys_mman_h" = "no"; then
234 if test -n "${with_target_subdir}"; then
235 # When built as a GCC target library, we can't do a link test. We
236 # simply assume that if we have mman.h, we have mmap.
239 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
242 if test "$have_mmap" = "no"; then
248 #include <sys/mman.h>
249 #if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
250 #error no MAP_ANONYMOUS
252 ], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
257 BACKTRACE_USES_MALLOC=0
258 if test "$ALLOC_FILE" = "alloc.lo"; then
259 BACKTRACE_USES_MALLOC=1
261 AC_SUBST(BACKTRACE_USES_MALLOC)
263 # Don't care about thread support
264 BACKTRACE_SUPPORTS_THREADS=0
265 AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
267 # Check for dl_iterate_phdr.
268 AC_CHECK_HEADERS(link.h)
269 if test "$ac_cv_header_link_h" = "no"; then
270 have_dl_iterate_phdr=no
272 # When built as a GCC target library, we can't do a link test.
273 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
274 [have_dl_iterate_phdr=no])
277 # Avoid dl_iterate_phdr on Solaris 10, where it is in the
278 # header file but is only in -ldl.
279 have_dl_iterate_phdr=no ;;
282 if test "$have_dl_iterate_phdr" = "yes"; then
283 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
286 # Check for the fcntl function.
287 if test -n "${with_target_subdir}"; then
289 *-*-mingw*) have_fcntl=no ;;
293 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
295 if test "$have_fcntl" = "yes"; then
296 AC_DEFINE([HAVE_FCNTL], 1,
297 [Define to 1 if you have the fcntl function])
300 AC_CHECK_DECLS(strnlen)
302 # Check for getexecname function.
303 if test -n "${with_target_subdir}"; then
305 *-*-solaris2*) have_getexecname=yes ;;
306 *) have_getexecname=no ;;
309 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
311 if test "$have_getexecname" = "yes"; then
312 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
315 AM_CONDITIONAL(LIBBACKTRACE_SUPPORTED,
316 [test "x${BACKTRACE_SUPPORTED}x${BACKTRACE_USES_MALLOC}" = "x1x0"])
318 AH_BOTTOM([#include "libbacktrace/backtrace-rename.h"])
319 AC_CONFIG_FILES([Makefile libsanitizer.spec libbacktrace/backtrace-supported.h])
320 AC_CONFIG_HEADER(config.h)
322 AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan asan ubsan], [DIR/Makefile ]),
323 [cat > vpsed$$ << \_EOF
324 s!`test -f '$<' || echo '$(srcdir)/'`!!
326 sed -f vpsed$$ $ac_file > tmp$$
329 echo 'MULTISUBDIR =' >> $ac_file
331 . ${multi_basedir}/config-ml.in
332 AS_UNSET([ml_norecursion])
335 if test "x$TSAN_SUPPORTED" = "xyes"; then
336 AC_CONFIG_FILES(AC_FOREACH([DIR], [tsan], [DIR/Makefile ]),
337 [cat > vpsed$$ << \_EOF
338 s!`test -f '$<' || echo '$(srcdir)/'`!!
340 sed -f vpsed$$ $ac_file > tmp$$
343 echo 'MULTISUBDIR =' >> $ac_file
345 . ${multi_basedir}/config-ml.in
346 AS_UNSET([ml_norecursion])
350 AC_SUBST([TSAN_TARGET_DEPENDENT_OBJECTS])