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