]> git.ipfire.org Git - thirdparty/gcc.git/blame - libsanitizer/configure.ac
Fortran: annotations for DO CONCURRENT loops [PR113305]
[thirdparty/gcc.git] / libsanitizer / configure.ac
CommitLineData
f35db108
WM
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3
f35db108
WM
4AC_INIT(package-unused, version-unused, libsanitizer)
5AC_CONFIG_SRCDIR([include/sanitizer/common_interface_defs.h])
2a6346c4 6
94213c10
MK
7AM_ENABLE_MULTILIB(, ..)
8
2a6346c4
L
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
c915a581
JJ
20AC_USE_SYSTEM_EXTENSIONS
21
2a6346c4
L
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)
d10a2df2 27GCC_LIBSTDCXX_RAW_CXX_FLAGS
2a6346c4 28
1868beee 29AM_INIT_AUTOMAKE(foreign no-dist)
2b723e21 30AM_MAINTAINER_MODE
2a6346c4 31
e8e66971
MR
32GCC_WITH_TOOLEXECLIBDIR
33
2a6346c4
L
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)'
e8e66971
MR
49 case ${with_toolexeclibdir} in
50 no)
51 toolexeclibdir='$(toolexecdir)/lib'
52 ;;
53 *)
54 toolexeclibdir=${with_toolexeclibdir}
55 ;;
56 esac
2a6346c4
L
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)
f35db108
WM
70
71# Checks for programs.
72AC_PROG_CC
73AC_PROG_CXX
74AM_PROG_AS
c915a581 75AC_PROG_RANLIB
f35db108
WM
76
77AC_LIBTOOL_DLOPEN
78AM_PROG_LIBTOOL
79
c915a581
JJ
80AC_PROG_AWK
81case "$AWK" in
82"") AC_MSG_ERROR([can't build without awk]) ;;
83esac
84
f35db108
WM
85AC_SUBST(enable_shared)
86AC_SUBST(enable_static)
87
6a6d3817
IS
88AM_CONDITIONAL([ENABLE_DARWIN_AT_RPATH], [test x$enable_darwin_at_rpath = xyes])
89
64548f3b
JJ
90AC_CHECK_SIZEOF([void *])
91
2a6346c4
L
92if test "${multilib}" = "yes"; then
93 multilib_arg="--enable-multilib"
94else
95 multilib_arg=
96fi
64548f3b
JJ
97
98# Get target configury.
99unset TSAN_SUPPORTED
9065ada9 100unset LSAN_SUPPORTED
8a769f81 101unset HWASAN_SUPPORTED
64548f3b
JJ
102. ${srcdir}/configure.tgt
103AM_CONDITIONAL(TSAN_SUPPORTED, [test "x$TSAN_SUPPORTED" = "xyes"])
9065ada9 104AM_CONDITIONAL(LSAN_SUPPORTED, [test "x$LSAN_SUPPORTED" = "xyes"])
8a769f81 105AM_CONDITIONAL(HWASAN_SUPPORTED, [test "x$HWASAN_SUPPORTED" = "xyes"])
f35db108 106
35814b03 107# Check for functions needed.
3b07c0e5 108AC_CHECK_FUNCS(clock_getres clock_gettime clock_settime lstat readlink)
35814b03
JJ
109
110# Common libraries that we need to link against for all sanitizer libs.
bf93d543 111link_sanitizer_common='-lpthread -lm'
692b1131
MO
112
113# At least for glibc, shm_open is in librt. But don't pull that
114# in if it still doesn't give us the function we want. This
115# test is copied from libgomp.
116AC_CHECK_LIB(rt, shm_open,
117 [link_sanitizer_common="-lrt $link_sanitizer_common"])
35814b03 118
bf93d543
AT
119# Do a configure time check for -ldl
120AC_CHECK_LIB(dl, dlsym,
121 [link_sanitizer_common="-ldl $link_sanitizer_common"])
122
35814b03
JJ
123# Set up the set of additional libraries that we need to link against for libasan.
124link_libasan=$link_sanitizer_common
125AC_SUBST(link_libasan)
126
edb07cb9
MM
127# Set up the set of additional libraries that we need to link against for libhwasan.
128link_libhwasan=$link_sanitizer_common
129AC_SUBST(link_libhwasan)
130
35814b03
JJ
131# Set up the set of additional libraries that we need to link against for libtsan.
132link_libtsan=$link_sanitizer_common
133AC_SUBST(link_libtsan)
134
135# Set up the set of additional libraries that we need to link against for libubsan.
136link_libubsan=$link_sanitizer_common
137AC_SUBST(link_libubsan)
138
139# Set up the set of additional libraries that we need to link against for liblsan.
140link_liblsan=$link_sanitizer_common
141AC_SUBST(link_liblsan)
142
692b1131
MO
143
144# At least for glibc, clock_gettime is in librt. But don't pull that
145# in if it still doesn't give us the function we want. This
146# test is copied from libgomp.
147AC_CHECK_LIB(rt, clock_gettime,
148 [link_libasan="-lrt $link_libasan"
149link_libtsan="-lrt $link_libtsan"
150# Other sanitizers do not override clock_* API
151])
152
f246eadc 153case "$host" in
692b1131
MO
154 *-*-darwin*) MAC_INTERPOSE=true ; enable_static=no ;;
155 *) MAC_INTERPOSE=false ;;
f246eadc 156esac
8c4d267c 157AM_CONDITIONAL(USING_MAC_INTERPOSE, $MAC_INTERPOSE)
f246eadc 158
c915a581
JJ
159backtrace_supported=yes
160
4a7eaf5f
YG
161AC_MSG_CHECKING([for necessary platform features])
162case "$target" in
163 *-*-linux*)
164 # Some old Linux distributions miss required syscalls.
165 sanitizer_supported=no
6be2672e
FW
166 AC_TRY_COMPILE([#include <sys/syscall.h>
167#include <unistd.h>],[
4a7eaf5f
YG
168 syscall (__NR_gettid);
169 syscall (__NR_futex);
170 syscall (__NR_exit_group);
171 ], [sanitizer_supported=yes])
172 ;;
173 *)
174 sanitizer_supported=yes
175 ;;
176esac
177AC_MSG_RESULT($sanitizer_supported)
178AM_CONDITIONAL(SANITIZER_SUPPORTED, test "$sanitizer_supported" = yes)
179
c915a581
JJ
180# Test for __sync support.
181AC_CACHE_CHECK([__sync extensions],
182[libsanitizer_cv_sys_sync],
183[if test -n "${with_target_subdir}"; then
184 libsanitizer_cv_sys_sync=yes
185 else
186 AC_LINK_IFELSE(
187 [AC_LANG_PROGRAM([int i;],
188 [__sync_bool_compare_and_swap (&i, i, i);
189 __sync_lock_test_and_set (&i, 1);
190 __sync_lock_release (&i);])],
191 [libsanitizer_cv_sys_sync=yes],
192 [libsanitizer_cv_sys_sync=no])
193 fi])
194if test "$libsanitizer_cv_sys_sync" = "yes"; then
195 AC_DEFINE([HAVE_SYNC_FUNCTIONS], 1,
196 [Define to 1 if you have the __sync functions])
197fi
198
199# Test for __atomic support.
200AC_CACHE_CHECK([__atomic extensions],
201[libsanitizer_cv_sys_atomic],
202[if test -n "${with_target_subdir}"; then
203 libsanitizer_cv_sys_atomic=yes
204 else
205 AC_LINK_IFELSE(
206 [AC_LANG_PROGRAM([int i;],
207 [__atomic_load_n (&i, __ATOMIC_ACQUIRE);
208 __atomic_store_n (&i, 1, __ATOMIC_RELEASE);])],
209 [libsanitizer_cv_sys_atomic=yes],
210 [libsanitizer_cv_sys_atomic=no])
211 fi])
212if test "$libsanitizer_cv_sys_atomic" = "yes"; then
213 AC_DEFINE([HAVE_ATOMIC_FUNCTIONS], 1,
214 [Define to 1 if you have the __atomic functions])
215fi
216
088d3cbc
RO
217# Check if assembler supports symbol assignment.
218AC_CACHE_CHECK([assembler symbol assignment],
219[libsanitizer_cv_as_sym_assign],
220[AC_COMPILE_IFELSE(
221 [AC_LANG_PROGRAM([],
222 [asm("a = b");])],
223 [libsanitizer_cv_as_sym_assign=yes],
224 [libsanitizer_cv_as_sym_assign=no])])
225if test "$libsanitizer_cv_as_sym_assign" = "yes"; then
226 as_sym_assign_defs=-DHAVE_AS_SYM_ASSIGN=1
227fi
228AC_SUBST(AS_SYM_ASSIGN_DEFS, [$as_sym_assign_defs])
229
c915a581
JJ
230# The library needs to be able to read the executable itself. Compile
231# a file to determine the executable format. The awk script
232# filetype.awk prints out the file type.
233AC_CACHE_CHECK([output filetype],
234[libsanitizer_cv_sys_filetype],
235[filetype=
236AC_COMPILE_IFELSE(
237 [AC_LANG_PROGRAM([int i;], [int j;])],
238 [filetype=`${AWK} -f $srcdir/../libbacktrace/filetype.awk conftest.$ac_objext`],
239 [AC_MSG_FAILURE([compiler failed])])
240libsanitizer_cv_sys_filetype=$filetype])
241
242# Match the file type to decide what files to compile.
243FORMAT_FILE=
244case "$libsanitizer_cv_sys_filetype" in
245elf*) FORMAT_FILE="elf.lo" ;;
246*) AC_MSG_WARN([could not determine output file type])
247 FORMAT_FILE="unknown.lo"
248 backtrace_supported=no
249 ;;
250esac
251AC_SUBST(FORMAT_FILE)
252
253# ELF defines.
254elfsize=
255case "$libsanitizer_cv_sys_filetype" in
256elf32) elfsize=32 ;;
257elf64) elfsize=64 ;;
258esac
259AC_DEFINE_UNQUOTED([BACKTRACE_ELF_SIZE], [$elfsize], [ELF size: 32 or 64])
260
261BACKTRACE_SUPPORTED=0
262if test "$backtrace_supported" = "yes"; then
263 BACKTRACE_SUPPORTED=1
264fi
265AC_SUBST(BACKTRACE_SUPPORTED)
266
267GCC_HEADER_STDINT(gstdint.h)
268
b5f58ba3 269AC_CHECK_HEADERS(sys/mman.h alloca.h)
c915a581
JJ
270if test "$ac_cv_header_sys_mman_h" = "no"; then
271 have_mmap=no
272else
273 if test -n "${with_target_subdir}"; then
274 # When built as a GCC target library, we can't do a link test. We
275 # simply assume that if we have mman.h, we have mmap.
276 have_mmap=yes
277 else
278 AC_CHECK_FUNC(mmap, [have_mmap=yes], [have_mmap=no])
279 fi
280fi
281if test "$have_mmap" = "no"; then
282 VIEW_FILE=read.lo
283 ALLOC_FILE=alloc.lo
284else
285 VIEW_FILE=mmapio.lo
22e05272 286 AC_PREPROC_IFELSE([AC_LANG_SOURCE([
c915a581
JJ
287#include <sys/mman.h>
288#if !defined(MAP_ANONYMOUS) && !defined(MAP_ANON)
289 #error no MAP_ANONYMOUS
290#endif
22e05272 291])], [ALLOC_FILE=mmap.lo], [ALLOC_FILE=alloc.lo])
c915a581
JJ
292fi
293AC_SUBST(VIEW_FILE)
294AC_SUBST(ALLOC_FILE)
295
296BACKTRACE_USES_MALLOC=0
297if test "$ALLOC_FILE" = "alloc.lo"; then
298 BACKTRACE_USES_MALLOC=1
299fi
300AC_SUBST(BACKTRACE_USES_MALLOC)
301
302# Don't care about thread support
303BACKTRACE_SUPPORTS_THREADS=0
304AC_SUBST(BACKTRACE_SUPPORTS_THREADS)
305
306# Check for dl_iterate_phdr.
307AC_CHECK_HEADERS(link.h)
308if test "$ac_cv_header_link_h" = "no"; then
309 have_dl_iterate_phdr=no
310else
311 # When built as a GCC target library, we can't do a link test.
312 AC_EGREP_HEADER([dl_iterate_phdr], [link.h], [have_dl_iterate_phdr=yes],
313 [have_dl_iterate_phdr=no])
c915a581
JJ
314fi
315if test "$have_dl_iterate_phdr" = "yes"; then
316 AC_DEFINE(HAVE_DL_ITERATE_PHDR, 1, [Define if dl_iterate_phdr is available.])
317fi
318
319# Check for the fcntl function.
320if test -n "${with_target_subdir}"; then
321 case "${host}" in
322 *-*-mingw*) have_fcntl=no ;;
323 *) have_fcntl=yes ;;
324 esac
325else
326 AC_CHECK_FUNC(fcntl, [have_fcntl=yes], [have_fcntl=no])
327fi
328if test "$have_fcntl" = "yes"; then
329 AC_DEFINE([HAVE_FCNTL], 1,
330 [Define to 1 if you have the fcntl function])
331fi
332
333AC_CHECK_DECLS(strnlen)
334
335# Check for getexecname function.
336if test -n "${with_target_subdir}"; then
337 case "${host}" in
338 *-*-solaris2*) have_getexecname=yes ;;
339 *) have_getexecname=no ;;
340 esac
341else
342 AC_CHECK_FUNC(getexecname, [have_getexecname=yes], [have_getexecname=no])
343fi
344if test "$have_getexecname" = "yes"; then
345 AC_DEFINE(HAVE_GETEXECNAME, 1, [Define if getexecname is available.])
346fi
347
d041a6fc
YG
348# Check for rpc/xdr.h
349AC_CHECK_HEADERS(rpc/xdr.h)
350if test x"$ac_cv_header_rpc_xdr_h" = xyes; then
351 rpc_defs="$rpc_defs -DHAVE_RPC_XDR_H=1"
352else
353 rpc_defs="$rpc_defs -DHAVE_RPC_XDR_H=0"
354fi
355
356# Check for tirpc/rpc/xdr.h
357AC_CHECK_HEADERS(tirpc/rpc/xdr.h)
358if test x"$ac_cv_header_tirpc_rpc_xdr_h" = xyes; then
359 rpc_defs="$rpc_defs -DHAVE_TIRPC_RPC_XDR_H=1"
360else
361 rpc_defs="$rpc_defs -DHAVE_TIRPC_RPC_XDR_H=0"
362fi
363
364AC_SUBST([RPC_DEFS], [$rpc_defs])
365
c915a581
JJ
366AM_CONDITIONAL(LIBBACKTRACE_SUPPORTED,
367 [test "x${BACKTRACE_SUPPORTED}x${BACKTRACE_USES_MALLOC}" = "x1x0"])
368
369AH_BOTTOM([#include "libbacktrace/backtrace-rename.h"])
370AC_CONFIG_FILES([Makefile libsanitizer.spec libbacktrace/backtrace-supported.h])
371AC_CONFIG_HEADER(config.h)
f35db108 372
8a769f81 373AC_CONFIG_FILES(AC_FOREACH([DIR], [interception sanitizer_common libbacktrace lsan asan ubsan], [DIR/Makefile ]),
f35db108
WM
374 [cat > vpsed$$ << \_EOF
375s!`test -f '$<' || echo '$(srcdir)/'`!!
376_EOF
377 sed -f vpsed$$ $ac_file > tmp$$
378 mv tmp$$ $ac_file
379 rm vpsed$$
380 echo 'MULTISUBDIR =' >> $ac_file
f64bcb29
L
381 ml_norecursion=yes
382 . ${multi_basedir}/config-ml.in
383 AS_UNSET([ml_norecursion])
f35db108
WM
384])
385
64548f3b 386if test "x$TSAN_SUPPORTED" = "xyes"; then
cd0be65c
WM
387 AC_CONFIG_FILES(AC_FOREACH([DIR], [tsan], [DIR/Makefile ]),
388 [cat > vpsed$$ << \_EOF
389s!`test -f '$<' || echo '$(srcdir)/'`!!
390_EOF
391 sed -f vpsed$$ $ac_file > tmp$$
392 mv tmp$$ $ac_file
393 rm vpsed$$
394 echo 'MULTISUBDIR =' >> $ac_file
395 ml_norecursion=yes
396 . ${multi_basedir}/config-ml.in
397 AS_UNSET([ml_norecursion])
398])
399fi
400
8a769f81
MM
401if test "x$HWASAN_SUPPORTED" = "xyes"; then
402 AC_CONFIG_FILES(AC_FOREACH([DIR], [hwasan], [DIR/Makefile ]),
403 [cat > vpsed$$ << \_EOF
404s!`test -f '$<' || echo '$(srcdir)/'`!!
405_EOF
406 sed -f vpsed$$ $ac_file > tmp$$
407 mv tmp$$ $ac_file
408 rm vpsed$$
409 echo 'MULTISUBDIR =' >> $ac_file
410 ml_norecursion=yes
411 . ${multi_basedir}/config-ml.in
412 AS_UNSET([ml_norecursion])
413])
414fi
415
b0edd457 416AC_SUBST([TSAN_TARGET_DEPENDENT_OBJECTS])
10189819 417AC_SUBST([SANITIZER_COMMON_TARGET_DEPENDENT_OBJECTS])
b0edd457 418
45ba6bf2
DS
419AC_ARG_ENABLE([werror],
420 [AS_HELP_STRING([--disable-werror], [disable building with -Werror])])
421
422ACX_PROG_CC_WARNING_OPTS([-Wextra -Wall -Wwrite-strings \
423 -Wmissing-format-attribute -Wcast-qual],
424 [WARN_FLAGS])
425AS_IF([test "x$enable_werror" != "xno"],
426 [WARN_FLAGS="$WARN_FLAGS -Werror"])
427AC_SUBST([WARN_FLAGS])
428
3c36aa6b
JJ
429# Determine what GCC version number to use in filesystem paths.
430GCC_BASE_VER
431
9069eb28
IT
432# Add CET specific flags if Intel CET is enabled.
433GCC_CET_FLAGS(CET_FLAGS)
e08835fd
YS
434
435# Always set -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 to sync with LLVM,
436# and keep struct *stat* have the same size.
437case "${host}" in
438 mips*-*) FILE64_FLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" ;;
439 *) FILE64_FLAGS="" ;;
440esac
441
442EXTRA_CFLAGS="$EXTRA_CFLAGS $CET_FLAGS $FILE64_FLAGS"
443EXTRA_CXXFLAGS="$EXTRA_CXXFLAGS $CET_FLAGS $FILE64_FLAGS"
9069eb28
IT
444EXTRA_ASFLAGS=$CET_FLAGS
445AC_SUBST(EXTRA_ASFLAGS)
446AC_SUBST(EXTRA_CFLAGS)
447AC_SUBST(EXTRA_CXXFLAGS)
448
f35db108 449AC_OUTPUT