configure.ac revision 1.1.1.9
1# -*- Autoconf -*- 2# Process this file with autoconf to produce a configure script. 3 4AC_INIT(package-unused, version-unused, libsanitizer) 5AC_CONFIG_SRCDIR([include/sanitizer/common_interface_defs.h]) 6 7AM_ENABLE_MULTILIB(, ..) 8 9AC_MSG_CHECKING([for --enable-version-specific-runtime-libs]) 10AC_ARG_ENABLE(version-specific-runtime-libs, 11[ --enable-version-specific-runtime-libs Specify that runtime libraries should be installed in a compiler-specific directory ], 12[case "$enableval" in 13 yes) version_specific_libs=yes ;; 14 no) version_specific_libs=no ;; 15 *) AC_MSG_ERROR([Unknown argument to enable/disable version-specific libs]);; 16 esac], 17[version_specific_libs=no]) 18AC_MSG_RESULT($version_specific_libs) 19 20AC_USE_SYSTEM_EXTENSIONS 21 22# Do not delete or change the following two lines. For why, see 23# http://gcc.gnu.org/ml/libstdc++/2003-07/msg00451.html 24AC_CANONICAL_SYSTEM 25target_alias=${target_alias-$host_alias} 26AC_SUBST(target_alias) 27GCC_LIBSTDCXX_RAW_CXX_FLAGS 28 29AM_INIT_AUTOMAKE(foreign no-dist) 30AM_MAINTAINER_MODE 31 32# Calculate toolexeclibdir 33# Also toolexecdir, though it's only used in toolexeclibdir 34case ${version_specific_libs} in 35 yes) 36 # Need the gcc compiler version to know where to install libraries 37 # and header files if --enable-version-specific-runtime-libs option 38 # is selected. 39 toolexecdir='$(libdir)/gcc/$(target_alias)' 40 toolexeclibdir='$(toolexecdir)/$(gcc_version)$(MULTISUBDIR)' 41 ;; 42 no) 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' 48 else 49 toolexecdir='$(libdir)/gcc-lib/$(target_alias)' 50 toolexeclibdir='$(libdir)' 51 fi 52 multi_os_directory=`$CC -print-multi-os-directory` 53 case $multi_os_directory in 54 .) ;; # Avoid trailing /. 55 *) toolexeclibdir=$toolexeclibdir/$multi_os_directory ;; 56 esac 57 ;; 58esac 59AC_SUBST(toolexecdir) 60AC_SUBST(toolexeclibdir) 61 62# Checks for programs. 63AC_PROG_CC 64AC_PROG_CXX 65AM_PROG_AS 66AC_PROG_RANLIB 67 68AC_LIBTOOL_DLOPEN 69AM_PROG_LIBTOOL 70 71AC_PROG_AWK 72case "$AWK" in 73"") AC_MSG_ERROR([can't build without awk]) ;; 74esac 75 76AC_SUBST(enable_shared) 77AC_SUBST(enable_static) 78 79AC_CHECK_SIZEOF([void *]) 80 81if test "${multilib}" = "yes"; then 82 multilib_arg="--enable-multilib" 83else 84 multilib_arg= 85fi 86 87# Get target configury. 88unset TSAN_SUPPORTED 89unset LSAN_SUPPORTED 90. ${srcdir}/configure.tgt 91AM_CONDITIONAL(TSAN_SUPPORTED, [test "x$TSAN_SUPPORTED" = "xyes"]) 92AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"]) 93 94# Check for functions needed. 95AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime lstat readlink) 96 97# Common libraries that we need to link against for all sanitizer libs. 98link_sanitizer_common='-lpthread -lm' 99 100# At least for glibc, shm_open is in librt. But don't pull that 101# in if it still doesn't give us the function we want. This 102# test is copied from libgomp. 103AC_CHECK_LIB(rt, shm_open, 104 [link_sanitizer_common="-lrt $link_sanitizer_common"]) 105 106# Do a configure time check for -ldl 107AC_CHECK_LIB(dl, dlsym, 108 [link_sanitizer_common="-ldl $link_sanitizer_common"]) 109 110# Set up the set of additional libraries that we need to link against for libasan. 111link_libasan=$link_sanitizer_common 112AC_SUBST(link_libasan) 113 114# Set up the set of additional libraries that we need to link against for libtsan. 115link_libtsan=$link_sanitizer_common 116AC_SUBST(link_libtsan) 117 118# Set up the set of additional libraries that we need to link against for libubsan. 119link_libubsan=$link_sanitizer_common 120AC_SUBST(link_libubsan) 121 122# Set up the set of additional libraries that we need to link against for liblsan. 123link_liblsan=$link_sanitizer_common 124AC_SUBST(link_liblsan) 125 126 127# At least for glibc, clock_gettime is in librt. But don't pull that 128# in if it still doesn't give us the function we want. This 129# test is copied from libgomp. 130AC_CHECK_LIB(rt, clock_gettime, 131 [link_libasan="-lrt $link_libasan" 132link_libtsan="-lrt $link_libtsan" 133# Other sanitizers do not override clock_* API 134]) 135 136case "$host" in 137 *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;; 138 *) MAC_INTERPOSE=false ;; 139esac 140AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE) 141 142backtrace_supported=yes 143 144AC_MSG_CHECKING([for necessary platform features]) 145case "$target" in 146 *-*-linux*) 147 # Some old Linux distributions miss required syscalls. 148 sanitizer_supported=no 149 AC_TRY_COMPILE([#include <sys/syscall.h>],[ 150 syscall (__NR_gettid); 151 syscall (__NR_futex); 152 syscall (__NR_exit_group); 153 ], [sanitizer_supported=yes]) 154 ;; 155 *) 156 sanitizer_supported=yes 157 ;; 158esac 159AC_MSG_RESULT($sanitizer_supported) 160AM_CONDITIONAL(SANITIZER_SUPPORTED, test "$sanitizer_supported" = yes) 161 162# Test for __sync support. 163AC_CACHE_CHECK([__sync extensions], 164[libsanitizer_cv_sys_sync], 165[if test -n "${with_target_subdir}"; then 166 libsanitizer_cv_sys_sync=yes 167 else 168 AC_LINK_IFELSE( 169 [AC_LANG_PROGRAM([int i;], 170 [__sync_bool_compare_and_swap (&i, i, i); 171 __sync_lock_test_and_set (&i, 1); 172 __sync_lock_release (&i);])], 173 [libsanitizer_cv_sys_sync=yes], 174 [libsanitizer_cv_sys_sync=no]) 175 fi]) 176if test "$libsanitizer_cv_sys_sync" = "yes"; then 177 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1, 178 [Define to 1 if you have the __sync functions]) 179fi 180 181# Test for __atomic support. 182AC_CACHE_CHECK([__atomic extensions], 183[libsanitizer_cv_sys_atomic], 184[if test -n "${with_target_subdir}"; then 185 libsanitizer_cv_sys_atomic=yes 186 else 187 AC_LINK_IFELSE( 188 [AC_LANG_PROGRAM([int i;], 189 [__atomic_load_n (&i, __ATOMIC_ACQUIRE); 190 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])], 191 [libsanitizer_cv_sys_atomic=yes], 192 [libsanitizer_cv_sys_atomic=no]) 193 fi]) 194if test "$libsanitizer_cv_sys_atomic" = "yes"; then 195 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1, 196 [Define to 1 if you have the __atomic functions]) 197fi 198 199# The library needs to be able to read the executable itself. Compile 200# a file to determine the executable format. The awk script 201# filetype.awk prints out the file type. 202AC_CACHE_CHECK([output filetype], 203[libsanitizer_cv_sys_filetype], 204[filetype= 205AC_COMPILE_IFELSE( 206 [AC_LANG_PROGRAM([int i;], [int j;])], 207 [filetype=`${AWK} -f $srcdir/../libbacktrace/filetype.awk conftest.$ac_objext`], 208 [AC_MSG_FAILURE([compiler failed])]) 209libsanitizer_cv_sys_filetype=$filetype]) 210 211# Match the file type to decide what files to compile. 212FORMAT_FILE= 213case "$libsanitizer_cv_sys_filetype" in 214elf*) FORMAT_FILE="elf.lo" ;; 215*) AC_MSG_WARN([could not determine output file type]) 216 FORMAT_FILE="unknown.lo" 217 backtrace_supported=no 218 ;; 219esac 220AC_SUBST(FORMAT_FILE) 221 222# ELF defines. 223elfsize= 224case "$libsanitizer_cv_sys_filetype" in 225elf32) elfsize=32 ;; 226elf64) elfsize=64 ;; 227esac 228AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64]) 229 230BACKTRACE_SUPPORTED=0 231if test "$backtrace_supported" = "yes"; then 232 BACKTRACE_SUPPORTED=1 233fi 234AC_SUBST(BACKTRACE_SUPPORTED) 235 236GCC_HEADER_STDINT(gstdint.h) 237 238AC_CHECK_HEADERS(sys/mman.h alloca.h) 239if test "$ac_cv_header_sys_mman_h" = "no"; then 240 have_mmap=no 241else 242 if test -n "${with_target_subdir}"; then 243 # When built as a GCC target library, we can't do a link test. We 244 # simply assume that if we have mman.h, we have mmap. 245 have_mmap=yes 246 else 247 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no]) 248 fi 249fi 250if test "$have_mmap" = "no"; then 251 VIEW_FILE=read.lo 252 ALLOC_FILE=alloc.lo 253else 254 VIEW_FILE=mmapio.lo 255 AC_PREPROC_IFELSE([AC_LANG_SOURCE([ 256#include <sys/mman.h> 257#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON) 258 #error no MAP_ANONYMOUS 259#endif 260])], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo]) 261fi 262AC_SUBST(VIEW_FILE) 263AC_SUBST(ALLOC_FILE) 264 265BACKTRACE_USES_MALLOC=0 266if test "$ALLOC_FILE" = "alloc.lo"; then 267 BACKTRACE_USES_MALLOC=1 268fi 269AC_SUBST(BACKTRACE_USES_MALLOC) 270 271# Don't care about thread support 272BACKTRACE_SUPPORTS_THREADS=0 273AC_SUBST(BACKTRACE_SUPPORTS_THREADS) 274 275# Check for dl_iterate_phdr. 276AC_CHECK_HEADERS(link.h) 277if test "$ac_cv_header_link_h" = "no"; then 278 have_dl_iterate_phdr=no 279else 280 # When built as a GCC target library, we can't do a link test. 281 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes], 282 [have_dl_iterate_phdr=no]) 283 case "${host}" in 284 *-*-solaris2.10*) 285 # Avoid dl_iterate_phdr on Solaris 10, where it is in the 286 # header file but is only in -ldl. 287 have_dl_iterate_phdr=no ;; 288 esac 289fi 290if test "$have_dl_iterate_phdr" = "yes"; then 291 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.]) 292fi 293 294# Check for the fcntl function. 295if test -n "${with_target_subdir}"; then 296 case "${host}" in 297 *-*-mingw*) have_fcntl=no ;; 298 *) have_fcntl=yes ;; 299 esac 300else 301 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no]) 302fi 303if test "$have_fcntl" = "yes"; then 304 AC_DEFINE([HAVE_FCNTL], 1, 305 [Define to 1 if you have the fcntl function]) 306fi 307 308AC_CHECK_DECLS(strnlen) 309 310# Check for getexecname function. 311if test -n "${with_target_subdir}"; then 312 case "${host}" in 313 *-*-solaris2*) have_getexecname=yes ;; 314 *) have_getexecname=no ;; 315 esac 316else 317 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no]) 318fi 319if test "$have_getexecname" = "yes"; then 320 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.]) 321fi 322 323# Check for rpc/xdr.h 324AC_CHECK_HEADERS(rpc/xdr.h) 325if test x"$ac_cv_header_rpc_xdr_h" = xyes; then 326 rpc_defs="$rpc_defs -DHAVE_RPC_XDR_H=1" 327else 328 rpc_defs="$rpc_defs -DHAVE_RPC_XDR_H=0" 329fi 330 331# Check for tirpc/rpc/xdr.h 332AC_CHECK_HEADERS(tirpc/rpc/xdr.h) 333if test x"$ac_cv_header_tirpc_rpc_xdr_h" = xyes; then 334 rpc_defs="$rpc_defs -DHAVE_TIRPC_RPC_XDR_H=1" 335else 336 rpc_defs="$rpc_defs -DHAVE_TIRPC_RPC_XDR_H=0" 337fi 338 339AC_SUBST([RPC_DEFS], [$rpc_defs]) 340 341AM_CONDITIONAL(LIBBACKTRACE_SUPPORTED, 342 [test "x${BACKTRACE_SUPPORTED}x${BACKTRACE_USES_MALLOC}" = "x1x0"]) 343 344AH_BOTTOM([#include "libbacktrace/backtrace-rename.h"]) 345AC_CONFIG_FILES([Makefile libsanitizer.spec libbacktrace/backtrace-supported.h]) 346AC_CONFIG_HEADER(config.h) 347 348AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan asan ubsan], [DIR/Makefile ]), 349 [cat > vpsed$$ << \_EOF 350s!`test -f '$<' || echo '$(srcdir)/'`!! 351_EOF 352 sed -f vpsed$$ $ac_file > tmp$$ 353 mv tmp$$ $ac_file 354 rm vpsed$$ 355 echo 'MULTISUBDIR =' >> $ac_file 356 ml_norecursion=yes 357 . ${multi_basedir}/config-ml.in 358 AS_UNSET([ml_norecursion]) 359]) 360 361if test "x$TSAN_SUPPORTED" = "xyes"; then 362 AC_CONFIG_FILES(AC_FOREACH([DIR], [tsan], [DIR/Makefile ]), 363 [cat > vpsed$$ << \_EOF 364s!`test -f '$<' || echo '$(srcdir)/'`!! 365_EOF 366 sed -f vpsed$$ $ac_file > tmp$$ 367 mv tmp$$ $ac_file 368 rm vpsed$$ 369 echo 'MULTISUBDIR =' >> $ac_file 370 ml_norecursion=yes 371 . ${multi_basedir}/config-ml.in 372 AS_UNSET([ml_norecursion]) 373]) 374fi 375 376AC_SUBST([TSAN_TARGET_DEPENDENT_OBJECTS]) 377AC_SUBST([SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS]) 378 379# Determine what GCC version number to use in filesystem paths. 380GCC_BASE_VER 381 382# Add CET specific flags if Intel CET is enabled. 383GCC_CET_FLAGS(CET_FLAGS) 384EXTRA_CFLAGS="$EXTRA_CFLAGS $CET_FLAGS" 385EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $CET_FLAGS" 386EXTRA_ASFLAGS=$CET_FLAGS 387AC_SUBST(EXTRA_ASFLAGS) 388AC_SUBST(EXTRA_CFLAGS) 389AC_SUBST(EXTRA_CXXFLAGS) 390 391AC_OUTPUT 392