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