]> git.ipfire.org Git - thirdparty/gcc.git/blob - libsanitizer/configure.ac
[Ada] Get rid of more references to Universal_Integer in expanded code
[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 GCC_WITH_TOOLEXECLIBDIR
33
34 # Calculate toolexeclibdir
35 # Also toolexecdir, though it's only used in toolexeclibdir
36 case ${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 ;;
67 esac
68 AC_SUBST(toolexecdir)
69 AC_SUBST(toolexeclibdir)
70
71 # Checks for programs.
72 AC_PROG_CC
73 AC_PROG_CXX
74 AM_PROG_AS
75 AC_PROG_RANLIB
76
77 AC_LIBTOOL_DLOPEN
78 AM_PROG_LIBTOOL
79
80 AC_PROG_AWK
81 case "$AWK" in
82 "") AC_MSG_ERROR([can't build without awk]) ;;
83 esac
84
85 AC_SUBST(enable_shared)
86 AC_SUBST(enable_static)
87
88 AC_CHECK_SIZEOF([void *])
89
90 if test "${multilib}" = "yes"; then
91 multilib_arg="--enable-multilib"
92 else
93 multilib_arg=
94 fi
95
96 # Get target configury.
97 unset TSAN_SUPPORTED
98 unset LSAN_SUPPORTED
99 . ${srcdir}/configure.tgt
100 AM_CONDITIONAL(TSAN_SUPPORTED, [test "x$TSAN_SUPPORTED" = "xyes"])
101 AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"])
102
103 # Check for functions needed.
104 AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime lstat readlink)
105
106 # Common libraries that we need to link against for all sanitizer libs.
107 link_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.
112 AC_CHECK_LIB(rt, shm_open,
113 [link_sanitizer_common="-lrt $link_sanitizer_common"])
114
115 # Do a configure time check for -ldl
116 AC_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.
120 link_libasan=$link_sanitizer_common
121 AC_SUBST(link_libasan)
122
123 # Set up the set of additional libraries that we need to link against for libtsan.
124 link_libtsan=$link_sanitizer_common
125 AC_SUBST(link_libtsan)
126
127 # Set up the set of additional libraries that we need to link against for libubsan.
128 link_libubsan=$link_sanitizer_common
129 AC_SUBST(link_libubsan)
130
131 # Set up the set of additional libraries that we need to link against for liblsan.
132 link_liblsan=$link_sanitizer_common
133 AC_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.
139 AC_CHECK_LIB(rt, clock_gettime,
140 [link_libasan="-lrt $link_libasan"
141 link_libtsan="-lrt $link_libtsan"
142 # Other sanitizers do not override clock_* API
143 ])
144
145 case "$host" in
146 *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;;
147 *) MAC_INTERPOSE=false ;;
148 esac
149 AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE)
150
151 backtrace_supported=yes
152
153 AC_MSG_CHECKING([for necessary platform features])
154 case "$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 ;;
167 esac
168 AC_MSG_RESULT($sanitizer_supported)
169 AM_CONDITIONAL(SANITIZER_SUPPORTED, test "$sanitizer_supported" = yes)
170
171 # Test for __sync support.
172 AC_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])
185 if test "$libsanitizer_cv_sys_sync" = "yes"; then
186 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
187 [Define to 1 if you have the __sync functions])
188 fi
189
190 # Test for __atomic support.
191 AC_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])
203 if test "$libsanitizer_cv_sys_atomic" = "yes"; then
204 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
205 [Define to 1 if you have the __atomic functions])
206 fi
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.
211 AC_CACHE_CHECK([output filetype],
212 [libsanitizer_cv_sys_filetype],
213 [filetype=
214 AC_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])])
218 libsanitizer_cv_sys_filetype=$filetype])
219
220 # Match the file type to decide what files to compile.
221 FORMAT_FILE=
222 case "$libsanitizer_cv_sys_filetype" in
223 elf*) FORMAT_FILE="elf.lo" ;;
224 *) AC_MSG_WARN([could not determine output file type])
225 FORMAT_FILE="unknown.lo"
226 backtrace_supported=no
227 ;;
228 esac
229 AC_SUBST(FORMAT_FILE)
230
231 # ELF defines.
232 elfsize=
233 case "$libsanitizer_cv_sys_filetype" in
234 elf32) elfsize=32 ;;
235 elf64) elfsize=64 ;;
236 esac
237 AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
238
239 BACKTRACE_SUPPORTED=0
240 if test "$backtrace_supported" = "yes"; then
241 BACKTRACE_SUPPORTED=1
242 fi
243 AC_SUBST(BACKTRACE_SUPPORTED)
244
245 GCC_HEADER_STDINT(gstdint.h)
246
247 AC_CHECK_HEADERS(sys/mman.h alloca.h)
248 if test "$ac_cv_header_sys_mman_h" = "no"; then
249 have_mmap=no
250 else
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
258 fi
259 if test "$have_mmap" = "no"; then
260 VIEW_FILE=read.lo
261 ALLOC_FILE=alloc.lo
262 else
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])
270 fi
271 AC_SUBST(VIEW_FILE)
272 AC_SUBST(ALLOC_FILE)
273
274 BACKTRACE_USES_MALLOC=0
275 if test "$ALLOC_FILE" = "alloc.lo"; then
276 BACKTRACE_USES_MALLOC=1
277 fi
278 AC_SUBST(BACKTRACE_USES_MALLOC)
279
280 # Don't care about thread support
281 BACKTRACE_SUPPORTS_THREADS=0
282 AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
283
284 # Check for dl_iterate_phdr.
285 AC_CHECK_HEADERS(link.h)
286 if test "$ac_cv_header_link_h" = "no"; then
287 have_dl_iterate_phdr=no
288 else
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])
292 fi
293 if test "$have_dl_iterate_phdr" = "yes"; then
294 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
295 fi
296
297 # Check for the fcntl function.
298 if test -n "${with_target_subdir}"; then
299 case "${host}" in
300 *-*-mingw*) have_fcntl=no ;;
301 *) have_fcntl=yes ;;
302 esac
303 else
304 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
305 fi
306 if test "$have_fcntl" = "yes"; then
307 AC_DEFINE([HAVE_FCNTL], 1,
308 [Define to 1 if you have the fcntl function])
309 fi
310
311 AC_CHECK_DECLS(strnlen)
312
313 # Check for getexecname function.
314 if test -n "${with_target_subdir}"; then
315 case "${host}" in
316 *-*-solaris2*) have_getexecname=yes ;;
317 *) have_getexecname=no ;;
318 esac
319 else
320 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
321 fi
322 if test "$have_getexecname" = "yes"; then
323 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
324 fi
325
326 # Check for rpc/xdr.h
327 AC_CHECK_HEADERS(rpc/xdr.h)
328 if test x"$ac_cv_header_rpc_xdr_h" = xyes; then
329 rpc_defs="$rpc_defs -DHAVE_RPC_XDR_H=1"
330 else
331 rpc_defs="$rpc_defs -DHAVE_RPC_XDR_H=0"
332 fi
333
334 # Check for tirpc/rpc/xdr.h
335 AC_CHECK_HEADERS(tirpc/rpc/xdr.h)
336 if test x"$ac_cv_header_tirpc_rpc_xdr_h" = xyes; then
337 rpc_defs="$rpc_defs -DHAVE_TIRPC_RPC_XDR_H=1"
338 else
339 rpc_defs="$rpc_defs -DHAVE_TIRPC_RPC_XDR_H=0"
340 fi
341
342 AC_SUBST([RPC_DEFS], [$rpc_defs])
343
344 AM_CONDITIONAL(LIBBACKTRACE_SUPPORTED,
345 [test "x${BACKTRACE_SUPPORTED}x${BACKTRACE_USES_MALLOC}" = "x1x0"])
346
347 AH_BOTTOM([#include "libbacktrace/backtrace-rename.h"])
348 AC_CONFIG_FILES([Makefile libsanitizer.spec libbacktrace/backtrace-supported.h])
349 AC_CONFIG_HEADER(config.h)
350
351 AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan asan ubsan], [DIR/Makefile ]),
352 [cat > vpsed$$ << \_EOF
353 s!`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
364 if test "x$TSAN_SUPPORTED" = "xyes"; then
365 AC_CONFIG_FILES(AC_FOREACH([DIR], [tsan], [DIR/Makefile ]),
366 [cat > vpsed$$ << \_EOF
367 s!`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 ])
377 fi
378
379 AC_SUBST([TSAN_TARGET_DEPENDENT_OBJECTS])
380 AC_SUBST([SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS])
381
382 # Determine what GCC version number to use in filesystem paths.
383 GCC_BASE_VER
384
385 # Add CET specific flags if Intel CET is enabled.
386 GCC_CET_FLAGS(CET_FLAGS)
387 EXTRA_CFLAGS="$EXTRA_CFLAGS $CET_FLAGS"
388 EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $CET_FLAGS"
389 EXTRA_ASFLAGS=$CET_FLAGS
390 AC_SUBST(EXTRA_ASFLAGS)
391 AC_SUBST(EXTRA_CFLAGS)
392 AC_SUBST(EXTRA_CXXFLAGS)
393
394 AC_OUTPUT