2 ##------------------------------------------------------------##
4 # The multiple-architecture stuff in this file is pretty
5 # cryptic. Read docs/internals/multiple-architectures.txt
6 # for at least a partial explanation of what is going on.
8 ##------------------------------------------------------------##
10 # Process this file with autoconf to produce a configure script.
11 AC_INIT([Valgrind],[3.16.0.GIT],[valgrind-users@lists.sourceforge.net])
12 AC_CONFIG_SRCDIR(coregrind/m_main.c)
13 AC_CONFIG_HEADERS([config.h])
14 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
18 #----------------------------------------------------------------------------
19 # Do NOT modify these flags here. Except in feature tests in which case
20 # the original values must be properly restored.
21 #----------------------------------------------------------------------------
25 #----------------------------------------------------------------------------
26 # Checks for various programs.
27 #----------------------------------------------------------------------------
34 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
35 # autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
36 # base (eg. most likely as Darwin-specific tests) we'll need one of the
38 # - put AC_PROG_OBJC in a Darwin-specific part of this file
39 # - Use AC_PROG_OBJC here and up the minimum autoconf version
40 # - Use the following, which is apparently equivalent:
41 # m4_ifdef([AC_PROG_OBJC],
43 # [AC_CHECK_TOOL([OBJC], [gcc])
45 # AC_SUBST([OBJCFLAGS])
48 # Set LTO_RANLIB variable to an lto enabled ranlib
49 if test "x$LTO_RANLIB" = "x"; then
50 AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
52 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
54 # provide a very basic definition for AC_PROG_SED if it's not provided by
55 # autoconf (as e.g. in autoconf 2.59).
56 m4_ifndef([AC_PROG_SED],
57 [AC_DEFUN([AC_PROG_SED],
59 AC_CHECK_PROGS([SED],[gsed sed])])])
62 # If no AR variable was specified, look up the name of the archiver. Otherwise
63 # do not touch the AR variable.
64 if test "x$AR" = "x"; then
65 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
67 AC_ARG_VAR([AR],[Archiver command])
69 # same for LTO_AR variable for lto enabled archiver
70 if test "x$LTO_AR" = "x"; then
71 AC_PATH_PROGS([LTO_AR], [gcc-ar])
73 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
76 # Check for the compiler support
77 if test "${GCC}" != "yes" ; then
78 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
81 # figure out where perl lives
82 AC_PATH_PROG(PERL, perl)
84 # figure out where gdb lives
85 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
86 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
88 # some older automake's don't have it so try something on our own
89 ifdef([AM_PROG_AS],[AM_PROG_AS],
99 # Check if 'diff' supports -u (universal diffs) and use it if possible.
101 AC_MSG_CHECKING([for diff -u])
104 # Comparing two identical files results in 0.
105 tmpfile="tmp-xxx-yyy-zzz"
107 if diff -u $tmpfile $tmpfile ; then
116 # Make sure we can compile in C99 mode.
118 if test "$ac_cv_prog_cc_c99" == "no"; then
119 AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
122 # We don't want gcc < 3.0
123 AC_MSG_CHECKING([for a supported version of gcc])
125 # Obtain the compiler version.
127 # A few examples of how the ${CC} --version output looks like:
129 # ######## gcc variants ########
130 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
131 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
132 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
133 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
134 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
135 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
136 # OS/X 10.7: i686-apple-darwin11-llvm-gcc-4.2 (GCC) 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)
138 # ######## clang variants ########
139 # Clang: clang version 2.9 (tags/RELEASE_29/final)
140 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
141 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
143 # ######## Apple LLVM variants ########
144 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
145 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
148 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
151 gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
152 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
155 # Don't use -dumpversion with clang: it will always produce "4.2.1".
156 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
157 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ;
160 gcc_version=`${CC} -dumpversion 2>/dev/null`
163 gcc_version=`${CC} -dumpversion 2>/dev/null`
164 if test "x$gcc_version" = x; then
165 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
169 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
170 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
172 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
173 # statements have to be quoted.
174 case "${is_clang}-${gcc_version}" in
175 applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
176 AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
179 AC_MSG_RESULT([ok (ICC version ${gcc_version})])
181 notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
182 AC_MSG_RESULT([ok (${gcc_version})])
184 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
185 AC_MSG_RESULT([ok (clang-${gcc_version})])
188 AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
189 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
193 #----------------------------------------------------------------------------
194 # Arch/OS/platform tests.
195 #----------------------------------------------------------------------------
196 # We create a number of arch/OS/platform-related variables. We prefix them
197 # all with "VGCONF_" which indicates that they are defined at
198 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
199 # variables used when compiling C files.
203 AC_MSG_CHECKING([for a supported CPU])
205 # ARCH_MAX reflects the most that this CPU can do: for example if it
206 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
207 # Ditto for amd64. It is used for more configuration below, but is not used
210 # Power PC returns powerpc for Big Endian. This was not changed when Little
211 # Endian support was added to the 64-bit architecture. The 64-bit Little
212 # Endian systems explicitly state le in the host_cpu. For clarity in the
213 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
214 # the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
215 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
216 # Endianness. The name PPC64 or ppc64 to 64-bit systems of either Endianness.
217 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
218 # Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
221 case "${host_cpu}" in
223 AC_MSG_RESULT([ok (${host_cpu})])
228 AC_MSG_RESULT([ok (${host_cpu})])
233 # this only referrs to 64-bit Big Endian
234 AC_MSG_RESULT([ok (${host_cpu})])
239 # this only referrs to 64-bit Little Endian
240 AC_MSG_RESULT([ok (${host_cpu})])
245 # On Linux this means only a 32-bit capable CPU.
246 AC_MSG_RESULT([ok (${host_cpu})])
251 AC_MSG_RESULT([ok (${host_cpu})])
256 AC_MSG_RESULT([ok (${host_cpu})])
261 AC_MSG_RESULT([ok (${host_cpu})])
266 AC_MSG_RESULT([ok (${host_cpu})])
271 AC_MSG_RESULT([ok (${host_cpu})])
276 AC_MSG_RESULT([ok (${host_cpu})])
281 AC_MSG_RESULT([ok (${host_cpu})])
286 AC_MSG_RESULT([ok (${host_cpu})])
290 AC_MSG_RESULT([ok (${host_cpu})])
295 AC_MSG_RESULT([no (${host_cpu})])
296 AC_MSG_ERROR([Unsupported host architecture. Sorry])
300 #----------------------------------------------------------------------------
302 # Sometimes it's convenient to subvert the bi-arch build system and
303 # just have a single build even though the underlying platform is
304 # capable of both. Hence handle --enable-only64bit and
305 # --enable-only32bit. Complain if both are issued :-)
306 # [Actually, if either of these options are used, I think both get built,
307 # but only one gets installed. So if you use an in-place build, both can be
310 # Check if a 64-bit only build has been requested
311 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
312 [AC_ARG_ENABLE(only64bit,
313 [ --enable-only64bit do a 64-bit only build],
314 [vg_cv_only64bit=$enableval],
315 [vg_cv_only64bit=no])])
317 # Check if a 32-bit only build has been requested
318 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
319 [AC_ARG_ENABLE(only32bit,
320 [ --enable-only32bit do a 32-bit only build],
321 [vg_cv_only32bit=$enableval],
322 [vg_cv_only32bit=no])])
325 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
327 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
330 #----------------------------------------------------------------------------
332 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
333 # compilation of many C files via -VGO_$(VGCONF_OS) and
334 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
335 AC_MSG_CHECKING([for a supported OS])
342 AC_MSG_RESULT([ok (${host_os})])
345 # Ok, this is linux. Check the kernel version
346 AC_MSG_CHECKING([for the kernel version])
351 0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*)
352 AC_MSG_RESULT([unsupported (${kernel})])
353 AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
357 AC_MSG_RESULT([2.6 or later (${kernel})])
364 AC_MSG_RESULT([ok (${host_os})])
366 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
367 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
368 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
369 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
370 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
371 AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
372 AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
373 AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
374 AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
376 AC_MSG_CHECKING([for the kernel version])
379 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
380 # has only one relevant version, the OS version. The `uname` check
381 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
382 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
383 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
384 # and we don't know of an macros similar to __GLIBC__ to get that info.
386 # XXX: `uname -r` won't do the right thing for cross-compiles, but
387 # that's not a problem yet.
389 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
390 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
391 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
392 # time support for 10.5 (the 9.* pattern just below), I'll leave it
393 # in for now, just in case anybody wants to give it a try. But I'm
394 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
397 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
398 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
399 DEFAULT_SUPP="darwin9.supp ${DEFAULT_SUPP}"
400 DEFAULT_SUPP="darwin9-drd.supp ${DEFAULT_SUPP}"
403 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
404 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
405 DEFAULT_SUPP="darwin10.supp ${DEFAULT_SUPP}"
406 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
409 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
410 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
411 DEFAULT_SUPP="darwin11.supp ${DEFAULT_SUPP}"
412 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
415 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
416 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
417 DEFAULT_SUPP="darwin12.supp ${DEFAULT_SUPP}"
418 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
421 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
422 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
423 DEFAULT_SUPP="darwin13.supp ${DEFAULT_SUPP}"
424 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
427 AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
428 AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
429 DEFAULT_SUPP="darwin14.supp ${DEFAULT_SUPP}"
430 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
433 AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
434 AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
435 DEFAULT_SUPP="darwin15.supp ${DEFAULT_SUPP}"
436 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
439 AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
440 AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
441 DEFAULT_SUPP="darwin16.supp ${DEFAULT_SUPP}"
442 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
445 AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
446 AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
447 DEFAULT_SUPP="darwin17.supp ${DEFAULT_SUPP}"
448 DEFAULT_SUPP="darwin10-drd.supp ${DEFAULT_SUPP}"
451 AC_MSG_RESULT([unsupported (${kernel})])
452 AC_MSG_ERROR([Valgrind works on Darwin 10.x, 11.x, 12.x, 13.x, 14.x, 15.x, 16.x and 17.x (Mac OS X 10.6/7/8/9/10/11 and macOS 10.12/13)])
458 AC_MSG_RESULT([ok (${host_os})])
461 uname_v=$( uname -v )
464 DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
467 DEFAULT_SUPP="solaris11.supp ${DEFAULT_SUPP}"
473 AC_MSG_RESULT([ok (${host_os})])
475 DEFAULT_SUPP="solaris12.supp ${DEFAULT_SUPP}"
479 AC_MSG_RESULT([no (${host_os})])
480 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
484 #----------------------------------------------------------------------------
486 # If we are building on a 64 bit platform test to see if the system
487 # supports building 32 bit programs and disable 32 bit support if it
488 # does not support building 32 bit programs
490 case "$ARCH_MAX-$VGCONF_OS" in
491 amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
492 AC_MSG_CHECKING([for 32 bit build support])
495 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
500 vg_cv_only64bit="yes"
503 CFLAGS=$safe_CFLAGS;;
505 AC_MSG_CHECKING([for 32 bit build support])
507 CFLAGS="$CFLAGS -mips32 -mabi=32"
508 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
509 #include <sys/prctl.h>
513 vg_cv_only64bit="yes"
516 CFLAGS=$safe_CFLAGS;;
519 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
521 [--enable-only32bit was specified but system does not support 32 bit builds])
524 #----------------------------------------------------------------------------
526 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
527 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
528 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
529 # above) will be "amd64" since that reflects the most that this cpu can do,
530 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
531 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
532 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
533 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
534 AC_SUBST(VGCONF_ARCH_PRI)
536 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
537 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
538 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
539 # It is empty if there is no secondary target.
540 AC_SUBST(VGCONF_ARCH_SEC)
542 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
543 # The entire system, including regression and performance tests, will be
544 # built for this target. The "_CAPS" indicates that the name is in capital
545 # letters, and it also uses '_' rather than '-' as a separator, because it's
546 # used to create various Makefile variables, which are all in caps by
547 # convention and cannot contain '-' characters. This is in contrast to
548 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
549 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
551 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
552 # Valgrind and tools will also be built for this target, but not the
553 # regression or performance tests.
555 # By default, the primary arch is the same as the "max" arch, as commented
556 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
557 # the big case statement just below here, in the case where we're building
558 # on a 64 bit machine but have been requested only to do a 32 bit build.
559 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
561 AC_MSG_CHECKING([for a supported CPU/OS combination])
563 # NB. The load address for a given platform may be specified in more
564 # than one place, in some cases, depending on whether we're doing a biarch,
565 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
566 # Be careful to give consistent values in all subcases. Also, all four
567 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
568 # even if it is to "0xUNSET".
570 case "$ARCH_MAX-$VGCONF_OS" in
572 VGCONF_ARCH_PRI="x86"
574 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
575 VGCONF_PLATFORM_SEC_CAPS=""
576 valt_load_address_pri_norml="0x58000000"
577 valt_load_address_pri_inner="0x38000000"
578 valt_load_address_sec_norml="0xUNSET"
579 valt_load_address_sec_inner="0xUNSET"
580 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
583 valt_load_address_sec_norml="0xUNSET"
584 valt_load_address_sec_inner="0xUNSET"
585 if test x$vg_cv_only64bit = xyes; then
586 VGCONF_ARCH_PRI="amd64"
588 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
589 VGCONF_PLATFORM_SEC_CAPS=""
590 valt_load_address_pri_norml="0x58000000"
591 valt_load_address_pri_inner="0x38000000"
592 elif test x$vg_cv_only32bit = xyes; then
593 VGCONF_ARCH_PRI="x86"
595 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
596 VGCONF_PLATFORM_SEC_CAPS=""
597 valt_load_address_pri_norml="0x58000000"
598 valt_load_address_pri_inner="0x38000000"
600 VGCONF_ARCH_PRI="amd64"
601 VGCONF_ARCH_SEC="x86"
602 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
603 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
604 valt_load_address_pri_norml="0x58000000"
605 valt_load_address_pri_inner="0x38000000"
606 valt_load_address_sec_norml="0x58000000"
607 valt_load_address_sec_inner="0x38000000"
609 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
612 VGCONF_ARCH_PRI="ppc32"
614 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
615 VGCONF_PLATFORM_SEC_CAPS=""
616 valt_load_address_pri_norml="0x58000000"
617 valt_load_address_pri_inner="0x38000000"
618 valt_load_address_sec_norml="0xUNSET"
619 valt_load_address_sec_inner="0xUNSET"
620 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
623 valt_load_address_sec_norml="0xUNSET"
624 valt_load_address_sec_inner="0xUNSET"
625 if test x$vg_cv_only64bit = xyes; then
626 VGCONF_ARCH_PRI="ppc64be"
628 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
629 VGCONF_PLATFORM_SEC_CAPS=""
630 valt_load_address_pri_norml="0x58000000"
631 valt_load_address_pri_inner="0x38000000"
632 elif test x$vg_cv_only32bit = xyes; then
633 VGCONF_ARCH_PRI="ppc32"
635 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
636 VGCONF_PLATFORM_SEC_CAPS=""
637 valt_load_address_pri_norml="0x58000000"
638 valt_load_address_pri_inner="0x38000000"
640 VGCONF_ARCH_PRI="ppc64be"
641 VGCONF_ARCH_SEC="ppc32"
642 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
643 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
644 valt_load_address_pri_norml="0x58000000"
645 valt_load_address_pri_inner="0x38000000"
646 valt_load_address_sec_norml="0x58000000"
647 valt_load_address_sec_inner="0x38000000"
649 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
652 # Little Endian is only supported on PPC64
653 valt_load_address_sec_norml="0xUNSET"
654 valt_load_address_sec_inner="0xUNSET"
655 VGCONF_ARCH_PRI="ppc64le"
657 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
658 VGCONF_PLATFORM_SEC_CAPS=""
659 valt_load_address_pri_norml="0x58000000"
660 valt_load_address_pri_inner="0x38000000"
661 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
663 # Darwin gets identified as 32-bit even when it supports 64-bit.
664 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
665 # all Macs support both 32-bit and 64-bit, so we just build both. If
666 # someone has a really old 32-bit only machine they can (hopefully?)
667 # build with --enable-only32bit. See bug 243362.
668 x86-darwin|amd64-darwin)
670 valt_load_address_sec_norml="0xUNSET"
671 valt_load_address_sec_inner="0xUNSET"
672 if test x$vg_cv_only64bit = xyes; then
673 VGCONF_ARCH_PRI="amd64"
675 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
676 VGCONF_PLATFORM_SEC_CAPS=""
677 valt_load_address_pri_norml="0x158000000"
678 valt_load_address_pri_inner="0x138000000"
679 elif test x$vg_cv_only32bit = xyes; then
680 VGCONF_ARCH_PRI="x86"
682 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
683 VGCONF_PLATFORM_SEC_CAPS=""
684 VGCONF_ARCH_PRI_CAPS="x86"
685 valt_load_address_pri_norml="0x58000000"
686 valt_load_address_pri_inner="0x38000000"
688 VGCONF_ARCH_PRI="amd64"
689 VGCONF_ARCH_SEC="x86"
690 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
691 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
692 valt_load_address_pri_norml="0x158000000"
693 valt_load_address_pri_inner="0x138000000"
694 valt_load_address_sec_norml="0x58000000"
695 valt_load_address_sec_inner="0x38000000"
697 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
700 VGCONF_ARCH_PRI="arm"
701 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
702 VGCONF_PLATFORM_SEC_CAPS=""
703 valt_load_address_pri_norml="0x58000000"
704 valt_load_address_pri_inner="0x38000000"
705 valt_load_address_sec_norml="0xUNSET"
706 valt_load_address_sec_inner="0xUNSET"
707 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
710 valt_load_address_sec_norml="0xUNSET"
711 valt_load_address_sec_inner="0xUNSET"
712 if test x$vg_cv_only64bit = xyes; then
713 VGCONF_ARCH_PRI="arm64"
715 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
716 VGCONF_PLATFORM_SEC_CAPS=""
717 valt_load_address_pri_norml="0x58000000"
718 valt_load_address_pri_inner="0x38000000"
719 elif test x$vg_cv_only32bit = xyes; then
720 VGCONF_ARCH_PRI="arm"
722 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
723 VGCONF_PLATFORM_SEC_CAPS=""
724 valt_load_address_pri_norml="0x58000000"
725 valt_load_address_pri_inner="0x38000000"
727 VGCONF_ARCH_PRI="arm64"
728 VGCONF_ARCH_SEC="arm"
729 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
730 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
731 valt_load_address_pri_norml="0x58000000"
732 valt_load_address_pri_inner="0x38000000"
733 valt_load_address_sec_norml="0x58000000"
734 valt_load_address_sec_inner="0x38000000"
736 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
739 VGCONF_ARCH_PRI="s390x"
741 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
742 VGCONF_PLATFORM_SEC_CAPS=""
743 # To improve branch prediction hit rate we want to have
744 # the generated code close to valgrind (host) code
745 valt_load_address_pri_norml="0x800000000"
746 valt_load_address_pri_inner="0x810000000"
747 valt_load_address_sec_norml="0xUNSET"
748 valt_load_address_sec_inner="0xUNSET"
749 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
752 VGCONF_ARCH_PRI="mips32"
754 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
755 VGCONF_PLATFORM_SEC_CAPS=""
756 valt_load_address_pri_norml="0x58000000"
757 valt_load_address_pri_inner="0x38000000"
758 valt_load_address_sec_norml="0xUNSET"
759 valt_load_address_sec_inner="0xUNSET"
760 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
763 valt_load_address_sec_norml="0xUNSET"
764 valt_load_address_sec_inner="0xUNSET"
765 if test x$vg_cv_only64bit = xyes; then
766 VGCONF_ARCH_PRI="mips64"
767 VGCONF_PLATFORM_SEC_CAPS=""
768 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
769 VGCONF_PLATFORM_SEC_CAPS=""
770 valt_load_address_pri_norml="0x58000000"
771 valt_load_address_pri_inner="0x38000000"
772 elif test x$vg_cv_only32bit = xyes; then
773 VGCONF_ARCH_PRI="mips32"
775 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
776 VGCONF_PLATFORM_SEC_CAPS=""
777 valt_load_address_pri_norml="0x58000000"
778 valt_load_address_pri_inner="0x38000000"
780 VGCONF_ARCH_PRI="mips64"
781 VGCONF_ARCH_SEC="mips32"
782 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
783 VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
784 valt_load_address_pri_norml="0x58000000"
785 valt_load_address_pri_inner="0x38000000"
786 valt_load_address_sec_norml="0x58000000"
787 valt_load_address_sec_inner="0x38000000"
789 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
792 VGCONF_ARCH_PRI="nanomips"
794 VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
795 VGCONF_PLATFORM_SEC_CAPS=""
796 valt_load_address_pri_norml="0x58000000"
797 valt_load_address_pri_inner="0x38000000"
798 valt_load_address_sec_norml="0xUNSET"
799 valt_load_address_sec_inner="0xUNSET"
800 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
803 VGCONF_ARCH_PRI="x86"
805 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
806 VGCONF_PLATFORM_SEC_CAPS=""
807 valt_load_address_pri_norml="0x58000000"
808 valt_load_address_pri_inner="0x38000000"
809 valt_load_address_sec_norml="0xUNSET"
810 valt_load_address_sec_inner="0xUNSET"
811 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
814 valt_load_address_sec_norml="0xUNSET"
815 valt_load_address_sec_inner="0xUNSET"
816 if test x$vg_cv_only64bit = xyes; then
817 VGCONF_ARCH_PRI="amd64"
819 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
820 VGCONF_PLATFORM_SEC_CAPS=""
821 valt_load_address_pri_norml="0x58000000"
822 valt_load_address_pri_inner="0x38000000"
823 elif test x$vg_cv_only32bit = xyes; then
824 VGCONF_ARCH_PRI="x86"
826 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
827 VGCONF_PLATFORM_SEC_CAPS=""
828 valt_load_address_pri_norml="0x58000000"
829 valt_load_address_pri_inner="0x38000000"
831 VGCONF_ARCH_PRI="amd64"
832 VGCONF_ARCH_SEC="x86"
833 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
834 VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
835 valt_load_address_pri_norml="0x58000000"
836 valt_load_address_pri_inner="0x38000000"
837 valt_load_address_sec_norml="0x58000000"
838 valt_load_address_sec_inner="0x38000000"
840 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
843 VGCONF_ARCH_PRI="unknown"
844 VGCONF_ARCH_SEC="unknown"
845 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
846 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
847 valt_load_address_pri_norml="0xUNSET"
848 valt_load_address_pri_inner="0xUNSET"
849 valt_load_address_sec_norml="0xUNSET"
850 valt_load_address_sec_inner="0xUNSET"
851 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
852 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
856 #----------------------------------------------------------------------------
858 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
860 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
861 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
862 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
863 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
864 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
865 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
866 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
867 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
868 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
869 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
870 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
871 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
872 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
873 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
874 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
875 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
876 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
877 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
878 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
879 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
880 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
881 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
882 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
883 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
884 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
885 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
886 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
887 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
888 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
889 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
890 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
892 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
894 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
895 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
896 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
897 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
898 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
899 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
900 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
901 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
902 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
903 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
904 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
905 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
906 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
907 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
908 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
909 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
910 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
911 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
912 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
913 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
914 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
915 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
916 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
917 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
918 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
919 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
920 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
921 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
922 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
923 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
924 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
925 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
926 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
927 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
928 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
929 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
930 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
933 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
934 # Relies on the assumption that the primary and secondary targets are
935 # for the same OS, so therefore only necessary to test the primary.
936 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
937 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
938 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
939 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
940 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
941 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
942 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
943 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
944 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
945 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
946 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
947 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
948 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
949 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
950 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
951 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
952 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
953 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
956 # Sometimes, in the Makefile.am files, it's useful to know whether or not
957 # there is a secondary target.
958 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
959 test x$VGCONF_PLATFORM_SEC_CAPS != x)
961 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
962 dnl fallback definition
963 dnl The macro is courtesy of Dave Hart:
964 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
965 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
966 if test -z "$$1_TRUE"; then :
975 #----------------------------------------------------------------------------
977 #----------------------------------------------------------------------------
979 # Check if this should be built as an inner Valgrind, to be run within
980 # another Valgrind. Choose the load address accordingly.
981 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
982 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
983 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
984 [AC_ARG_ENABLE(inner,
985 [ --enable-inner enables self-hosting],
986 [vg_cv_inner=$enableval],
988 if test "$vg_cv_inner" = yes; then
989 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
990 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
991 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
993 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
994 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
997 #----------------------------------------------------------------------------
998 # Undefined behaviour sanitiser
999 #----------------------------------------------------------------------------
1000 # Check whether we should build with the undefined beahviour sanitiser.
1002 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1003 [AC_ARG_ENABLE(ubsan,
1004 [ --enable-ubsan enables the undefined behaviour sanitiser],
1005 [vg_cv_ubsan=$enableval],
1008 #----------------------------------------------------------------------------
1009 # Extra fine-tuning of installation directories
1010 #----------------------------------------------------------------------------
1012 [ --with-tmpdir=PATH Specify path for temporary files],
1015 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1016 AC_SUBST(VG_TMPDIR, [$tmpdir])
1018 #----------------------------------------------------------------------------
1020 #----------------------------------------------------------------------------
1021 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1022 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1023 AC_MSG_CHECKING([for xcode sdk include path])
1024 AC_ARG_WITH(xcodedir,
1025 [ --with-xcode-path=PATH Specify path for xcode sdk includes],
1026 [xcodedir="$withval"],
1028 if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1029 xcrundir=`xcrun --sdk macosx --show-sdk-path`
1030 if test -z "$xcrundir"; then
1031 xcodedir="/usr/include"
1033 xcodedir="$xcrundir/usr/include"
1036 xcodedir="/usr/include"
1039 AC_MSG_RESULT([$xcodedir])
1040 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1041 AC_SUBST(XCODE_DIR, [$xcodedir])])
1043 #----------------------------------------------------------------------------
1044 # Libc and suppressions
1045 #----------------------------------------------------------------------------
1046 # This variable will collect the suppression files to be used.
1047 AC_SUBST(DEFAULT_SUPP)
1049 AC_CHECK_HEADER([features.h])
1051 if test x$ac_cv_header_features_h = xyes; then
1052 rm -f conftest.$ac_ext
1053 cat <<_ACEOF >conftest.$ac_ext
1054 #include <features.h>
1055 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1056 glibc version is: __GLIBC__ __GLIBC_MINOR__
1059 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1062 # not really a version check
1063 AC_EGREP_CPP([DARWIN_LIBC], [
1064 #include <sys/cdefs.h>
1065 #if defined(__DARWIN_VERS_1050)
1069 GLIBC_VERSION="darwin")
1071 # not really a version check
1072 AC_EGREP_CPP([BIONIC_LIBC], [
1073 #if defined(__ANDROID__)
1077 GLIBC_VERSION="bionic")
1079 # there is only one version of libc on Solaris
1080 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1081 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1082 GLIBC_VERSION="solaris"
1085 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1087 if test x$GLIBC_VERSION = x; then
1088 if $CC -dumpmachine | grep -q musl; then
1093 AC_MSG_CHECKING([the glibc version])
1095 case "${GLIBC_VERSION}" in
1097 AC_MSG_RESULT(${GLIBC_VERSION} family)
1098 DEFAULT_SUPP="glibc-2.2.supp ${DEFAULT_SUPP}"
1099 DEFAULT_SUPP="glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1100 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1103 AC_MSG_RESULT(${GLIBC_VERSION} family)
1104 DEFAULT_SUPP="glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1105 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1106 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1109 AC_MSG_RESULT(${GLIBC_VERSION} family)
1110 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1111 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1112 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1115 AC_MSG_RESULT(${GLIBC_VERSION} family)
1116 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1117 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1118 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1119 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1120 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1123 AC_MSG_RESULT(${GLIBC_VERSION} family)
1124 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1125 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1126 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1127 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1128 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1129 DEFAULT_SUPP="glibc-2.34567-NPTL-helgrind.supp ${DEFAULT_SUPP}"
1130 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1133 AC_MSG_RESULT(Darwin)
1134 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1135 # DEFAULT_SUPP set by kernel version check above.
1138 AC_MSG_RESULT(Bionic)
1139 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1140 DEFAULT_SUPP="bionic.supp ${DEFAULT_SUPP}"
1143 AC_MSG_RESULT(Solaris)
1144 # DEFAULT_SUPP set in host_os switch-case above.
1145 # No other suppression file is used.
1149 AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1150 # no DEFAULT_SUPP file yet for musl libc.
1153 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1154 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1155 AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1159 AC_SUBST(GLIBC_VERSION)
1162 if test "$VGCONF_OS" != "solaris"; then
1163 # Add default suppressions for the X client libraries. Make no
1164 # attempt to detect whether such libraries are installed on the
1165 # build machine (or even if any X facilities are present); just
1166 # add the suppressions antidisirregardless.
1167 DEFAULT_SUPP="xfree-4.supp ${DEFAULT_SUPP}"
1168 DEFAULT_SUPP="xfree-3.supp ${DEFAULT_SUPP}"
1170 # Add glibc and X11 suppressions for exp-sgcheck
1171 DEFAULT_SUPP="exp-sgcheck.supp ${DEFAULT_SUPP}"
1175 #----------------------------------------------------------------------------
1176 # Platform variants?
1177 #----------------------------------------------------------------------------
1179 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1180 # But there are times where we need a bit more control. The motivating
1181 # and currently only case is Android: this is almost identical to
1182 # {x86,arm,mips}-linux, but not quite. So this introduces the concept of
1183 # platform variant tags, which get passed in the compile as
1184 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1186 # In almost all cases, the <variant> bit is "vanilla". But for Android
1187 # it is "android" instead.
1189 # Consequently (eg), plain arm-linux would build with
1191 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1193 # whilst an Android build would have
1195 # -DVGP_arm_linux -DVGPV_arm_linux_android
1197 # Same for x86. The setup of the platform variant is pushed relatively far
1198 # down this file in order that we can inspect any of the variables set above.
1200 # In the normal case ..
1201 VGCONF_PLATVARIANT="vanilla"
1204 if test "$GLIBC_VERSION" = "bionic";
1206 VGCONF_PLATVARIANT="android"
1209 AC_SUBST(VGCONF_PLATVARIANT)
1212 # FIXME: do we also want to define automake variables
1213 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1214 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1215 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1216 # do that. Problem is that we can't do and-ing in Makefile.am's, but
1217 # that's what we'd need to do to use this, since what we'd want to write
1220 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1222 # Hmm. Can't think of a nice clean solution to this.
1224 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1225 test x$VGCONF_PLATVARIANT = xvanilla)
1226 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1227 test x$VGCONF_PLATVARIANT = xandroid)
1230 #----------------------------------------------------------------------------
1231 # Checking for various library functions and other definitions
1232 #----------------------------------------------------------------------------
1234 # Check for AT_FDCWD
1236 AC_MSG_CHECKING([for AT_FDCWD])
1237 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1244 ac_have_at_fdcwd=yes
1245 AC_MSG_RESULT([yes])
1251 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1253 # Check for stpncpy function definition in string.h
1254 # This explicitly checks with _GNU_SOURCE defined since that is also
1255 # used in the test case (some systems might define it without anyway
1256 # since stpncpy is part of The Open Group Base Specifications Issue 7
1257 # IEEE Std 1003.1-2008.
1258 AC_MSG_CHECKING([for stpncpy])
1259 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1266 char *r = stpncpy(d, s, n);
1268 ac_have_gnu_stpncpy=yes
1269 AC_MSG_RESULT([yes])
1271 ac_have_gnu_stpncpy=no
1275 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1277 # Check for PTRACE_GETREGS
1279 AC_MSG_CHECKING([for PTRACE_GETREGS])
1280 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1283 #include <sys/ptrace.h>
1284 #include <sys/user.h>
1287 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1289 AC_MSG_RESULT([yes])
1290 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1291 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1297 # Check for CLOCK_MONOTONIC
1299 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1301 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1305 clock_gettime(CLOCK_MONOTONIC, &t);
1308 AC_MSG_RESULT([yes])
1309 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1310 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1316 # Check for ELF32/64_CHDR
1318 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1321 # Check for PTHREAD_RWLOCK_T
1323 AC_MSG_CHECKING([for pthread_rwlock_t])
1325 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1327 #include <pthread.h>
1329 pthread_rwlock_t rwl;
1331 AC_MSG_RESULT([yes])
1332 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1333 [Define to 1 if you have the `pthread_rwlock_t' type.])
1339 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1341 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1343 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1345 #include <pthread.h>
1347 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1349 AC_MSG_RESULT([yes])
1350 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1351 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1357 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1359 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1361 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1363 #include <pthread.h>
1365 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1367 AC_MSG_RESULT([yes])
1368 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1369 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1375 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1377 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1379 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1381 #include <pthread.h>
1383 return (PTHREAD_MUTEX_RECURSIVE_NP);
1385 AC_MSG_RESULT([yes])
1386 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1387 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1393 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1395 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1397 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1399 #include <pthread.h>
1401 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1404 AC_MSG_RESULT([yes])
1405 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1406 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1412 # Check whether pthread_mutex_t has a member called __m_kind.
1414 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1415 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1417 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1420 [#include <pthread.h>])
1423 # Check whether pthread_mutex_t has a member called __data.__kind.
1425 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1426 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1428 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1431 [#include <pthread.h>])
1433 # Convenience function. Set flags based on the existing HWCAP entries.
1434 # The AT_HWCAP entries are generated by glibc, and are based on
1435 # functions supported by the hardware/system/libc.
1436 # Subsequent support for whether the capability will actually be utilized
1437 # will also be checked against the compiler capabilities.
1439 # AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1440 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1442 AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1443 if LD_SHOW_AUXV=1 `which true` | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1445 AC_MSG_RESULT([yes])
1446 AC_SUBST([$2],[yes])
1453 # gather hardware capabilities. (hardware/kernel/libc)
1454 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1455 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1456 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1457 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1458 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1459 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1460 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1461 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1464 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1465 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1466 # compiler support for isa 2.07 level instructions
1467 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1468 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1470 __asm__ __volatile__("mtvsrd 1,2 ");
1472 ac_asm_have_isa_2_07=yes
1473 AC_MSG_RESULT([yes])
1475 ac_asm_have_isa_2_07=no
1478 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1479 -a x$HWCAP_HAS_ISA_2_07 = xyes])
1481 # altivec (vsx) support.
1482 # does this compiler support -maltivec and does it have the include file
1484 AC_MSG_CHECKING([for Altivec support in the compiler ])
1486 CFLAGS="-maltivec -Werror"
1487 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1488 #include <altivec.h>
1490 vector unsigned int v;
1493 AC_MSG_RESULT([yes])
1499 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1500 -a x$HWCAP_HAS_ALTIVEC = xyes])
1502 # Check that both: the compiler supports -mvsx and that the assembler
1503 # understands VSX instructions. If either of those doesn't work,
1504 # conclude that we can't do VSX.
1505 AC_MSG_CHECKING([for VSX compiler flag support])
1507 CFLAGS="-mvsx -Werror"
1508 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1511 ac_compiler_supports_vsx_flag=yes
1512 AC_MSG_RESULT([yes])
1514 ac_compiler_supports_vsx_flag=no
1519 AC_MSG_CHECKING([for VSX support in the assembler ])
1521 CFLAGS="-mvsx -Werror"
1522 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1523 #include <altivec.h>
1525 vector unsigned int v;
1526 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1528 ac_compiler_supports_vsx=yes
1529 AC_MSG_RESULT([yes])
1531 ac_compiler_supports_vsx=no
1535 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1536 -a x$ac_compiler_supports_vsx = xyes \
1537 -a x$HWCAP_HAS_VSX = xyes ])
1539 # DFP (Decimal Float)
1540 AC_MSG_CHECKING([that assembler knows DFP])
1541 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1544 __asm__ __volatile__("adtr 1, 2, 3")
1546 __asm__ __volatile__("dadd 1, 2, 3");
1547 __asm__ __volatile__("dcffix 1, 2");
1551 AC_MSG_RESULT([yes])
1556 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1558 CFLAGS="-mhard-dfp -Werror"
1559 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1562 __asm__ __volatile__("adtr 1, 2, 3")
1564 __asm__ __volatile__("dadd 1, 2, 3");
1565 __asm__ __volatile__("dcffix 1, 2");
1568 ac_compiler_have_dfp=yes
1569 AC_MSG_RESULT([yes])
1571 ac_compiler_have_dfp=no
1575 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1576 -a x$ac_compiler_have_dfp = xyes \
1577 -a x$HWCAP_HAS_DFP = xyes )
1579 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1580 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1582 _Decimal64 x = 0.0DD;
1584 ac_compiler_have_dfp_type=yes
1585 AC_MSG_RESULT([yes])
1587 ac_compiler_have_dfp_type=no
1590 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1591 -a x$HWCAP_HAS_DFP = xyes )
1594 # HTM (Hardware Transactional Memory)
1595 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1597 CFLAGS="-mhtm -Werror"
1598 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1602 AC_MSG_RESULT([yes])
1603 ac_compiler_supports_htm=yes
1606 ac_compiler_supports_htm=no
1610 AC_MSG_CHECKING([if compiler can find the htm builtins])
1612 CFLAGS="-mhtm -Werror"
1613 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1615 if (__builtin_tbegin (0))
1618 AC_MSG_RESULT([yes])
1619 ac_compiler_sees_htm_builtins=yes
1622 ac_compiler_sees_htm_builtins=no
1626 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1627 -a x$ac_compiler_sees_htm_builtins = xyes \
1628 -a x$HWCAP_HAS_HTM = xyes )
1631 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1633 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1635 __asm__ __volatile__("cnttzw 1,2 ");
1637 ac_asm_have_isa_3_00=yes
1638 AC_MSG_RESULT([yes])
1640 ac_asm_have_isa_3_00=no
1644 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1645 -a x$HWCAP_HAS_ISA_3_00 = xyes])
1647 # Check for pthread_create@GLIBC2.0
1648 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1651 CFLAGS="-lpthread -Werror"
1652 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1653 extern int pthread_create_glibc_2_0(void*, const void*,
1654 void *(*)(void*), void*);
1655 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1659 * Apparently on PowerPC linking this program succeeds and generates an
1660 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1662 #error This test does not work properly on PowerPC.
1664 pthread_create_glibc_2_0(0, 0, 0, 0);
1668 ac_have_pthread_create_glibc_2_0=yes
1669 AC_MSG_RESULT([yes])
1670 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1671 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1673 ac_have_pthread_create_glibc_2_0=no
1678 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1679 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1682 # Check for dlinfo RTLD_DI_TLS_MODID
1683 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1687 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1694 size_t sizes[10000];
1695 size_t modid_offset;
1696 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1699 ac_have_dlinfo_rtld_di_tls_modid=yes
1700 AC_MSG_RESULT([yes])
1701 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1702 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1704 ac_have_dlinfo_rtld_di_tls_modid=no
1709 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1710 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1713 # Check for eventfd_t, eventfd() and eventfd_read()
1714 AC_MSG_CHECKING([for eventfd()])
1716 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1717 #include <sys/eventfd.h>
1723 eventfd_read(fd, &ev);
1726 AC_MSG_RESULT([yes])
1727 AC_DEFINE([HAVE_EVENTFD], 1,
1728 [Define to 1 if you have the `eventfd' function.])
1729 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1730 [Define to 1 if you have the `eventfd_read' function.])
1735 # Check whether compiler can process #include <thread> without errors
1736 # clang 3.3 cannot process <thread> from e.g.
1737 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1739 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1741 safe_CXXFLAGS=$CXXFLAGS
1744 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
1748 ac_cxx_can_include_thread_header=yes
1749 AC_MSG_RESULT([yes])
1751 ac_cxx_can_include_thread_header=no
1754 CXXFLAGS=$safe_CXXFLAGS
1757 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
1760 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
1761 # of the user_regs_struct from sys/user.h. They are structurally the same
1762 # but we get either one or the other.
1764 AC_CHECK_TYPE([struct user_regs_struct],
1765 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
1766 [[#include <sys/ptrace.h>]
1767 [#include <sys/time.h>]
1768 [#include <sys/user.h>]])
1769 if test "$sys_user_has_user_regs" = "yes"; then
1770 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
1771 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
1774 AC_MSG_CHECKING([for __NR_membarrier])
1775 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1776 #include <linux/unistd.h>
1778 return __NR_membarrier
1780 ac_have_nr_membarrier=yes
1781 AC_MSG_RESULT([yes])
1783 ac_have_nr_membarrier=no
1787 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
1789 #----------------------------------------------------------------------------
1790 # Checking for supported compiler flags.
1791 #----------------------------------------------------------------------------
1793 case "${host_cpu}" in
1795 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1796 if test -z "$ARCH"; then
1797 # does this compiler support -march=mips32 (mips32 default) ?
1798 AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
1801 CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
1803 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1806 FLAG_M32="-mips32 -mabi=32"
1807 AC_MSG_RESULT([yes])
1817 # does this compiler support -march=mips64r2 (mips64r2 default) ?
1818 AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
1821 CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
1823 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1826 FLAG_M64="-march=mips64r2 -mabi=64"
1827 AC_MSG_RESULT([yes])
1840 # does this compiler support -m32 ?
1841 AC_MSG_CHECKING([if gcc accepts -m32])
1844 CFLAGS="-m32 -Werror"
1846 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1850 AC_MSG_RESULT([yes])
1860 # does this compiler support -m64 ?
1861 AC_MSG_CHECKING([if gcc accepts -m64])
1864 CFLAGS="-m64 -Werror"
1866 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1870 AC_MSG_RESULT([yes])
1882 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
1883 if test -z "$ARCH"; then
1884 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
1885 AC_MSG_CHECKING([if gcc accepts -march=octeon])
1888 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
1890 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1893 FLAG_OCTEON="-march=octeon"
1894 AC_MSG_RESULT([yes])
1901 AC_SUBST(FLAG_OCTEON)
1904 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
1905 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
1908 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
1910 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1913 FLAG_OCTEON2="-march=octeon2"
1914 AC_MSG_RESULT([yes])
1921 AC_SUBST(FLAG_OCTEON2)
1925 # does this compiler support -mmsa (MIPS MSA ASE) ?
1926 AC_MSG_CHECKING([if gcc accepts -mmsa])
1929 CFLAGS="$CFLAGS -mmsa -Werror"
1931 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
1935 AC_MSG_RESULT([yes])
1944 # Are we compiling for the MIPS64 n32 ABI?
1945 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
1946 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1947 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
1952 FLAG_M64="-march=mips64r2 -mabi=n32"
1953 AC_MSG_RESULT([yes])
1958 # Are we compiling for the MIPS64 n64 ABI?
1959 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
1960 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
1961 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
1966 AC_MSG_RESULT([yes])
1971 # We enter the code block below in the following case:
1972 # Target architecture is set to mips64, the desired abi
1973 # was not specified and the compiler's default abi setting
1974 # is neither n32 nor n64.
1975 # Probe for and set the abi to either n64 or n32, in that order,
1976 # which is required for a mips64 build of valgrind.
1977 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
1979 CFLAGS="$CFLAGS -mabi=64 -Werror"
1980 AC_MSG_CHECKING([if gcc is n64 capable])
1981 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
1985 AC_MSG_RESULT([yes])
1991 if test "x$VGCONF_ABI" = "x"; then
1993 CFLAGS="$CFLAGS -mabi=n32 -Werror"
1994 AC_MSG_CHECKING([if gcc is n32 capable])
1995 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
1999 FLAG_M64="-march=mips64r2 -mabi=n32"
2000 AC_MSG_RESULT([yes])
2008 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2009 [test x$VGCONF_ABI != x])
2010 AC_SUBST(VGCONF_ABI)
2013 # does this compiler support -mmmx ?
2014 AC_MSG_CHECKING([if gcc accepts -mmmx])
2017 CFLAGS="-mmmx -Werror"
2019 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2023 AC_MSG_RESULT([yes])
2033 # does this compiler support -msse ?
2034 AC_MSG_CHECKING([if gcc accepts -msse])
2037 CFLAGS="-msse -Werror"
2039 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2043 AC_MSG_RESULT([yes])
2053 # does this compiler support -mpreferred-stack-boundary=2 when
2054 # generating code for a 32-bit target? Note that we only care about
2055 # this when generating code for (32-bit) x86, so if the compiler
2056 # doesn't recognise -m32 it's no big deal. We'll just get code for
2057 # the Memcheck and other helper functions, that is a bit slower than
2058 # it could be, on x86; and no difference at all on any other platform.
2059 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2062 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2064 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2067 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2068 AC_MSG_RESULT([yes])
2070 PREFERRED_STACK_BOUNDARY_2=""
2075 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2078 # does this compiler support -mlong-double-128 ?
2079 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2081 CFLAGS="-mlong-double-128 -Werror"
2082 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2085 ac_compiler_supports_mlong_double_128=yes
2086 AC_MSG_RESULT([yes])
2088 ac_compiler_supports_mlong_double_128=no
2092 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2093 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2094 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2096 # does this toolchain support lto ?
2097 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2099 # If not enable-lto=* arg is provided, default to no, as lto builds are
2100 # a lot slower, and so not appropriate for Valgrind developments.
2101 # --enable-lto=yes should be used by distro packagers.
2102 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2104 [ --enable-lto enables building with link time optimisation],
2105 [vg_cv_lto=$enableval],
2108 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2109 AC_MSG_CHECKING([if toolchain accepts lto])
2111 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2112 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2113 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2114 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2116 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2117 extern void somefun(void);
2121 LTO_CFLAGS=$TEST_LTO_CFLAGS
2122 AC_MSG_RESULT([yes])
2130 AC_SUBST(LTO_CFLAGS)
2132 # if we could not compile with lto args, or lto was disabled,
2133 # then set LTO_AR/LTO_RANLIB to the non lto values
2134 # define in config.h ENABLE_LTO (not needed by the code currently, but
2135 # this guarantees we recompile everything if we re-configure and rebuild
2136 # in a build dir previously build with another value of --enable-lto
2137 if test "x${LTO_CFLAGS}" = "x"; then
2139 LTO_RANLIB=${RANLIB}
2143 AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2146 # Convenience function to check whether GCC supports a particular
2147 # warning option. Takes two arguments,
2148 # first the warning flag name to check (without -W), then the
2149 # substitution name to set with -Wno-warning-flag if the flag exists,
2150 # or the empty string if the compiler doesn't accept the flag. Note
2151 # that checking is done against the warning flag itself, but the
2152 # substitution is then done to cancel the warning flag.
2153 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2154 AC_MSG_CHECKING([if gcc accepts -W$1])
2156 CFLAGS="-W$1 -Werror"
2157 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2158 AC_SUBST([$2], [-Wno-$1])
2159 AC_MSG_RESULT([yes])], [
2161 AC_MSG_RESULT([no])])
2165 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2166 # -W$1 (instead of -Wno-$1).
2167 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2168 AC_MSG_CHECKING([if gcc accepts -W$1])
2170 CFLAGS="-W$1 -Werror"
2171 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2172 AC_SUBST([$2], [-W$1])
2173 AC_MSG_RESULT([yes])], [
2175 AC_MSG_RESULT([no])])
2179 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2180 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2181 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2182 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2183 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2184 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2185 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2186 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2187 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2189 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2190 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2191 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2192 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2193 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2194 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2195 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2196 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2197 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2198 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2199 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2201 # Does this compiler support -Wformat-security ?
2202 # Special handling is needed, because certain GCC versions require -Wformat
2203 # being present if -Wformat-security is given. Otherwise a warning is issued.
2204 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2205 # And with that the warning will be turned into an error with the result
2206 # that -Wformat-security is believed to be unsupported when in fact it is.
2207 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2209 CFLAGS="-Wformat -Wformat-security -Werror"
2210 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2211 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2212 AC_MSG_RESULT([yes])], [
2213 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2214 AC_MSG_RESULT([no])])
2217 # does this compiler support -Wextra or the older -W ?
2219 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2222 CFLAGS="-Wextra -Werror"
2224 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2227 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2228 AC_MSG_RESULT([-Wextra])
2231 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2234 AC_SUBST([FLAG_W_EXTRA], [-W])
2237 AC_SUBST([FLAG_W_EXTRA], [])
2238 AC_MSG_RESULT([not supported])
2243 # On ARM we do not want to pass -Wcast-align as that produces loads
2244 # of warnings. GCC is just being conservative. See here:
2245 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2246 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2247 AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2249 AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2252 # does this compiler support -faligned-new ?
2253 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2255 safe_CXXFLAGS=$CXXFLAGS
2256 CXXFLAGS="-faligned-new -Werror"
2259 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2262 FLAG_FALIGNED_NEW="-faligned-new"
2263 AC_MSG_RESULT([yes])
2265 FLAG_FALIGNED_NEW=""
2268 CXXFLAGS=$safe_CXXFLAGS
2271 AC_SUBST(FLAG_FALIGNED_NEW)
2273 # does this compiler support -fno-stack-protector ?
2274 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2277 CFLAGS="-fno-stack-protector -Werror"
2279 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2282 no_stack_protector=yes
2283 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2284 AC_MSG_RESULT([yes])
2286 no_stack_protector=no
2287 FLAG_FNO_STACK_PROTECTOR=""
2292 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2294 # does this compiler support -finline-functions ?
2295 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2298 CFLAGS="-finline-functions -Werror"
2300 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2303 inline_functions=yes
2304 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2305 AC_MSG_RESULT([yes])
2308 FLAG_FINLINE_FUNCTIONS=""
2313 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2315 # Does GCC support disabling Identical Code Folding?
2316 # We want to disabled Identical Code Folding for the
2317 # tools preload shared objects to get better backraces.
2318 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2319 # "The optimization reduces code size and may disturb
2320 # unwind stacks by replacing a function by equivalent
2321 # one with a different name."
2322 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2325 CFLAGS="-fno-ipa-icf -Werror"
2327 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2331 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2332 AC_MSG_RESULT([yes])
2340 AC_SUBST(FLAG_FNO_IPA_ICF)
2343 # Does this compiler support -fsanitize=undefined. This is true for
2344 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2345 # also checks for alignment violations on memory accesses which the valgrind
2346 # code base is sprinkled (if not littered) with. As those alignment issues
2347 # don't pose a problem we want to suppress warnings about them.
2348 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2349 # GCCs do not support that.
2351 # Only checked for if --enable-ubsan was given.
2352 if test "x${vg_cv_ubsan}" = "xyes"; then
2353 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2355 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2356 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2359 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2360 LIB_UBSAN="-static-libubsan"
2361 AC_MSG_RESULT([yes])
2363 CFLAGS="-fsanitize=undefined -Werror"
2364 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2367 FLAG_FSANITIZE="-fsanitize=undefined"
2368 LIB_UBSAN="-static-libubsan"
2369 AC_MSG_RESULT([yes])
2377 AC_SUBST(FLAG_FSANITIZE)
2380 # does this compiler support --param inline-unit-growth=... ?
2382 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2385 CFLAGS="--param inline-unit-growth=900 -Werror"
2387 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2390 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2391 ["--param inline-unit-growth=900"])
2392 AC_MSG_RESULT([yes])
2394 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2400 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2402 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2405 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2407 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2411 AC_MSG_RESULT([yes])
2416 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2420 # does this compiler support -g -gz=zlib ?
2422 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2425 CFLAGS="-g -gz=zlib"
2427 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2431 AC_MSG_RESULT([yes])
2436 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2440 # does this compiler support -g -gz=zlib-gnu ?
2442 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2445 CFLAGS="-g -gz=zlib-gnu"
2447 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2450 ac_have_gz_zlib_gnu=yes
2451 AC_MSG_RESULT([yes])
2453 ac_have_gz_zlib_gnu=no
2456 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2460 # does this compiler support nested functions ?
2462 AC_MSG_CHECKING([if gcc accepts nested functions])
2464 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2465 int foo() { return 1; }
2468 ac_have_nested_functions=yes
2469 AC_MSG_RESULT([yes])
2471 ac_have_nested_functions=no
2474 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2477 # does this compiler support the 'p' constraint in ASM statements ?
2479 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2481 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2483 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2485 ac_have_asm_constraint_p=yes
2486 AC_MSG_RESULT([yes])
2488 ac_have_asm_constraint_p=no
2491 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2494 # Does this compiler and linker support -pie?
2495 # Some compilers actually do not support -pie and report its usage
2496 # as an error. We need to check if it is safe to use it first.
2498 AC_MSG_CHECKING([if gcc accepts -pie])
2503 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2506 AC_SUBST([FLAG_PIE], ["-pie"])
2507 AC_MSG_RESULT([yes])
2509 AC_SUBST([FLAG_PIE], [""])
2515 # Does this compiler support -no-pie?
2516 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2517 # default. However this gets in the way with some tests, we use -no-pie
2520 AC_MSG_CHECKING([if gcc accepts -no-pie])
2525 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2528 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2529 AC_MSG_RESULT([yes])
2531 AC_SUBST([FLAG_NO_PIE], [""])
2537 # We want to use use the -Ttext-segment option to the linker.
2538 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2539 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2540 # semantics are NOT what we want (GNU gold -Ttext is fine).
2542 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2543 # will reside. -Ttext aligns just the .text section start (but not any
2546 # So test for -Ttext-segment which is supported by all bfd ld versions
2547 # and use that if it exists. If it doesn't exist it must be an older
2548 # version of gold and we can fall back to using -Ttext which has the
2551 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2554 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2557 [AC_LANG_SOURCE([int _start () { return 0; }])],
2559 linker_using_t_text="no"
2560 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2561 AC_MSG_RESULT([yes])
2563 linker_using_t_text="yes"
2564 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2569 # If the linker only supports -Ttext (not -Ttext-segment) then we will
2570 # have to strip any build-id ELF NOTEs from the statically linked tools.
2571 # Otherwise the build-id NOTE might end up at the default load address.
2572 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2573 # gold versions also support -Ttext-segment. So just assume that unless
2574 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2575 if test "x${linker_using_t_text}" = "xyes"; then
2576 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2577 # does the linker support -Wl,--build-id=none ? Note, it's
2578 # important that we test indirectly via whichever C compiler
2579 # is selected, rather than testing /usr/bin/ld or whatever
2581 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2583 CFLAGS="-Wl,--build-id=none -Werror"
2586 [AC_LANG_PROGRAM([ ], [return 0;])],
2588 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2589 AC_MSG_RESULT([yes])
2591 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2595 AC_MSG_NOTICE([ld -Ttext-segment used, no need to strip build-id NOTEs.])
2596 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2600 # does the ppc assembler support "mtocrf" et al?
2601 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2603 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2604 __asm__ __volatile__("mtocrf 4,0");
2605 __asm__ __volatile__("mfocrf 0,4");
2607 ac_have_as_ppc_mftocrf=yes
2608 AC_MSG_RESULT([yes])
2610 ac_have_as_ppc_mftocrf=no
2613 if test x$ac_have_as_ppc_mftocrf = xyes ; then
2614 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
2618 # does the ppc assembler support "lfdp" and other phased out floating point insns?
2619 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
2621 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2622 do { typedef struct {
2626 dbl_pair_t dbl_pair[3];
2627 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
2630 ac_have_as_ppc_fpPO=yes
2631 AC_MSG_RESULT([yes])
2633 ac_have_as_ppc_fpPO=no
2636 if test x$ac_have_as_ppc_fpPO = xyes ; then
2637 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
2641 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
2642 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
2644 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2646 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
2647 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
2649 ac_have_as_amd64_fxsave64=yes
2650 AC_MSG_RESULT([yes])
2652 ac_have_as_amd64_fxsave64=no
2655 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
2656 AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
2659 # does the x86/amd64 assembler understand SSE3 instructions?
2660 # Note, this doesn't generate a C-level symbol. It generates a
2661 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
2662 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
2664 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2665 do { long long int x;
2666 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
2670 AC_MSG_RESULT([yes])
2676 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
2679 # Ditto for SSSE3 instructions (note extra S)
2680 # Note, this doesn't generate a C-level symbol. It generates a
2681 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
2682 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
2684 save_CFLAGS="$CFLAGS"
2685 CFLAGS="$CFLAGS -msse -Werror"
2686 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2687 do { long long int x;
2688 __asm__ __volatile__(
2689 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
2692 ac_have_as_ssse3=yes
2693 AC_MSG_RESULT([yes])
2698 CFLAGS="$save_CFLAGS"
2700 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
2703 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
2704 # Note, this doesn't generate a C-level symbol. It generates a
2705 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
2706 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
2707 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2709 __asm__ __volatile__(
2710 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
2713 ac_have_as_pclmulqdq=yes
2714 AC_MSG_RESULT([yes])
2716 ac_have_as_pclmulqdq=no
2720 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
2723 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
2724 # Note, this doesn't generate a C-level symbol. It generates a
2725 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
2726 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
2727 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2730 * Carry-less multiplication of xmm1 with xmm2 and store the result in
2731 * xmm3. The immediate is used to determine which quadwords of xmm1 and
2732 * xmm2 should be used.
2734 __asm__ __volatile__(
2735 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
2738 ac_have_as_vpclmulqdq=yes
2739 AC_MSG_RESULT([yes])
2741 ac_have_as_vpclmulqdq=no
2745 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
2748 # does the x86/amd64 assembler understand FMA4 instructions?
2749 # Note, this doesn't generate a C-level symbol. It generates a
2750 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
2751 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
2752 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2754 __asm__ __volatile__(
2755 "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
2758 ac_have_as_vfmaddpd=yes
2759 AC_MSG_RESULT([yes])
2761 ac_have_as_vfmaddpd=no
2765 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
2768 # does the x86/amd64 assembler understand the LZCNT instruction?
2769 # Note, this doesn't generate a C-level symbol. It generates a
2770 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
2771 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
2773 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2775 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
2778 ac_have_as_lzcnt=yes
2779 AC_MSG_RESULT([yes])
2785 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
2788 # does the x86/amd64 assembler understand the LOOPNEL instruction?
2789 # Note, this doesn't generate a C-level symbol. It generates a
2790 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
2791 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
2793 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2795 __asm__ __volatile__("1: loopnel 1b\n");
2798 ac_have_as_loopnel=yes
2799 AC_MSG_RESULT([yes])
2801 ac_have_as_loopnel=no
2805 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
2808 # does the x86/amd64 assembler understand ADDR32 ?
2809 # Note, this doesn't generate a C-level symbol. It generates a
2810 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
2811 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
2813 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2815 asm volatile ("addr32 rep movsb");
2818 ac_have_as_addr32=yes
2819 AC_MSG_RESULT([yes])
2821 ac_have_as_addr32=no
2825 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
2828 # does the x86/amd64 assembler understand SSE 4.2 instructions?
2829 # Note, this doesn't generate a C-level symbol. It generates a
2830 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
2831 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
2833 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2834 do { long long int x;
2835 __asm__ __volatile__(
2836 "crc32q %%r15,%%r15" : : : "r15" );
2837 __asm__ __volatile__(
2838 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
2839 __asm__ __volatile__(
2840 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
2843 ac_have_as_sse42=yes
2844 AC_MSG_RESULT([yes])
2850 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
2853 # does the x86/amd64 assembler understand AVX instructions?
2854 # Note, this doesn't generate a C-level symbol. It generates a
2855 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
2856 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
2858 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2859 do { long long int x;
2860 __asm__ __volatile__(
2861 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
2862 __asm__ __volatile__(
2863 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2867 AC_MSG_RESULT([yes])
2873 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
2876 # does the x86/amd64 assembler understand AVX2 instructions?
2877 # Note, this doesn't generate a C-level symbol. It generates a
2878 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
2879 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
2881 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2882 do { long long int x;
2883 __asm__ __volatile__(
2884 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2885 __asm__ __volatile__(
2886 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
2890 AC_MSG_RESULT([yes])
2896 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
2899 # does the x86/amd64 assembler understand TSX instructions and
2900 # the XACQUIRE/XRELEASE prefixes?
2901 # Note, this doesn't generate a C-level symbol. It generates a
2902 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
2903 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
2905 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2907 __asm__ __volatile__(
2910 " xacquire lock incq 0(%rsp) \n\t"
2911 " xrelease lock incq 0(%rsp) \n"
2916 AC_MSG_RESULT([yes])
2922 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
2925 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
2926 # Note, this doesn't generate a C-level symbol. It generates a
2927 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
2928 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
2930 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2931 do { unsigned int h, l;
2932 __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
2933 __asm__ __volatile__(
2934 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
2935 __asm__ __volatile__(
2936 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
2940 AC_MSG_RESULT([yes])
2946 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
2949 # does the x86/amd64 assembler understand FMA instructions?
2950 # Note, this doesn't generate a C-level symbol. It generates a
2951 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
2952 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
2954 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2955 do { unsigned int h, l;
2956 __asm__ __volatile__(
2957 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
2958 __asm__ __volatile__(
2959 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
2960 __asm__ __volatile__(
2961 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
2965 AC_MSG_RESULT([yes])
2971 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
2974 # does the amd64 assembler understand MPX instructions?
2975 # Note, this doesn't generate a C-level symbol. It generates a
2976 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
2977 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
2979 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2981 asm ("bndmov %bnd0,(%rsp)");
2982 asm ("bndldx 3(%rbx,%rdx), %bnd2");
2983 asm ("bnd call foo\n"
2990 AC_MSG_RESULT([yes])
2996 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
2999 # does the amd64 assembler understand ADX instructions?
3000 # Note, this doesn't generate a C-level symbol. It generates a
3001 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3002 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3004 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3006 asm ("adcxq %r14,%r8");
3010 AC_MSG_RESULT([yes])
3016 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3019 # does the amd64 assembler understand the RDRAND instruction?
3020 # Note, this doesn't generate a C-level symbol. It generates a
3021 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3022 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3024 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3026 asm ("rdrand %r14");
3027 asm ("rdrand %r14d");
3028 asm ("rdrand %r14w");
3031 ac_have_as_rdrand=yes
3032 AC_MSG_RESULT([yes])
3034 ac_have_as_rdrand=no
3038 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3041 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3043 # Note, this doesn't generate a C-level symbol. It generates a
3044 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3045 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3047 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3049 asm ("vcvtph2ps %xmm5, %ymm10");
3050 // If we put the dollar sign and zero together, the shell processing
3051 // this configure.ac script substitutes the command name in. Sigh.
3052 asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3056 AC_MSG_RESULT([yes])
3062 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3065 # does the x86/amd64 assembler understand MOVBE?
3066 # Note, this doesn't generate a C-level symbol. It generates a
3067 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3068 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3070 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3071 do { long long int x;
3072 __asm__ __volatile__(
3073 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3076 ac_have_as_movbe=yes
3077 AC_MSG_RESULT([yes])
3083 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3086 # Does the C compiler support the "ifunc" attribute
3087 # Note, this doesn't generate a C-level symbol. It generates a
3088 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3089 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3091 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3092 static void mytest(void) {}
3094 static void (*resolve_test(void))(void)
3096 return (void (*)(void))&mytest;
3099 void test(void) __attribute__((ifunc("resolve_test")));
3107 ac_have_ifunc_attr=yes
3108 AC_MSG_RESULT([yes])
3110 ac_have_ifunc_attr=no
3114 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3116 # Does the C compiler support the armv8 crc feature flag
3117 # Note, this doesn't generate a C-level symbol. It generates a
3118 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3119 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3121 save_CFLAGS="$CFLAGS"
3122 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3123 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3129 ac_have_armv8_crc_feature=yes
3130 AC_MSG_RESULT([yes])
3132 ac_have_armv8_crc_feature=no
3135 CFLAGS="$save_CFLAGS"
3137 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3140 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3141 # Note, this doesn't generate a C-level symbol. It generates a
3142 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3143 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3145 save_CFLAGS="$CFLAGS"
3146 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3147 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3150 __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3154 ac_have_armv81_feature=yes
3155 AC_MSG_RESULT([yes])
3157 ac_have_armv81_feature=no
3160 CFLAGS="$save_CFLAGS"
3162 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3165 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
3166 # when building the tool executables. I think we should get rid of it.
3168 # Check for TLS support in the compiler and linker
3169 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3171 [vg_cv_linktime_tls=yes],
3172 [vg_cv_linktime_tls=no])
3173 # Native compilation: check whether running a program using TLS succeeds.
3174 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3175 # succeeds but running programs using TLS fails.
3176 # Cross-compiling: check whether linking a program using TLS succeeds.
3177 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3178 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
3179 [vg_cv_tls=$enableval],
3180 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3184 [vg_cv_tls=$vg_cv_linktime_tls])])])
3186 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3187 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3191 #----------------------------------------------------------------------------
3192 # Solaris-specific checks.
3193 #----------------------------------------------------------------------------
3195 if test "$VGCONF_OS" = "solaris" ; then
3196 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3198 # Solaris-specific check determining if the Sun Studio Assembler is used to
3199 # build Valgrind. The test checks if the x86/amd64 assembler understands the
3200 # cmovl.l instruction, if yes then it's Sun Assembler.
3202 # C-level symbol: none
3203 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3205 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3206 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3208 __asm__ __volatile__("cmovl.l %edx, %eax");
3210 solaris_have_sun_studio_as=yes
3211 AC_MSG_RESULT([yes])
3213 solaris_have_sun_studio_as=no
3216 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3218 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3219 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3220 # See solaris/vgpreload-solaris.mapfile for details.
3221 # gcc on older Solaris instructs linker to include these symbols,
3222 # gcc on illumos and newer Solaris does not.
3224 # C-level symbol: none
3225 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3227 save_CFLAGS="$CFLAGS"
3228 CFLAGS="$CFLAGS -std=gnu99"
3229 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3230 temp_dir=$( /usr/bin/mktemp -d )
3231 cat <<_ACEOF >${temp_dir}/mylib.c
3233 int myfunc(void) { printf("LaPutyka\n"); }
3235 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3236 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3237 if test "x${xpg_present}" = "x" ; then
3238 solaris_xpg_symbols_present=no
3241 solaris_xpg_symbols_present=yes
3242 AC_MSG_RESULT([yes])
3245 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3246 CFLAGS="$save_CFLAGS"
3249 # Solaris-specific check determining if gcc enables largefile support by
3250 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3251 # variable with gcc flags which disable it.
3253 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3254 save_CFLAGS="$CFLAGS"
3255 CFLAGS="$CFLAGS -m32"
3256 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3257 return _LARGEFILE_SOURCE;
3259 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3260 AC_MSG_RESULT([yes])
3262 SOLARIS_UNDEF_LARGESOURCE=""
3266 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3269 # Solaris-specific check determining if /proc/self/cmdline
3270 # or /proc/<pid>/cmdline is supported.
3272 # C-level symbol: SOLARIS_PROC_CMDLINE
3273 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3275 AC_CHECK_FILE([/proc/self/cmdline],
3277 solaris_proc_cmdline=yes
3278 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3279 [Define to 1 if you have /proc/self/cmdline.])
3281 solaris_proc_cmdline=no
3283 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3286 # Solaris-specific check determining default platform for the Valgrind launcher.
3287 # Used in case the launcher cannot select platform by looking at the client
3288 # image (for example because the executable is a shell script).
3290 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3291 # Automake-level symbol: none
3293 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3294 # Get the ELF class of /bin/sh first.
3295 if ! test -f /bin/sh; then
3296 AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3298 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3299 case "$elf_class" in
3301 default_arch="$VGCONF_ARCH_PRI";
3304 if test "x$VGCONF_ARCH_SEC" != "x"; then
3305 default_arch="$VGCONF_ARCH_SEC"
3307 default_arch="$VGCONF_ARCH_PRI";
3311 AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3314 default_platform="$default_arch-$VGCONF_OS"
3315 AC_MSG_RESULT([$default_platform])
3316 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3317 [Default platform for Valgrind launcher.])
3320 # Solaris-specific check determining if the old syscalls are available.
3322 # C-level symbol: SOLARIS_OLD_SYSCALLS
3323 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3325 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3326 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3327 #include <sys/syscall.h>
3331 solaris_old_syscalls=yes
3332 AC_MSG_RESULT([yes])
3333 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3334 [Define to 1 if you have the old Solaris syscalls.])
3336 solaris_old_syscalls=no
3339 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3342 # Solaris-specific check determining if the new accept() syscall is available.
3345 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3348 # New syscall (available on illumos):
3349 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3350 # int version, int flags);
3352 # If the old syscall is present then the following syscall will fail with
3353 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3354 # available then it will fail with EINVAL (because the flags parameter is
3357 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3358 # Automake-level symbol: none
3360 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3361 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3362 #include <sys/syscall.h>
3366 syscall(SYS_accept, 0, 0, 0, 0, -1);
3367 return !(errno == EINVAL);
3369 AC_MSG_RESULT([yes])
3370 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3371 [Define to 1 if you have the new `accept' syscall.])
3377 # Solaris-specific check determining if the new illumos pipe() syscall is
3381 # longlong_t pipe();
3383 # New syscall (available on illumos):
3384 # int pipe(intptr_t arg, int flags);
3386 # If the old syscall is present then the following call will succeed, if the
3387 # new syscall is available then it will fail with EFAULT (because address 0
3388 # cannot be accessed).
3390 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3391 # Automake-level symbol: none
3393 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3394 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3395 #include <sys/syscall.h>
3399 syscall(SYS_pipe, 0, 0);
3400 return !(errno == EFAULT);
3402 AC_MSG_RESULT([yes])
3403 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3404 [Define to 1 if you have the new `pipe' syscall.])
3410 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3414 # int lwp_kill(id_t lwpid, int sig);
3416 # New syscall (available on Solaris 11):
3417 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3418 # int si_code, timespec_t *timeout);
3420 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3421 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3423 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3424 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3425 #include <sys/syscall.h>
3427 return !SYS_lwp_sigqueue;
3429 solaris_lwp_sigqueue_syscall=yes
3430 AC_MSG_RESULT([yes])
3431 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3432 [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3434 solaris_lwp_sigqueue_syscall=no
3437 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3440 # Solaris-specific check determining if the lwp_sigqueue() syscall
3441 # takes both pid and thread id arguments or just thread id.
3443 # Old syscall (available up to Solaris 11.3):
3444 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3445 # int si_code, timespec_t *timeout);
3447 # New syscall (available since Solaris 11.4):
3448 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3449 # int si_code, timespec_t *timeout);
3451 # If the old syscall is present then the following syscall will fail with
3452 # EINVAL (because signal is out of range); if the new syscall is available
3453 # then it will fail with ESRCH (because it would not find such thread in the
3456 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3457 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3459 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3460 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3461 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3462 #include <sys/syscall.h>
3466 syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3467 return !(errno == ESRCH);
3469 solaris_lwp_sigqueue_syscall_takes_pid=yes
3470 AC_MSG_RESULT([yes])
3471 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3472 [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3474 solaris_lwp_sigqueue_syscall_takes_pid=no
3477 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3478 test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3480 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3484 # Solaris-specific check determining if the new lwp_name() syscall is
3487 # New syscall (available on Solaris 11):
3488 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3490 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3491 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3493 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3494 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3495 #include <sys/syscall.h>
3497 return !SYS_lwp_name;
3499 solaris_lwp_name_syscall=yes
3500 AC_MSG_RESULT([yes])
3501 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3502 [Define to 1 if you have the new `lwp_name' syscall.])
3504 solaris_lwp_name_syscall=no
3507 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3510 # Solaris-specific check determining if the new getrandom() syscall is
3513 # New syscall (available on Solaris 11):
3514 # int getrandom(void *buf, size_t buflen, uint_t flags);
3516 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3517 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3519 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3520 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3521 #include <sys/syscall.h>
3523 return !SYS_getrandom;
3525 solaris_getrandom_syscall=yes
3526 AC_MSG_RESULT([yes])
3527 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3528 [Define to 1 if you have the new `getrandom' syscall.])
3530 solaris_getrandom_syscall=no
3533 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3536 # Solaris-specific check determining if the new zone() syscall subcodes
3537 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available. These subcodes
3538 # were added in Solaris 11 but are missing on illumos.
3540 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3541 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3543 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3544 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3545 #include <sys/zone.h>
3547 return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3549 solaris_zone_defunct=yes
3550 AC_MSG_RESULT([yes])
3551 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3552 [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3554 solaris_zone_defunct=no
3557 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3560 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
3561 # for auditon(2) subcode of the auditsys() syscall are available.
3562 # These commands are available in Solaris 11 and illumos but were removed
3565 # C-level symbol: SOLARIS_AUDITON_STAT
3566 # Automake-level symbol: SOLARIS_AUDITON_STAT
3568 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
3569 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3570 #include <bsm/audit.h>
3572 return !(A_GETSTAT && A_SETSTAT);
3574 solaris_auditon_stat=yes
3575 AC_MSG_RESULT([yes])
3576 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
3577 [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
3579 solaris_auditon_stat=no
3582 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
3585 # Solaris-specific check determining if the new shmsys() syscall subcodes
3586 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
3587 # These subcodes were added in Solaris 11 but are missing on illumos.
3589 # C-level symbol: SOLARIS_SHM_NEW
3590 # Automake-level symbol: SOLARIS_SHM_NEW
3592 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
3593 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3594 #include <sys/ipc_impl.h>
3595 #include <sys/shm.h>
3596 #include <sys/shm_impl.h>
3598 return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
3601 AC_MSG_RESULT([yes])
3602 AC_DEFINE([SOLARIS_SHM_NEW], 1,
3603 [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
3608 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
3611 # Solaris-specific check determining if prxregset_t is available. Illumos
3612 # currently does not define it on the x86 platform.
3614 # C-level symbol: SOLARIS_PRXREGSET_T
3615 # Automake-level symbol: SOLARIS_PRXREGSET_T
3617 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
3618 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3619 #include <sys/procfs_isa.h>
3621 return !sizeof(prxregset_t);
3623 solaris_prxregset_t=yes
3624 AC_MSG_RESULT([yes])
3625 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
3626 [Define to 1 if you have the `prxregset_t' type.])
3628 solaris_prxregset_t=no
3631 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
3634 # Solaris-specific check determining if the new frealpathat() syscall is
3637 # New syscall (available on Solaris 11.1):
3638 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
3640 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3641 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
3643 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
3644 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3645 #include <sys/syscall.h>
3647 return !SYS_frealpathat;
3649 solaris_frealpathat_syscall=yes
3650 AC_MSG_RESULT([yes])
3651 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
3652 [Define to 1 if you have the new `frealpathat' syscall.])
3654 solaris_frealpathat_syscall=no
3657 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
3660 # Solaris-specific check determining if the new uuidsys() syscall is
3663 # New syscall (available on newer Solaris):
3664 # int uuidsys(struct uuid *uuid);
3666 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
3667 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
3669 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
3670 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3671 #include <sys/syscall.h>
3673 return !SYS_uuidsys;
3675 solaris_uuidsys_syscall=yes
3676 AC_MSG_RESULT([yes])
3677 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
3678 [Define to 1 if you have the new `uuidsys' syscall.])
3680 solaris_uuidsys_syscall=no
3683 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
3686 # Solaris-specific check determining if the new labelsys() syscall subcode
3687 # TNDB_GET_TNIP is available. This subcode was added in Solaris 11 but is
3688 # missing on illumos.
3690 # C-level symbol: SOLARIS_TNDB_GET_TNIP
3691 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
3693 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
3694 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3695 #include <sys/tsol/tndb.h>
3697 return !TNDB_GET_TNIP;
3699 solaris_tndb_get_tnip=yes
3700 AC_MSG_RESULT([yes])
3701 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
3702 [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
3704 solaris_tndb_get_tnip=no
3707 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
3710 # Solaris-specific check determining if the new labelsys() syscall opcodes
3711 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
3712 # added in Solaris 11 but are missing on illumos.
3714 # C-level symbol: SOLARIS_TSOL_CLEARANCE
3715 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
3717 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
3718 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3719 #include <sys/tsol/tsyscall.h>
3721 return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
3723 solaris_tsol_clearance=yes
3724 AC_MSG_RESULT([yes])
3725 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
3726 [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
3728 solaris_tsol_clearance=no
3731 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
3734 # Solaris-specific check determining if the new pset() syscall subcode
3735 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
3736 # is missing on illumos and Solaris 11.3.
3738 # C-level symbol: SOLARIS_PSET_GET_NAME
3739 # Automake-level symbol: SOLARIS_PSET_GET_NAME
3741 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
3742 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3743 #include <sys/pset.h>
3745 return !(PSET_GET_NAME);
3747 solaris_pset_get_name=yes
3748 AC_MSG_RESULT([yes])
3749 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
3750 [Define to 1 if you have the `PSET_GET_NAME' constants.])
3752 solaris_pset_get_name=no
3755 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
3758 # Solaris-specific check determining if the utimesys() syscall is
3759 # available (on illumos and older Solaris).
3761 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
3762 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
3764 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
3765 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3766 #include <sys/syscall.h>
3768 return !SYS_utimesys;
3770 solaris_utimesys_syscall=yes
3771 AC_MSG_RESULT([yes])
3772 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
3773 [Define to 1 if you have the `utimesys' syscall.])
3775 solaris_utimesys_syscall=no
3778 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
3781 # Solaris-specific check determining if the utimensat() syscall is
3782 # available (on newer Solaris).
3784 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3785 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
3787 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
3788 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3789 #include <sys/syscall.h>
3791 return !SYS_utimensat;
3793 solaris_utimensat_syscall=yes
3794 AC_MSG_RESULT([yes])
3795 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
3796 [Define to 1 if you have the `utimensat' syscall.])
3798 solaris_utimensat_syscall=no
3801 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
3804 # Solaris-specific check determining if the spawn() syscall is available
3805 # (on newer Solaris).
3807 # C-level symbol: SOLARIS_SPAWN_SYSCALL
3808 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
3810 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
3811 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3812 #include <sys/syscall.h>
3816 solaris_spawn_syscall=yes
3817 AC_MSG_RESULT([yes])
3818 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
3819 [Define to 1 if you have the `spawn' syscall.])
3821 solaris_spawn_syscall=no
3824 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
3827 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
3828 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
3830 # C-level symbol: SOLARIS_MODCTL_MODNVL
3831 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
3833 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
3834 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3835 #include <sys/modctl.h>
3837 return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
3839 solaris_modctl_modnvl=yes
3840 AC_MSG_RESULT([yes])
3841 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
3842 [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
3844 solaris_modctl_modnvl=no
3847 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
3850 # Solaris-specific check determining whether nscd (name switch cache daemon)
3851 # attaches its door at /system/volatile/name_service_door (Solaris)
3852 # or at /var/run/name_service_door (illumos).
3854 # Note that /var/run is a symlink to /system/volatile on Solaris
3855 # but not vice versa on illumos.
3857 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3858 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
3860 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
3861 if test -e /system/volatile/name_service_door; then
3862 solaris_nscd_door_system_volatile=yes
3863 AC_MSG_RESULT([/system/volatile/name_service_door])
3864 AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
3865 [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
3867 solaris_nscd_door_system_volatile=no
3868 AC_MSG_RESULT([/var/run/name_service_door])
3870 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
3873 # Solaris-specific check determining if the new gethrt() fasttrap is available.
3875 # New fasttrap (available on Solaris 11):
3876 # hrt_t *gethrt(void);
3878 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
3879 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
3881 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
3882 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3883 #include <sys/trap.h>
3887 solaris_gethrt_fasttrap=yes
3888 AC_MSG_RESULT([yes])
3889 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
3890 [Define to 1 if you have the new `gethrt' fasttrap.])
3892 solaris_gethrt_fasttrap=no
3895 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
3898 # Solaris-specific check determining if the new get_zone_offset() fasttrap
3901 # New fasttrap (available on Solaris 11):
3902 # zonehrtoffset_t *get_zone_offset(void);
3904 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3905 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
3907 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
3908 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3909 #include <sys/trap.h>
3911 return !T_GETZONEOFFSET;
3913 solaris_getzoneoffset_fasttrap=yes
3914 AC_MSG_RESULT([yes])
3915 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
3916 [Define to 1 if you have the new `get_zone_offset' fasttrap.])
3918 solaris_getzoneoffset_fasttrap=no
3921 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
3924 # Solaris-specific check determining if the execve() syscall
3925 # takes fourth argument (flags) or not.
3927 # Old syscall (available on illumos):
3928 # int execve(const char *fname, const char **argv, const char **envp);
3930 # New syscall (available on Solaris):
3931 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
3933 # If the new syscall is present then it will fail with EINVAL (because flags
3934 # are invalid); if the old syscall is available then it will fail with ENOENT
3935 # (because the file could not be found).
3937 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3938 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
3940 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
3941 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3942 #include <sys/syscall.h>
3946 syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
3947 return !(errno == EINVAL);
3949 solaris_execve_syscall_takes_flags=yes
3950 AC_MSG_RESULT([yes])
3951 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
3952 [Define to 1 if you have the new `execve' syscall which accepts flags.])
3954 solaris_execve_syscall_takes_flags=no
3957 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
3958 test x$solaris_execve_syscall_takes_flags = xyes)
3961 # Solaris-specific check determining version of the repository cache protocol.
3962 # Every Solaris version uses a different one, ranging from 21 to current 25.
3963 # The check is very ugly, though.
3965 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
3966 # Automake-level symbol: none
3968 AC_PATH_PROG(DIS_PATH, dis, false)
3969 if test "x$DIS_PATH" = "xfalse"; then
3970 AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
3972 AC_CHECK_LIB(scf, scf_handle_bind, [], [
3973 AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
3974 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3977 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
3978 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
3979 libscf=/usr/lib/64/libscf.so.1
3981 libscf=/usr/lib/libscf.so.1
3983 if ! $DIS_PATH -F scf_handle_bind $libscf | grep -q 0x526570; then
3984 AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
3985 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3987 hex=$( $DIS_PATH -F scf_handle_bind $libscf | sed -n 's/.*0x526570\(..\).*/\1/p' )
3988 if test -z "$hex"; then
3989 AC_MSG_WARN([Version of the repository cache protocol is empty?!])
3990 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
3992 version=$( printf "%d\n" 0x$hex )
3993 AC_MSG_RESULT([$version])
3994 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
3995 [Version number of the repository door cache protocol.])
3998 # Solaris-specific check determining if "sysstat" segment reservation type
4001 # New "sysstat" segment reservation (available on Solaris 11.4):
4002 # - program header type: PT_SUNW_SYSSTAT
4003 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4005 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4006 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4008 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4009 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4010 #include <sys/auxv.h>
4012 return !AT_SUN_SYSSTAT_ADDR;
4014 solaris_reserve_sysstat_addr=yes
4015 AC_MSG_RESULT([yes])
4016 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4017 [Define to 1 if you have the new `sysstat' segment reservation.])
4019 solaris_reserve_sysstat_addr=no
4022 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4025 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4028 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4029 # - program header type: PT_SUNW_SYSSTAT_ZONE
4030 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4032 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4033 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4035 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4036 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4037 #include <sys/auxv.h>
4039 return !AT_SUN_SYSSTAT_ZONE_ADDR;
4041 solaris_reserve_sysstat_zone_addr=yes
4042 AC_MSG_RESULT([yes])
4043 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4044 [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4046 solaris_reserve_sysstat_zone_addr=no
4049 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4052 # Solaris-specific check determining if the system_stats() syscall is available
4053 # (on newer Solaris).
4055 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4056 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4058 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4059 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4060 #include <sys/syscall.h>
4062 return !SYS_system_stats;
4064 solaris_system_stats_syscall=yes
4065 AC_MSG_RESULT([yes])
4066 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4067 [Define to 1 if you have the `system_stats' syscall.])
4069 solaris_system_stats_syscall=no
4072 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4075 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4076 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4078 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4079 # Automake-level symbol: none
4081 AC_CHECK_TYPE([struct _fpchip_state],
4082 [solaris_fpchip_state_takes_underscore=yes],
4083 [solaris_fpchip_state_takes_underscore=no],
4084 [[#include <sys/regset.h>]])
4085 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4086 AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4087 [Define to 1 if fpregset_t defines struct _fpchip_state])
4091 # Solaris-specific check determining if schedctl page shared between kernel
4092 # and userspace program is executable (illumos, older Solaris) or not (newer
4095 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4096 # Automake-level symbol: none
4098 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4099 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4103 #include <schedctl.h>
4107 schedctl_t *scp = schedctl_init();
4111 int fd = open("/proc/self/map", O_RDONLY);
4116 while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4117 if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4118 fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4119 (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4120 return (map.pr_mflags & MA_EXEC);
4126 solaris_schedctl_page_exec=no
4129 solaris_schedctl_page_exec=yes
4130 AC_MSG_RESULT([yes])
4131 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4132 [Define to 1 if you have the schedctl page executable.])
4136 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4137 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4138 # an initial thread pointer for libc (newer Solaris).
4140 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4141 # Automake-level symbol: none
4143 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4144 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4145 #include <sys/fasttrap_isa.h>
4147 return !FT_SCRATCHSIZE;
4149 solaris_pt_sunwdtrace_thrp=yes
4150 AC_MSG_RESULT([yes])
4151 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4152 [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4154 solaris_pt_sunwdtrace_thrp=no
4159 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4160 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4161 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4162 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4163 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4164 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4165 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4166 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4167 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4168 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4169 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4170 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4171 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4172 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4173 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4174 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4175 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4176 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4177 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4178 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4179 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4180 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4181 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4182 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4183 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4184 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4185 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4186 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4187 fi # test "$VGCONF_OS" = "solaris"
4190 #----------------------------------------------------------------------------
4191 # Checks for C header files.
4192 #----------------------------------------------------------------------------
4194 AC_CHECK_HEADERS([ \
4212 # Verify whether the <linux/futex.h> header is usable.
4213 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4215 save_CFLAGS="$CFLAGS"
4216 CFLAGS="$CFLAGS -D__user="
4217 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4218 #include <linux/futex.h>
4222 ac_have_usable_linux_futex_h=yes
4223 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4224 [Define to 1 if you have a usable <linux/futex.h> header file.])
4225 AC_MSG_RESULT([yes])
4227 ac_have_usable_linux_futex_h=no
4230 CFLAGS="$save_CFLAGS"
4233 #----------------------------------------------------------------------------
4234 # Checks for typedefs, structures, and compiler characteristics.
4235 #----------------------------------------------------------------------------
4242 #----------------------------------------------------------------------------
4243 # Checks for library functions.
4244 #----------------------------------------------------------------------------
4248 AC_CHECK_LIB([pthread], [pthread_create])
4249 AC_CHECK_LIB([rt], [clock_gettime])
4262 pthread_barrier_init \
4263 pthread_condattr_setclock \
4264 pthread_mutex_timedlock \
4265 pthread_rwlock_timedrdlock \
4266 pthread_rwlock_timedwrlock \
4269 pthread_setname_np \
4290 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4291 # libraries with any shared object and/or executable. This is NOT what we
4292 # want for e.g. vgpreload_core-x86-linux.so
4295 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4296 [test x$ac_cv_func_pthread_barrier_init = xyes])
4297 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4298 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4299 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4300 [test x$ac_cv_func_pthread_spin_lock = xyes])
4301 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4302 [test x$ac_cv_func_pthread_setname_np = xyes])
4303 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4304 [test x$ac_cv_func_copy_file_range = xyes])
4305 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4306 [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4307 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4308 [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4310 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4311 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4312 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4313 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4314 [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4317 #----------------------------------------------------------------------------
4319 #----------------------------------------------------------------------------
4320 # Do we have a useable MPI setup on the primary and/or secondary targets?
4321 # On Linux, by default, assumes mpicc and -m32/-m64
4322 # Note: this is a kludge in that it assumes the specified mpicc
4323 # understands -m32/-m64 regardless of what is specified using
4325 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4326 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4329 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4330 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4331 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4332 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4333 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4334 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4335 mflag_primary=$FLAG_M32
4336 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4337 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4338 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4339 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4340 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4341 mflag_primary=$FLAG_M64
4342 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4343 mflag_primary="$FLAG_M32 -arch i386"
4344 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4345 mflag_primary="$FLAG_M64 -arch x86_64"
4349 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4350 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4351 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4352 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX ; then
4353 mflag_secondary=$FLAG_M32
4354 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4355 mflag_secondary="$FLAG_M32 -arch i386"
4360 [ --with-mpicc= Specify name of MPI2-ised C compiler],
4365 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4366 ## use these values in the check for a functioning mpicc.
4368 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4369 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4370 AM_COND_IF([VGCONF_OS_IS_LINUX],
4371 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4372 LDFLAGS_MPI="-fpic -shared"])
4373 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4374 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4375 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4376 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4377 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4378 LDFLAGS_MPI="-fpic -shared"])
4380 AC_SUBST([CFLAGS_MPI])
4381 AC_SUBST([LDFLAGS_MPI])
4384 ## See if MPI_CC works for the primary target
4386 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4388 saved_CFLAGS=$CFLAGS
4390 CFLAGS="$CFLAGS_MPI $mflag_primary"
4391 saved_LDFLAGS="$LDFLAGS"
4392 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4393 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4397 int ni, na, nd, comb;
4398 int r = MPI_Init(NULL,NULL);
4399 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4400 r |= MPI_Finalize();
4403 ac_have_mpi2_pri=yes
4404 AC_MSG_RESULT([yes, $MPI_CC])
4410 CFLAGS=$saved_CFLAGS
4411 LDFLAGS="$saved_LDFLAGS"
4412 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4414 ## See if MPI_CC works for the secondary target. Complication: what if
4415 ## there is no secondary target? We need this to then fail.
4416 ## Kludge this by making MPI_CC something which will surely fail in
4419 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4421 saved_CFLAGS=$CFLAGS
4422 saved_LDFLAGS="$LDFLAGS"
4423 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4424 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4425 CC="$MPI_CC this will surely fail"
4429 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4430 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4434 int ni, na, nd, comb;
4435 int r = MPI_Init(NULL,NULL);
4436 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4437 r |= MPI_Finalize();
4440 ac_have_mpi2_sec=yes
4441 AC_MSG_RESULT([yes, $MPI_CC])
4447 CFLAGS=$saved_CFLAGS
4448 LDFLAGS="$saved_LDFLAGS"
4449 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4452 #----------------------------------------------------------------------------
4453 # Other library checks
4454 #----------------------------------------------------------------------------
4455 # There now follow some tests for Boost, and OpenMP. These
4456 # tests are present because Drd has some regression tests that use
4457 # these packages. All regression test programs all compiled only
4458 # for the primary target. And so it is important that the configure
4459 # checks that follow, use the correct -m32 or -m64 flag for the
4460 # primary target (called $mflag_primary). Otherwise, we can end up
4461 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4462 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4463 # only build (meaning, the primary target is x86-linux), the build
4464 # of the regtest programs that use Boost fails, because they are
4465 # build as 32-bit (IN THIS EXAMPLE).
4467 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4468 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4471 # Check whether the boost library 1.35 or later has been installed.
4472 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4474 AC_MSG_CHECKING([for boost])
4477 safe_CXXFLAGS=$CXXFLAGS
4478 CXXFLAGS="$mflag_primary"
4480 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4482 AC_LINK_IFELSE([AC_LANG_SOURCE([
4483 #include <boost/thread.hpp>
4484 static void thread_func(void)
4486 int main(int argc, char** argv)
4488 boost::thread t(thread_func);
4493 ac_have_boost_1_35=yes
4494 AC_SUBST([BOOST_CFLAGS], [])
4495 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4496 AC_MSG_RESULT([yes])
4498 ac_have_boost_1_35=no
4503 CXXFLAGS=$safe_CXXFLAGS
4506 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4509 # does this compiler support -fopenmp, does it have the include file
4510 # <omp.h> and does it have libgomp ?
4512 AC_MSG_CHECKING([for OpenMP])
4515 CFLAGS="-fopenmp $mflag_primary -Werror"
4517 AC_LINK_IFELSE([AC_LANG_SOURCE([
4519 int main(int argc, char** argv)
4527 AC_MSG_RESULT([yes])
4534 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
4537 # Check for __builtin_popcount
4538 AC_MSG_CHECKING([for __builtin_popcount()])
4539 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4541 __builtin_popcount(2);
4544 AC_MSG_RESULT([yes])
4545 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
4546 [Define to 1 if compiler provides __builtin_popcount().])
4551 # Check for __builtin_clz
4552 AC_MSG_CHECKING([for __builtin_clz()])
4553 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4558 AC_MSG_RESULT([yes])
4559 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
4560 [Define to 1 if compiler provides __builtin_clz().])
4565 # Check for __builtin_ctz
4566 AC_MSG_CHECKING([for __builtin_ctz()])
4567 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4572 AC_MSG_RESULT([yes])
4573 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
4574 [Define to 1 if compiler provides __builtin_ctz().])
4579 # does this compiler have built-in functions for atomic memory access for the
4581 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
4584 CFLAGS="$mflag_primary"
4586 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4588 return (__sync_bool_compare_and_swap(&variable, 1, 2)
4589 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4591 ac_have_builtin_atomic_primary=yes
4592 AC_MSG_RESULT([yes])
4593 AC_DEFINE(HAVE_BUILTIN_ATOMIC, 1, [Define to 1 if gcc supports __sync_bool_compare_and_swap() and __sync_add_and_fetch() for the primary target])
4595 ac_have_builtin_atomic_primary=no
4601 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
4602 [test x$ac_have_builtin_atomic_primary = xyes])
4605 # does this compiler have built-in functions for atomic memory access for the
4606 # secondary target ?
4608 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4610 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
4613 CFLAGS="$mflag_secondary"
4615 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4617 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
4619 ac_have_builtin_atomic_secondary=yes
4620 AC_MSG_RESULT([yes])
4622 ac_have_builtin_atomic_secondary=no
4630 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
4631 [test x$ac_have_builtin_atomic_secondary = xyes])
4633 # does this compiler have built-in functions for atomic memory access on
4634 # 64-bit integers for all targets ?
4636 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
4638 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4641 uint64_t variable = 1;
4642 return __sync_add_and_fetch(&variable, 1)
4644 ac_have_builtin_atomic64_primary=yes
4646 ac_have_builtin_atomic64_primary=no
4649 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
4652 CFLAGS="$mflag_secondary"
4654 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4657 uint64_t variable = 1;
4658 return __sync_add_and_fetch(&variable, 1)
4660 ac_have_builtin_atomic64_secondary=yes
4662 ac_have_builtin_atomic64_secondary=no
4669 if test x$ac_have_builtin_atomic64_primary = xyes && \
4670 test x$VGCONF_PLATFORM_SEC_CAPS = x \
4671 -o x$ac_have_builtin_atomic64_secondary = xyes; then
4672 AC_MSG_RESULT([yes])
4673 ac_have_builtin_atomic64=yes
4676 ac_have_builtin_atomic64=no
4679 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
4680 [test x$ac_have_builtin_atomic64 = xyes])
4683 # does g++ have built-in functions for atomic memory access ?
4684 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
4686 safe_CXXFLAGS=$CXXFLAGS
4687 CXXFLAGS="$mflag_primary"
4690 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
4692 return (__sync_bool_compare_and_swap(&variable, 1, 2)
4693 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
4695 ac_have_builtin_atomic_cxx=yes
4696 AC_MSG_RESULT([yes])
4697 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
4699 ac_have_builtin_atomic_cxx=no
4704 CXXFLAGS=$safe_CXXFLAGS
4706 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
4709 if test x$ac_have_usable_linux_futex_h = xyes \
4710 -a x$ac_have_builtin_atomic_primary = xyes; then
4711 ac_enable_linux_ticket_lock_primary=yes
4713 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
4714 [test x$ac_enable_linux_ticket_lock_primary = xyes])
4716 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
4717 -a x$ac_have_usable_linux_futex_h = xyes \
4718 -a x$ac_have_builtin_atomic_secondary = xyes; then
4719 ac_enable_linux_ticket_lock_secondary=yes
4721 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
4722 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
4725 # does libstdc++ support annotating shared pointers ?
4726 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
4728 safe_CXXFLAGS=$CXXFLAGS
4729 CXXFLAGS="-std=c++0x"
4732 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4735 std::shared_ptr<int> p
4737 ac_have_shared_ptr=yes
4739 ac_have_shared_ptr=no
4741 if test x$ac_have_shared_ptr = xyes; then
4742 # If compilation of the program below fails because of a syntax error
4743 # triggered by substituting one of the annotation macros then that
4744 # means that libstdc++ supports these macros.
4745 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4746 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
4747 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
4750 std::shared_ptr<int> p
4752 ac_have_shared_pointer_annotation=no
4755 ac_have_shared_pointer_annotation=yes
4756 AC_MSG_RESULT([yes])
4757 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
4758 [Define to 1 if libstd++ supports annotating shared pointers])
4761 ac_have_shared_pointer_annotation=no
4766 CXXFLAGS=$safe_CXXFLAGS
4768 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
4769 [test x$ac_have_shared_pointer_annotation = xyes])
4772 #----------------------------------------------------------------------------
4773 # Ok. We're done checking.
4774 #----------------------------------------------------------------------------
4776 # Nb: VEX/Makefile is generated from Makefile.vex.in.
4779 VEX/Makefile:Makefile.vex.in
4788 gdbserver_tests/Makefile
4789 gdbserver_tests/solaris/Makefile
4795 memcheck/tests/Makefile
4796 memcheck/tests/common/Makefile
4797 memcheck/tests/amd64/Makefile
4798 memcheck/tests/x86/Makefile
4799 memcheck/tests/linux/Makefile
4800 memcheck/tests/darwin/Makefile
4801 memcheck/tests/solaris/Makefile
4802 memcheck/tests/amd64-linux/Makefile
4803 memcheck/tests/arm64-linux/Makefile
4804 memcheck/tests/x86-linux/Makefile
4805 memcheck/tests/amd64-solaris/Makefile
4806 memcheck/tests/x86-solaris/Makefile
4807 memcheck/tests/ppc32/Makefile
4808 memcheck/tests/ppc64/Makefile
4809 memcheck/tests/s390x/Makefile
4810 memcheck/tests/mips32/Makefile
4811 memcheck/tests/mips64/Makefile
4812 memcheck/tests/vbit-test/Makefile
4814 cachegrind/tests/Makefile
4815 cachegrind/tests/x86/Makefile
4816 cachegrind/cg_annotate
4819 callgrind/callgrind_annotate
4820 callgrind/callgrind_control
4821 callgrind/tests/Makefile
4823 helgrind/tests/Makefile
4825 drd/scripts/download-and-build-splash2
4828 massif/tests/Makefile
4833 lackey/tests/Makefile
4836 none/tests/scripts/Makefile
4837 none/tests/amd64/Makefile
4838 none/tests/ppc32/Makefile
4839 none/tests/ppc64/Makefile
4840 none/tests/x86/Makefile
4841 none/tests/arm/Makefile
4842 none/tests/arm64/Makefile
4843 none/tests/s390x/Makefile
4844 none/tests/mips32/Makefile
4845 none/tests/mips64/Makefile
4846 none/tests/nanomips/Makefile
4847 none/tests/linux/Makefile
4848 none/tests/darwin/Makefile
4849 none/tests/solaris/Makefile
4850 none/tests/amd64-linux/Makefile
4851 none/tests/x86-linux/Makefile
4852 none/tests/amd64-darwin/Makefile
4853 none/tests/x86-darwin/Makefile
4854 none/tests/amd64-solaris/Makefile
4855 none/tests/x86-solaris/Makefile
4856 exp-sgcheck/Makefile
4857 exp-sgcheck/tests/Makefile
4859 exp-bbv/tests/Makefile
4860 exp-bbv/tests/x86/Makefile
4861 exp-bbv/tests/x86-linux/Makefile
4862 exp-bbv/tests/amd64-linux/Makefile
4863 exp-bbv/tests/ppc32-linux/Makefile
4864 exp-bbv/tests/arm-linux/Makefile
4868 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
4869 [chmod +x coregrind/link_tool_exe_linux])
4870 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
4871 [chmod +x coregrind/link_tool_exe_darwin])
4872 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
4873 [chmod +x coregrind/link_tool_exe_solaris])
4878 Maximum build arch: ${ARCH_MAX}
4879 Primary build arch: ${VGCONF_ARCH_PRI}
4880 Secondary build arch: ${VGCONF_ARCH_SEC}
4881 Build OS: ${VGCONF_OS}
4882 Link Time Optimisation: ${vg_cv_lto}
4883 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
4884 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
4885 Platform variant: ${VGCONF_PLATVARIANT}
4886 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
4887 Default supp files: ${DEFAULT_SUPP}