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.
12 # Define major, minor, micro and suffix here once, then reuse them
13 # for version number in valgrind.h and vg-entities (documentation).
14 # suffix must be empty for a release, otherwise it is GIT or RC1, etc.
15 # Also set the (expected/last) release date here.
16 # Do not forget to rerun ./autogen.sh
17 m4_define([v_major_ver], [3])
18 m4_define([v_minor_ver], [19])
19 m4_define([v_micro_ver], [0])
20 m4_define([v_suffix_ver], [])
21 m4_define([v_rel_date], ["11 Apr 2022"])
22 m4_define([v_version],
23 m4_if(v_suffix_ver, [],
24 [v_major_ver.v_minor_ver.v_micro_ver],
25 [v_major_ver.v_minor_ver.v_micro_ver.v_suffix_ver]))
26 AC_INIT([Valgrind],[v_version],[valgrind-users@lists.sourceforge.net])
29 AC_SUBST(VG_VER_MAJOR, v_major_ver)
30 AC_SUBST(VG_VER_MINOR, v_minor_ver)
32 # For docs/xml/vg-entities.xml
33 AC_SUBST(VG_DATE, v_rel_date)
35 AC_CONFIG_SRCDIR(coregrind/m_main.c)
36 AC_CONFIG_HEADERS([config.h])
37 AM_INIT_AUTOMAKE([foreign dist-bzip2 subdir-objects])
41 #----------------------------------------------------------------------------
42 # Do NOT modify these flags here. Except in feature tests in which case
43 # the original values must be properly restored.
44 #----------------------------------------------------------------------------
48 #----------------------------------------------------------------------------
49 # Checks for various programs.
50 #----------------------------------------------------------------------------
57 # AC_PROG_OBJC apparently causes problems on older Linux distros (eg. with
58 # autoconf 2.59). If we ever have any Objective-C code in the Valgrind code
59 # base (eg. most likely as Darwin-specific tests) we'll need one of the
61 # - put AC_PROG_OBJC in a Darwin-specific part of this file
62 # - Use AC_PROG_OBJC here and up the minimum autoconf version
63 # - Use the following, which is apparently equivalent:
64 # m4_ifdef([AC_PROG_OBJC],
66 # [AC_CHECK_TOOL([OBJC], [gcc])
68 # AC_SUBST([OBJCFLAGS])
71 # Set LTO_RANLIB variable to an lto enabled ranlib
72 if test "x$LTO_RANLIB" = "x"; then
73 AC_PATH_PROGS([LTO_RANLIB], [gcc-ranlib])
75 AC_ARG_VAR([LTO_RANLIB],[Library indexer command for link time optimisation])
77 # provide a very basic definition for AC_PROG_SED if it's not provided by
78 # autoconf (as e.g. in autoconf 2.59).
79 m4_ifndef([AC_PROG_SED],
80 [AC_DEFUN([AC_PROG_SED],
82 AC_CHECK_PROGS([SED],[gsed sed])])])
85 # If no AR variable was specified, look up the name of the archiver. Otherwise
86 # do not touch the AR variable.
87 if test "x$AR" = "x"; then
88 AC_PATH_PROGS([AR], [`echo $LD | $SED 's/ld$/ar/'` "ar"], [ar])
90 AC_ARG_VAR([AR],[Archiver command])
92 # same for LTO_AR variable for lto enabled archiver
93 if test "x$LTO_AR" = "x"; then
94 AC_PATH_PROGS([LTO_AR], [gcc-ar])
96 AC_ARG_VAR([LTO_AR],[Archiver command for link time optimisation])
99 # Check for the compiler support
100 if test "${GCC}" != "yes" ; then
101 AC_MSG_ERROR([Valgrind relies on GCC to be compiled])
104 # figure out where perl lives
105 AC_PATH_PROG(PERL, perl)
107 # figure out where gdb lives
108 AC_PATH_PROG(GDB, gdb, "/no/gdb/was/found/at/configure/time")
109 AC_DEFINE_UNQUOTED(GDB_PATH, "$GDB", [path to GDB])
111 # some older automake's don't have it so try something on our own
112 ifdef([AM_PROG_AS],[AM_PROG_AS],
122 # Check if 'diff' supports -u (universal diffs) and use it if possible.
124 AC_MSG_CHECKING([for diff -u])
127 # Comparing two identical files results in 0.
128 tmpfile="tmp-xxx-yyy-zzz"
130 if diff -u $tmpfile $tmpfile ; then
139 # Make sure we can compile in C99 mode.
141 if test "$ac_cv_prog_cc_c99" = "no"; then
142 AC_MSG_ERROR([Valgrind relies on a C compiler supporting C99])
145 # We don't want gcc < 3.0
146 AC_MSG_CHECKING([for a supported version of gcc])
148 # Obtain the compiler version.
150 # A few examples of how the ${CC} --version output looks like:
152 # ######## gcc variants ########
153 # Arch Linux: i686-pc-linux-gnu-gcc (GCC) 4.6.2
154 # Debian Linux: gcc (Debian 4.3.2-1.1) 4.3.2
155 # openSUSE: gcc (SUSE Linux) 4.5.1 20101208 [gcc-4_5-branch revision 167585]
156 # Exherbo Linux: x86_64-pc-linux-gnu-gcc (Exherbo gcc-4.6.2) 4.6.2
157 # MontaVista Linux for ARM: arm-none-linux-gnueabi-gcc (Sourcery G++ Lite 2009q1-203) 4.3.3
158 # OS/X 10.6: i686-apple-darwin10-gcc-4.2.1 (GCC) 4.2.1 (Apple Inc. build 5666) (dot 3)
159 # 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)
161 # ######## clang variants ########
162 # Clang: clang version 2.9 (tags/RELEASE_29/final)
163 # Apple clang: Apple clang version 3.1 (tags/Apple/clang-318.0.58) (based on LLVM 3.1svn)
164 # FreeBSD clang: FreeBSD clang version 3.1 (branches/release_31 156863) 20120523
166 # ######## Apple LLVM variants ########
167 # Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
168 # Apple LLVM version 6.0 (clang-600.0.51) (based on LLVM 3.5svn)
171 if test "x`${CC} --version | $SED -n -e 's/.*\Apple \(LLVM\) version.*clang.*/\1/p'`" = "xLLVM" ;
174 gcc_version=`${CC} --version | $SED -n -e 's/.*LLVM version \([0-9.]*\).*$/\1/p'`
175 elif test "x`${CC} --version | $SED -n -e 's/.*\(clang\) version.*/\1/p'`" = "xclang" ;
178 # Don't use -dumpversion with clang: it will always produce "4.2.1".
179 gcc_version=`${CC} --version | $SED -n -e 's/.*clang version \([0-9.]*\).*$/\1/p'`
180 elif test "x`${CC} --version | $SED -n -e 's/icc.*\(ICC\).*/\1/p'`" = "xICC" ;
183 gcc_version=`${CC} -dumpversion 2>/dev/null`
186 gcc_version=`${CC} -dumpversion 2>/dev/null`
187 if test "x$gcc_version" = x; then
188 gcc_version=`${CC} --version | $SED -n -e 's/[^ ]*gcc[^ ]* ([^)]*) \([0-9.]*\).*$/\1/p'`
192 AM_CONDITIONAL(COMPILER_IS_CLANG, test $is_clang = clang -o $is_clang = applellvm)
193 AM_CONDITIONAL(COMPILER_IS_ICC, test $is_clang = icc)
195 # Note: m4 arguments are quoted with [ and ] so square brackets in shell
196 # statements have to be quoted.
197 case "${is_clang}-${gcc_version}" in
198 applellvm-5.1|applellvm-[[6-9]].*|applellvm-[[1-9][0-9]]*)
199 AC_MSG_RESULT([ok (Apple LLVM version ${gcc_version})])
201 icc-1[[3-9]].*|icc-202[[0-9]].*)
202 AC_MSG_RESULT([ok (ICC version ${gcc_version})])
204 notclang-[[3-9]]|notclang-[[3-9]].*|notclang-[[1-9][0-9]]*)
205 AC_MSG_RESULT([ok (${gcc_version})])
207 clang-2.9|clang-[[3-9]].*|clang-[[1-9][0-9]]*)
208 AC_MSG_RESULT([ok (clang-${gcc_version})])
211 AC_MSG_RESULT([no (${is_clang}-${gcc_version})])
212 AC_MSG_ERROR([please use gcc >= 3.0 or clang >= 2.9 or icc >= 13.0 or Apple LLVM >= 5.1])
216 #----------------------------------------------------------------------------
217 # Arch/OS/platform tests.
218 #----------------------------------------------------------------------------
219 # We create a number of arch/OS/platform-related variables. We prefix them
220 # all with "VGCONF_" which indicates that they are defined at
221 # configure-time, and distinguishes them from the VGA_*/VGO_*/VGP_*
222 # variables used when compiling C files.
226 AC_MSG_CHECKING([for a supported CPU])
228 # ARCH_MAX reflects the most that this CPU can do: for example if it
229 # is a 64-bit capable PowerPC, then it must be set to ppc64 and not ppc32.
230 # Ditto for amd64. It is used for more configuration below, but is not used
233 # Power PC returns powerpc for Big Endian. This was not changed when Little
234 # Endian support was added to the 64-bit architecture. The 64-bit Little
235 # Endian systems explicitly state le in the host_cpu. For clarity in the
236 # Valgrind code, the ARCH_MAX name will state LE or BE for the endianness of
237 # the 64-bit system. Big Endian is the only mode supported on 32-bit Power PC.
238 # The abreviation PPC or ppc refers to 32-bit and 64-bit systems with either
239 # Endianness. The name PPC64 or ppc64 to 64-bit systems of either Endianness.
240 # The names ppc64be or PPC64BE refer to only 64-bit systems that are Big
241 # Endian. Similarly, ppc64le or PPC64LE refer to only 64-bit systems that are
244 case "${host_cpu}" in
246 AC_MSG_RESULT([ok (${host_cpu})])
251 AC_MSG_RESULT([ok (${host_cpu})])
256 # this only referrs to 64-bit Big Endian
257 AC_MSG_RESULT([ok (${host_cpu})])
262 # this only referrs to 64-bit Little Endian
263 AC_MSG_RESULT([ok (${host_cpu})])
268 # On Linux this means only a 32-bit capable CPU.
269 AC_MSG_RESULT([ok (${host_cpu})])
274 AC_MSG_RESULT([ok (${host_cpu})])
279 AC_MSG_RESULT([ok (${host_cpu})])
284 AC_MSG_RESULT([ok (${host_cpu})])
289 AC_MSG_RESULT([ok (${host_cpu})])
294 AC_MSG_RESULT([ok (${host_cpu})])
299 AC_MSG_RESULT([ok (${host_cpu})])
304 AC_MSG_RESULT([ok (${host_cpu})])
309 AC_MSG_RESULT([ok (${host_cpu})])
313 AC_MSG_RESULT([ok (${host_cpu})])
318 AC_MSG_RESULT([no (${host_cpu})])
319 AC_MSG_ERROR([Unsupported host architecture. Sorry])
323 #----------------------------------------------------------------------------
325 # Sometimes it's convenient to subvert the bi-arch build system and
326 # just have a single build even though the underlying platform is
327 # capable of both. Hence handle --enable-only64bit and
328 # --enable-only32bit. Complain if both are issued :-)
329 # [Actually, if either of these options are used, I think both get built,
330 # but only one gets installed. So if you use an in-place build, both can be
333 # Check if a 64-bit only build has been requested
334 AC_CACHE_CHECK([for a 64-bit only build], vg_cv_only64bit,
335 [AC_ARG_ENABLE(only64bit,
336 [ --enable-only64bit do a 64-bit only build],
337 [vg_cv_only64bit=$enableval],
338 [vg_cv_only64bit=no])])
340 # Check if a 32-bit only build has been requested
341 AC_CACHE_CHECK([for a 32-bit only build], vg_cv_only32bit,
342 [AC_ARG_ENABLE(only32bit,
343 [ --enable-only32bit do a 32-bit only build],
344 [vg_cv_only32bit=$enableval],
345 [vg_cv_only32bit=no])])
348 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
350 [Nonsensical: both --enable-only64bit and --enable-only32bit.])
353 #----------------------------------------------------------------------------
355 # VGCONF_OS is the primary build OS, eg. "linux". It is passed in to
356 # compilation of many C files via -VGO_$(VGCONF_OS) and
357 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
358 AC_MSG_CHECKING([for a supported OS])
365 AC_MSG_RESULT([ok (${host_os})])
368 # Ok, this is linux. Check the kernel version
369 AC_MSG_CHECKING([for the kernel version])
374 0.*|1.*|2.0.*|2.1.*|2.2.*|2.3.*|2.4.*|2.5.*)
375 AC_MSG_RESULT([unsupported (${kernel})])
376 AC_MSG_ERROR([Valgrind needs a Linux kernel >= 2.6])
380 AC_MSG_RESULT([2.6 or later (${kernel})])
387 AC_MSG_RESULT([ok (${host_os})])
389 AC_DEFINE([FREEBSD_10], 1000, [FREEBSD_VERS value for FreeBSD 10.x])
391 AC_DEFINE([FREEBSD_11], 1100, [FREEBSD_VERS value for FreeBSD 11.x])
393 AC_DEFINE([FREEBSD_12], 1200, [FREEBSD_VERS value for FreeBSD 12.0 to 12.1])
395 AC_DEFINE([FREEBSD_12_2], 1220, [FREEBSD_VERS value for FreeBSD 12.2])
397 AC_DEFINE([FREEBSD_13_0], 1300, [FREEBSD_VERS value for FreeBSD 13.0])
399 AC_DEFINE([FREEBSD_13_1], 1310, [FREEBSD_VERS value for FreeBSD 13.1+])
401 AC_DEFINE([FREEBSD_14], 1400, [FREEBSD_VERS value for FreeBSD 14.x])
404 AC_MSG_CHECKING([for the kernel version])
409 AC_MSG_RESULT([FreeBSD 10.x (${kernel})])
410 AC_DEFINE([FREEBSD_VERS], FREEBSD_10, [FreeBSD version])
411 freebsd_vers=$freebsd_10
414 AC_MSG_RESULT([FreeBSD 11.x (${kernel})])
415 AC_DEFINE([FREEBSD_VERS], FREEBSD_11, [FreeBSD version])
416 freebsd_vers=$freebsd_11
421 AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
422 AC_DEFINE([FREEBSD_VERS], FREEBSD_12, [FreeBSD version])
423 freebsd_vers=$freebsd_12
426 AC_MSG_RESULT([FreeBSD 12.x (${kernel})])
427 AC_DEFINE([FREEBSD_VERS], FREEBSD_12_2, [FreeBSD version])
428 freebsd_vers=$freebsd_12_2
435 AC_MSG_RESULT([FreeBSD 13.0 (${kernel})])
436 AC_DEFINE([FREEBSD_VERS], FREEBSD_13_0, [FreeBSD version])
437 freebsd_vers=$freebsd_13_0
440 AC_MSG_RESULT([FreeBSD 13.1+ (${kernel})])
441 AC_DEFINE([FREEBSD_VERS], FREEBSD_13_1, [FreeBSD version])
442 freebsd_vers=$freebsd_13_1
447 AC_MSG_RESULT([FreeBSD 14.x (${kernel})])
448 AC_DEFINE([FREEBSD_VERS], FREEBSD_14, [FreeBSD version])
449 freebsd_vers=$freebsd_14
452 AC_MSG_RESULT([unsupported (${kernel})])
453 AC_MSG_ERROR([Valgrind works on FreeBSD 10.x to 14.x])
457 DEFAULT_SUPP="$srcdir/freebsd.supp $srcdir/freebsd-helgrind.supp $srcdir/freebsd-drd.supp ${DEFAULT_SUPP}"
461 AC_MSG_RESULT([ok (${host_os})])
463 AC_DEFINE([DARWIN_10_5], 100500, [DARWIN_VERS value for Mac OS X 10.5])
464 AC_DEFINE([DARWIN_10_6], 100600, [DARWIN_VERS value for Mac OS X 10.6])
465 AC_DEFINE([DARWIN_10_7], 100700, [DARWIN_VERS value for Mac OS X 10.7])
466 AC_DEFINE([DARWIN_10_8], 100800, [DARWIN_VERS value for Mac OS X 10.8])
467 AC_DEFINE([DARWIN_10_9], 100900, [DARWIN_VERS value for Mac OS X 10.9])
468 AC_DEFINE([DARWIN_10_10], 101000, [DARWIN_VERS value for Mac OS X 10.10])
469 AC_DEFINE([DARWIN_10_11], 101100, [DARWIN_VERS value for Mac OS X 10.11])
470 AC_DEFINE([DARWIN_10_12], 101200, [DARWIN_VERS value for macOS 10.12])
471 AC_DEFINE([DARWIN_10_13], 101300, [DARWIN_VERS value for macOS 10.13])
473 AC_MSG_CHECKING([for the kernel version])
476 # Nb: for Darwin we set DEFAULT_SUPP here. That's because Darwin
477 # has only one relevant version, the OS version. The `uname` check
478 # is a good way to get that version (i.e. "Darwin 9.6.0" is Mac OS
479 # X 10.5.6, and "Darwin 10.x" is Mac OS X 10.6.x Snow Leopard,
480 # and possibly "Darwin 11.x" is Mac OS X 10.7.x Lion),
481 # and we don't know of an macros similar to __GLIBC__ to get that info.
483 # XXX: `uname -r` won't do the right thing for cross-compiles, but
484 # that's not a problem yet.
486 # jseward 21 Sept 2011: I seriously doubt whether V 3.7.0 will work
487 # on OS X 10.5.x; I haven't tested yet, and only plan to test 3.7.0
488 # on 10.6.8 and 10.7.1. Although tempted to delete the configure
489 # time support for 10.5 (the 9.* pattern just below), I'll leave it
490 # in for now, just in case anybody wants to give it a try. But I'm
491 # assuming that 3.7.0 is a Snow Leopard and Lion-only release.
494 AC_MSG_RESULT([Darwin 9.x (${kernel}) / Mac OS X 10.5 Leopard])
495 AC_DEFINE([DARWIN_VERS], DARWIN_10_5, [Darwin / Mac OS X version])
496 DEFAULT_SUPP="$srcdir/darwin9.supp ${DEFAULT_SUPP}"
497 DEFAULT_SUPP="$srcdir/darwin9-drd.supp ${DEFAULT_SUPP}"
500 AC_MSG_RESULT([Darwin 10.x (${kernel}) / Mac OS X 10.6 Snow Leopard])
501 AC_DEFINE([DARWIN_VERS], DARWIN_10_6, [Darwin / Mac OS X version])
502 DEFAULT_SUPP="$srcdir/darwin10.supp ${DEFAULT_SUPP}"
503 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
506 AC_MSG_RESULT([Darwin 11.x (${kernel}) / Mac OS X 10.7 Lion])
507 AC_DEFINE([DARWIN_VERS], DARWIN_10_7, [Darwin / Mac OS X version])
508 DEFAULT_SUPP="$srcdir/darwin11.supp ${DEFAULT_SUPP}"
509 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
512 AC_MSG_RESULT([Darwin 12.x (${kernel}) / Mac OS X 10.8 Mountain Lion])
513 AC_DEFINE([DARWIN_VERS], DARWIN_10_8, [Darwin / Mac OS X version])
514 DEFAULT_SUPP="$srcdir/darwin12.supp ${DEFAULT_SUPP}"
515 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
518 AC_MSG_RESULT([Darwin 13.x (${kernel}) / Mac OS X 10.9 Mavericks])
519 AC_DEFINE([DARWIN_VERS], DARWIN_10_9, [Darwin / Mac OS X version])
520 DEFAULT_SUPP="$srcdir/darwin13.supp ${DEFAULT_SUPP}"
521 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
524 AC_MSG_RESULT([Darwin 14.x (${kernel}) / Mac OS X 10.10 Yosemite])
525 AC_DEFINE([DARWIN_VERS], DARWIN_10_10, [Darwin / Mac OS X version])
526 DEFAULT_SUPP="$srcdir/darwin14.supp ${DEFAULT_SUPP}"
527 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
530 AC_MSG_RESULT([Darwin 15.x (${kernel}) / Mac OS X 10.11 El Capitan])
531 AC_DEFINE([DARWIN_VERS], DARWIN_10_11, [Darwin / Mac OS X version])
532 DEFAULT_SUPP="$srcdir/darwin15.supp ${DEFAULT_SUPP}"
533 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
536 AC_MSG_RESULT([Darwin 16.x (${kernel}) / macOS 10.12 Sierra])
537 AC_DEFINE([DARWIN_VERS], DARWIN_10_12, [Darwin / Mac OS X version])
538 DEFAULT_SUPP="$srcdir/darwin16.supp ${DEFAULT_SUPP}"
539 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
542 AC_MSG_RESULT([Darwin 17.x (${kernel}) / macOS 10.13 High Sierra])
543 AC_DEFINE([DARWIN_VERS], DARWIN_10_13, [Darwin / Mac OS X version])
544 DEFAULT_SUPP="$srcdir/darwin17.supp ${DEFAULT_SUPP}"
545 DEFAULT_SUPP="$srcdir/darwin10-drd.supp ${DEFAULT_SUPP}"
548 AC_MSG_RESULT([unsupported (${kernel})])
549 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)])
555 AC_MSG_RESULT([ok (${host_os})])
558 uname_v=$( uname -v )
561 DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
564 DEFAULT_SUPP="$srcdir/solaris11.supp ${DEFAULT_SUPP}"
570 AC_MSG_RESULT([ok (${host_os})])
572 DEFAULT_SUPP="$srcdir/solaris12.supp ${DEFAULT_SUPP}"
576 AC_MSG_RESULT([no (${host_os})])
577 AC_MSG_ERROR([Valgrind is operating system specific. Sorry.])
581 #----------------------------------------------------------------------------
583 # If we are building on a 64 bit platform test to see if the system
584 # supports building 32 bit programs and disable 32 bit support if it
585 # does not support building 32 bit programs
587 case "$ARCH_MAX-$VGCONF_OS" in
588 amd64-linux|ppc64be-linux|arm64-linux|amd64-solaris)
589 AC_MSG_CHECKING([for 32 bit build support])
592 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
597 vg_cv_only64bit="yes"
600 CFLAGS=$safe_CFLAGS;;
602 AC_MSG_CHECKING([for 32 bit build support])
604 CFLAGS="$CFLAGS -mips32 -mabi=32"
605 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
606 #include <sys/prctl.h>
610 vg_cv_only64bit="yes"
613 CFLAGS=$safe_CFLAGS;;
616 if test x$vg_cv_only64bit = xyes -a x$vg_cv_only32bit = xyes; then
618 [--enable-only32bit was specified but system does not support 32 bit builds])
621 #----------------------------------------------------------------------------
623 # VGCONF_ARCH_PRI is the arch for the primary build target, eg. "amd64". By
624 # default it's the same as ARCH_MAX. But if, say, we do a build on an amd64
625 # machine, but --enable-only32bit has been requested, then ARCH_MAX (see
626 # above) will be "amd64" since that reflects the most that this cpu can do,
627 # but VGCONF_ARCH_PRI will be downgraded to "x86", since that reflects the
628 # arch corresponding to the primary build (VGCONF_PLATFORM_PRI_CAPS). It is
629 # passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_PRI) and
630 # -VGP_$(VGCONF_ARCH_PRI)_$(VGCONF_OS).
631 AC_SUBST(VGCONF_ARCH_PRI)
633 # VGCONF_ARCH_SEC is the arch for the secondary build target, eg. "x86".
634 # It is passed in to compilation of many C files via -VGA_$(VGCONF_ARCH_SEC)
635 # and -VGP_$(VGCONF_ARCH_SEC)_$(VGCONF_OS), if there is a secondary target.
636 # It is empty if there is no secondary target.
637 AC_SUBST(VGCONF_ARCH_SEC)
639 # VGCONF_PLATFORM_PRI_CAPS is the primary build target, eg. "AMD64_LINUX".
640 # The entire system, including regression and performance tests, will be
641 # built for this target. The "_CAPS" indicates that the name is in capital
642 # letters, and it also uses '_' rather than '-' as a separator, because it's
643 # used to create various Makefile variables, which are all in caps by
644 # convention and cannot contain '-' characters. This is in contrast to
645 # VGCONF_ARCH_PRI and VGCONF_OS which are not in caps.
646 AC_SUBST(VGCONF_PLATFORM_PRI_CAPS)
648 # VGCONF_PLATFORM_SEC_CAPS is the secondary build target, if there is one.
649 # Valgrind and tools will also be built for this target, but not the
650 # regression or performance tests.
652 # By default, the primary arch is the same as the "max" arch, as commented
653 # above (at the definition of ARCH_MAX). We may choose to downgrade it in
654 # the big case statement just below here, in the case where we're building
655 # on a 64 bit machine but have been requested only to do a 32 bit build.
656 AC_SUBST(VGCONF_PLATFORM_SEC_CAPS)
658 AC_MSG_CHECKING([for a supported CPU/OS combination])
660 # NB. The load address for a given platform may be specified in more
661 # than one place, in some cases, depending on whether we're doing a biarch,
662 # 32-bit only or 64-bit only build. eg see case for amd64-linux below.
663 # Be careful to give consistent values in all subcases. Also, all four
664 # valt_load_addres_{pri,sec}_{norml,inner} values must always be set,
665 # even if it is to "0xUNSET".
667 case "$ARCH_MAX-$VGCONF_OS" in
669 VGCONF_ARCH_PRI="x86"
671 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
672 VGCONF_PLATFORM_SEC_CAPS=""
673 valt_load_address_pri_norml="0x58000000"
674 valt_load_address_pri_inner="0x38000000"
675 valt_load_address_sec_norml="0xUNSET"
676 valt_load_address_sec_inner="0xUNSET"
677 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
680 valt_load_address_sec_norml="0xUNSET"
681 valt_load_address_sec_inner="0xUNSET"
682 if test x$vg_cv_only64bit = xyes; then
683 VGCONF_ARCH_PRI="amd64"
685 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
686 VGCONF_PLATFORM_SEC_CAPS=""
687 valt_load_address_pri_norml="0x58000000"
688 valt_load_address_pri_inner="0x38000000"
689 elif test x$vg_cv_only32bit = xyes; then
690 VGCONF_ARCH_PRI="x86"
692 VGCONF_PLATFORM_PRI_CAPS="X86_LINUX"
693 VGCONF_PLATFORM_SEC_CAPS=""
694 valt_load_address_pri_norml="0x58000000"
695 valt_load_address_pri_inner="0x38000000"
697 VGCONF_ARCH_PRI="amd64"
698 VGCONF_ARCH_SEC="x86"
699 VGCONF_PLATFORM_PRI_CAPS="AMD64_LINUX"
700 VGCONF_PLATFORM_SEC_CAPS="X86_LINUX"
701 valt_load_address_pri_norml="0x58000000"
702 valt_load_address_pri_inner="0x38000000"
703 valt_load_address_sec_norml="0x58000000"
704 valt_load_address_sec_inner="0x38000000"
706 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
709 VGCONF_ARCH_PRI="ppc32"
711 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
712 VGCONF_PLATFORM_SEC_CAPS=""
713 valt_load_address_pri_norml="0x58000000"
714 valt_load_address_pri_inner="0x38000000"
715 valt_load_address_sec_norml="0xUNSET"
716 valt_load_address_sec_inner="0xUNSET"
717 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
720 valt_load_address_sec_norml="0xUNSET"
721 valt_load_address_sec_inner="0xUNSET"
722 if test x$vg_cv_only64bit = xyes; then
723 VGCONF_ARCH_PRI="ppc64be"
725 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
726 VGCONF_PLATFORM_SEC_CAPS=""
727 valt_load_address_pri_norml="0x58000000"
728 valt_load_address_pri_inner="0x38000000"
729 elif test x$vg_cv_only32bit = xyes; then
730 VGCONF_ARCH_PRI="ppc32"
732 VGCONF_PLATFORM_PRI_CAPS="PPC32_LINUX"
733 VGCONF_PLATFORM_SEC_CAPS=""
734 valt_load_address_pri_norml="0x58000000"
735 valt_load_address_pri_inner="0x38000000"
737 VGCONF_ARCH_PRI="ppc64be"
738 VGCONF_ARCH_SEC="ppc32"
739 VGCONF_PLATFORM_PRI_CAPS="PPC64BE_LINUX"
740 VGCONF_PLATFORM_SEC_CAPS="PPC32_LINUX"
741 valt_load_address_pri_norml="0x58000000"
742 valt_load_address_pri_inner="0x38000000"
743 valt_load_address_sec_norml="0x58000000"
744 valt_load_address_sec_inner="0x38000000"
746 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
749 # Little Endian is only supported on PPC64
750 valt_load_address_sec_norml="0xUNSET"
751 valt_load_address_sec_inner="0xUNSET"
752 VGCONF_ARCH_PRI="ppc64le"
754 VGCONF_PLATFORM_PRI_CAPS="PPC64LE_LINUX"
755 VGCONF_PLATFORM_SEC_CAPS=""
756 valt_load_address_pri_norml="0x58000000"
757 valt_load_address_pri_inner="0x38000000"
758 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
761 VGCONF_ARCH_PRI="x86"
763 VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
764 VGCONF_PLATFORM_SEC_CAPS=""
765 valt_load_address_pri_norml="0x38000000"
766 valt_load_address_pri_inner="0x28000000"
767 valt_load_address_sec_norml="0xUNSET"
768 valt_load_address_sec_inner="0xUNSET"
769 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
772 if test x$vg_cv_only64bit = xyes; then
773 VGCONF_ARCH_PRI="amd64"
775 VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
776 VGCONF_PLATFORM_SEC_CAPS=""
777 elif test x$vg_cv_only32bit = xyes; then
778 VGCONF_ARCH_PRI="x86"
780 VGCONF_PLATFORM_PRI_CAPS="X86_FREEBSD"
781 VGCONF_PLATFORM_SEC_CAPS=""
783 VGCONF_ARCH_PRI="amd64"
784 VGCONF_ARCH_SEC="x86"
785 VGCONF_PLATFORM_PRI_CAPS="AMD64_FREEBSD"
786 VGCONF_PLATFORM_SEC_CAPS="X86_FREEBSD"
788 # These work with either base clang or ports installed gcc
789 # Hand rolled compilers probably need INSTALL_DIR/lib (at least for gcc)
790 if test x$is_clang = xclang ; then
791 FLAG_32ON64="-B/usr/lib32"
793 GCC_MAJOR_VERSION=`${CC} -dumpversion | $SED 's/\..*//' 2>/dev/null`
794 FLAG_32ON64="-B/usr/local/lib32/gcc${GCC_MAJOR_VERSION} -Wl,-rpath,/usr/local/lib32/gcc${GCC_MAJOR_VERSION}/"
796 valt_load_address_pri_norml="0x38000000"
797 valt_load_address_pri_inner="0x28000000"
798 valt_load_address_sec_norml="0x38000000"
799 valt_load_address_sec_inner="0x28000000"
800 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
802 # Darwin gets identified as 32-bit even when it supports 64-bit.
803 # (Not sure why, possibly because 'uname' returns "i386"?) Just about
804 # all Macs support both 32-bit and 64-bit, so we just build both. If
805 # someone has a really old 32-bit only machine they can (hopefully?)
806 # build with --enable-only32bit. See bug 243362.
807 x86-darwin|amd64-darwin)
809 valt_load_address_sec_norml="0xUNSET"
810 valt_load_address_sec_inner="0xUNSET"
811 if test x$vg_cv_only64bit = xyes; then
812 VGCONF_ARCH_PRI="amd64"
814 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
815 VGCONF_PLATFORM_SEC_CAPS=""
816 valt_load_address_pri_norml="0x158000000"
817 valt_load_address_pri_inner="0x138000000"
818 elif test x$vg_cv_only32bit = xyes; then
819 VGCONF_ARCH_PRI="x86"
821 VGCONF_PLATFORM_PRI_CAPS="X86_DARWIN"
822 VGCONF_PLATFORM_SEC_CAPS=""
823 VGCONF_ARCH_PRI_CAPS="x86"
824 valt_load_address_pri_norml="0x58000000"
825 valt_load_address_pri_inner="0x38000000"
827 VGCONF_ARCH_PRI="amd64"
828 VGCONF_ARCH_SEC="x86"
829 VGCONF_PLATFORM_PRI_CAPS="AMD64_DARWIN"
830 VGCONF_PLATFORM_SEC_CAPS="X86_DARWIN"
831 valt_load_address_pri_norml="0x158000000"
832 valt_load_address_pri_inner="0x138000000"
833 valt_load_address_sec_norml="0x58000000"
834 valt_load_address_sec_inner="0x38000000"
836 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
839 VGCONF_ARCH_PRI="arm"
840 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
841 VGCONF_PLATFORM_SEC_CAPS=""
842 valt_load_address_pri_norml="0x58000000"
843 valt_load_address_pri_inner="0x38000000"
844 valt_load_address_sec_norml="0xUNSET"
845 valt_load_address_sec_inner="0xUNSET"
846 AC_MSG_RESULT([ok (${host_cpu}-${host_os})])
849 valt_load_address_sec_norml="0xUNSET"
850 valt_load_address_sec_inner="0xUNSET"
851 if test x$vg_cv_only64bit = xyes; then
852 VGCONF_ARCH_PRI="arm64"
854 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
855 VGCONF_PLATFORM_SEC_CAPS=""
856 valt_load_address_pri_norml="0x58000000"
857 valt_load_address_pri_inner="0x38000000"
858 elif test x$vg_cv_only32bit = xyes; then
859 VGCONF_ARCH_PRI="arm"
861 VGCONF_PLATFORM_PRI_CAPS="ARM_LINUX"
862 VGCONF_PLATFORM_SEC_CAPS=""
863 valt_load_address_pri_norml="0x58000000"
864 valt_load_address_pri_inner="0x38000000"
866 VGCONF_ARCH_PRI="arm64"
867 VGCONF_ARCH_SEC="arm"
868 VGCONF_PLATFORM_PRI_CAPS="ARM64_LINUX"
869 VGCONF_PLATFORM_SEC_CAPS="ARM_LINUX"
870 valt_load_address_pri_norml="0x58000000"
871 valt_load_address_pri_inner="0x38000000"
872 valt_load_address_sec_norml="0x58000000"
873 valt_load_address_sec_inner="0x38000000"
875 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
878 VGCONF_ARCH_PRI="s390x"
880 VGCONF_PLATFORM_PRI_CAPS="S390X_LINUX"
881 VGCONF_PLATFORM_SEC_CAPS=""
882 # To improve branch prediction hit rate we want to have
883 # the generated code close to valgrind (host) code
884 valt_load_address_pri_norml="0x800000000"
885 valt_load_address_pri_inner="0x810000000"
886 valt_load_address_sec_norml="0xUNSET"
887 valt_load_address_sec_inner="0xUNSET"
888 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
891 VGCONF_ARCH_PRI="mips32"
893 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
894 VGCONF_PLATFORM_SEC_CAPS=""
895 valt_load_address_pri_norml="0x58000000"
896 valt_load_address_pri_inner="0x38000000"
897 valt_load_address_sec_norml="0xUNSET"
898 valt_load_address_sec_inner="0xUNSET"
899 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
902 valt_load_address_sec_norml="0xUNSET"
903 valt_load_address_sec_inner="0xUNSET"
904 if test x$vg_cv_only64bit = xyes; then
905 VGCONF_ARCH_PRI="mips64"
906 VGCONF_PLATFORM_SEC_CAPS=""
907 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
908 VGCONF_PLATFORM_SEC_CAPS=""
909 valt_load_address_pri_norml="0x58000000"
910 valt_load_address_pri_inner="0x38000000"
911 elif test x$vg_cv_only32bit = xyes; then
912 VGCONF_ARCH_PRI="mips32"
914 VGCONF_PLATFORM_PRI_CAPS="MIPS32_LINUX"
915 VGCONF_PLATFORM_SEC_CAPS=""
916 valt_load_address_pri_norml="0x58000000"
917 valt_load_address_pri_inner="0x38000000"
919 VGCONF_ARCH_PRI="mips64"
920 VGCONF_ARCH_SEC="mips32"
921 VGCONF_PLATFORM_PRI_CAPS="MIPS64_LINUX"
922 VGCONF_PLATFORM_SEC_CAPS="MIPS32_LINUX"
923 valt_load_address_pri_norml="0x58000000"
924 valt_load_address_pri_inner="0x38000000"
925 valt_load_address_sec_norml="0x58000000"
926 valt_load_address_sec_inner="0x38000000"
928 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
931 VGCONF_ARCH_PRI="nanomips"
933 VGCONF_PLATFORM_PRI_CAPS="NANOMIPS_LINUX"
934 VGCONF_PLATFORM_SEC_CAPS=""
935 valt_load_address_pri_norml="0x58000000"
936 valt_load_address_pri_inner="0x38000000"
937 valt_load_address_sec_norml="0xUNSET"
938 valt_load_address_sec_inner="0xUNSET"
939 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
942 VGCONF_ARCH_PRI="x86"
944 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
945 VGCONF_PLATFORM_SEC_CAPS=""
946 valt_load_address_pri_norml="0x58000000"
947 valt_load_address_pri_inner="0x38000000"
948 valt_load_address_sec_norml="0xUNSET"
949 valt_load_address_sec_inner="0xUNSET"
950 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
953 valt_load_address_sec_norml="0xUNSET"
954 valt_load_address_sec_inner="0xUNSET"
955 if test x$vg_cv_only64bit = xyes; then
956 VGCONF_ARCH_PRI="amd64"
958 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
959 VGCONF_PLATFORM_SEC_CAPS=""
960 valt_load_address_pri_norml="0x58000000"
961 valt_load_address_pri_inner="0x38000000"
962 elif test x$vg_cv_only32bit = xyes; then
963 VGCONF_ARCH_PRI="x86"
965 VGCONF_PLATFORM_PRI_CAPS="X86_SOLARIS"
966 VGCONF_PLATFORM_SEC_CAPS=""
967 valt_load_address_pri_norml="0x58000000"
968 valt_load_address_pri_inner="0x38000000"
970 VGCONF_ARCH_PRI="amd64"
971 VGCONF_ARCH_SEC="x86"
972 VGCONF_PLATFORM_PRI_CAPS="AMD64_SOLARIS"
973 VGCONF_PLATFORM_SEC_CAPS="X86_SOLARIS"
974 valt_load_address_pri_norml="0x58000000"
975 valt_load_address_pri_inner="0x38000000"
976 valt_load_address_sec_norml="0x58000000"
977 valt_load_address_sec_inner="0x38000000"
979 AC_MSG_RESULT([ok (${ARCH_MAX}-${VGCONF_OS})])
982 VGCONF_ARCH_PRI="unknown"
983 VGCONF_ARCH_SEC="unknown"
984 VGCONF_PLATFORM_PRI_CAPS="UNKNOWN"
985 VGCONF_PLATFORM_SEC_CAPS="UNKNOWN"
986 valt_load_address_pri_norml="0xUNSET"
987 valt_load_address_pri_inner="0xUNSET"
988 valt_load_address_sec_norml="0xUNSET"
989 valt_load_address_sec_inner="0xUNSET"
990 AC_MSG_RESULT([no (${ARCH_MAX}-${VGCONF_OS})])
991 AC_MSG_ERROR([Valgrind is platform specific. Sorry. Please consider doing a port.])
995 #----------------------------------------------------------------------------
997 # Set up VGCONF_ARCHS_INCLUDE_<arch>. Either one or two of these become
999 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_X86,
1000 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1001 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
1002 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1003 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD \
1004 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1005 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN \
1006 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1007 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS )
1008 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_AMD64,
1009 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1010 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1011 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN \
1012 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS )
1013 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC32,
1014 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1015 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX )
1016 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_PPC64,
1017 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1018 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX )
1019 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM,
1020 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1021 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX )
1022 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_ARM64,
1023 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX )
1024 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_S390X,
1025 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX )
1026 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS32,
1027 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1028 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX )
1029 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_MIPS64,
1030 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX )
1031 AM_CONDITIONAL(VGCONF_ARCHS_INCLUDE_NANOMIPS,
1032 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX )
1034 # Set up VGCONF_PLATFORMS_INCLUDE_<platform>. Either one or two of these
1036 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_LINUX,
1037 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1038 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX)
1039 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_LINUX,
1040 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX)
1041 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC32_LINUX,
1042 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1043 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX)
1044 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64BE_LINUX,
1045 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX)
1046 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_PPC64LE_LINUX,
1047 test x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX)
1048 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM_LINUX,
1049 test x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1050 -o x$VGCONF_PLATFORM_SEC_CAPS = xARM_LINUX)
1051 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_ARM64_LINUX,
1052 test x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX)
1053 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_S390X_LINUX,
1054 test x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1055 -o x$VGCONF_PLATFORM_SEC_CAPS = xS390X_LINUX)
1056 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS32_LINUX,
1057 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1058 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX)
1059 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_MIPS64_LINUX,
1060 test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX)
1061 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_NANOMIPS_LINUX,
1062 test x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1063 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_FREEBSD,
1064 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1065 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD)
1066 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_FREEBSD,
1067 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1068 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_DARWIN,
1069 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1070 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN)
1071 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_DARWIN,
1072 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1073 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_X86_SOLARIS,
1074 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1075 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS)
1076 AM_CONDITIONAL(VGCONF_PLATFORMS_INCLUDE_AMD64_SOLARIS,
1077 test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1080 # Similarly, set up VGCONF_OS_IS_<os>. Exactly one of these becomes defined.
1081 # Relies on the assumption that the primary and secondary targets are
1082 # for the same OS, so therefore only necessary to test the primary.
1083 AM_CONDITIONAL(VGCONF_OS_IS_LINUX,
1084 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
1085 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
1086 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
1087 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64BE_LINUX \
1088 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64LE_LINUX \
1089 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
1090 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
1091 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX \
1092 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
1093 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
1094 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX)
1095 AM_CONDITIONAL(VGCONF_OS_IS_FREEBSD,
1096 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1097 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD)
1098 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN,
1099 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1100 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1101 AM_CONDITIONAL(VGCONF_OS_IS_SOLARIS,
1102 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1103 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS)
1104 AM_CONDITIONAL(VGCONF_OS_IS_DARWIN_OR_FREEBSD,
1105 test x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
1106 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
1107 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN \
1108 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN)
1111 # Sometimes, in the Makefile.am files, it's useful to know whether or not
1112 # there is a secondary target.
1113 AM_CONDITIONAL(VGCONF_HAVE_PLATFORM_SEC,
1114 test x$VGCONF_PLATFORM_SEC_CAPS != x)
1116 dnl automake-1.10 does not have AM_COND_IF (added in 1.11), so we supply a
1117 dnl fallback definition
1118 dnl The macro is courtesy of Dave Hart:
1119 dnl https://lists.gnu.org/archive/html/automake/2010-12/msg00045.html
1120 m4_ifndef([AM_COND_IF], [AC_DEFUN([AM_COND_IF], [
1121 if test -z "$$1_TRUE"; then :
1130 #----------------------------------------------------------------------------
1132 #----------------------------------------------------------------------------
1134 # Check if this should be built as an inner Valgrind, to be run within
1135 # another Valgrind. Choose the load address accordingly.
1136 AC_SUBST(VALT_LOAD_ADDRESS_PRI)
1137 AC_SUBST(VALT_LOAD_ADDRESS_SEC)
1138 AC_CACHE_CHECK([for use as an inner Valgrind], vg_cv_inner,
1139 [AC_ARG_ENABLE(inner,
1140 [ --enable-inner enables self-hosting],
1141 [vg_cv_inner=$enableval],
1143 if test "$vg_cv_inner" = yes; then
1144 AC_DEFINE([ENABLE_INNER], 1, [configured to run as an inner Valgrind])
1145 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_inner
1146 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_inner
1148 VALT_LOAD_ADDRESS_PRI=$valt_load_address_pri_norml
1149 VALT_LOAD_ADDRESS_SEC=$valt_load_address_sec_norml
1152 #----------------------------------------------------------------------------
1153 # Undefined behaviour sanitiser
1154 #----------------------------------------------------------------------------
1155 # Check whether we should build with the undefined beahviour sanitiser.
1157 AC_CACHE_CHECK([for using the undefined behaviour sanitiser], vg_cv_ubsan,
1158 [AC_ARG_ENABLE(ubsan,
1159 [ --enable-ubsan enables the undefined behaviour sanitiser],
1160 [vg_cv_ubsan=$enableval],
1163 #----------------------------------------------------------------------------
1164 # Extra fine-tuning of installation directories
1165 #----------------------------------------------------------------------------
1167 [ --with-tmpdir=PATH Specify path for temporary files],
1170 AC_DEFINE_UNQUOTED(VG_TMPDIR, "$tmpdir", [Temporary files directory])
1171 AC_SUBST(VG_TMPDIR, [$tmpdir])
1173 #----------------------------------------------------------------------------
1175 #----------------------------------------------------------------------------
1176 AM_COND_IF([VGCONF_OS_IS_DARWIN],
1177 [AC_CHECK_PROG([XCRUN], [xcrun], [yes], [no])
1178 AC_MSG_CHECKING([for xcode sdk include path])
1179 AC_ARG_WITH(xcodedir,
1180 [ --with-xcode-path=PATH Specify path for xcode sdk includes],
1181 [xcodedir="$withval"],
1183 if test "x$XCRUN" != "xno" -a ! -d /usr/include; then
1184 xcrundir=`xcrun --sdk macosx --show-sdk-path`
1185 if test -z "$xcrundir"; then
1186 xcodedir="/usr/include"
1188 xcodedir="$xcrundir/usr/include"
1191 xcodedir="/usr/include"
1194 AC_MSG_RESULT([$xcodedir])
1195 AC_DEFINE_UNQUOTED(XCODE_DIR, "$xcodedir", [xcode sdk include directory])
1196 AC_SUBST(XCODE_DIR, [$xcodedir])])
1198 #----------------------------------------------------------------------------
1199 # Libc and suppressions
1200 #----------------------------------------------------------------------------
1201 # This variable will collect the suppression files to be used.
1202 AC_SUBST(DEFAULT_SUPP)
1204 AC_CHECK_HEADER([features.h])
1206 if test x$ac_cv_header_features_h = xyes; then
1207 rm -f conftest.$ac_ext
1208 cat <<_ACEOF >conftest.$ac_ext
1209 #include <features.h>
1210 #if defined(__GNU_LIBRARY__) && defined(__GLIBC__) && defined(__GLIBC_MINOR__)
1211 glibc version is: __GLIBC__ __GLIBC_MINOR__
1214 GLIBC_VERSION="`$CPP -P conftest.$ac_ext | $SED -n 's/^glibc version is: //p' | $SED 's/ /./g'`"
1217 # not really a version check
1218 AC_EGREP_CPP([DARWIN_LIBC], [
1219 #include <sys/cdefs.h>
1220 #if defined(__DARWIN_VERS_1050)
1224 GLIBC_VERSION="darwin")
1226 AC_EGREP_CPP([FREEBSD_LIBC], [
1227 #include <sys/cdefs.h>
1228 #if defined(__FreeBSD__)
1232 GLIBC_VERSION="freebsd")
1234 # not really a version check
1235 AC_EGREP_CPP([BIONIC_LIBC], [
1236 #if defined(__ANDROID__)
1240 GLIBC_VERSION="bionic")
1242 # there is only one version of libc on Solaris
1243 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS \
1244 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_SOLARIS; then
1245 GLIBC_VERSION="solaris"
1248 # GLIBC_VERSION is empty if a musl libc is used, so use the toolchain tuple
1250 if test x$GLIBC_VERSION = x; then
1251 if $CC -dumpmachine | grep -q musl; then
1256 # If this is glibc then figure out the generic (in file) libc.so and
1257 # libpthread.so file paths to use in suppressions. Before 2.34 libpthread
1258 # was a separate library, afterwards it was merged into libc.so and
1259 # the library is called libc.so.6 (before it was libc-2.[0-9]+.so).
1260 # Use this fact to set GLIBC_LIBC_PATH and GLIBC_LIBPTHREAD_PATH.
1261 case ${GLIBC_VERSION} in
1263 AC_MSG_CHECKING([whether pthread_create needs libpthread])
1264 AC_LINK_IFELSE([AC_LANG_CALL([], [pthread_create])],
1267 GLIBC_LIBC_PATH="*/lib*/libc.so.6"
1268 GLIBC_LIBPTHREAD_PATH="$GLIBC_LIBC_PATH"
1270 AC_MSG_RESULT([yes])
1271 GLIBC_LIBC_PATH="*/lib*/libc-2.*so*"
1272 GLIBC_LIBPTHREAD_PATH="*/lib*/libpthread-2.*so*"
1276 AC_MSG_CHECKING([not glibc...])
1277 AC_MSG_RESULT([${GLIBC_VERSION}])
1281 AC_MSG_CHECKING([the glibc version])
1283 case "${GLIBC_VERSION}" in
1285 AC_MSG_RESULT(${GLIBC_VERSION} family)
1286 DEFAULT_SUPP="$srcdir/glibc-2.2.supp ${DEFAULT_SUPP}"
1287 DEFAULT_SUPP="$srcdir/glibc-2.2-LinuxThreads-helgrind.supp ${DEFAULT_SUPP}"
1288 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1291 AC_MSG_RESULT(${GLIBC_VERSION} family)
1292 DEFAULT_SUPP="$srcdir/glibc-${GLIBC_VERSION}.supp ${DEFAULT_SUPP}"
1293 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1294 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1297 AC_MSG_RESULT(${GLIBC_VERSION} family)
1298 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1299 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1300 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1303 AC_MSG_RESULT(${GLIBC_VERSION} family)
1304 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1305 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1306 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1307 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1308 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1311 AC_MSG_RESULT(${GLIBC_VERSION} family)
1312 AC_DEFINE([GLIBC_MANDATORY_STRLEN_REDIRECT], 1,
1313 [Define to 1 if strlen() has been optimized heavily (amd64 glibc >= 2.10)])
1314 AC_DEFINE([GLIBC_MANDATORY_INDEX_AND_STRLEN_REDIRECT], 1,
1315 [Define to 1 if index() and strlen() have been optimized heavily (x86 glibc >= 2.12)])
1316 DEFAULT_SUPP="glibc-2.X.supp ${DEFAULT_SUPP}"
1317 DEFAULT_SUPP="glibc-2.X-helgrind.supp ${DEFAULT_SUPP}"
1318 DEFAULT_SUPP="glibc-2.X-drd.supp ${DEFAULT_SUPP}"
1321 AC_MSG_RESULT(Darwin)
1322 AC_DEFINE([DARWIN_LIBC], 1, [Define to 1 if you're using Darwin])
1323 # DEFAULT_SUPP set by kernel version check above.
1326 AC_MSG_RESULT(FreeBSD)
1327 AC_DEFINE([FREEBSD_LIBC], 1, [Define to 1 if you're using FreeBSD])
1328 # DEFAULT_SUPP set by kernel version check above.
1331 AC_MSG_RESULT(Bionic)
1332 AC_DEFINE([BIONIC_LIBC], 1, [Define to 1 if you're using Bionic])
1333 DEFAULT_SUPP="$srcdir/bionic.supp ${DEFAULT_SUPP}"
1336 AC_MSG_RESULT(Solaris)
1337 # DEFAULT_SUPP set in host_os switch-case above.
1338 # No other suppression file is used.
1342 AC_DEFINE([MUSL_LIBC], 1, [Define to 1 if you're using Musl libc])
1343 DEFAULT_SUPP="$srcdir/musl.supp ${DEFAULT_SUPP}"
1346 AC_MSG_RESULT([unsupported version ${GLIBC_VERSION}])
1347 AC_MSG_ERROR([Valgrind requires glibc version 2.2 or later, uClibc,])
1348 AC_MSG_ERROR([musl libc, Darwin libc, Bionic libc or Solaris libc])
1352 AC_SUBST(GLIBC_VERSION)
1353 AC_SUBST(GLIBC_LIBC_PATH)
1354 AC_SUBST(GLIBC_LIBPTHREAD_PATH)
1357 if test "$VGCONF_OS" != "solaris"; then
1358 # Add default suppressions for the X client libraries. Make no
1359 # attempt to detect whether such libraries are installed on the
1360 # build machine (or even if any X facilities are present); just
1361 # add the suppressions antidisirregardless.
1362 DEFAULT_SUPP="$srcdir/xfree-4.supp ${DEFAULT_SUPP}"
1363 DEFAULT_SUPP="$srcdir/xfree-3.supp ${DEFAULT_SUPP}"
1367 #----------------------------------------------------------------------------
1368 # Platform variants?
1369 #----------------------------------------------------------------------------
1371 # Normally the PLAT = (ARCH, OS) characterisation of the platform is enough.
1372 # But there are times where we need a bit more control. The motivating
1373 # and currently only case is Android: this is almost identical to
1374 # {x86,arm,mips}-linux, but not quite. So this introduces the concept of
1375 # platform variant tags, which get passed in the compile as
1376 # -DVGPV_<arch>_<os>_<variant> along with the main -DVGP_<arch>_<os> definition.
1378 # In almost all cases, the <variant> bit is "vanilla". But for Android
1379 # it is "android" instead.
1381 # Consequently (eg), plain arm-linux would build with
1383 # -DVGP_arm_linux -DVGPV_arm_linux_vanilla
1385 # whilst an Android build would have
1387 # -DVGP_arm_linux -DVGPV_arm_linux_android
1389 # Same for x86. The setup of the platform variant is pushed relatively far
1390 # down this file in order that we can inspect any of the variables set above.
1392 # In the normal case ..
1393 VGCONF_PLATVARIANT="vanilla"
1396 if test "$GLIBC_VERSION" = "bionic";
1398 VGCONF_PLATVARIANT="android"
1401 AC_SUBST(VGCONF_PLATVARIANT)
1404 # FIXME: do we also want to define automake variables
1405 # VGCONF_PLATVARIANT_IS_<WHATEVER>, where WHATEVER is (currently)
1406 # VANILLA or ANDROID ? This would be in the style of VGCONF_ARCHS_INCLUDE,
1407 # VGCONF_PLATFORMS_INCLUDE and VGCONF_OS_IS above? Could easily enough
1408 # do that. Problem is that we can't do and-ing in Makefile.am's, but
1409 # that's what we'd need to do to use this, since what we'd want to write
1412 # VGCONF_PLATFORMS_INCLUDE_ARM_LINUX && VGCONF_PLATVARIANT_IS_ANDROID
1414 # Hmm. Can't think of a nice clean solution to this.
1416 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_VANILLA,
1417 test x$VGCONF_PLATVARIANT = xvanilla)
1418 AM_CONDITIONAL(VGCONF_PLATVARIANT_IS_ANDROID,
1419 test x$VGCONF_PLATVARIANT = xandroid)
1422 #----------------------------------------------------------------------------
1423 # Checking for various library functions and other definitions
1424 #----------------------------------------------------------------------------
1426 # Check for AT_FDCWD
1428 AC_MSG_CHECKING([for AT_FDCWD])
1429 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1436 ac_have_at_fdcwd=yes
1437 AC_MSG_RESULT([yes])
1443 AM_CONDITIONAL([HAVE_AT_FDCWD], [test x$ac_have_at_fdcwd = xyes])
1445 # Check for stpncpy function definition in string.h
1446 # This explicitly checks with _GNU_SOURCE defined since that is also
1447 # used in the test case (some systems might define it without anyway
1448 # since stpncpy is part of The Open Group Base Specifications Issue 7
1449 # IEEE Std 1003.1-2008.
1450 AC_MSG_CHECKING([for stpncpy])
1451 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1458 char *r = stpncpy(d, s, n);
1460 ac_have_gnu_stpncpy=yes
1461 AC_MSG_RESULT([yes])
1463 ac_have_gnu_stpncpy=no
1467 AM_CONDITIONAL([HAVE_GNU_STPNCPY], [test x$ac_have_gnu_stpncpy = xyes])
1469 # Check for PTRACE_GETREGS
1471 AC_MSG_CHECKING([for PTRACE_GETREGS])
1472 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1475 #include <sys/ptrace.h>
1476 #include <sys/user.h>
1479 long res = ptrace (PTRACE_GETREGS, 0, p, p);
1481 AC_MSG_RESULT([yes])
1482 AC_DEFINE([HAVE_PTRACE_GETREGS], 1,
1483 [Define to 1 if you have the `PTRACE_GETREGS' ptrace request.])
1489 # Check for CLOCK_MONOTONIC
1491 AC_MSG_CHECKING([for CLOCK_MONOTONIC])
1493 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1497 clock_gettime(CLOCK_MONOTONIC, &t);
1500 AC_MSG_RESULT([yes])
1501 AC_DEFINE([HAVE_CLOCK_MONOTONIC], 1,
1502 [Define to 1 if you have the `CLOCK_MONOTONIC' constant.])
1508 # Check for ELF32/64_CHDR
1510 AC_CHECK_TYPES([Elf32_Chdr, Elf64_Chdr], [], [], [[#include <elf.h>]])
1513 # Check for PTHREAD_RWLOCK_T
1515 AC_MSG_CHECKING([for pthread_rwlock_t])
1517 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1519 #include <pthread.h>
1521 pthread_rwlock_t rwl;
1523 AC_MSG_RESULT([yes])
1524 AC_DEFINE([HAVE_PTHREAD_RWLOCK_T], 1,
1525 [Define to 1 if you have the `pthread_rwlock_t' type.])
1531 # Check for PTHREAD_MUTEX_ADAPTIVE_NP
1533 AC_MSG_CHECKING([for PTHREAD_MUTEX_ADAPTIVE_NP])
1535 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1537 #include <pthread.h>
1539 return (PTHREAD_MUTEX_ADAPTIVE_NP);
1541 AC_MSG_RESULT([yes])
1542 AC_DEFINE([HAVE_PTHREAD_MUTEX_ADAPTIVE_NP], 1,
1543 [Define to 1 if you have the `PTHREAD_MUTEX_ADAPTIVE_NP' constant.])
1549 # Check for PTHREAD_MUTEX_ERRORCHECK_NP
1551 AC_MSG_CHECKING([for PTHREAD_MUTEX_ERRORCHECK_NP])
1553 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1555 #include <pthread.h>
1557 return (PTHREAD_MUTEX_ERRORCHECK_NP);
1559 AC_MSG_RESULT([yes])
1560 AC_DEFINE([HAVE_PTHREAD_MUTEX_ERRORCHECK_NP], 1,
1561 [Define to 1 if you have the `PTHREAD_MUTEX_ERRORCHECK_NP' constant.])
1567 # Check for PTHREAD_MUTEX_RECURSIVE_NP
1569 AC_MSG_CHECKING([for PTHREAD_MUTEX_RECURSIVE_NP])
1571 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1573 #include <pthread.h>
1575 return (PTHREAD_MUTEX_RECURSIVE_NP);
1577 AC_MSG_RESULT([yes])
1578 AC_DEFINE([HAVE_PTHREAD_MUTEX_RECURSIVE_NP], 1,
1579 [Define to 1 if you have the `PTHREAD_MUTEX_RECURSIVE_NP' constant.])
1585 # Check for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP
1587 AC_MSG_CHECKING([for PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP])
1589 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1591 #include <pthread.h>
1593 pthread_mutex_t m = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
1596 AC_MSG_RESULT([yes])
1597 AC_DEFINE([HAVE_PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP], 1,
1598 [Define to 1 if you have the `PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP' constant.])
1604 # Check whether pthread_mutex_t has a member called __m_kind.
1606 AC_CHECK_MEMBER([pthread_mutex_t.__m_kind],
1607 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__M_KIND],
1609 [Define to 1 if pthread_mutex_t has a member called __m_kind.])
1612 [#include <pthread.h>])
1615 # Check whether pthread_mutex_t has a member called __data.__kind.
1617 AC_CHECK_MEMBER([pthread_mutex_t.__data.__kind],
1618 [AC_DEFINE([HAVE_PTHREAD_MUTEX_T__DATA__KIND],
1620 [Define to 1 if pthread_mutex_t has a member __data.__kind.])
1623 [#include <pthread.h>])
1625 # Convenience function. Set flags based on the existing HWCAP entries.
1626 # The AT_HWCAP entries are generated by glibc, and are based on
1627 # functions supported by the hardware/system/libc.
1628 # Subsequent support for whether the capability will actually be utilized
1629 # will also be checked against the compiler capabilities.
1631 # AC_HWCAP_CONTAINS_FLAG[hwcap_string_to_match],[VARIABLE_TO_SET]
1632 AC_DEFUN([AC_HWCAP_CONTAINS_FLAG],[
1634 AC_MSG_CHECKING([if AT_HWCAP contains the $AUXV_CHECK_FOR indicator])
1635 if env LD_SHOW_AUXV=1 true | grep ^AT_HWCAP | grep -q -w ${AUXV_CHECK_FOR}
1637 AC_MSG_RESULT([yes])
1638 AC_SUBST([$2],[yes])
1645 # gather hardware capabilities. (hardware/kernel/libc)
1646 AC_HWCAP_CONTAINS_FLAG([altivec],[HWCAP_HAS_ALTIVEC])
1647 AC_HWCAP_CONTAINS_FLAG([vsx],[HWCAP_HAS_VSX])
1648 AC_HWCAP_CONTAINS_FLAG([dfp],[HWCAP_HAS_DFP])
1649 AC_HWCAP_CONTAINS_FLAG([arch_2_05],[HWCAP_HAS_ISA_2_05])
1650 AC_HWCAP_CONTAINS_FLAG([arch_2_06],[HWCAP_HAS_ISA_2_06])
1651 AC_HWCAP_CONTAINS_FLAG([arch_2_07],[HWCAP_HAS_ISA_2_07])
1652 AC_HWCAP_CONTAINS_FLAG([arch_3_00],[HWCAP_HAS_ISA_3_00])
1653 AC_HWCAP_CONTAINS_FLAG([arch_3_1],[HWCAP_HAS_ISA_3_1])
1654 AC_HWCAP_CONTAINS_FLAG([htm],[HWCAP_HAS_HTM])
1655 AC_HWCAP_CONTAINS_FLAG([mma],[HWCAP_HAS_MMA])
1658 AM_CONDITIONAL(HAS_ISA_2_05, [test x$HWCAP_HAS_ISA_2_05 = xyes])
1659 AM_CONDITIONAL(HAS_ISA_2_06, [test x$HWCAP_HAS_ISA_2_06 = xyes])
1660 # compiler support for isa 2.07 level instructions
1661 AC_MSG_CHECKING([that assembler knows ISA 2.07 instructions ])
1662 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1664 __asm__ __volatile__("mtvsrd 1,2 ");
1666 ac_asm_have_isa_2_07=yes
1667 AC_MSG_RESULT([yes])
1669 ac_asm_have_isa_2_07=no
1672 AM_CONDITIONAL(HAS_ISA_2_07, [test x$ac_asm_have_isa_2_07 = xyes \
1673 -a x$HWCAP_HAS_ISA_2_07 = xyes])
1675 # altivec (vsx) support.
1676 # does this compiler support -maltivec and does it have the include file
1678 AC_MSG_CHECKING([for Altivec support in the compiler ])
1680 CFLAGS="-maltivec -Werror"
1681 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1682 #include <altivec.h>
1684 vector unsigned int v;
1687 AC_MSG_RESULT([yes])
1693 AM_CONDITIONAL([HAS_ALTIVEC], [test x$ac_have_altivec = xyes \
1694 -a x$HWCAP_HAS_ALTIVEC = xyes])
1696 # Check that both: the compiler supports -mvsx and that the assembler
1697 # understands VSX instructions. If either of those doesn't work,
1698 # conclude that we can't do VSX.
1699 AC_MSG_CHECKING([for VSX compiler flag support])
1701 CFLAGS="-mvsx -Werror"
1702 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1705 ac_compiler_supports_vsx_flag=yes
1706 AC_MSG_RESULT([yes])
1708 ac_compiler_supports_vsx_flag=no
1713 AC_MSG_CHECKING([for VSX support in the assembler ])
1715 CFLAGS="-mvsx -Werror"
1716 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1717 #include <altivec.h>
1719 vector unsigned int v;
1720 __asm__ __volatile__("xsmaddadp 32, 32, 33" ::: "memory","cc");
1722 ac_compiler_supports_vsx=yes
1723 AC_MSG_RESULT([yes])
1725 ac_compiler_supports_vsx=no
1729 AM_CONDITIONAL([HAS_VSX], [test x$ac_compiler_supports_vsx_flag = xyes \
1730 -a x$ac_compiler_supports_vsx = xyes \
1731 -a x$HWCAP_HAS_VSX = xyes ])
1733 # DFP (Decimal Float)
1734 # The initial DFP support was added in Power 6. The dcffix instruction
1735 # support was added in Power 7.
1736 AC_MSG_CHECKING([that assembler knows DFP])
1737 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1740 __asm__ __volatile__("adtr 1, 2, 3")
1742 __asm__ __volatile__(".machine power7;\n" \
1748 AC_MSG_RESULT([yes])
1753 AC_MSG_CHECKING([that compiler knows -mhard-dfp switch])
1755 CFLAGS="-mhard-dfp -Werror"
1757 # The dcffix instruction is Power 7
1758 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1761 __asm__ __volatile__("adtr 1, 2, 3")
1763 __asm__ __volatile__(".machine power7;\n" \
1768 ac_compiler_have_dfp=yes
1769 AC_MSG_RESULT([yes])
1771 ac_compiler_have_dfp=no
1775 AM_CONDITIONAL(HAS_DFP, test x$ac_asm_have_dfp = xyes \
1776 -a x$ac_compiler_have_dfp = xyes \
1777 -a x$HWCAP_HAS_DFP = xyes )
1779 AC_MSG_CHECKING([that compiler knows DFP datatypes])
1780 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1782 _Decimal64 x = 0.0DD;
1784 ac_compiler_have_dfp_type=yes
1785 AC_MSG_RESULT([yes])
1787 ac_compiler_have_dfp_type=no
1790 AM_CONDITIONAL(BUILD_DFP_TESTS, test x$ac_compiler_have_dfp_type = xyes \
1791 -a x$HWCAP_HAS_DFP = xyes )
1794 # HTM (Hardware Transactional Memory)
1795 AC_MSG_CHECKING([if compiler accepts the -mhtm flag])
1797 CFLAGS="-mhtm -Werror"
1798 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1802 AC_MSG_RESULT([yes])
1803 ac_compiler_supports_htm=yes
1806 ac_compiler_supports_htm=no
1810 AC_MSG_CHECKING([if compiler can find the htm builtins])
1812 CFLAGS="-mhtm -Werror"
1813 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1815 if (__builtin_tbegin (0))
1818 AC_MSG_RESULT([yes])
1819 ac_compiler_sees_htm_builtins=yes
1822 ac_compiler_sees_htm_builtins=no
1826 AM_CONDITIONAL(SUPPORTS_HTM, test x$ac_compiler_supports_htm = xyes \
1827 -a x$ac_compiler_sees_htm_builtins = xyes \
1828 -a x$HWCAP_HAS_HTM = xyes )
1830 # isa 3.0 checking. (actually 3.0 or newer)
1831 AC_MSG_CHECKING([that assembler knows ISA 3.00 ])
1833 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1835 __asm__ __volatile__ (".machine power9;\n" \
1838 # guest_ppc_helpers.c needs the HAS_ISA_3_OO to enable copy, paste,
1841 CFLAGS="-DHAS_ISA_3_00"
1842 ac_asm_have_isa_3_00=yes
1843 AC_MSG_RESULT([yes])
1845 ac_asm_have_isa_3_00=no
1851 AC_MSG_CHECKING([that assembler knows xscvhpdp ])
1853 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1855 __asm__ __volatile__ (".machine power9;\n" \
1856 "xscvhpdp 1,2;\n" );
1858 ac_asm_have_xscvhpdp=yes
1859 AC_MSG_RESULT([yes])
1861 ac_asm_have_xscvhpdp=no
1865 # darn instruction checking
1866 AC_MSG_CHECKING([that assembler knows darn instruction ])
1868 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1870 __asm__ __volatile__(".machine power9; darn 1,0 ");
1872 ac_asm_have_darn_inst=yes
1873 AC_MSG_RESULT([yes])
1875 ac_asm_have_darn_inst=no
1880 AC_MSG_CHECKING([that assembler knows ISA 3.1 ])
1881 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
1883 __asm__ __volatile__ (".machine power10;\n" \
1886 ac_asm_have_isa_3_1=yes
1887 AC_MSG_RESULT([yes])
1889 ac_asm_have_isa_3_1=no
1894 AM_CONDITIONAL(HAS_ISA_3_00, [test x$ac_asm_have_isa_3_00 = xyes \
1895 -a x$HWCAP_HAS_ISA_3_00 = xyes])
1897 AM_CONDITIONAL(HAS_XSCVHPDP, [test x$ac_asm_have_xscvhpdp = xyes])
1898 AM_CONDITIONAL(HAS_DARN, [test x$ac_asm_have_darn_inst = xyes])
1900 AM_CONDITIONAL(HAS_ISA_3_1, [test x$ac_asm_have_isa_3_1 = xyes \
1901 -a x$HWCAP_HAS_ISA_3_1 = xyes])
1903 # Check for pthread_create@GLIBC2.0
1904 AC_MSG_CHECKING([for pthread_create@GLIBC2.0()])
1907 CFLAGS="-lpthread -Werror"
1908 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1909 extern int pthread_create_glibc_2_0(void*, const void*,
1910 void *(*)(void*), void*);
1911 __asm__(".symver pthread_create_glibc_2_0, pthread_create@GLIBC_2.0");
1915 * Apparently on PowerPC linking this program succeeds and generates an
1916 * executable with the undefined symbol pthread_create@GLIBC_2.0.
1918 #error This test does not work properly on PowerPC.
1920 pthread_create_glibc_2_0(0, 0, 0, 0);
1924 ac_have_pthread_create_glibc_2_0=yes
1925 AC_MSG_RESULT([yes])
1926 AC_DEFINE([HAVE_PTHREAD_CREATE_GLIBC_2_0], 1,
1927 [Define to 1 if you have the `pthread_create@glibc2.0' function.])
1929 ac_have_pthread_create_glibc_2_0=no
1934 AM_CONDITIONAL(HAVE_PTHREAD_CREATE_GLIBC_2_0,
1935 test x$ac_have_pthread_create_glibc_2_0 = xyes)
1938 # Check for dlinfo RTLD_DI_TLS_MODID
1939 AC_MSG_CHECKING([for dlinfo RTLD_DI_TLS_MODID])
1943 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1950 size_t sizes[10000];
1951 size_t modid_offset;
1952 (void) dlinfo ((void*)sizes, RTLD_DI_TLS_MODID, &modid_offset);
1955 ac_have_dlinfo_rtld_di_tls_modid=yes
1956 AC_MSG_RESULT([yes])
1957 AC_DEFINE([HAVE_DLINFO_RTLD_DI_TLS_MODID], 1,
1958 [Define to 1 if you have a dlinfo that can do RTLD_DI_TLS_MODID.])
1960 ac_have_dlinfo_rtld_di_tls_modid=no
1965 AM_CONDITIONAL(HAVE_DLINFO_RTLD_DI_TLS_MODID,
1966 test x$ac_have_dlinfo_rtld_di_tls_modid = xyes)
1969 # Check for eventfd_t, eventfd() and eventfd_read()
1970 AC_MSG_CHECKING([for eventfd()])
1972 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
1973 #include <sys/eventfd.h>
1979 eventfd_read(fd, &ev);
1982 AC_MSG_RESULT([yes])
1983 AC_DEFINE([HAVE_EVENTFD], 1,
1984 [Define to 1 if you have the `eventfd' function.])
1985 AC_DEFINE([HAVE_EVENTFD_READ], 1,
1986 [Define to 1 if you have the `eventfd_read' function.])
1991 # Check whether compiler can process #include <thread> without errors
1992 # clang 3.3 cannot process <thread> from e.g.
1993 # gcc (Ubuntu/Linaro 4.6.3-1ubuntu5) 4.6.3
1995 AC_MSG_CHECKING([that C++ compiler can include <thread> header file])
1997 safe_CXXFLAGS=$CXXFLAGS
2000 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2004 ac_cxx_can_include_thread_header=yes
2005 AC_MSG_RESULT([yes])
2007 ac_cxx_can_include_thread_header=no
2010 CXXFLAGS=$safe_CXXFLAGS
2013 AM_CONDITIONAL(CXX_CAN_INCLUDE_THREAD_HEADER, test x$ac_cxx_can_include_thread_header = xyes)
2015 # Check whether compiler can process #include <condition_variable> without errors
2017 AC_MSG_CHECKING([that C++ compiler can include <condition_variable> header file])
2019 safe_CXXFLAGS=$CXXFLAGS
2022 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2023 #include <condition_variable>
2026 ac_cxx_can_include_condition_variable_header=yes
2027 AC_MSG_RESULT([yes])
2029 ac_cxx_can_include_condition_variable_header=no
2032 CXXFLAGS=$safe_CXXFLAGS
2035 AM_CONDITIONAL(CXX_CAN_INCLUDE_CONDITION_VARIABLE_HEADER, test x$ac_cxx_can_include_condition_variable_header = xyes)
2037 # check for std::shared_timed_mutex, this is a C++ 14 feature
2039 AC_MSG_CHECKING([that C++ compiler can use std::shared_timed_mutex])
2041 safe_CXXFLAGS=$CXXFLAGS
2042 CXXFLAGS="-std=c++1y -pthread"
2044 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2045 #include <shared_mutex>
2046 std::shared_timed_mutex test_mutex;
2049 ac_cxx_can_use_shared_timed_mutex=yes
2050 AC_MSG_RESULT([yes])
2052 ac_cxx_can_use_shared_timed_mutex=no
2055 CXXFLAGS=$safe_CXXFLAGS
2058 AM_CONDITIONAL(CXX_CAN_USE_SHARED_TIMED_MUTEX, test x$ac_cxx_can_use_shared_timed_mutex = xyes)
2060 # check for std::shared_mutex, this is a C++ 11 feature
2062 AC_MSG_CHECKING([that C++ compiler can use std::timed_mutex])
2064 safe_CXXFLAGS=$CXXFLAGS
2065 CXXFLAGS="-std=c++0x -pthread"
2067 AC_COMPILE_IFELSE([AC_LANG_SOURCE([
2069 std::timed_mutex test_mutex;
2072 ac_cxx_can_use_timed_mutex=yes
2073 AC_MSG_RESULT([yes])
2075 ac_cxx_can_use_timed_mutex=no
2078 CXXFLAGS=$safe_CXXFLAGS
2081 AM_CONDITIONAL(CXX_CAN_USE_TIMED_MUTEX, test x$ac_cxx_can_use_timed_mutex = xyes)
2083 # On aarch64 before glibc 2.20 we would get the kernel user_pt_regs instead
2084 # of the user_regs_struct from sys/user.h. They are structurally the same
2085 # but we get either one or the other.
2087 AC_CHECK_TYPE([struct user_regs_struct],
2088 [sys_user_has_user_regs=yes], [sys_user_has_user_regs=no],
2089 [[#include <sys/ptrace.h>]
2090 [#include <sys/time.h>]
2091 [#include <sys/user.h>]])
2092 if test "$sys_user_has_user_regs" = "yes"; then
2093 AC_DEFINE(HAVE_SYS_USER_REGS, 1,
2094 [Define to 1 if <sys/user.h> defines struct user_regs_struct])
2097 AC_MSG_CHECKING([for __NR_membarrier])
2098 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2099 #include <linux/unistd.h>
2101 return __NR_membarrier
2103 ac_have_nr_membarrier=yes
2104 AC_MSG_RESULT([yes])
2106 ac_have_nr_membarrier=no
2110 AM_CONDITIONAL(HAVE_NR_MEMBARRIER, [test x$ac_have_nr_membarrier = xyes])
2112 #----------------------------------------------------------------------------
2113 # Checking for supported compiler flags.
2114 #----------------------------------------------------------------------------
2116 case "${host_cpu}" in
2118 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2119 if test -z "$ARCH"; then
2120 # does this compiler support -march=mips32 (mips32 default) ?
2121 AC_MSG_CHECKING([if gcc accepts -march=mips32 -mabi=32])
2124 CFLAGS="$CFLAGS -mips32 -mabi=32 -Werror"
2126 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2129 FLAG_M32="-mips32 -mabi=32"
2130 AC_MSG_RESULT([yes])
2140 # does this compiler support -march=mips64r2 (mips64r2 default) ?
2141 AC_MSG_CHECKING([if gcc accepts -march=mips64r2 -mabi=64])
2144 CFLAGS="$CFLAGS -march=mips64r2 -mabi=64 -Werror"
2146 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2149 FLAG_M64="-march=mips64r2 -mabi=64"
2150 AC_MSG_RESULT([yes])
2163 # does this compiler support -m32 ?
2164 AC_MSG_CHECKING([if gcc accepts -m32])
2167 CFLAGS="${FLAG_32ON64} -m32 -Werror"
2169 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2172 FLAG_M32="${FLAG_32ON64} -m32"
2173 AC_MSG_RESULT([yes])
2183 # does this compiler support -m64 ?
2184 AC_MSG_CHECKING([if gcc accepts -m64])
2187 CFLAGS="-m64 -Werror"
2189 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2193 AC_MSG_RESULT([yes])
2205 ARCH=$(echo "$CFLAGS" | grep -E -e '-march=@<:@^ @:>@+' -e '\B-mips@<:@^ +@:>@')
2206 if test -z "$ARCH"; then
2207 # does this compiler support -march=octeon (Cavium OCTEON I Specific) ?
2208 AC_MSG_CHECKING([if gcc accepts -march=octeon])
2211 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon -Werror"
2213 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2216 FLAG_OCTEON="-march=octeon"
2217 AC_MSG_RESULT([yes])
2224 AC_SUBST(FLAG_OCTEON)
2227 # does this compiler support -march=octeon2 (Cavium OCTEON II Specific) ?
2228 AC_MSG_CHECKING([if gcc accepts -march=octeon2])
2231 CFLAGS="$CFLAGS $FLAG_M64 -march=octeon2 -Werror"
2233 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2236 FLAG_OCTEON2="-march=octeon2"
2237 AC_MSG_RESULT([yes])
2244 AC_SUBST(FLAG_OCTEON2)
2248 # does this compiler support -mmsa (MIPS MSA ASE) ?
2249 AC_MSG_CHECKING([if gcc accepts -mmsa])
2252 CFLAGS="$CFLAGS -mmsa -Werror"
2254 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2258 AC_MSG_RESULT([yes])
2267 # Are we compiling for the MIPS64 n32 ABI?
2268 AC_MSG_CHECKING([if gcc is producing mips n32 binaries])
2269 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2270 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABIN32))
2275 FLAG_M64="-march=mips64r2 -mabi=n32"
2276 AC_MSG_RESULT([yes])
2281 # Are we compiling for the MIPS64 n64 ABI?
2282 AC_MSG_CHECKING([if gcc is producing mips n64 binaries])
2283 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
2284 #if !defined(_MIPS_SIM) || (defined(_MIPS_SIM) && (_MIPS_SIM != _ABI64))
2289 AC_MSG_RESULT([yes])
2294 # We enter the code block below in the following case:
2295 # Target architecture is set to mips64, the desired abi
2296 # was not specified and the compiler's default abi setting
2297 # is neither n32 nor n64.
2298 # Probe for and set the abi to either n64 or n32, in that order,
2299 # which is required for a mips64 build of valgrind.
2300 if test "$ARCH_MAX" = "mips64" -a "x$VGCONF_ABI" = "x"; then
2302 CFLAGS="$CFLAGS -mabi=64 -Werror"
2303 AC_MSG_CHECKING([if gcc is n64 capable])
2304 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2308 AC_MSG_RESULT([yes])
2314 if test "x$VGCONF_ABI" = "x"; then
2316 CFLAGS="$CFLAGS -mabi=n32 -Werror"
2317 AC_MSG_CHECKING([if gcc is n32 capable])
2318 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
2322 FLAG_M64="-march=mips64r2 -mabi=n32"
2323 AC_MSG_RESULT([yes])
2331 AM_CONDITIONAL([VGCONF_HAVE_ABI],
2332 [test x$VGCONF_ABI != x])
2333 AC_SUBST(VGCONF_ABI)
2336 # does this compiler support -mmmx ?
2337 AC_MSG_CHECKING([if gcc accepts -mmmx])
2340 CFLAGS="-mmmx -Werror"
2342 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2346 AC_MSG_RESULT([yes])
2356 # does this compiler support -msse ?
2357 AC_MSG_CHECKING([if gcc accepts -msse])
2360 CFLAGS="-msse -Werror"
2362 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2366 AC_MSG_RESULT([yes])
2376 # does this compiler support -mpreferred-stack-boundary=2 when
2377 # generating code for a 32-bit target? Note that we only care about
2378 # this when generating code for (32-bit) x86, so if the compiler
2379 # doesn't recognise -m32 it's no big deal. We'll just get code for
2380 # the Memcheck and other helper functions, that is a bit slower than
2381 # it could be, on x86; and no difference at all on any other platform.
2382 AC_MSG_CHECKING([if gcc accepts -mpreferred-stack-boundary=2 -m32])
2385 CFLAGS="-mpreferred-stack-boundary=2 -m32 -Werror"
2387 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2390 PREFERRED_STACK_BOUNDARY_2="-mpreferred-stack-boundary=2"
2391 AC_MSG_RESULT([yes])
2393 PREFERRED_STACK_BOUNDARY_2=""
2398 AC_SUBST(PREFERRED_STACK_BOUNDARY_2)
2401 # does this compiler support -mlong-double-128 ?
2402 AC_MSG_CHECKING([if gcc accepts -mlong-double-128])
2404 CFLAGS="-mlong-double-128 -Werror"
2405 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2408 ac_compiler_supports_mlong_double_128=yes
2409 AC_MSG_RESULT([yes])
2411 ac_compiler_supports_mlong_double_128=no
2415 AM_CONDITIONAL(HAS_MLONG_DOUBLE_128, test x$ac_compiler_supports_mlong_double_128 = xyes)
2416 FLAG_MLONG_DOUBLE_128="-mlong-double-128"
2417 AC_SUBST(FLAG_MLONG_DOUBLE_128)
2419 # does this toolchain support lto ?
2420 # Not checked for if --enable-lto=no was given, or if LTO_AR or LTO_RANLIG
2422 # If not enable-lto=* arg is provided, default to no, as lto builds are
2423 # a lot slower, and so not appropriate for Valgrind developments.
2424 # --enable-lto=yes should be used by distro packagers.
2425 AC_CACHE_CHECK([for using the link time optimisation], vg_cv_lto,
2427 [ --enable-lto enables building with link time optimisation],
2428 [vg_cv_lto=$enableval],
2431 if test "x${vg_cv_lto}" != "xno" -a "x${LTO_AR}" != "x" -a "x${LTO_RANLIB}" != "x"; then
2432 AC_MSG_CHECKING([if toolchain accepts lto])
2434 TEST_LTO_CFLAGS="-flto -flto-partition=one -fuse-linker-plugin"
2435 # Note : using 'one' partition is giving a slightly smaller/faster memcheck
2436 # and ld/lto-trans1 still needs a reasonable memory (about 0.5GB) when linking.
2437 CFLAGS="$TEST_LTO_CFLAGS -Werror"
2439 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2440 extern void somefun(void);
2444 LTO_CFLAGS=$TEST_LTO_CFLAGS
2445 AC_MSG_RESULT([yes])
2453 AC_SUBST(LTO_CFLAGS)
2455 # if we could not compile with lto args, or lto was disabled,
2456 # then set LTO_AR/LTO_RANLIB to the non lto values
2457 # define in config.h ENABLE_LTO (not needed by the code currently, but
2458 # this guarantees we recompile everything if we re-configure and rebuild
2459 # in a build dir previously build with another value of --enable-lto
2460 if test "x${LTO_CFLAGS}" = "x"; then
2462 LTO_RANLIB=${RANLIB}
2466 AC_DEFINE([ENABLE_LTO], 1, [configured to build with lto link time optimisation])
2469 # Convenience function to check whether GCC supports a particular
2470 # warning option. Takes two arguments,
2471 # first the warning flag name to check (without -W), then the
2472 # substitution name to set with -Wno-warning-flag if the flag exists,
2473 # or the empty string if the compiler doesn't accept the flag. Note
2474 # that checking is done against the warning flag itself, but the
2475 # substitution is then done to cancel the warning flag.
2476 AC_DEFUN([AC_GCC_WARNING_SUBST_NO],[
2477 AC_MSG_CHECKING([if gcc accepts -W$1])
2479 CFLAGS="-W$1 -Werror"
2480 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2481 AC_SUBST([$2], [-Wno-$1])
2482 AC_MSG_RESULT([yes])], [
2484 AC_MSG_RESULT([no])])
2488 # Convenience function. Like AC_GCC_WARNING_SUBST_NO, except it substitutes
2489 # -W$1 (instead of -Wno-$1).
2490 AC_DEFUN([AC_GCC_WARNING_SUBST],[
2491 AC_MSG_CHECKING([if gcc accepts -W$1])
2493 CFLAGS="-W$1 -Werror"
2494 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2495 AC_SUBST([$2], [-W$1])
2496 AC_MSG_RESULT([yes])], [
2498 AC_MSG_RESULT([no])])
2502 AC_GCC_WARNING_SUBST_NO([memset-transposed-args], [FLAG_W_NO_MEMSET_TRANSPOSED_ARGS])
2503 AC_GCC_WARNING_SUBST_NO([nonnull], [FLAG_W_NO_NONNULL])
2504 AC_GCC_WARNING_SUBST_NO([overflow], [FLAG_W_NO_OVERFLOW])
2505 AC_GCC_WARNING_SUBST_NO([pointer-sign], [FLAG_W_NO_POINTER_SIGN])
2506 AC_GCC_WARNING_SUBST_NO([uninitialized], [FLAG_W_NO_UNINITIALIZED])
2507 AC_GCC_WARNING_SUBST_NO([unused-function], [FLAG_W_NO_UNUSED_FUNCTION])
2508 AC_GCC_WARNING_SUBST_NO([static-local-in-inline], [FLAG_W_NO_STATIC_LOCAL_IN_INLINE])
2509 AC_GCC_WARNING_SUBST_NO([mismatched-new-delete], [FLAG_W_NO_MISMATCHED_NEW_DELETE])
2510 AC_GCC_WARNING_SUBST_NO([infinite-recursion], [FLAG_W_NO_INFINITE_RECURSION])
2511 AC_GCC_WARNING_SUBST_NO([expansion-to-defined], [FLAG_W_NO_EXPANSION_TO_DEFINED])
2513 AC_GCC_WARNING_SUBST([write-strings], [FLAG_W_WRITE_STRINGS])
2514 AC_GCC_WARNING_SUBST([empty-body], [FLAG_W_EMPTY_BODY])
2515 AC_GCC_WARNING_SUBST([format], [FLAG_W_FORMAT])
2516 AC_GCC_WARNING_SUBST([format-signedness], [FLAG_W_FORMAT_SIGNEDNESS])
2517 AC_GCC_WARNING_SUBST([cast-qual], [FLAG_W_CAST_QUAL])
2518 AC_GCC_WARNING_SUBST([old-style-declaration], [FLAG_W_OLD_STYLE_DECLARATION])
2519 AC_GCC_WARNING_SUBST([ignored-qualifiers], [FLAG_W_IGNORED_QUALIFIERS])
2520 AC_GCC_WARNING_SUBST([missing-parameter-type], [FLAG_W_MISSING_PARAMETER_TYPE])
2521 AC_GCC_WARNING_SUBST([logical-op], [FLAG_W_LOGICAL_OP])
2522 AC_GCC_WARNING_SUBST([enum-conversion], [FLAG_W_ENUM_CONVERSION])
2523 AC_GCC_WARNING_SUBST([implicit-fallthrough=2], [FLAG_W_IMPLICIT_FALLTHROUGH])
2525 # Does this compiler support -Wformat-security ?
2526 # Special handling is needed, because certain GCC versions require -Wformat
2527 # being present if -Wformat-security is given. Otherwise a warning is issued.
2528 # However, AC_GCC_WARNING_SUBST will stick in -Werror (see r15323 for rationale).
2529 # And with that the warning will be turned into an error with the result
2530 # that -Wformat-security is believed to be unsupported when in fact it is.
2531 AC_MSG_CHECKING([if gcc accepts -Wformat-security])
2533 CFLAGS="-Wformat -Wformat-security -Werror"
2534 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[;]])], [
2535 AC_SUBST([FLAG_W_FORMAT_SECURITY], [-Wformat-security])
2536 AC_MSG_RESULT([yes])], [
2537 AC_SUBST([FLAG_W_FORMAT_SECURITY], [])
2538 AC_MSG_RESULT([no])])
2541 # does this compiler support -Wextra or the older -W ?
2543 AC_MSG_CHECKING([if gcc accepts -Wextra or -W])
2546 CFLAGS="-Wextra -Werror"
2548 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2551 AC_SUBST([FLAG_W_EXTRA], [-Wextra])
2552 AC_MSG_RESULT([-Wextra])
2555 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2558 AC_SUBST([FLAG_W_EXTRA], [-W])
2561 AC_SUBST([FLAG_W_EXTRA], [])
2562 AC_MSG_RESULT([not supported])
2567 # On ARM we do not want to pass -Wcast-align as that produces loads
2568 # of warnings. GCC is just being conservative. See here:
2569 # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65459#c4
2570 if test "X$VGCONF_ARCH_PRI" = "Xarm"; then
2571 AC_SUBST([FLAG_W_CAST_ALIGN], [""])
2573 AC_SUBST([FLAG_W_CAST_ALIGN], [-Wcast-align])
2576 # does this compiler support -faligned-new ?
2577 AC_MSG_CHECKING([if g++ accepts -faligned-new])
2579 safe_CXXFLAGS=$CXXFLAGS
2580 CXXFLAGS="-faligned-new -Werror"
2583 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2586 FLAG_FALIGNED_NEW="-faligned-new"
2587 AC_MSG_RESULT([yes])
2589 FLAG_FALIGNED_NEW=""
2592 CXXFLAGS=$safe_CXXFLAGS
2595 AC_SUBST(FLAG_FALIGNED_NEW)
2597 # does this compiler support -fsized-deallocation ?
2598 AC_MSG_CHECKING([if g++ accepts -fsized-deallocation])
2600 safe_CXXFLAGS=$CXXFLAGS
2601 CXXFLAGS="-fsized-deallocation -Werror"
2604 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2607 FLAG_FSIZED_DEALLOCATION="-fsized-deallocation"
2608 ac_have_sized_deallocation=yes
2609 AC_MSG_RESULT([yes])
2611 FLAG_FSIZED_DEALLOCATION=""
2612 ac_have_sized_deallocation=no
2615 CXXFLAGS=$safe_CXXFLAGS
2618 AC_SUBST(FLAG_FSIZED_DEALLOCATION)
2619 AM_CONDITIONAL([HAVE_FSIZED_DEALLOCATION], [test x$ac_have_sized_deallocation = xyes])
2621 # does this compiler support C++17 aligned new/delete?
2622 AC_MSG_CHECKING([if g++ supports aligned new and delete])
2624 safe_CXXFLAGS=$CXXFLAGS
2625 CXXFLAGS="-std=c++17"
2628 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
2632 operator delete(nullptr, std::align_val_t(64U));
2634 ac_have_aligned_cxx_alloc=yes
2635 AC_MSG_RESULT([yes])
2637 ac_have_aligned_cxx_alloc=no
2640 CXXFLAGS=$safe_CXXFLAGS
2643 AM_CONDITIONAL([HAVE_ALIGNED_CXX_ALLOC], [test x$ac_have_aligned_cxx_alloc = xyes])
2645 # does this compiler support -fno-stack-protector ?
2646 AC_MSG_CHECKING([if gcc accepts -fno-stack-protector])
2649 CFLAGS="-fno-stack-protector -Werror"
2651 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2654 no_stack_protector=yes
2655 FLAG_FNO_STACK_PROTECTOR="-fno-stack-protector"
2656 AC_MSG_RESULT([yes])
2658 no_stack_protector=no
2659 FLAG_FNO_STACK_PROTECTOR=""
2664 AC_SUBST(FLAG_FNO_STACK_PROTECTOR)
2666 # does this compiler support -finline-functions ?
2667 AC_MSG_CHECKING([if gcc accepts -finline-functions])
2670 CFLAGS="-finline-functions -Werror"
2672 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2675 inline_functions=yes
2676 FLAG_FINLINE_FUNCTIONS="-finline-functions"
2677 AC_MSG_RESULT([yes])
2680 FLAG_FINLINE_FUNCTIONS=""
2685 AC_SUBST(FLAG_FINLINE_FUNCTIONS)
2687 # Does GCC support disabling Identical Code Folding?
2688 # We want to disabled Identical Code Folding for the
2689 # tools preload shared objects to get better backraces.
2690 # For GCC 5.1+ -fipa-icf is enabled by default at -O2.
2691 # "The optimization reduces code size and may disturb
2692 # unwind stacks by replacing a function by equivalent
2693 # one with a different name."
2694 AC_MSG_CHECKING([if gcc accepts -fno-ipa-icf])
2697 CFLAGS="-fno-ipa-icf -Werror"
2699 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2703 FLAG_FNO_IPA_ICF="-fno-ipa-icf"
2704 AC_MSG_RESULT([yes])
2712 AC_SUBST(FLAG_FNO_IPA_ICF)
2715 # Does this compiler support -fsanitize=undefined. This is true for
2716 # GCC 4.9 and newer. However, the undefined behaviour sanitiser in GCC 5.1
2717 # also checks for alignment violations on memory accesses which the valgrind
2718 # code base is sprinkled (if not littered) with. As those alignment issues
2719 # don't pose a problem we want to suppress warnings about them.
2720 # In GCC 5.1 this can be done by passing -fno-sanitize=alignment. Earlier
2721 # GCCs do not support that.
2723 # Only checked for if --enable-ubsan was given.
2724 if test "x${vg_cv_ubsan}" = "xyes"; then
2725 AC_MSG_CHECKING([if gcc accepts -fsanitize=undefined -fno-sanitize=alignment])
2727 CFLAGS="-fsanitize=undefined -fno-sanitize=alignment -Werror"
2728 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2731 FLAG_FSANITIZE="-fsanitize=undefined -fno-sanitize=alignment"
2732 LIB_UBSAN="-static-libubsan"
2733 AC_MSG_RESULT([yes])
2735 CFLAGS="-fsanitize=undefined -Werror"
2736 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2739 FLAG_FSANITIZE="-fsanitize=undefined"
2740 LIB_UBSAN="-static-libubsan"
2741 AC_MSG_RESULT([yes])
2749 AC_SUBST(FLAG_FSANITIZE)
2752 # does this compiler support --param inline-unit-growth=... ?
2754 AC_MSG_CHECKING([if gcc accepts --param inline-unit-growth])
2757 CFLAGS="--param inline-unit-growth=900 -Werror"
2759 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2762 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH],
2763 ["--param inline-unit-growth=900"])
2764 AC_MSG_RESULT([yes])
2766 AC_SUBST([FLAG_UNLIMITED_INLINE_UNIT_GROWTH], [""])
2772 # does this compiler support -gdwarf-4 -fdebug-types-section ?
2774 AC_MSG_CHECKING([if gcc accepts -gdwarf-4 -fdebug-types-section])
2777 CFLAGS="-gdwarf-4 -fdebug-types-section -Werror"
2779 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2783 AC_MSG_RESULT([yes])
2788 AM_CONDITIONAL(DWARF4, test x$ac_have_dwarf4 = xyes)
2792 # does this compiler support -g -gz=zlib ?
2794 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib])
2797 CFLAGS="-g -gz=zlib"
2799 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2803 AC_MSG_RESULT([yes])
2808 AM_CONDITIONAL(GZ_ZLIB, test x$ac_have_gz_zlib = xyes)
2812 # does this compiler support -g -gz=zlib-gnu ?
2814 AC_MSG_CHECKING([if gcc accepts -g -gz=zlib-gnu])
2817 CFLAGS="-g -gz=zlib-gnu"
2819 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2822 ac_have_gz_zlib_gnu=yes
2823 AC_MSG_RESULT([yes])
2825 ac_have_gz_zlib_gnu=no
2828 AM_CONDITIONAL(GZ_ZLIB_GNU, test x$ac_have_gz_zlib_gnu = xyes)
2832 # does this compiler support nested functions ?
2834 AC_MSG_CHECKING([if gcc accepts nested functions])
2836 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2837 int foo() { return 1; }
2840 ac_have_nested_functions=yes
2841 AC_MSG_RESULT([yes])
2843 ac_have_nested_functions=no
2846 AM_CONDITIONAL([HAVE_NESTED_FUNCTIONS], [test x$ac_have_nested_functions = xyes])
2849 # does this compiler support the 'p' constraint in ASM statements ?
2851 AC_MSG_CHECKING([if gcc accepts the 'p' constraint in asm statements])
2853 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2855 __asm__ __volatile__ ("movdqa (%0),%%xmm6\n" : "=p" (p));
2857 ac_have_asm_constraint_p=yes
2858 AC_MSG_RESULT([yes])
2860 ac_have_asm_constraint_p=no
2863 AM_CONDITIONAL([HAVE_ASM_CONSTRAINT_P], [test x$ac_have_asm_constraint_p = xyes])
2866 # Does this compiler and linker support -pie?
2867 # Some compilers actually do not support -pie and report its usage
2868 # as an error. We need to check if it is safe to use it first.
2870 AC_MSG_CHECKING([if gcc accepts -pie])
2875 AC_LINK_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2878 AC_SUBST([FLAG_PIE], ["-pie"])
2879 AC_MSG_RESULT([yes])
2881 AC_SUBST([FLAG_PIE], [""])
2887 # Does this compiler support -no-pie?
2888 # On Ubuntu 16.10+, gcc produces position independent executables (PIE) by
2889 # default. However this gets in the way with some tests, we use -no-pie
2892 AC_MSG_CHECKING([if gcc accepts -no-pie])
2895 CFLAGS="-no-pie -Werror"
2897 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
2900 AC_SUBST([FLAG_NO_PIE], ["-no-pie"])
2901 AC_MSG_RESULT([yes])
2903 AC_SUBST([FLAG_NO_PIE], [""])
2909 # We want to use use the -Ttext-segment option to the linker.
2910 # GNU (bfd) ld supports this directly. Newer GNU gold linkers
2911 # support it as an alias of -Ttext. Sadly GNU (bfd) ld's -Ttext
2912 # semantics are NOT what we want (GNU gold -Ttext is fine).
2914 # For GNU (bfd) ld -Ttext-segment chooses the base at which ELF headers
2915 # will reside. -Ttext aligns just the .text section start (but not any
2918 # LLVM ld.lld 10.0 changed the semantics of its -Ttext. See "Breaking changes"
2919 # in https://releases.llvm.org/10.0.0/tools/lld/docs/ReleaseNotes.html
2920 # The --image-base option (since version 6.0?) provides the semantics needed.
2921 # -Ttext-segment generates an error, but -Ttext now more closely
2922 # follows the GNU (bfd) ld's -Ttext.
2924 # So test first for --image-base support, and if that fails then
2925 # for -Ttext-segment which is supported by all bfd ld versions
2926 # and use that if it exists. If it doesn't exist it must be an older
2927 # version of gold and we can fall back to using -Ttext which has the
2931 AC_MSG_CHECKING([if the linker accepts -Wl,--image-base])
2933 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,--image-base=$valt_load_address_pri_norml -Werror"
2936 [AC_LANG_SOURCE([int _start () { return 0; }])],
2938 linker_using_t_text="no"
2939 AC_SUBST([FLAG_T_TEXT], ["--image-base"])
2940 AC_MSG_RESULT([yes])
2944 AC_MSG_CHECKING([if the linker accepts -Wl,-Ttext-segment])
2946 CFLAGS="-static -nodefaultlibs -nostartfiles -Wl,-Ttext-segment=$valt_load_address_pri_norml -Werror"
2949 [AC_LANG_SOURCE([int _start () { return 0; }])],
2951 linker_using_t_text="no"
2952 AC_SUBST([FLAG_T_TEXT], ["-Ttext-segment"])
2953 AC_MSG_RESULT([yes])
2955 linker_using_t_text="yes"
2956 AC_SUBST([FLAG_T_TEXT], ["-Ttext"])
2963 # If the linker only supports -Ttext (not -Ttext-segment or --image-base) then we will
2964 # have to strip any build-id ELF NOTEs from the statically linked tools.
2965 # Otherwise the build-id NOTE might end up at the default load address.
2966 # (Pedantically if the linker is gold then -Ttext is fine, but newer
2967 # gold versions also support -Ttext-segment. So just assume that unless
2968 # we can use -Ttext-segment we need to strip the build-id NOTEs.
2969 if test "x${linker_using_t_text}" = "xyes"; then
2970 AC_MSG_NOTICE([ld -Ttext used, need to strip build-id NOTEs.])
2971 # does the linker support -Wl,--build-id=none ? Note, it's
2972 # important that we test indirectly via whichever C compiler
2973 # is selected, rather than testing /usr/bin/ld or whatever
2975 AC_MSG_CHECKING([if the linker accepts -Wl,--build-id=none])
2977 CFLAGS="-Wl,--build-id=none -Werror"
2980 [AC_LANG_PROGRAM([ ], [return 0;])],
2982 AC_SUBST([FLAG_NO_BUILD_ID], ["-Wl,--build-id=none"])
2983 AC_MSG_RESULT([yes])
2985 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2989 AC_MSG_NOTICE([ld --image-base or -Ttext-segment used, no need to strip build-id NOTEs.])
2990 AC_SUBST([FLAG_NO_BUILD_ID], [""])
2994 # does the ppc assembler support "mtocrf" et al?
2995 AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
2997 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
2998 __asm__ __volatile__("mtocrf 4,0");
2999 __asm__ __volatile__("mfocrf 0,4");
3001 ac_have_as_ppc_mftocrf=yes
3002 AC_MSG_RESULT([yes])
3004 ac_have_as_ppc_mftocrf=no
3007 if test x$ac_have_as_ppc_mftocrf = xyes ; then
3008 AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
3012 # does the ppc assembler support "lfdp" and other phased out floating point insns?
3013 AC_MSG_CHECKING([if ppc32/64 asm supports phased out floating point instructions])
3015 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3016 do { typedef struct {
3020 dbl_pair_t dbl_pair[3];
3021 __asm__ volatile ("lfdp 10, %0"::"m" (dbl_pair[0]));
3024 ac_have_as_ppc_fpPO=yes
3025 AC_MSG_RESULT([yes])
3027 ac_have_as_ppc_fpPO=no
3030 if test x$ac_have_as_ppc_fpPO = xyes ; then
3031 AC_DEFINE(HAVE_AS_PPC_FPPO, 1, [Define to 1 if as supports floating point phased out category.])
3035 # does the amd64 assembler understand "fxsave64" and "fxrstor64"?
3036 AC_MSG_CHECKING([if amd64 assembler supports fxsave64/fxrstor64])
3038 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3040 asm __volatile__("fxsave64 (%0)" : : "r" (p) : "memory" );
3041 asm __volatile__("fxrstor64 (%0)" : : "r" (p) : "memory" );
3043 ac_have_as_amd64_fxsave64=yes
3044 AC_MSG_RESULT([yes])
3046 ac_have_as_amd64_fxsave64=no
3049 if test x$ac_have_as_amd64_fxsave64 = xyes ; then
3050 AC_DEFINE(HAVE_AS_AMD64_FXSAVE64, 1, [Define to 1 if as supports fxsave64/fxrstor64.])
3053 # does the x86/amd64 assembler understand SSE3 instructions?
3054 # Note, this doesn't generate a C-level symbol. It generates a
3055 # automake-level symbol (BUILD_SSE3_TESTS), used in test Makefile.am's
3056 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE3])
3058 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3059 do { long long int x;
3060 __asm__ __volatile__("fisttpq (%0)" : :"r"(&x) ); }
3064 AC_MSG_RESULT([yes])
3070 AM_CONDITIONAL(BUILD_SSE3_TESTS, test x$ac_have_as_sse3 = xyes)
3073 # Ditto for SSSE3 instructions (note extra S)
3074 # Note, this doesn't generate a C-level symbol. It generates a
3075 # automake-level symbol (BUILD_SSSE3_TESTS), used in test Makefile.am's
3076 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSSE3])
3078 save_CFLAGS="$CFLAGS"
3079 CFLAGS="$CFLAGS -msse -Werror"
3080 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3081 do { long long int x;
3082 __asm__ __volatile__(
3083 "pabsb (%0),%%xmm7" : : "r"(&x) : "xmm7" ); }
3086 ac_have_as_ssse3=yes
3087 AC_MSG_RESULT([yes])
3092 CFLAGS="$save_CFLAGS"
3094 AM_CONDITIONAL(BUILD_SSSE3_TESTS, test x$ac_have_as_ssse3 = xyes)
3097 # does the x86/amd64 assembler understand the PCLMULQDQ instruction?
3098 # Note, this doesn't generate a C-level symbol. It generates a
3099 # automake-level symbol (BUILD_PCLMULQDQ_TESTS), used in test Makefile.am's
3100 AC_MSG_CHECKING([if x86/amd64 assembler supports 'pclmulqdq'])
3101 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3103 __asm__ __volatile__(
3104 "pclmulqdq \$17,%%xmm6,%%xmm7" : : : "xmm6", "xmm7" ); }
3107 ac_have_as_pclmulqdq=yes
3108 AC_MSG_RESULT([yes])
3110 ac_have_as_pclmulqdq=no
3114 AM_CONDITIONAL(BUILD_PCLMULQDQ_TESTS, test x$ac_have_as_pclmulqdq = xyes)
3117 # does the x86/amd64 assembler understand the VPCLMULQDQ instruction?
3118 # Note, this doesn't generate a C-level symbol. It generates a
3119 # automake-level symbol (BUILD_VPCLMULQDQ_TESTS), used in test Makefile.am's
3120 AC_MSG_CHECKING([if x86/amd64 assembler supports 'vpclmulqdq'])
3121 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3124 * Carry-less multiplication of xmm1 with xmm2 and store the result in
3125 * xmm3. The immediate is used to determine which quadwords of xmm1 and
3126 * xmm2 should be used.
3128 __asm__ __volatile__(
3129 "vpclmulqdq \$0,%%xmm1,%%xmm2,%%xmm3" : : : );
3132 ac_have_as_vpclmulqdq=yes
3133 AC_MSG_RESULT([yes])
3135 ac_have_as_vpclmulqdq=no
3139 AM_CONDITIONAL(BUILD_VPCLMULQDQ_TESTS, test x$ac_have_as_vpclmulqdq = xyes)
3142 # does the x86/amd64 assembler understand FMA4 instructions?
3143 # Note, this doesn't generate a C-level symbol. It generates a
3144 # automake-level symbol (BUILD_AFM4_TESTS), used in test Makefile.am's
3145 AC_MSG_CHECKING([if x86/amd64 assembler supports FMA4 'vfmaddpd'])
3146 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3148 __asm__ __volatile__(
3149 "vfmaddpd %%xmm7,%%xmm8,%%xmm6,%%xmm9" : : : );
3152 ac_have_as_vfmaddpd=yes
3153 AC_MSG_RESULT([yes])
3155 ac_have_as_vfmaddpd=no
3159 AM_CONDITIONAL(BUILD_FMA4_TESTS, test x$ac_have_as_vfmaddpd = xyes)
3162 # does the x86/amd64 assembler understand the LZCNT instruction?
3163 # Note, this doesn't generate a C-level symbol. It generates a
3164 # automake-level symbol (BUILD_LZCNT_TESTS), used in test Makefile.am's
3165 AC_MSG_CHECKING([if x86/amd64 assembler supports 'lzcnt'])
3167 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3169 __asm__ __volatile__("lzcnt %%rax,%%rax" : : : "rax");
3172 ac_have_as_lzcnt=yes
3173 AC_MSG_RESULT([yes])
3179 AM_CONDITIONAL([BUILD_LZCNT_TESTS], [test x$ac_have_as_lzcnt = xyes])
3182 # does the x86/amd64 assembler understand the LOOPNEL instruction?
3183 # Note, this doesn't generate a C-level symbol. It generates a
3184 # automake-level symbol (BUILD_LOOPNEL_TESTS), used in test Makefile.am's
3185 AC_MSG_CHECKING([if x86/amd64 assembler supports 'loopnel'])
3187 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3189 __asm__ __volatile__("1: loopnel 1b\n");
3192 ac_have_as_loopnel=yes
3193 AC_MSG_RESULT([yes])
3195 ac_have_as_loopnel=no
3199 AM_CONDITIONAL([BUILD_LOOPNEL_TESTS], [test x$ac_have_as_loopnel = xyes])
3202 # does the x86/amd64 assembler understand ADDR32 ?
3203 # Note, this doesn't generate a C-level symbol. It generates a
3204 # automake-level symbol (BUILD_ADDR32_TESTS), used in test Makefile.am's
3205 AC_MSG_CHECKING([if x86/amd64 assembler supports 'addr32'])
3207 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3209 asm volatile ("addr32 rep movsb");
3212 ac_have_as_addr32=yes
3213 AC_MSG_RESULT([yes])
3215 ac_have_as_addr32=no
3219 AM_CONDITIONAL([BUILD_ADDR32_TESTS], [test x$ac_have_as_addr32 = xyes])
3222 # does the x86/amd64 assembler understand SSE 4.2 instructions?
3223 # Note, this doesn't generate a C-level symbol. It generates a
3224 # automake-level symbol (BUILD_SSE42_TESTS), used in test Makefile.am's
3225 AC_MSG_CHECKING([if x86/amd64 assembler speaks SSE4.2])
3227 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3228 do { long long int x;
3229 __asm__ __volatile__(
3230 "crc32q %%r15,%%r15" : : : "r15" );
3231 __asm__ __volatile__(
3232 "pblendvb (%%rcx), %%xmm11" : : : "memory", "xmm11");
3233 __asm__ __volatile__(
3234 "aesdec %%xmm2, %%xmm1" : : : "xmm2", "xmm1"); }
3237 ac_have_as_sse42=yes
3238 AC_MSG_RESULT([yes])
3244 AM_CONDITIONAL(BUILD_SSE42_TESTS, test x$ac_have_as_sse42 = xyes)
3247 # does the x86/amd64 assembler understand AVX instructions?
3248 # Note, this doesn't generate a C-level symbol. It generates a
3249 # automake-level symbol (BUILD_AVX_TESTS), used in test Makefile.am's
3250 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX])
3252 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3253 do { long long int x;
3254 __asm__ __volatile__(
3255 "vmovupd (%%rsp), %%ymm7" : : : "xmm7" );
3256 __asm__ __volatile__(
3257 "vaddpd %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3261 AC_MSG_RESULT([yes])
3267 AM_CONDITIONAL(BUILD_AVX_TESTS, test x$ac_have_as_avx = xyes)
3270 # does the x86/amd64 assembler understand AVX2 instructions?
3271 # Note, this doesn't generate a C-level symbol. It generates a
3272 # automake-level symbol (BUILD_AVX2_TESTS), used in test Makefile.am's
3273 AC_MSG_CHECKING([if x86/amd64 assembler speaks AVX2])
3275 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3276 do { long long int x;
3277 __asm__ __volatile__(
3278 "vpsravd (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3279 __asm__ __volatile__(
3280 "vpaddb %%ymm6,%%ymm7,%%ymm8" : : : "xmm6","xmm7","xmm8"); }
3284 AC_MSG_RESULT([yes])
3290 AM_CONDITIONAL(BUILD_AVX2_TESTS, test x$ac_have_as_avx2 = xyes)
3293 # does the x86/amd64 assembler understand TSX instructions and
3294 # the XACQUIRE/XRELEASE prefixes?
3295 # Note, this doesn't generate a C-level symbol. It generates a
3296 # automake-level symbol (BUILD_TSX_TESTS), used in test Makefile.am's
3297 AC_MSG_CHECKING([if x86/amd64 assembler speaks TSX])
3299 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3301 __asm__ __volatile__(
3304 " xacquire lock incq 0(%rsp) \n\t"
3305 " xrelease lock incq 0(%rsp) \n"
3310 AC_MSG_RESULT([yes])
3316 AM_CONDITIONAL(BUILD_TSX_TESTS, test x$ac_have_as_tsx = xyes)
3319 # does the x86/amd64 assembler understand BMI1 and BMI2 instructions?
3320 # Note, this doesn't generate a C-level symbol. It generates a
3321 # automake-level symbol (BUILD_BMI_TESTS), used in test Makefile.am's
3322 AC_MSG_CHECKING([if x86/amd64 assembler speaks BMI1 and BMI2])
3324 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3325 do { unsigned int h, l;
3326 __asm__ __volatile__( "mulx %rax,%rcx,%r8" );
3327 __asm__ __volatile__(
3328 "andn %2, %1, %0" : "=r" (h) : "r" (0x1234567), "r" (0x7654321) );
3329 __asm__ __volatile__(
3330 "movl %2, %%edx; mulx %3, %1, %0" : "=r" (h), "=r" (l) : "g" (0x1234567), "rm" (0x7654321) : "edx" ); }
3334 AC_MSG_RESULT([yes])
3340 AM_CONDITIONAL(BUILD_BMI_TESTS, test x$ac_have_as_bmi = xyes)
3343 # does the x86/amd64 assembler understand FMA instructions?
3344 # Note, this doesn't generate a C-level symbol. It generates a
3345 # automake-level symbol (BUILD_FMA_TESTS), used in test Makefile.am's
3346 AC_MSG_CHECKING([if x86/amd64 assembler speaks FMA])
3348 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3349 do { unsigned int h, l;
3350 __asm__ __volatile__(
3351 "vfmadd132ps (%%rsp), %%ymm8, %%ymm7" : : : "xmm7", "xmm8" );
3352 __asm__ __volatile__(
3353 "vfnmsub231sd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" );
3354 __asm__ __volatile__(
3355 "vfmsubadd213pd (%%rsp), %%xmm8, %%xmm7" : : : "xmm7", "xmm8" ); }
3359 AC_MSG_RESULT([yes])
3365 AM_CONDITIONAL(BUILD_FMA_TESTS, test x$ac_have_as_fma = xyes)
3368 # does the amd64 assembler understand MPX instructions?
3369 # Note, this doesn't generate a C-level symbol. It generates a
3370 # automake-level symbol (BUILD_MPX_TESTS), used in test Makefile.am's
3371 AC_MSG_CHECKING([if amd64 assembler knows the MPX instructions])
3373 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3375 asm ("bndmov %bnd0,(%rsp)");
3376 asm ("bndldx 3(%rbx,%rdx), %bnd2");
3377 asm ("bnd call foo\n"
3384 AC_MSG_RESULT([yes])
3390 AM_CONDITIONAL(BUILD_MPX_TESTS, test x$ac_have_as_mpx = xyes)
3393 # does the amd64 assembler understand ADX instructions?
3394 # Note, this doesn't generate a C-level symbol. It generates a
3395 # automake-level symbol (BUILD_ADX_TESTS), used in test Makefile.am's
3396 AC_MSG_CHECKING([if amd64 assembler knows the ADX instructions])
3398 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3400 asm ("adcxq %r14,%r8");
3404 AC_MSG_RESULT([yes])
3410 AM_CONDITIONAL(BUILD_ADX_TESTS, test x$ac_have_as_adx = xyes)
3413 # does the amd64 assembler understand the RDRAND instruction?
3414 # Note, this doesn't generate a C-level symbol. It generates a
3415 # automake-level symbol (BUILD_RDRAND_TESTS), used in test Makefile.am's
3416 AC_MSG_CHECKING([if amd64 assembler knows the RDRAND instruction])
3418 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3420 asm ("rdrand %r14");
3421 asm ("rdrand %r14d");
3422 asm ("rdrand %r14w");
3425 ac_have_as_rdrand=yes
3426 AC_MSG_RESULT([yes])
3428 ac_have_as_rdrand=no
3432 AM_CONDITIONAL(BUILD_RDRAND_TESTS, test x$ac_have_as_rdrand = xyes)
3434 # does the amd64 assembler understand the RDSEED instruction?
3435 # Note, this doesn't generate a C-level symbol. It generates a
3436 # automake-level symbol (BUILD_RDSEED_TESTS), used in test Makefile.am's
3437 AC_MSG_CHECKING([if amd64 assembler knows the RDSEED instruction])
3439 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3441 asm ("rdseed %r14");
3442 asm ("rdseed %r14d");
3443 asm ("rdseed %r14w");
3446 ac_have_as_rdseed=yes
3447 AC_MSG_RESULT([yes])
3449 ac_have_as_rdseed=no
3453 AM_CONDITIONAL(BUILD_RDSEED_TESTS, test x$ac_have_as_rdseed = xyes)
3455 # does the amd64 assembler understand the F16C instructions (VCVTPH2PS and
3457 # Note, this doesn't generate a C-level symbol. It generates a
3458 # automake-level symbol (BUILD_F16C_TESTS), used in test Makefile.am's
3459 AC_MSG_CHECKING([if amd64 assembler knows the F16C instructions])
3461 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3463 asm ("vcvtph2ps %xmm5, %ymm10");
3464 // If we put the dollar sign and zero together, the shell processing
3465 // this configure.ac script substitutes the command name in. Sigh.
3466 asm ("vcvtps2ph $" "0, %ymm10, %xmm5");
3470 AC_MSG_RESULT([yes])
3476 AM_CONDITIONAL(BUILD_F16C_TESTS, test x$ac_have_as_f16c = xyes)
3479 # does the x86/amd64 assembler understand MOVBE?
3480 # Note, this doesn't generate a C-level symbol. It generates a
3481 # automake-level symbol (BUILD_MOVBE_TESTS), used in test Makefile.am's
3482 AC_MSG_CHECKING([if x86/amd64 assembler knows the MOVBE insn])
3484 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3485 do { long long int x;
3486 __asm__ __volatile__(
3487 "movbe (%%rsp), %%r15" : : : "memory", "r15" ); }
3490 ac_have_as_movbe=yes
3491 AC_MSG_RESULT([yes])
3497 AM_CONDITIONAL(BUILD_MOVBE_TESTS, test x$ac_have_as_movbe = xyes)
3500 # Does the C compiler support the "ifunc" attribute
3501 # Note, this doesn't generate a C-level symbol. It generates a
3502 # automake-level symbol (BUILD_IFUNC_TESTS), used in test Makefile.am's
3503 AC_MSG_CHECKING([if gcc supports the ifunc attribute])
3505 AC_LINK_IFELSE([AC_LANG_SOURCE([[
3506 static void mytest(void) {}
3508 static void (*resolve_test(void))(void)
3510 return (void (*)(void))&mytest;
3513 void test(void) __attribute__((ifunc("resolve_test")));
3521 ac_have_ifunc_attr=yes
3522 AC_MSG_RESULT([yes])
3524 ac_have_ifunc_attr=no
3528 AM_CONDITIONAL(BUILD_IFUNC_TESTS, test x$ac_have_ifunc_attr = xyes)
3530 # Does the C compiler support the armv8 crc feature flag
3531 # Note, this doesn't generate a C-level symbol. It generates a
3532 # automake-level symbol (BUILD_ARMV8_CRC_TESTS), used in test Makefile.am's
3533 AC_MSG_CHECKING([if gcc supports the armv8 crc feature flag])
3535 save_CFLAGS="$CFLAGS"
3536 CFLAGS="$CFLAGS -march=armv8-a+crc -Werror"
3537 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3543 ac_have_armv8_crc_feature=yes
3544 AC_MSG_RESULT([yes])
3546 ac_have_armv8_crc_feature=no
3549 CFLAGS="$save_CFLAGS"
3551 AM_CONDITIONAL(BUILD_ARMV8_CRC_TESTS, test x$ac_have_armv8_crc_feature = xyes)
3554 # Does the C compiler support the armv81 flag and the assembler v8.1 instructions
3555 # Note, this doesn't generate a C-level symbol. It generates a
3556 # automake-level symbol (BUILD_ARMV81_TESTS), used in test Makefile.am's
3557 AC_MSG_CHECKING([if gcc supports the armv81 feature flag and assembler supports v8.1 instructions])
3559 save_CFLAGS="$CFLAGS"
3560 CFLAGS="$CFLAGS -march=armv8.1-a -Werror"
3561 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3564 __asm__ __volatile__("ldadd x0, x1, [x2]" ::: "memory");
3568 ac_have_armv81_feature=yes
3569 AC_MSG_RESULT([yes])
3571 ac_have_armv81_feature=no
3574 CFLAGS="$save_CFLAGS"
3576 AM_CONDITIONAL(BUILD_ARMV81_TESTS, test x$ac_have_armv81_feature = xyes)
3579 # Does the C compiler support the armv82 flag and the assembler v8.2 instructions
3580 # Note, this doesn't generate a C-level symbol. It generates a
3581 # automake-level symbol (BUILD_ARMV82_TESTS), used in test Makefile.am's
3582 AC_MSG_CHECKING([if gcc supports the armv82 feature flag and assembler supports v8.2 instructions])
3584 save_CFLAGS="$CFLAGS"
3585 CFLAGS="$CFLAGS -march=armv8.2-a+fp16 -Werror"
3586 AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
3589 __asm__ __volatile__("faddp h0, v1.2h");
3593 ac_have_armv82_feature=yes
3594 AC_MSG_RESULT([yes])
3596 ac_have_armv82_feature=no
3599 CFLAGS="$save_CFLAGS"
3601 AM_CONDITIONAL(BUILD_ARMV82_TESTS, test x$ac_have_armv82_feature = xyes)
3604 # XXX JRS 2010 Oct 13: what is this for? For sure, we don't need this
3605 # when building the tool executables. I think we should get rid of it.
3607 # Check for TLS support in the compiler and linker
3608 AC_LINK_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3610 [vg_cv_linktime_tls=yes],
3611 [vg_cv_linktime_tls=no])
3612 # Native compilation: check whether running a program using TLS succeeds.
3613 # Linking only is not sufficient -- e.g. on Red Hat 7.3 linking TLS programs
3614 # succeeds but running programs using TLS fails.
3615 # Cross-compiling: check whether linking a program using TLS succeeds.
3616 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
3617 [AC_ARG_ENABLE(tls, [ --enable-tls platform supports TLS],
3618 [vg_cv_tls=$enableval],
3619 [AC_RUN_IFELSE([AC_LANG_PROGRAM([[static __thread int foo;]],
3623 [vg_cv_tls=$vg_cv_linktime_tls])])])
3625 if test "$vg_cv_tls" = yes -a $is_clang != applellvm; then
3626 AC_DEFINE([HAVE_TLS], 1, [can use __thread to define thread-local variables])
3630 #----------------------------------------------------------------------------
3631 # Solaris-specific checks.
3632 #----------------------------------------------------------------------------
3634 if test "$VGCONF_OS" = "solaris" ; then
3635 AC_CHECK_HEADERS([sys/lgrp_user_impl.h])
3637 # Solaris-specific check determining if the Sun Studio Assembler is used to
3638 # build Valgrind. The test checks if the x86/amd64 assembler understands the
3639 # cmovl.l instruction, if yes then it's Sun Assembler.
3641 # C-level symbol: none
3642 # Automake-level symbol: SOLARIS_SUN_STUDIO_AS
3644 AC_MSG_CHECKING([if x86/amd64 assembler speaks cmovl.l (Solaris-specific)])
3645 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3647 __asm__ __volatile__("cmovl.l %edx, %eax");
3649 solaris_have_sun_studio_as=yes
3650 AC_MSG_RESULT([yes])
3652 solaris_have_sun_studio_as=no
3655 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, test x$solaris_have_sun_studio_as = xyes)
3657 # Solaris-specific check determining if symbols __xpg4 and __xpg6
3658 # are present in linked shared libraries when gcc is invoked with -std=gnu99.
3659 # See solaris/vgpreload-solaris.mapfile for details.
3660 # gcc on older Solaris instructs linker to include these symbols,
3661 # gcc on illumos and newer Solaris does not.
3663 # C-level symbol: none
3664 # Automake-level symbol: SOLARIS_XPG_SYMBOLS_PRESENT
3666 save_CFLAGS="$CFLAGS"
3667 CFLAGS="$CFLAGS -std=gnu99"
3668 AC_MSG_CHECKING([if xpg symbols are present with -std=gnu99 (Solaris-specific)])
3669 temp_dir=$( /usr/bin/mktemp -d )
3670 cat <<_ACEOF >${temp_dir}/mylib.c
3672 int myfunc(void) { printf("LaPutyka\n"); }
3674 ${CC} ${CFLAGS} -fpic -shared -o ${temp_dir}/mylib.so ${temp_dir}/mylib.c
3675 xpg_present=$( /usr/bin/nm ${temp_dir}/mylib.so | ${EGREP} '(__xpg4|__xpg6)' )
3676 if test "x${xpg_present}" = "x" ; then
3677 solaris_xpg_symbols_present=no
3680 solaris_xpg_symbols_present=yes
3681 AC_MSG_RESULT([yes])
3684 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, test x$solaris_xpg_symbols_present = xyes)
3685 CFLAGS="$save_CFLAGS"
3688 # Solaris-specific check determining if gcc enables largefile support by
3689 # default for 32-bit executables. If it does, then set SOLARIS_UNDEF_LARGESOURCE
3690 # variable with gcc flags which disable it.
3692 AC_MSG_CHECKING([if gcc enables largefile support for 32-bit apps (Solaris-specific)])
3693 save_CFLAGS="$CFLAGS"
3694 CFLAGS="$CFLAGS -m32"
3695 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[
3696 return _LARGEFILE_SOURCE;
3698 SOLARIS_UNDEF_LARGESOURCE="-U_LARGEFILE_SOURCE -U_LARGEFILE64_SOURCE -U_FILE_OFFSET_BITS"
3699 AC_MSG_RESULT([yes])
3701 SOLARIS_UNDEF_LARGESOURCE=""
3705 AC_SUBST(SOLARIS_UNDEF_LARGESOURCE)
3708 # Solaris-specific check determining if /proc/self/cmdline
3709 # or /proc/<pid>/cmdline is supported.
3711 # C-level symbol: SOLARIS_PROC_CMDLINE
3712 # Automake-level symbol: SOLARIS_PROC_CMDLINE
3714 AC_CHECK_FILE([/proc/self/cmdline],
3716 solaris_proc_cmdline=yes
3717 AC_DEFINE([SOLARIS_PROC_CMDLINE], 1,
3718 [Define to 1 if you have /proc/self/cmdline.])
3720 solaris_proc_cmdline=no
3722 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, test x$solaris_proc_cmdline = xyes)
3725 # Solaris-specific check determining default platform for the Valgrind launcher.
3726 # Used in case the launcher cannot select platform by looking at the client
3727 # image (for example because the executable is a shell script).
3729 # C-level symbol: SOLARIS_LAUNCHER_DEFAULT_PLATFORM
3730 # Automake-level symbol: none
3732 AC_MSG_CHECKING([for default platform of Valgrind launcher (Solaris-specific)])
3733 # Get the ELF class of /bin/sh first.
3734 if ! test -f /bin/sh; then
3735 AC_MSG_ERROR([Shell interpreter `/bin/sh' not found.])
3737 elf_class=$( /usr/bin/file /bin/sh | sed -n 's/.*ELF \(..\)-bit.*/\1/p' )
3738 case "$elf_class" in
3740 default_arch="$VGCONF_ARCH_PRI";
3743 if test "x$VGCONF_ARCH_SEC" != "x"; then
3744 default_arch="$VGCONF_ARCH_SEC"
3746 default_arch="$VGCONF_ARCH_PRI";
3750 AC_MSG_ERROR([Cannot determine ELF class of `/bin/sh'.])
3753 default_platform="$default_arch-$VGCONF_OS"
3754 AC_MSG_RESULT([$default_platform])
3755 AC_DEFINE_UNQUOTED([SOLARIS_LAUNCHER_DEFAULT_PLATFORM], ["$default_platform"],
3756 [Default platform for Valgrind launcher.])
3759 # Solaris-specific check determining if the old syscalls are available.
3761 # C-level symbol: SOLARIS_OLD_SYSCALLS
3762 # Automake-level symbol: SOLARIS_OLD_SYSCALLS
3764 AC_MSG_CHECKING([for the old Solaris syscalls (Solaris-specific)])
3765 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3766 #include <sys/syscall.h>
3770 solaris_old_syscalls=yes
3771 AC_MSG_RESULT([yes])
3772 AC_DEFINE([SOLARIS_OLD_SYSCALLS], 1,
3773 [Define to 1 if you have the old Solaris syscalls.])
3775 solaris_old_syscalls=no
3778 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, test x$solaris_old_syscalls = xyes)
3781 # Solaris-specific check determining if the new accept() syscall is available.
3784 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3787 # New syscall (available on illumos):
3788 # int accept(int sock, struct sockaddr *name, socklen_t *namelenp,
3789 # int version, int flags);
3791 # If the old syscall is present then the following syscall will fail with
3792 # ENOTSOCK (because file descriptor 0 is not a socket), if the new syscall is
3793 # available then it will fail with EINVAL (because the flags parameter is
3796 # C-level symbol: SOLARIS_NEW_ACCEPT_SYSCALL
3797 # Automake-level symbol: none
3799 AC_MSG_CHECKING([for the new `accept' syscall (Solaris-specific)])
3800 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3801 #include <sys/syscall.h>
3805 syscall(SYS_accept, 0, 0, 0, 0, -1);
3806 return !(errno == EINVAL);
3808 AC_MSG_RESULT([yes])
3809 AC_DEFINE([SOLARIS_NEW_ACCEPT_SYSCALL], 1,
3810 [Define to 1 if you have the new `accept' syscall.])
3816 # Solaris-specific check determining if the new illumos pipe() syscall is
3820 # longlong_t pipe();
3822 # New syscall (available on illumos):
3823 # int pipe(intptr_t arg, int flags);
3825 # If the old syscall is present then the following call will succeed, if the
3826 # new syscall is available then it will fail with EFAULT (because address 0
3827 # cannot be accessed).
3829 # C-level symbol: SOLARIS_NEW_PIPE_SYSCALL
3830 # Automake-level symbol: none
3832 AC_MSG_CHECKING([for the new `pipe' syscall (Solaris-specific)])
3833 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3834 #include <sys/syscall.h>
3838 syscall(SYS_pipe, 0, 0);
3839 return !(errno == EFAULT);
3841 AC_MSG_RESULT([yes])
3842 AC_DEFINE([SOLARIS_NEW_PIPE_SYSCALL], 1,
3843 [Define to 1 if you have the new `pipe' syscall.])
3849 # Solaris-specific check determining if the new lwp_sigqueue() syscall is
3853 # int lwp_kill(id_t lwpid, int sig);
3855 # New syscall (available on Solaris 11):
3856 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3857 # int si_code, timespec_t *timeout);
3859 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3860 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL
3862 AC_MSG_CHECKING([for the new `lwp_sigqueue' syscall (Solaris-specific)])
3863 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3864 #include <sys/syscall.h>
3866 return !SYS_lwp_sigqueue;
3868 solaris_lwp_sigqueue_syscall=yes
3869 AC_MSG_RESULT([yes])
3870 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL], 1,
3871 [Define to 1 if you have the new `lwp_sigqueue' syscall.])
3873 solaris_lwp_sigqueue_syscall=no
3876 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, test x$solaris_lwp_sigqueue_syscall = xyes)
3879 # Solaris-specific check determining if the lwp_sigqueue() syscall
3880 # takes both pid and thread id arguments or just thread id.
3882 # Old syscall (available up to Solaris 11.3):
3883 # int lwp_sigqueue(id_t lwpid, int sig, void *value,
3884 # int si_code, timespec_t *timeout);
3886 # New syscall (available since Solaris 11.4):
3887 # int lwp_sigqueue(pid_t pid, id_t lwpid, int sig, void *value,
3888 # int si_code, timespec_t *timeout);
3890 # If the old syscall is present then the following syscall will fail with
3891 # EINVAL (because signal is out of range); if the new syscall is available
3892 # then it will fail with ESRCH (because it would not find such thread in the
3895 # C-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3896 # Automake-level symbol: SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID
3898 AM_COND_IF(SOLARIS_LWP_SIGQUEUE_SYSCALL,
3899 AC_MSG_CHECKING([if the `lwp_sigqueue' syscall accepts pid (Solaris-specific)])
3900 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
3901 #include <sys/syscall.h>
3905 syscall(SYS_lwp_sigqueue, 0, 101, 0, 0, 0, 0);
3906 return !(errno == ESRCH);
3908 solaris_lwp_sigqueue_syscall_takes_pid=yes
3909 AC_MSG_RESULT([yes])
3910 AC_DEFINE([SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID], 1,
3911 [Define to 1 if you have the new `lwp_sigqueue' syscall which accepts pid.])
3913 solaris_lwp_sigqueue_syscall_takes_pid=no
3916 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID,
3917 test x$solaris_lwp_sigqueue_syscall_takes_pid = xyes)
3919 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, test x = y)
3923 # Solaris-specific check determining if the new lwp_name() syscall is
3926 # New syscall (available on Solaris 11):
3927 # int lwp_name(int opcode, id_t lwpid, char *name, size_t len);
3929 # C-level symbol: SOLARIS_LWP_NAME_SYSCALL
3930 # Automake-level symbol: SOLARIS_LWP_NAME_SYSCALL
3932 AC_MSG_CHECKING([for the new `lwp_name' syscall (Solaris-specific)])
3933 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3934 #include <sys/syscall.h>
3936 return !SYS_lwp_name;
3938 solaris_lwp_name_syscall=yes
3939 AC_MSG_RESULT([yes])
3940 AC_DEFINE([SOLARIS_LWP_NAME_SYSCALL], 1,
3941 [Define to 1 if you have the new `lwp_name' syscall.])
3943 solaris_lwp_name_syscall=no
3946 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, test x$solaris_lwp_name_syscall = xyes)
3949 # Solaris-specific check determining if the new getrandom() syscall is
3952 # New syscall (available on Solaris 11):
3953 # int getrandom(void *buf, size_t buflen, uint_t flags);
3955 # C-level symbol: SOLARIS_GETRANDOM_SYSCALL
3956 # Automake-level symbol: SOLARIS_GETRANDOM_SYSCALL
3958 AC_MSG_CHECKING([for the new `getrandom' syscall (Solaris-specific)])
3959 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3960 #include <sys/syscall.h>
3962 return !SYS_getrandom;
3964 solaris_getrandom_syscall=yes
3965 AC_MSG_RESULT([yes])
3966 AC_DEFINE([SOLARIS_GETRANDOM_SYSCALL], 1,
3967 [Define to 1 if you have the new `getrandom' syscall.])
3969 solaris_getrandom_syscall=no
3972 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, test x$solaris_getrandom_syscall = xyes)
3975 # Solaris-specific check determining if the new zone() syscall subcodes
3976 # ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT are available. These subcodes
3977 # were added in Solaris 11 but are missing on illumos.
3979 # C-level symbol: SOLARIS_ZONE_DEFUNCT
3980 # Automake-level symbol: SOLARIS_ZONE_DEFUNCT
3982 AC_MSG_CHECKING([for ZONE_LIST_DEFUNCT and ZONE_GETATTR_DEFUNCT (Solaris-specific)])
3983 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
3984 #include <sys/zone.h>
3986 return !(ZONE_LIST_DEFUNCT && ZONE_GETATTR_DEFUNCT);
3988 solaris_zone_defunct=yes
3989 AC_MSG_RESULT([yes])
3990 AC_DEFINE([SOLARIS_ZONE_DEFUNCT], 1,
3991 [Define to 1 if you have the `ZONE_LIST_DEFUNCT' and `ZONE_GETATTR_DEFUNC' constants.])
3993 solaris_zone_defunct=no
3996 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, test x$solaris_zone_defunct = xyes)
3999 # Solaris-specific check determining if commands A_GETSTAT and A_SETSTAT
4000 # for auditon(2) subcode of the auditsys() syscall are available.
4001 # These commands are available in Solaris 11 and illumos but were removed
4004 # C-level symbol: SOLARIS_AUDITON_STAT
4005 # Automake-level symbol: SOLARIS_AUDITON_STAT
4007 AC_MSG_CHECKING([for A_GETSTAT and A_SETSTAT auditon(2) commands (Solaris-specific)])
4008 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4009 #include <bsm/audit.h>
4011 return !(A_GETSTAT && A_SETSTAT);
4013 solaris_auditon_stat=yes
4014 AC_MSG_RESULT([yes])
4015 AC_DEFINE([SOLARIS_AUDITON_STAT], 1,
4016 [Define to 1 if you have the `A_GETSTAT' and `A_SETSTAT' constants.])
4018 solaris_auditon_stat=no
4021 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, test x$solaris_auditon_stat = xyes)
4024 # Solaris-specific check determining if the new shmsys() syscall subcodes
4025 # IPC_XSTAT64, SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM are available.
4026 # These subcodes were added in Solaris 11 but are missing on illumos.
4028 # C-level symbol: SOLARIS_SHM_NEW
4029 # Automake-level symbol: SOLARIS_SHM_NEW
4031 AC_MSG_CHECKING([for SHMADV, SHM_ADV_GET, SHM_ADV_SET and SHMGET_OSM (Solaris-specific)])
4032 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4033 #include <sys/ipc_impl.h>
4034 #include <sys/shm.h>
4035 #include <sys/shm_impl.h>
4037 return !(IPC_XSTAT64 && SHMADV && SHM_ADV_GET && SHM_ADV_SET && SHMGET_OSM);
4040 AC_MSG_RESULT([yes])
4041 AC_DEFINE([SOLARIS_SHM_NEW], 1,
4042 [Define to 1 if you have the `IPC_XSTAT64', `SHMADV', `SHM_ADV_GET', `SHM_ADV_SET' and `SHMGET_OSM' constants.])
4047 AM_CONDITIONAL(SOLARIS_SHM_NEW, test x$solaris_shm_new = xyes)
4050 # Solaris-specific check determining if prxregset_t is available. Illumos
4051 # currently does not define it on the x86 platform.
4053 # C-level symbol: SOLARIS_PRXREGSET_T
4054 # Automake-level symbol: SOLARIS_PRXREGSET_T
4056 AC_MSG_CHECKING([for the `prxregset_t' type (Solaris-specific)])
4057 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4058 #include <sys/procfs_isa.h>
4060 return !sizeof(prxregset_t);
4062 solaris_prxregset_t=yes
4063 AC_MSG_RESULT([yes])
4064 AC_DEFINE([SOLARIS_PRXREGSET_T], 1,
4065 [Define to 1 if you have the `prxregset_t' type.])
4067 solaris_prxregset_t=no
4070 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, test x$solaris_prxregset_t = xyes)
4073 # Solaris-specific check determining if the new frealpathat() syscall is
4076 # New syscall (available on Solaris 11.1):
4077 # int frealpathat(int fd, char *path, char *buf, size_t buflen);
4079 # C-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4080 # Automake-level symbol: SOLARIS_FREALPATHAT_SYSCALL
4082 AC_MSG_CHECKING([for the new `frealpathat' syscall (Solaris-specific)])
4083 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4084 #include <sys/syscall.h>
4086 return !SYS_frealpathat;
4088 solaris_frealpathat_syscall=yes
4089 AC_MSG_RESULT([yes])
4090 AC_DEFINE([SOLARIS_FREALPATHAT_SYSCALL], 1,
4091 [Define to 1 if you have the new `frealpathat' syscall.])
4093 solaris_frealpathat_syscall=no
4096 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, test x$solaris_frealpathat_syscall = xyes)
4099 # Solaris-specific check determining if the new uuidsys() syscall is
4102 # New syscall (available on newer Solaris):
4103 # int uuidsys(struct uuid *uuid);
4105 # C-level symbol: SOLARIS_UUIDSYS_SYSCALL
4106 # Automake-level symbol: SOLARIS_UUIDSYS_SYSCALL
4108 AC_MSG_CHECKING([for the new `uuidsys' syscall (Solaris-specific)])
4109 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4110 #include <sys/syscall.h>
4112 return !SYS_uuidsys;
4114 solaris_uuidsys_syscall=yes
4115 AC_MSG_RESULT([yes])
4116 AC_DEFINE([SOLARIS_UUIDSYS_SYSCALL], 1,
4117 [Define to 1 if you have the new `uuidsys' syscall.])
4119 solaris_uuidsys_syscall=no
4122 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, test x$solaris_uuidsys_syscall = xyes)
4125 # Solaris-specific check determining if the new labelsys() syscall subcode
4126 # TNDB_GET_TNIP is available. This subcode was added in Solaris 11 but is
4127 # missing on illumos.
4129 # C-level symbol: SOLARIS_TNDB_GET_TNIP
4130 # Automake-level symbol: SOLARIS_TNDB_GET_TNIP
4132 AC_MSG_CHECKING([for TNDB_GET_TNIP (Solaris-specific)])
4133 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4134 #include <sys/tsol/tndb.h>
4136 return !TNDB_GET_TNIP;
4138 solaris_tndb_get_tnip=yes
4139 AC_MSG_RESULT([yes])
4140 AC_DEFINE([SOLARIS_TNDB_GET_TNIP], 1,
4141 [Define to 1 if you have the `TNDB_GET_TNIP' constant.])
4143 solaris_tndb_get_tnip=no
4146 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, test x$solaris_tndb_get_tnip = xyes)
4149 # Solaris-specific check determining if the new labelsys() syscall opcodes
4150 # TSOL_GETCLEARANCE and TSOL_SETCLEARANCE are available. These opcodes were
4151 # added in Solaris 11 but are missing on illumos.
4153 # C-level symbol: SOLARIS_TSOL_CLEARANCE
4154 # Automake-level symbol: SOLARIS_TSOL_CLEARANCE
4156 AC_MSG_CHECKING([for TSOL_GETCLEARANCE and TSOL_SETCLEARANCE (Solaris-specific)])
4157 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4158 #include <sys/tsol/tsyscall.h>
4160 return !(TSOL_GETCLEARANCE && TSOL_SETCLEARANCE);
4162 solaris_tsol_clearance=yes
4163 AC_MSG_RESULT([yes])
4164 AC_DEFINE([SOLARIS_TSOL_CLEARANCE], 1,
4165 [Define to 1 if you have the `TSOL_GETCLEARANCE' and `TSOL_SETCLEARANCE' constants.])
4167 solaris_tsol_clearance=no
4170 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, test x$solaris_tsol_clearance = xyes)
4173 # Solaris-specific check determining if the new pset() syscall subcode
4174 # PSET_GET_NAME is available. This subcode was added in Solaris 11.4 but
4175 # is missing on illumos and Solaris 11.3.
4177 # C-level symbol: SOLARIS_PSET_GET_NAME
4178 # Automake-level symbol: SOLARIS_PSET_GET_NAME
4180 AC_MSG_CHECKING([for PSET_GET_NAME (Solaris-specific)])
4181 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4182 #include <sys/pset.h>
4184 return !(PSET_GET_NAME);
4186 solaris_pset_get_name=yes
4187 AC_MSG_RESULT([yes])
4188 AC_DEFINE([SOLARIS_PSET_GET_NAME], 1,
4189 [Define to 1 if you have the `PSET_GET_NAME' constants.])
4191 solaris_pset_get_name=no
4194 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, test x$solaris_pset_get_name = xyes)
4197 # Solaris-specific check determining if the utimesys() syscall is
4198 # available (on illumos and older Solaris).
4200 # C-level symbol: SOLARIS_UTIMESYS_SYSCALL
4201 # Automake-level symbol: SOLARIS_UTIMESYS_SYSCALL
4203 AC_MSG_CHECKING([for the `utimesys' syscall (Solaris-specific)])
4204 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4205 #include <sys/syscall.h>
4207 return !SYS_utimesys;
4209 solaris_utimesys_syscall=yes
4210 AC_MSG_RESULT([yes])
4211 AC_DEFINE([SOLARIS_UTIMESYS_SYSCALL], 1,
4212 [Define to 1 if you have the `utimesys' syscall.])
4214 solaris_utimesys_syscall=no
4217 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, test x$solaris_utimesys_syscall = xyes)
4220 # Solaris-specific check determining if the utimensat() syscall is
4221 # available (on newer Solaris).
4223 # C-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4224 # Automake-level symbol: SOLARIS_UTIMENSAT_SYSCALL
4226 AC_MSG_CHECKING([for the `utimensat' syscall (Solaris-specific)])
4227 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4228 #include <sys/syscall.h>
4230 return !SYS_utimensat;
4232 solaris_utimensat_syscall=yes
4233 AC_MSG_RESULT([yes])
4234 AC_DEFINE([SOLARIS_UTIMENSAT_SYSCALL], 1,
4235 [Define to 1 if you have the `utimensat' syscall.])
4237 solaris_utimensat_syscall=no
4240 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, test x$solaris_utimensat_syscall = xyes)
4243 # Solaris-specific check determining if the spawn() syscall is available
4244 # (on newer Solaris).
4246 # C-level symbol: SOLARIS_SPAWN_SYSCALL
4247 # Automake-level symbol: SOLARIS_SPAWN_SYSCALL
4249 AC_MSG_CHECKING([for the `spawn' syscall (Solaris-specific)])
4250 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4251 #include <sys/syscall.h>
4255 solaris_spawn_syscall=yes
4256 AC_MSG_RESULT([yes])
4257 AC_DEFINE([SOLARIS_SPAWN_SYSCALL], 1,
4258 [Define to 1 if you have the `spawn' syscall.])
4260 solaris_spawn_syscall=no
4263 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, test x$solaris_spawn_syscall = xyes)
4266 # Solaris-specific check determining if commands MODNVL_CTRLMAP through
4267 # MODDEVINFO_CACHE_TS for modctl() syscall are available (on newer Solaris).
4269 # C-level symbol: SOLARIS_MODCTL_MODNVL
4270 # Automake-level symbol: SOLARIS_MODCTL_MODNVL
4272 AC_MSG_CHECKING([for MODNVL_CTRLMAP through MODDEVINFO_CACHE_TS modctl(2) commands (Solaris-specific)])
4273 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4274 #include <sys/modctl.h>
4276 return !(MODNVL_CTRLMAP && MODDEVINFO_CACHE_TS);
4278 solaris_modctl_modnvl=yes
4279 AC_MSG_RESULT([yes])
4280 AC_DEFINE([SOLARIS_MODCTL_MODNVL], 1,
4281 [Define to 1 if you have the `MODNVL_CTRLMAP' through `MODDEVINFO_CACHE_TS' constants.])
4283 solaris_modctl_modnvl=no
4286 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, test x$solaris_modctl_modnvl = xyes)
4289 # Solaris-specific check determining whether nscd (name switch cache daemon)
4290 # attaches its door at /system/volatile/name_service_door (Solaris)
4291 # or at /var/run/name_service_door (illumos).
4293 # Note that /var/run is a symlink to /system/volatile on Solaris
4294 # but not vice versa on illumos.
4296 # C-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4297 # Automake-level symbol: SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE
4299 AC_MSG_CHECKING([for nscd door location (Solaris-specific)])
4300 if test -e /system/volatile/name_service_door; then
4301 solaris_nscd_door_system_volatile=yes
4302 AC_MSG_RESULT([/system/volatile/name_service_door])
4303 AC_DEFINE([SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE], 1,
4304 [Define to 1 if nscd attaches to /system/volatile/name_service_door.])
4306 solaris_nscd_door_system_volatile=no
4307 AC_MSG_RESULT([/var/run/name_service_door])
4309 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, test x$solaris_nscd_door_system_volatile = xyes)
4312 # Solaris-specific check determining if the new gethrt() fasttrap is available.
4314 # New fasttrap (available on Solaris 11):
4315 # hrt_t *gethrt(void);
4317 # C-level symbol: SOLARIS_GETHRT_FASTTRAP
4318 # Automake-level symbol: SOLARIS_GETHRT_FASTTRAP
4320 AC_MSG_CHECKING([for the new `gethrt' fasttrap (Solaris-specific)])
4321 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4322 #include <sys/trap.h>
4326 solaris_gethrt_fasttrap=yes
4327 AC_MSG_RESULT([yes])
4328 AC_DEFINE([SOLARIS_GETHRT_FASTTRAP], 1,
4329 [Define to 1 if you have the new `gethrt' fasttrap.])
4331 solaris_gethrt_fasttrap=no
4334 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, test x$solaris_gethrt_fasttrap = xyes)
4337 # Solaris-specific check determining if the new get_zone_offset() fasttrap
4340 # New fasttrap (available on Solaris 11):
4341 # zonehrtoffset_t *get_zone_offset(void);
4343 # C-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4344 # Automake-level symbol: SOLARIS_GETZONEOFFSET_FASTTRAP
4346 AC_MSG_CHECKING([for the new `get_zone_offset' fasttrap (Solaris-specific)])
4347 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4348 #include <sys/trap.h>
4350 return !T_GETZONEOFFSET;
4352 solaris_getzoneoffset_fasttrap=yes
4353 AC_MSG_RESULT([yes])
4354 AC_DEFINE([SOLARIS_GETZONEOFFSET_FASTTRAP], 1,
4355 [Define to 1 if you have the new `get_zone_offset' fasttrap.])
4357 solaris_getzoneoffset_fasttrap=no
4360 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, test x$solaris_getzoneoffset_fasttrap = xyes)
4363 # Solaris-specific check determining if the execve() syscall
4364 # takes fourth argument (flags) or not.
4366 # Old syscall (available on illumos):
4367 # int execve(const char *fname, const char **argv, const char **envp);
4369 # New syscall (available on Solaris):
4370 # int execve(uintptr_t file, const char **argv, const char **envp, int flags);
4372 # If the new syscall is present then it will fail with EINVAL (because flags
4373 # are invalid); if the old syscall is available then it will fail with ENOENT
4374 # (because the file could not be found).
4376 # C-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4377 # Automake-level symbol: SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS
4379 AC_MSG_CHECKING([if the `execve' syscall accepts flags (Solaris-specific)])
4380 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4381 #include <sys/syscall.h>
4385 syscall(SYS_execve, "/no/existing/path", 0, 0, 0xdeadbeef, 0, 0);
4386 return !(errno == EINVAL);
4388 solaris_execve_syscall_takes_flags=yes
4389 AC_MSG_RESULT([yes])
4390 AC_DEFINE([SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS], 1,
4391 [Define to 1 if you have the new `execve' syscall which accepts flags.])
4393 solaris_execve_syscall_takes_flags=no
4396 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS,
4397 test x$solaris_execve_syscall_takes_flags = xyes)
4400 # Solaris-specific check determining version of the repository cache protocol.
4401 # Every Solaris version uses a different one, ranging from 21 to current 25.
4402 # The check is very ugly, though.
4404 # C-level symbol: SOLARIS_REPCACHE_PROTOCOL_VERSION vv
4405 # Automake-level symbol: none
4407 AC_PATH_PROG(DIS_PATH, dis, false)
4408 if test "x$DIS_PATH" = "xfalse"; then
4409 AC_MSG_FAILURE([Object code disassembler (`dis') not found.])
4411 AC_CHECK_LIB(scf, scf_handle_bind, [], [
4412 AC_MSG_WARN([Function `scf_handle_bind' was not found in `libscf'.])
4413 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4416 AC_MSG_CHECKING([for version of the repository cache protocol (Solaris-specific)])
4417 if test "X$VGCONF_ARCH_PRI" = "Xamd64"; then
4418 libscf=/usr/lib/64/libscf.so.1
4420 libscf=/usr/lib/libscf.so.1
4422 if ! $DIS_PATH -F scf_handle_bind $libscf | grep -q 0x526570; then
4423 AC_MSG_WARN([Function `scf_handle_bind' does not contain repository cache protocol version.])
4424 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4426 hex=$( $DIS_PATH -F scf_handle_bind $libscf | sed -n 's/.*0x526570\(..\).*/\1/p' )
4427 if test -z "$hex"; then
4428 AC_MSG_WARN([Version of the repository cache protocol is empty?!])
4429 AC_MSG_ERROR([Cannot determine version of the repository cache protocol.])
4431 version=$( printf "%d\n" 0x$hex )
4432 AC_MSG_RESULT([$version])
4433 AC_DEFINE_UNQUOTED([SOLARIS_REPCACHE_PROTOCOL_VERSION], [$version],
4434 [Version number of the repository door cache protocol.])
4437 # Solaris-specific check determining if "sysstat" segment reservation type
4440 # New "sysstat" segment reservation (available on Solaris 11.4):
4441 # - program header type: PT_SUNW_SYSSTAT
4442 # - auxiliary vector entry: AT_SUN_SYSSTAT_ADDR
4444 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4445 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ADDR
4447 AC_MSG_CHECKING([for the new `sysstat' segment reservation (Solaris-specific)])
4448 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4449 #include <sys/auxv.h>
4451 return !AT_SUN_SYSSTAT_ADDR;
4453 solaris_reserve_sysstat_addr=yes
4454 AC_MSG_RESULT([yes])
4455 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ADDR], 1,
4456 [Define to 1 if you have the new `sysstat' segment reservation.])
4458 solaris_reserve_sysstat_addr=no
4461 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, test x$solaris_reserve_sysstat_addr = xyes)
4464 # Solaris-specific check determining if "sysstat_zone" segment reservation type
4467 # New "sysstat_zone" segment reservation (available on Solaris 11.4):
4468 # - program header type: PT_SUNW_SYSSTAT_ZONE
4469 # - auxiliary vector entry: AT_SUN_SYSSTAT_ZONE_ADDR
4471 # C-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4472 # Automake-level symbol: SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR
4474 AC_MSG_CHECKING([for the new `sysstat_zone' segment reservation (Solaris-specific)])
4475 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4476 #include <sys/auxv.h>
4478 return !AT_SUN_SYSSTAT_ZONE_ADDR;
4480 solaris_reserve_sysstat_zone_addr=yes
4481 AC_MSG_RESULT([yes])
4482 AC_DEFINE([SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR], 1,
4483 [Define to 1 if you have the new `sysstat_zone' segment reservation.])
4485 solaris_reserve_sysstat_zone_addr=no
4488 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, test x$solaris_reserve_sysstat_zone_addr = xyes)
4491 # Solaris-specific check determining if the system_stats() syscall is available
4492 # (on newer Solaris).
4494 # C-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4495 # Automake-level symbol: SOLARIS_SYSTEM_STATS_SYSCALL
4497 AC_MSG_CHECKING([for the `system_stats' syscall (Solaris-specific)])
4498 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4499 #include <sys/syscall.h>
4501 return !SYS_system_stats;
4503 solaris_system_stats_syscall=yes
4504 AC_MSG_RESULT([yes])
4505 AC_DEFINE([SOLARIS_SYSTEM_STATS_SYSCALL], 1,
4506 [Define to 1 if you have the `system_stats' syscall.])
4508 solaris_system_stats_syscall=no
4511 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, test x$solaris_system_stats_syscall = xyes)
4514 # Solaris-specific check determining if fpregset_t defines struct _fpchip_state
4515 # (on newer illumos) or struct fpchip_state (Solaris, older illumos).
4517 # C-level symbol: SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE
4518 # Automake-level symbol: none
4520 AC_CHECK_TYPE([struct _fpchip_state],
4521 [solaris_fpchip_state_takes_underscore=yes],
4522 [solaris_fpchip_state_takes_underscore=no],
4523 [[#include <sys/regset.h>]])
4524 if test "$solaris_fpchip_state_takes_underscore" = "yes"; then
4525 AC_DEFINE(SOLARIS_FPCHIP_STATE_TAKES_UNDERSCORE, 1,
4526 [Define to 1 if fpregset_t defines struct _fpchip_state])
4530 # Solaris-specific check determining if schedctl page shared between kernel
4531 # and userspace program is executable (illumos, older Solaris) or not (newer
4534 # C-level symbol: SOLARIS_SCHEDCTL_PAGE_EXEC
4535 # Automake-level symbol: none
4537 AC_MSG_CHECKING([if schedctl page is executable (Solaris-specific)])
4538 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4542 #include <schedctl.h>
4546 schedctl_t *scp = schedctl_init();
4550 int fd = open("/proc/self/map", O_RDONLY);
4555 while ((rd = read(fd, &map, sizeof(map))) == sizeof(map)) {
4556 if (map.pr_vaddr == ((uintptr_t) scp & PAGEMASK)) {
4557 fprintf(stderr, "%#lx [%zu] %s\n", map.pr_vaddr, map.pr_size,
4558 (map.pr_mflags & MA_EXEC) ? "x" : "no-x");
4559 return (map.pr_mflags & MA_EXEC);
4565 solaris_schedctl_page_exec=no
4568 solaris_schedctl_page_exec=yes
4569 AC_MSG_RESULT([yes])
4570 AC_DEFINE([SOLARIS_SCHEDCTL_PAGE_EXEC], 1,
4571 [Define to 1 if you have the schedctl page executable.])
4575 # Solaris-specific check determining if PT_SUNWDTRACE program header provides
4576 # scratch space for DTrace fasttrap provider (illumos, older Solaris) or just
4577 # an initial thread pointer for libc (newer Solaris).
4579 # C-level symbol: SOLARIS_PT_SUNDWTRACE_THRP
4580 # Automake-level symbol: none
4582 AC_MSG_CHECKING([if PT_SUNWDTRACE serves for initial thread pointer (Solaris-specific)])
4583 AC_RUN_IFELSE([AC_LANG_PROGRAM([[
4584 #include <sys/fasttrap_isa.h>
4586 return !FT_SCRATCHSIZE;
4588 solaris_pt_sunwdtrace_thrp=yes
4589 AC_MSG_RESULT([yes])
4590 AC_DEFINE([SOLARIS_PT_SUNDWTRACE_THRP], 1,
4591 [Define to 1 if PT_SUNWDTRACE program header provides just an initial thread pointer for libc.])
4593 solaris_pt_sunwdtrace_thrp=no
4598 AM_CONDITIONAL(SOLARIS_SUN_STUDIO_AS, false)
4599 AM_CONDITIONAL(SOLARIS_XPG_SYMBOLS_PRESENT, false)
4600 AM_CONDITIONAL(SOLARIS_PROC_CMDLINE, false)
4601 AM_CONDITIONAL(SOLARIS_OLD_SYSCALLS, false)
4602 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL, false)
4603 AM_CONDITIONAL(SOLARIS_LWP_SIGQUEUE_SYSCALL_TAKES_PID, false)
4604 AM_CONDITIONAL(SOLARIS_LWP_NAME_SYSCALL, false)
4605 AM_CONDITIONAL(SOLARIS_GETRANDOM_SYSCALL, false)
4606 AM_CONDITIONAL(SOLARIS_ZONE_DEFUNCT, false)
4607 AM_CONDITIONAL(SOLARIS_AUDITON_STAT, false)
4608 AM_CONDITIONAL(SOLARIS_SHM_NEW, false)
4609 AM_CONDITIONAL(SOLARIS_PRXREGSET_T, false)
4610 AM_CONDITIONAL(SOLARIS_FREALPATHAT_SYSCALL, false)
4611 AM_CONDITIONAL(SOLARIS_UUIDSYS_SYSCALL, false)
4612 AM_CONDITIONAL(SOLARIS_TNDB_GET_TNIP, false)
4613 AM_CONDITIONAL(SOLARIS_TSOL_CLEARANCE, false)
4614 AM_CONDITIONAL(SOLARIS_PSET_GET_NAME, false)
4615 AM_CONDITIONAL(SOLARIS_UTIMESYS_SYSCALL, false)
4616 AM_CONDITIONAL(SOLARIS_UTIMENSAT_SYSCALL, false)
4617 AM_CONDITIONAL(SOLARIS_SPAWN_SYSCALL, false)
4618 AM_CONDITIONAL(SOLARIS_MODCTL_MODNVL, false)
4619 AM_CONDITIONAL(SOLARIS_NSCD_DOOR_SYSTEM_VOLATILE, false)
4620 AM_CONDITIONAL(SOLARIS_GETHRT_FASTTRAP, false)
4621 AM_CONDITIONAL(SOLARIS_GETZONEOFFSET_FASTTRAP, false)
4622 AM_CONDITIONAL(SOLARIS_EXECVE_SYSCALL_TAKES_FLAGS, false)
4623 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ADDR, false)
4624 AM_CONDITIONAL(SOLARIS_RESERVE_SYSSTAT_ZONE_ADDR, false)
4625 AM_CONDITIONAL(SOLARIS_SYSTEM_STATS_SYSCALL, false)
4626 fi # test "$VGCONF_OS" = "solaris"
4628 #----------------------------------------------------------------------------
4629 # FreeBSD-specific checks.
4630 #----------------------------------------------------------------------------
4632 # Rather than having a large number of feature test as above with Solaris
4633 # these tests are per-version. This may not be entirely relialable for
4634 # FreeBSD development branches (XX.Y-CURRENT) or pre-release branches
4635 # (XX.Y-STABLE) but it should work for XX-Y-RELEASE
4637 if test "$VGCONF_OS" = "freebsd" ; then
4639 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, test $freebsd_vers -ge $freebsd_13_0)
4643 AM_CONDITIONAL(FREEBSD_VERS_13_PLUS, false)
4645 fi # test "$VGCONF_OS" = "freebsd"
4648 #----------------------------------------------------------------------------
4649 # Checks for C header files.
4650 #----------------------------------------------------------------------------
4652 AC_CHECK_HEADERS([ \
4670 # Verify whether the <linux/futex.h> header is usable.
4671 AC_MSG_CHECKING([if <linux/futex.h> is usable])
4673 save_CFLAGS="$CFLAGS"
4674 CFLAGS="$CFLAGS -D__user="
4675 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
4676 #include <linux/futex.h>
4680 ac_have_usable_linux_futex_h=yes
4681 AC_DEFINE([HAVE_USABLE_LINUX_FUTEX_H], 1,
4682 [Define to 1 if you have a usable <linux/futex.h> header file.])
4683 AC_MSG_RESULT([yes])
4685 ac_have_usable_linux_futex_h=no
4688 CFLAGS="$save_CFLAGS"
4691 #----------------------------------------------------------------------------
4692 # Checks for typedefs, structures, and compiler characteristics.
4693 #----------------------------------------------------------------------------
4697 AC_CHECK_HEADERS_ONCE([sys/time.h])
4699 AC_CHECK_TYPE([struct statx], [
4700 AC_DEFINE([HAVE_STRUCT_STATX_IN_SYS_STAT_H], 1,
4701 [Define to 1 if <sys/stat.h> declares struct statx.])
4704 #include <sys/stat.h>
4708 #----------------------------------------------------------------------------
4709 # Checks for library functions.
4710 #----------------------------------------------------------------------------
4714 AC_CHECK_LIB([pthread], [pthread_create])
4715 AC_CHECK_LIB([rt], [clock_gettime])
4734 pthread_barrier_init \
4735 pthread_condattr_setclock \
4736 pthread_mutex_timedlock \
4737 pthread_rwlock_timedrdlock \
4738 pthread_rwlock_timedwrlock \
4739 pthread_setname_np \
4760 # AC_CHECK_LIB adds any library found to the variable LIBS, and links these
4761 # libraries with any shared object and/or executable. This is NOT what we
4762 # want for e.g. vgpreload_core-x86-linux.so
4765 AM_CONDITIONAL([HAVE_PTHREAD_BARRIER],
4766 [test x$ac_cv_func_pthread_barrier_init = xyes])
4767 AM_CONDITIONAL([HAVE_PTHREAD_MUTEX_TIMEDLOCK],
4768 [test x$ac_cv_func_pthread_mutex_timedlock = xyes])
4769 AM_CONDITIONAL([HAVE_PTHREAD_SPINLOCK],
4770 [test x$ac_cv_func_pthread_spin_lock = xyes])
4771 AM_CONDITIONAL([HAVE_PTHREAD_SETNAME_NP],
4772 [test x$ac_cv_func_pthread_setname_np = xyes])
4773 AM_CONDITIONAL([HAVE_COPY_FILE_RANGE],
4774 [test x$ac_cv_func_copy_file_range = xyes])
4775 AM_CONDITIONAL([HAVE_PREADV_PWRITEV],
4776 [test x$ac_cv_func_preadv = xyes && test x$ac_cv_func_pwritev = xyes])
4777 AM_CONDITIONAL([HAVE_PREADV2_PWRITEV2],
4778 [test x$ac_cv_func_preadv2 = xyes && test x$ac_cv_func_pwritev2 = xyes])
4779 AM_CONDITIONAL([HAVE_SETCONTEXT], [test x$ac_cv_func_setcontext = xyes])
4780 AM_CONDITIONAL([HAVE_SWAPCONTEXT], [test x$ac_cv_func_swapcontext = xyes])
4781 AM_CONDITIONAL([HAVE_MEMFD_CREATE],
4782 [test x$ac_cv_func_memfd_create = xyes])
4784 if test x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4785 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4786 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX; then
4787 AC_DEFINE([DISABLE_PTHREAD_SPINLOCK_INTERCEPT], 1,
4788 [Disable intercept pthread_spin_lock() on MIPS32, MIPS64 and nanoMIPS.])
4791 #----------------------------------------------------------------------------
4793 #----------------------------------------------------------------------------
4794 # Do we have a useable MPI setup on the primary and/or secondary targets?
4795 # On Linux, by default, assumes mpicc and -m32/-m64
4796 # Note: this is a kludge in that it assumes the specified mpicc
4797 # understands -m32/-m64 regardless of what is specified using
4799 AC_PATH_PROG([MPI_CC], [mpicc], [mpicc],
4800 [$PATH:/usr/lib/openmpi/bin:/usr/lib64/openmpi/bin])
4803 if test x$VGCONF_PLATFORM_PRI_CAPS = xX86_LINUX \
4804 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_FREEBSD \
4805 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC32_LINUX \
4806 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM_LINUX \
4807 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS32_LINUX \
4808 -o x$VGCONF_PLATFORM_PRI_CAPS = xNANOMIPS_LINUX \
4809 -o x$VGCONF_PLATFORM_PRI_CAPS = xX86_SOLARIS ; then
4810 mflag_primary=$FLAG_M32
4811 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_LINUX \
4812 -o x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_FREEBSD \
4813 -o x$VGCONF_PLATFORM_PRI_CAPS = xPPC64_LINUX \
4814 -o x$VGCONF_PLATFORM_PRI_CAPS = xARM64_LINUX \
4815 -o x$VGCONF_PLATFORM_PRI_CAPS = xMIPS64_LINUX \
4816 -o x$VGCONF_PLATFORM_PRI_CAPS = xS390X_LINUX ; then
4817 mflag_primary=$FLAG_M64
4818 elif test x$VGCONF_PLATFORM_PRI_CAPS = xX86_DARWIN ; then
4819 mflag_primary="$FLAG_M32 -arch i386"
4820 elif test x$VGCONF_PLATFORM_PRI_CAPS = xAMD64_DARWIN ; then
4821 mflag_primary="$FLAG_M64 -arch x86_64"
4825 if test x$VGCONF_PLATFORM_SEC_CAPS = xX86_LINUX \
4826 -o x$VGCONF_PLATFORM_SEC_CAPS = xPPC32_LINUX \
4827 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_SOLARIS \
4828 -o x$VGCONF_PLATFORM_SEC_CAPS = xMIPS32_LINUX \
4829 -o x$VGCONF_PLATFORM_SEC_CAPS = xX86_FREEBSD ; then
4830 mflag_secondary=$FLAG_M32
4831 elif test x$VGCONF_PLATFORM_SEC_CAPS = xX86_DARWIN ; then
4832 mflag_secondary="$FLAG_M32 -arch i386"
4837 [ --with-mpicc= Specify name of MPI2-ised C compiler],
4842 ## We AM_COND_IF here instead of automake "if" in mpi/Makefile.am so that we can
4843 ## use these values in the check for a functioning mpicc.
4845 ## We leave the MPI_FLAG_M3264_ logic in mpi/Makefile.am and assume that
4846 ## mflag_primary/mflag_secondary are sufficient approximations of that behavior
4847 AM_COND_IF([VGCONF_OS_IS_LINUX],
4848 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4849 LDFLAGS_MPI="-fpic -shared"])
4850 AM_COND_IF([VGCONF_OS_IS_FREEBSD],
4851 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4852 LDFLAGS_MPI="-fpic -shared"])
4853 AM_COND_IF([VGCONF_OS_IS_DARWIN],
4854 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -dynamic"
4855 LDFLAGS_MPI="-dynamic -dynamiclib -all_load"])
4856 AM_COND_IF([VGCONF_OS_IS_SOLARIS],
4857 [CFLAGS_MPI="-g -O -fno-omit-frame-pointer -Wall -fpic"
4858 LDFLAGS_MPI="-fpic -shared"])
4860 AC_SUBST([CFLAGS_MPI])
4861 AC_SUBST([LDFLAGS_MPI])
4864 ## See if MPI_CC works for the primary target
4866 AC_MSG_CHECKING([primary target for usable MPI2-compliant C compiler and mpi.h])
4868 saved_CFLAGS=$CFLAGS
4870 CFLAGS="$CFLAGS_MPI $mflag_primary"
4871 saved_LDFLAGS="$LDFLAGS"
4872 LDFLAGS="$LDFLAGS_MPI $mflag_primary"
4873 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4877 int ni, na, nd, comb;
4878 int r = MPI_Init(NULL,NULL);
4879 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4880 r |= MPI_Finalize();
4883 ac_have_mpi2_pri=yes
4884 AC_MSG_RESULT([yes, $MPI_CC])
4890 CFLAGS=$saved_CFLAGS
4891 LDFLAGS="$saved_LDFLAGS"
4892 AM_CONDITIONAL(BUILD_MPIWRAP_PRI, test x$ac_have_mpi2_pri = xyes)
4894 ## See if MPI_CC works for the secondary target. Complication: what if
4895 ## there is no secondary target? We need this to then fail.
4896 ## Kludge this by making MPI_CC something which will surely fail in
4899 AC_MSG_CHECKING([secondary target for usable MPI2-compliant C compiler and mpi.h])
4901 saved_CFLAGS=$CFLAGS
4902 saved_LDFLAGS="$LDFLAGS"
4903 LDFLAGS="$LDFLAGS_MPI $mflag_secondary"
4904 if test x$VGCONF_PLATFORM_SEC_CAPS = x ; then
4905 CC="$MPI_CC this will surely fail"
4909 CFLAGS="$CFLAGS_MPI $mflag_secondary"
4910 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
4914 int ni, na, nd, comb;
4915 int r = MPI_Init(NULL,NULL);
4916 r |= MPI_Type_get_envelope( MPI_INT, &ni, &na, &nd, &comb );
4917 r |= MPI_Finalize();
4920 ac_have_mpi2_sec=yes
4921 AC_MSG_RESULT([yes, $MPI_CC])
4927 CFLAGS=$saved_CFLAGS
4928 LDFLAGS="$saved_LDFLAGS"
4929 AM_CONDITIONAL(BUILD_MPIWRAP_SEC, test x$ac_have_mpi2_sec = xyes)
4932 #----------------------------------------------------------------------------
4933 # Other library checks
4934 #----------------------------------------------------------------------------
4935 # There now follow some tests for Boost, and OpenMP. These
4936 # tests are present because Drd has some regression tests that use
4937 # these packages. All regression test programs all compiled only
4938 # for the primary target. And so it is important that the configure
4939 # checks that follow, use the correct -m32 or -m64 flag for the
4940 # primary target (called $mflag_primary). Otherwise, we can end up
4941 # in a situation (eg) where, on amd64-linux, the test for Boost checks
4942 # for usable 64-bit Boost facilities, but because we are doing a 32-bit
4943 # only build (meaning, the primary target is x86-linux), the build
4944 # of the regtest programs that use Boost fails, because they are
4945 # build as 32-bit (IN THIS EXAMPLE).
4947 # Hence: ALWAYS USE $mflag_primary FOR CONFIGURE TESTS FOR FACILITIES
4948 # NEEDED BY THE REGRESSION TEST PROGRAMS.
4951 # Check whether the boost library 1.35 or later has been installed.
4952 # The Boost.Threads library has undergone a major rewrite in version 1.35.0.
4954 AC_MSG_CHECKING([for boost])
4957 safe_CXXFLAGS=$CXXFLAGS
4958 CXXFLAGS="$mflag_primary"
4960 LIBS="-lboost_thread-mt -lboost_system-mt $LIBS"
4962 AC_LINK_IFELSE([AC_LANG_SOURCE([
4963 #include <boost/thread.hpp>
4964 static void thread_func(void)
4966 int main(int argc, char** argv)
4968 boost::thread t(thread_func);
4973 ac_have_boost_1_35=yes
4974 AC_SUBST([BOOST_CFLAGS], [])
4975 AC_SUBST([BOOST_LIBS], ["-lboost_thread-mt -lboost_system-mt"])
4976 AC_MSG_RESULT([yes])
4978 ac_have_boost_1_35=no
4983 CXXFLAGS=$safe_CXXFLAGS
4986 AM_CONDITIONAL([HAVE_BOOST_1_35], [test x$ac_have_boost_1_35 = xyes])
4989 # does this compiler support -fopenmp, does it have the include file
4990 # <omp.h> and does it have libgomp ?
4992 AC_MSG_CHECKING([for OpenMP])
4995 CFLAGS="-fopenmp $mflag_primary -Werror"
4997 AC_LINK_IFELSE([AC_LANG_SOURCE([
4999 int main(int argc, char** argv)
5007 AC_MSG_RESULT([yes])
5014 AM_CONDITIONAL([HAVE_OPENMP], [test x$ac_have_openmp = xyes])
5017 # Check for __builtin_popcount
5018 AC_MSG_CHECKING([for __builtin_popcount()])
5019 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5021 __builtin_popcount(2);
5024 AC_MSG_RESULT([yes])
5025 AC_DEFINE([HAVE_BUILTIN_POPCOUT], 1,
5026 [Define to 1 if compiler provides __builtin_popcount().])
5031 # Check for __builtin_clz
5032 AC_MSG_CHECKING([for __builtin_clz()])
5033 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5038 AC_MSG_RESULT([yes])
5039 AC_DEFINE([HAVE_BUILTIN_CLZ], 1,
5040 [Define to 1 if compiler provides __builtin_clz().])
5045 # Check for __builtin_ctz
5046 AC_MSG_CHECKING([for __builtin_ctz()])
5047 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5052 AC_MSG_RESULT([yes])
5053 AC_DEFINE([HAVE_BUILTIN_CTZ], 1,
5054 [Define to 1 if compiler provides __builtin_ctz().])
5059 # does this compiler have built-in functions for atomic memory access for the
5061 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the primary target])
5064 CFLAGS="$mflag_primary"
5066 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5068 return (__sync_bool_compare_and_swap(&variable, 1, 2)
5069 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5071 ac_have_builtin_atomic_primary=yes
5072 AC_MSG_RESULT([yes])
5073 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])
5075 ac_have_builtin_atomic_primary=no
5081 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC],
5082 [test x$ac_have_builtin_atomic_primary = xyes])
5085 # does this compiler have built-in functions for atomic memory access for the
5086 # secondary target ?
5088 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5090 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch for the secondary target])
5093 CFLAGS="$mflag_secondary"
5095 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5097 return (__sync_add_and_fetch(&variable, 1) ? 1 : 0)
5099 ac_have_builtin_atomic_secondary=yes
5100 AC_MSG_RESULT([yes])
5102 ac_have_builtin_atomic_secondary=no
5110 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_SECONDARY],
5111 [test x$ac_have_builtin_atomic_secondary = xyes])
5113 # does this compiler have built-in functions for atomic memory access on
5114 # 64-bit integers for all targets ?
5116 AC_MSG_CHECKING([if gcc supports __sync_add_and_fetch on uint64_t for all targets])
5118 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5121 uint64_t variable = 1;
5122 return __sync_add_and_fetch(&variable, 1)
5124 ac_have_builtin_atomic64_primary=yes
5126 ac_have_builtin_atomic64_primary=no
5129 if test x$VGCONF_PLATFORM_SEC_CAPS != x; then
5132 CFLAGS="$mflag_secondary"
5134 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5137 uint64_t variable = 1;
5138 return __sync_add_and_fetch(&variable, 1)
5140 ac_have_builtin_atomic64_secondary=yes
5142 ac_have_builtin_atomic64_secondary=no
5149 if test x$ac_have_builtin_atomic64_primary = xyes && \
5150 test x$VGCONF_PLATFORM_SEC_CAPS = x \
5151 -o x$ac_have_builtin_atomic64_secondary = xyes; then
5152 AC_MSG_RESULT([yes])
5153 ac_have_builtin_atomic64=yes
5156 ac_have_builtin_atomic64=no
5159 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC64],
5160 [test x$ac_have_builtin_atomic64 = xyes])
5163 # does g++ have built-in functions for atomic memory access ?
5164 AC_MSG_CHECKING([if g++ supports __sync_add_and_fetch])
5166 safe_CXXFLAGS=$CXXFLAGS
5167 CXXFLAGS="$mflag_primary"
5170 AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[
5172 return (__sync_bool_compare_and_swap(&variable, 1, 2)
5173 && __sync_add_and_fetch(&variable, 1) ? 1 : 0)
5175 ac_have_builtin_atomic_cxx=yes
5176 AC_MSG_RESULT([yes])
5177 AC_DEFINE(HAVE_BUILTIN_ATOMIC_CXX, 1, [Define to 1 if g++ supports __sync_bool_compare_and_swap() and __sync_add_and_fetch()])
5179 ac_have_builtin_atomic_cxx=no
5184 CXXFLAGS=$safe_CXXFLAGS
5186 AM_CONDITIONAL([HAVE_BUILTIN_ATOMIC_CXX], [test x$ac_have_builtin_atomic_cxx = xyes])
5189 if test x$ac_have_usable_linux_futex_h = xyes \
5190 -a x$ac_have_builtin_atomic_primary = xyes; then
5191 ac_enable_linux_ticket_lock_primary=yes
5193 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_PRIMARY],
5194 [test x$ac_enable_linux_ticket_lock_primary = xyes])
5196 if test x$VGCONF_PLATFORM_SEC_CAPS != x \
5197 -a x$ac_have_usable_linux_futex_h = xyes \
5198 -a x$ac_have_builtin_atomic_secondary = xyes; then
5199 ac_enable_linux_ticket_lock_secondary=yes
5201 AM_CONDITIONAL([ENABLE_LINUX_TICKET_LOCK_SECONDARY],
5202 [test x$ac_enable_linux_ticket_lock_secondary = xyes])
5205 # does libstdc++ support annotating shared pointers ?
5206 AC_MSG_CHECKING([if libstdc++ supports annotating shared pointers])
5208 safe_CXXFLAGS=$CXXFLAGS
5209 CXXFLAGS="-std=c++0x"
5212 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5215 std::shared_ptr<int> p
5217 ac_have_shared_ptr=yes
5219 ac_have_shared_ptr=no
5221 if test x$ac_have_shared_ptr = xyes; then
5222 # If compilation of the program below fails because of a syntax error
5223 # triggered by substituting one of the annotation macros then that
5224 # means that libstdc++ supports these macros.
5225 AC_LINK_IFELSE([AC_LANG_PROGRAM([[
5226 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_BEFORE(a) (a)----
5227 #define _GLIBCXX_SYNCHRONIZATION_HAPPENS_AFTER(a) (a)----
5230 std::shared_ptr<int> p
5232 ac_have_shared_pointer_annotation=no
5235 ac_have_shared_pointer_annotation=yes
5236 AC_MSG_RESULT([yes])
5237 AC_DEFINE(HAVE_SHARED_POINTER_ANNOTATION, 1,
5238 [Define to 1 if libstd++ supports annotating shared pointers])
5241 ac_have_shared_pointer_annotation=no
5246 CXXFLAGS=$safe_CXXFLAGS
5248 AM_CONDITIONAL([HAVE_SHARED_POINTER_ANNOTATION],
5249 [test x$ac_have_shared_pointer_annotation = xyes])
5252 #----------------------------------------------------------------------------
5253 # Ok. We're done checking.
5254 #----------------------------------------------------------------------------
5256 # Nb: VEX/Makefile is generated from Makefile.vex.in.
5259 VEX/Makefile:Makefile.vex.in
5263 glibc-2.X-helgrind.supp
5267 docs/xml/vg-entities.xml
5272 gdbserver_tests/Makefile
5273 gdbserver_tests/solaris/Makefile
5279 memcheck/tests/Makefile
5280 memcheck/tests/common/Makefile
5281 memcheck/tests/amd64/Makefile
5282 memcheck/tests/x86/Makefile
5283 memcheck/tests/linux/Makefile
5284 memcheck/tests/linux/debuginfod-check.vgtest
5285 memcheck/tests/darwin/Makefile
5286 memcheck/tests/solaris/Makefile
5287 memcheck/tests/freebsd/Makefile
5288 memcheck/tests/amd64-linux/Makefile
5289 memcheck/tests/arm64-linux/Makefile
5290 memcheck/tests/x86-linux/Makefile
5291 memcheck/tests/amd64-solaris/Makefile
5292 memcheck/tests/x86-solaris/Makefile
5293 memcheck/tests/amd64-freebsd/Makefile
5294 memcheck/tests/x86-freebsd/Makefile
5295 memcheck/tests/ppc32/Makefile
5296 memcheck/tests/ppc64/Makefile
5297 memcheck/tests/s390x/Makefile
5298 memcheck/tests/mips32/Makefile
5299 memcheck/tests/mips64/Makefile
5300 memcheck/tests/vbit-test/Makefile
5302 cachegrind/tests/Makefile
5303 cachegrind/tests/x86/Makefile
5304 cachegrind/cg_annotate
5307 callgrind/callgrind_annotate
5308 callgrind/callgrind_control
5309 callgrind/tests/Makefile
5311 helgrind/tests/Makefile
5313 drd/scripts/download-and-build-splash2
5316 massif/tests/Makefile
5321 lackey/tests/Makefile
5324 none/tests/scripts/Makefile
5325 none/tests/amd64/Makefile
5326 none/tests/ppc32/Makefile
5327 none/tests/ppc64/Makefile
5328 none/tests/x86/Makefile
5329 none/tests/arm/Makefile
5330 none/tests/arm64/Makefile
5331 none/tests/s390x/Makefile
5332 none/tests/mips32/Makefile
5333 none/tests/mips64/Makefile
5334 none/tests/nanomips/Makefile
5335 none/tests/linux/Makefile
5336 none/tests/darwin/Makefile
5337 none/tests/solaris/Makefile
5338 none/tests/freebsd/Makefile
5339 none/tests/amd64-linux/Makefile
5340 none/tests/x86-linux/Makefile
5341 none/tests/amd64-darwin/Makefile
5342 none/tests/x86-darwin/Makefile
5343 none/tests/amd64-solaris/Makefile
5344 none/tests/x86-solaris/Makefile
5346 exp-bbv/tests/Makefile
5347 exp-bbv/tests/x86/Makefile
5348 exp-bbv/tests/x86-linux/Makefile
5349 exp-bbv/tests/amd64-linux/Makefile
5350 exp-bbv/tests/ppc32-linux/Makefile
5351 exp-bbv/tests/arm-linux/Makefile
5355 AC_CONFIG_FILES([coregrind/link_tool_exe_linux],
5356 [chmod +x coregrind/link_tool_exe_linux])
5357 AC_CONFIG_FILES([coregrind/link_tool_exe_freebsd],
5358 [chmod +x coregrind/link_tool_exe_freebsd])
5359 AC_CONFIG_FILES([coregrind/link_tool_exe_darwin],
5360 [chmod +x coregrind/link_tool_exe_darwin])
5361 AC_CONFIG_FILES([coregrind/link_tool_exe_solaris],
5362 [chmod +x coregrind/link_tool_exe_solaris])
5363 AC_CONFIG_FILES([tests/filter_stderr_basic],
5364 [chmod +x tests/filter_stderr_basic])
5365 AC_CONFIG_FILES([tests/filter_discards],
5366 [chmod +x tests/filter_discards])
5367 AC_CONFIG_FILES([memcheck/tests/filter_stderr],
5368 [chmod +x memcheck/tests/filter_stderr])
5369 AC_CONFIG_FILES([memcheck/tests/filter_dw4],
5370 [chmod +x memcheck/tests/filter_dw4])
5371 AC_CONFIG_FILES([memcheck/tests/filter_overlaperror],
5372 [chmod +x memcheck/tests/filter_overlaperror])
5373 AC_CONFIG_FILES([memcheck/tests/x86/filter_pushfpopf],
5374 [chmod +x memcheck/tests/x86/filter_pushfpopf])
5375 AC_CONFIG_FILES([gdbserver_tests/filter_gdb],
5376 [chmod +x gdbserver_tests/filter_gdb])
5377 AC_CONFIG_FILES([gdbserver_tests/filter_memcheck_monitor],
5378 [chmod +x gdbserver_tests/filter_memcheck_monitor])
5379 AC_CONFIG_FILES([gdbserver_tests/filter_stderr],
5380 [chmod +x gdbserver_tests/filter_stderr])
5381 AC_CONFIG_FILES([gdbserver_tests/filter_vgdb],
5382 [chmod +x gdbserver_tests/filter_vgdb])
5383 AC_CONFIG_FILES([drd/tests/filter_stderr],
5384 [chmod +x drd/tests/filter_stderr])
5385 AC_CONFIG_FILES([drd/tests/filter_error_count],
5386 [chmod +x drd/tests/filter_error_count])
5387 AC_CONFIG_FILES([drd/tests/filter_error_summary],
5388 [chmod +x drd/tests/filter_error_summary])
5389 AC_CONFIG_FILES([drd/tests/filter_stderr_and_thread_no_and_offset],
5390 [chmod +x drd/tests/filter_stderr_and_thread_no_and_offset])
5391 AC_CONFIG_FILES([drd/tests/filter_thread_no],
5392 [chmod +x drd/tests/filter_thread_no])
5393 AC_CONFIG_FILES([drd/tests/filter_xml_and_thread_no],
5394 [chmod +x drd/tests/filter_xml_and_thread_no])
5395 AC_CONFIG_FILES([helgrind/tests/filter_stderr],
5396 [chmod +x helgrind/tests/filter_stderr])
5402 Maximum build arch: ${ARCH_MAX}
5403 Primary build arch: ${VGCONF_ARCH_PRI}
5404 Secondary build arch: ${VGCONF_ARCH_SEC}
5405 Build OS: ${VGCONF_OS}
5406 Link Time Optimisation: ${vg_cv_lto}
5407 Primary build target: ${VGCONF_PLATFORM_PRI_CAPS}
5408 Secondary build target: ${VGCONF_PLATFORM_SEC_CAPS}
5409 Platform variant: ${VGCONF_PLATVARIANT}
5410 Primary -DVGPV string: -DVGPV_${VGCONF_ARCH_PRI}_${VGCONF_OS}_${VGCONF_PLATVARIANT}=1
5411 Default supp files: ${DEFAULT_SUPP}