]> git.ipfire.org Git - thirdparty/gcc.git/blob - libsanitizer/configure.ac
Update GCC to autoconf 2.69, automake 1.15.1 (PR bootstrap/82856).
[thirdparty/gcc.git] / libsanitizer / configure.ac
1 # -*- Autoconf -*-
2 # Process this file with autoconf to produce a configure script.
3
4 AC_INIT(package-unused, version-unused, libsanitizer)
5 AC_CONFIG_SRCDIR([include/sanitizer/common_interface_defs.h])
6
7 AM_ENABLE_MULTILIB(, ..)
8
9 AC_MSG_CHECKING([for --enable-version-specific-runtime-libs])
10 AC_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])
18 AC_MSG_RESULT($version_specific_libs)
19
20 AC_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
24 AC_CANONICAL_SYSTEM
25 target_alias=${target_alias-$host_alias}
26 AC_SUBST(target_alias)
27 GCC_LIBSTDCXX_RAW_CXX_FLAGS
28
29 AM_INIT_AUTOMAKE(foreign no-dist)
30 AM_MAINTAINER_MODE
31
32 # Calculate toolexeclibdir
33 # Also toolexecdir, though it's only used in toolexeclibdir
34 case ${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 ;;
58 esac
59 AC_SUBST(toolexecdir)
60 AC_SUBST(toolexeclibdir)
61
62 # Checks for programs.
63 AC_PROG_CC
64 AC_PROG_CXX
65 AM_PROG_AS
66 AC_PROG_RANLIB
67
68 AC_LIBTOOL_DLOPEN
69 AM_PROG_LIBTOOL
70
71 AC_PROG_AWK
72 case "$AWK" in
73 "") AC_MSG_ERROR([can't build without awk]) ;;
74 esac
75
76 AC_SUBST(enable_shared)
77 AC_SUBST(enable_static)
78
79 AC_CHECK_SIZEOF([void *])
80
81 if test "${multilib}" = "yes"; then
82 multilib_arg="--enable-multilib"
83 else
84 multilib_arg=
85 fi
86
87 # Get target configury.
88 unset TSAN_SUPPORTED
89 unset LSAN_SUPPORTED
90 . ${srcdir}/configure.tgt
91 AM_CONDITIONAL(TSAN_SUPPORTED, [test "x$TSAN_SUPPORTED" = "xyes"])
92 AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"])
93
94 # Check for functions needed.
95 AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime lstat readlink)
96
97 # Common libraries that we need to link against for all sanitizer libs.
98 link_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.
103 AC_CHECK_LIB(rt, shm_open,
104 [link_sanitizer_common="-lrt $link_sanitizer_common"])
105
106 # Do a configure time check for -ldl
107 AC_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.
111 link_libasan=$link_sanitizer_common
112 AC_SUBST(link_libasan)
113
114 # Set up the set of additional libraries that we need to link against for libtsan.
115 link_libtsan=$link_sanitizer_common
116 AC_SUBST(link_libtsan)
117
118 # Set up the set of additional libraries that we need to link against for libubsan.
119 link_libubsan=$link_sanitizer_common
120 AC_SUBST(link_libubsan)
121
122 # Set up the set of additional libraries that we need to link against for liblsan.
123 link_liblsan=$link_sanitizer_common
124 AC_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.
130 AC_CHECK_LIB(rt, clock_gettime,
131 [link_libasan="-lrt $link_libasan"
132 link_libtsan="-lrt $link_libtsan"
133 # Other sanitizers do not override clock_* API
134 ])
135
136 case "$host" in
137 *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;;
138 *) MAC_INTERPOSE=false ;;
139 esac
140 AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE)
141
142 backtrace_supported=yes
143
144 AC_MSG_CHECKING([for necessary platform features])
145 case "$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 ;;
158 esac
159 AC_MSG_RESULT($sanitizer_supported)
160 AM_CONDITIONAL(SANITIZER_SUPPORTED, test "$sanitizer_supported" = yes)
161
162 # Test for __sync support.
163 AC_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])
176 if test "$libsanitizer_cv_sys_sync" = "yes"; then
177 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
178 [Define to 1 if you have the __sync functions])
179 fi
180
181 # Test for __atomic support.
182 AC_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])
194 if test "$libsanitizer_cv_sys_atomic" = "yes"; then
195 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
196 [Define to 1 if you have the __atomic functions])
197 fi
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.
202 AC_CACHE_CHECK([output filetype],
203 [libsanitizer_cv_sys_filetype],
204 [filetype=
205 AC_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])])
209 libsanitizer_cv_sys_filetype=$filetype])
210
211 # Match the file type to decide what files to compile.
212 FORMAT_FILE=
213 case "$libsanitizer_cv_sys_filetype" in
214 elf*) FORMAT_FILE="elf.lo" ;;
215 *) AC_MSG_WARN([could not determine output file type])
216 FORMAT_FILE="unknown.lo"
217 backtrace_supported=no
218 ;;
219 esac
220 AC_SUBST(FORMAT_FILE)
221
222 # ELF defines.
223 elfsize=
224 case "$libsanitizer_cv_sys_filetype" in
225 elf32) elfsize=32 ;;
226 elf64) elfsize=64 ;;
227 esac
228 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
229
230 BACKTRACE_SUPPORTED=0
231 if test "$backtrace_supported" = "yes"; then
232 BACKTRACE_SUPPORTED=1
233 fi
234 AC_SUBST(BACKTRACE_SUPPORTED)
235
236 GCC_HEADER_STDINT(gstdint.h)
237
238 AC_CHECK_HEADERS(sys/mman.h alloca.h)
239 if test "$ac_cv_header_sys_mman_h" = "no"; then
240 have_mmap=no
241 else
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
249 fi
250 if test "$have_mmap" = "no"; then
251 VIEW_FILE=read.lo
252 ALLOC_FILE=alloc.lo
253 else
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])
261 fi
262 AC_SUBST(VIEW_FILE)
263 AC_SUBST(ALLOC_FILE)
264
265 BACKTRACE_USES_MALLOC=0
266 if test "$ALLOC_FILE" = "alloc.lo"; then
267 BACKTRACE_USES_MALLOC=1
268 fi
269 AC_SUBST(BACKTRACE_USES_MALLOC)
270
271 # Don't care about thread support
272 BACKTRACE_SUPPORTS_THREADS=0
273 AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
274
275 # Check for dl_iterate_phdr.
276 AC_CHECK_HEADERS(link.h)
277 if test "$ac_cv_header_link_h" = "no"; then
278 have_dl_iterate_phdr=no
279 else
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
289 fi
290 if test "$have_dl_iterate_phdr" = "yes"; then
291 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
292 fi
293
294 # Check for the fcntl function.
295 if test -n "${with_target_subdir}"; then
296 case "${host}" in
297 *-*-mingw*) have_fcntl=no ;;
298 *) have_fcntl=yes ;;
299 esac
300 else
301 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
302 fi
303 if test "$have_fcntl" = "yes"; then
304 AC_DEFINE([HAVE_FCNTL], 1,
305 [Define to 1 if you have the fcntl function])
306 fi
307
308 AC_CHECK_DECLS(strnlen)
309
310 # Check for getexecname function.
311 if test -n "${with_target_subdir}"; then
312 case "${host}" in
313 *-*-solaris2*) have_getexecname=yes ;;
314 *) have_getexecname=no ;;
315 esac
316 else
317 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
318 fi
319 if test "$have_getexecname" = "yes"; then
320 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
321 fi
322
323 # Check for rpc/xdr.h
324 AC_CHECK_HEADERS(rpc/xdr.h)
325 if test x"$ac_cv_header_rpc_xdr_h" = xyes; then
326 rpc_defs="$rpc_defs -DHAVE_RPC_XDR_H=1"
327 else
328 rpc_defs="$rpc_defs -DHAVE_RPC_XDR_H=0"
329 fi
330
331 # Check for tirpc/rpc/xdr.h
332 AC_CHECK_HEADERS(tirpc/rpc/xdr.h)
333 if test x"$ac_cv_header_tirpc_rpc_xdr_h" = xyes; then
334 rpc_defs="$rpc_defs -DHAVE_TIRPC_RPC_XDR_H=1"
335 else
336 rpc_defs="$rpc_defs -DHAVE_TIRPC_RPC_XDR_H=0"
337 fi
338
339 AC_SUBST([RPC_DEFS], [$rpc_defs])
340
341 AM_CONDITIONAL(LIBBACKTRACE_SUPPORTED,
342 [test "x${BACKTRACE_SUPPORTED}x${BACKTRACE_USES_MALLOC}" = "x1x0"])
343
344 AH_BOTTOM([#include "libbacktrace/backtrace-rename.h"])
345 AC_CONFIG_FILES([Makefile libsanitizer.spec libbacktrace/backtrace-supported.h])
346 AC_CONFIG_HEADER(config.h)
347
348 AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan asan ubsan], [DIR/Makefile ]),
349 [cat > vpsed$$ << \_EOF
350 s!`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
361 if test "x$TSAN_SUPPORTED" = "xyes"; then
362 AC_CONFIG_FILES(AC_FOREACH([DIR], [tsan], [DIR/Makefile ]),
363 [cat > vpsed$$ << \_EOF
364 s!`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 ])
374 fi
375
376 AC_SUBST([TSAN_TARGET_DEPENDENT_OBJECTS])
377 AC_SUBST([SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS])
378
379 # Determine what GCC version number to use in filesystem paths.
380 GCC_BASE_VER
381
382 # Add CET specific flags if Intel CET is enabled.
383 GCC_CET_FLAGS(CET_FLAGS)
384 EXTRA_CFLAGS="$EXTRA_CFLAGS $CET_FLAGS"
385 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $CET_FLAGS"
386 EXTRA_ASFLAGS=$CET_FLAGS
387 AC_SUBST(EXTRA_ASFLAGS)
388 AC_SUBST(EXTRA_CFLAGS)
389 AC_SUBST(EXTRA_CXXFLAGS)
390
391 AC_OUTPUT